Portability | GHC |
---|---|
Stability | experimental |
Maintainer | chrisdone@gmail.com |
Safe Haskell | None |
Combinator-based type-safe formatting (like printf() or FORMAT) for Text.
Example:
>>>
formatPerson =
>>>
print (now "Person's name is " . ident . text . now ", age is " . hex . now "\n")
>>>
"Dave"
>>>
"Jones"
>>>
35
- 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
- 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
Holey generators
later :: Monoid m => (a -> m) -> Format m b (a -> b)Source
Append something to the output stream, taking the value as an argument to a formatting function later.
Renderers
hprint :: Handle -> Format Builder (IO ()) a -> aSource
Run the formatter and put the output onto the given Handle.
General
Integers
Render an integer using hexadecimal notation. (No leading 0x is added.) hex :: Build Integer
Floats
expt :: Real a => Int -> Build aSource
Render a floating point number using scientific/engineering notation (e.g. 2.3e123), with the given number of decimal places.
fixed :: Real a => Int -> Build aSource
Render a floating point number using normal notation, with the given number of decimal places.
prec :: Real a => Int -> Build aSource
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.
shortest :: Real a => Build aSource
Render a floating point number using the smallest number of digits that correctly represent it.