A formatter. When you construct formatters the first type
parameter, r, will remain polymorphic. The second type
parameter, a, will change to reflect the types of the data that
will be formatted. For example, in
myFormat :: Format r (Text -> Int -> r)
myFormat = "Person's name is " % text % ", age is " % hex
the first type parameter remains polymorphic, and the second type
parameter is Text -> Int -> r, which indicates that it formats a
Text and an Int.
When you run the Format, for example with format, you provide the arguments and they will be formatted into a string.
> format ("Person's name is " % text % ", age is " % hex) "Dave" 54
"Person's name is Dave, age is 36"
Instances5Category, Functor, IsString, Semigroup, Monoid
Category FormatDefined in formatting-7.2.0 · Formatting.InternalThe same as (%). At present using Category has an import overhead, but one day it might be imported as standard.
Functor (Format r)Defined in formatting-7.2.0 · Formatting.InternalThis can be used almost like contramap, e.g:
formatter :: Format r (b -> r) formatter = _ adapter :: a -> b adapter = _ adapted :: Format r (a -> r) adapted = fmap (. adapter) formattera ~ r => IsString (Format r a)Defined in formatting-7.2.0 · Formatting.InternalUseful instance for writing format string. With this you can write
"Foo"instead ofnow "Foo!".Semigroup (Format r (a -> r))Defined in formatting-7.2.0 · Formatting.InternalMonoid (Format r (a -> r))Defined in formatting-7.2.0 · Formatting.InternalUseful instance for applying two formatters to the same input argument. For example:
format (year <> "/" % month) nowwill yield"2015/01".