formatting-5.4: Combinator-based type-safe formatting (like printf() or FORMAT)

Copyright(c) 2013 Chris Done, 2013 Shachaf Ben-Kiki
LicenseBSD3
Maintainerchrisdone@gmail.com
Stabilityexperimental
PortabilityGHC
Safe HaskellSafe-Inferred
LanguageHaskell98

Formatting.Holey

Contents

Description

Copy of the holey monoids library but with constructor exported.

Synopsis

Formatting library

type Format a = forall r. Holey Builder r (a -> r) Source

A formatter.

type Holey m r a = HoleyT r a m Source

newtype HoleyT r a m Source

The type of a monoid with holes. The underlying monoid is represented by type parameter m. The r is the result type and stays polymorphic until the very last moment when run is called. The last argument a is always a function with zero or more arguments, finally resulting in r. Ordering the arguments in this order allows holey monoids to be composed using ., stacking the expected arguments. Note that the Monoid constraint is only used in the identity Holey and in composing two Holeys.

Constructors

Holey 

Fields

runHM :: (m -> r) -> a
 

Instances

Functor (HoleyT r a) 
(IsString m, (~) * a r) => IsString (Holey m r a)

Very useful instance for writing format string.

(%) :: Monoid n => Holey n b c -> Holey n b1 b -> Holey n b1 c Source

Composition operator. The same as category composition.

(%.) :: Holey m r (a -> b) -> Holey a b c -> Holey m r c Source

Function compose two holeys. Will feed the result of one holey into another.

now :: m -> Holey m r r Source

Insert a constant monoidal value.

bind :: Holey m b c -> (m -> Holey n a b) -> Holey n a c Source

Monadic indexed bind for holey monoids.

later :: (a -> m) -> Holey m r (a -> r) Source

Insert a monoidal value that is not specified until the computation is run. The argument that is expected later is converted to the monoid type using the given conversion function.