Combinator-based type-safe formatting (like printf() or FORMAT) for Text.
formatPerson = print (now "Person's name is " . ident . text . now ", age is " . hex . now "n") "Dave" "Jones" 35
- type Format m a b = forall r. ((m -> r) -> a) -> (m -> r) -> b
- type Build a = forall r b. ((Builder -> r) -> b) -> (Builder -> r) -> a -> b
- type Wrap r m a t = ((m -> a) -> t) -> (r -> a) -> t
- now :: Monoid m => m -> Format m a a
- later :: Monoid m => (a -> m) -> Format m b (a -> b)
- wrap :: (m -> r) -> Wrap r m a t
- run :: Monoid f => Format f f a -> a
- ident :: Monoid m => ((m -> r) -> b) -> (m -> r) -> m -> b
- format :: Format Builder Text a -> a
- builder :: Format Builder Builder a -> a
- print :: Format Builder (IO ()) a -> a
- hprint :: Handle -> Format Builder (IO ()) a -> a
- build :: Buildable a => Build a
- text :: Build Text
- stext :: Build Text
- string :: Build String
- hex :: Build Integer
- expt :: Real a => Int -> Build a
- fixed :: Real a => Int -> Build a
- prec :: Real a => Int -> Build a
- shortest :: Real a => Build a
- left :: Buildable a => Int -> Char -> Build a
- right :: Buildable a => Int -> Char -> Build a
- data Text
- data Builder
- class Buildable p
Continuation based string formatter.
Append something to the output stream, taking the value as an argument to a formatting function later.
Run the formatter and put the output onto the given Handle.
Render an integer using hexadecimal notation. (No leading 0x is added.) hex :: Build Integer
Render a floating point number using scientific/engineering notation (e.g. 2.3e123), with the given number of decimal places.
Render a floating point number using normal notation, with the given number of decimal places.
Render a floating point number, with the given number of digits of precision. Uses decimal notation for values between 0.1 and 9,999,999, and scientific notation otherwise.
Render a floating point number using the smallest number of digits that correctly represent it.
Pad the left hand side of a string until it reaches k characters wide, if necessary filling with character c.
Pad the right hand side of a string until it reaches k characters wide, if necessary filling with character c.
Builder is an efficient way to build lazy
There are several functions for constructing builders, but only one
to inspect them: to extract any data, you have to turn them into
Text values using
Internally, a builder constructs a lazy
Text by filling arrays
piece by piece. As each buffer is filled, it is 'popped' off, to
become a new chunk of the resulting lazy
Text. All this is
hidden from the user of the
class Buildable p
The class of types that can be rendered to a