Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class FromBuilder a where
- fromBuilder :: Builder -> a
- formatted :: FromBuilder t => (t -> o) -> Format o a -> a
Documentation
class FromBuilder a where Source #
Anything that can be created from a Builder
.
This class makes it easier to add formatting to other API's.
See formatted
for some examples of this class in action.
fromBuilder :: Builder -> a Source #
Instances
FromBuilder Text Source # | |
Defined in Formatting.FromBuilder fromBuilder :: Builder -> Text Source # | |
FromBuilder Builder Source # | |
Defined in Formatting.FromBuilder fromBuilder :: Builder -> Builder Source # | |
FromBuilder Text Source # | |
Defined in Formatting.FromBuilder fromBuilder :: Builder -> Text Source # | |
FromBuilder [Char] Source # | |
Defined in Formatting.FromBuilder fromBuilder :: Builder -> [Char] Source # |
formatted :: FromBuilder t => (t -> o) -> Format o a -> a Source #
Makes it easy to add formatting to any api that is expecting a builder, a strict or lazy text, or a string. It is essentially (flip runFormat), but with a more generous type due to the typeclass.
For example:
>>> formatted TL.putStr ("x is: " % int % "n") 7
x is: 7
>>> formatted T.putStr ("x is: " % int % "n") 7
x is: 7
>>> formatted (id TL.Text) ("x is: " % int % "n") 7
"x is: 7n"
>>> formatted (id
T.Text) ("x is: " % int % "n") 7
"x is: 7n"