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

Copyright(c) 2013 Chris Done, 2013 Shachaf Ben-Kiki
Safe HaskellSafe-Inferred




Copy of the holey monoids library but with constructor exported.


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.




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


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.