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

Safe HaskellNone




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.

newtype Holey m r a 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


(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 cSource

Composition operator. The same as category composition.

now :: m -> Holey m r rSource

Insert a constant monoidal value.

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

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.

hmap :: (m -> n) -> Holey m r a -> Holey n r aSource

Convert between underlying Monoid types.