formatting-7.2.0: Combinator-based type-safe formatting (like printf() or FORMAT)
Safe HaskellSafe-Inferred
LanguageHaskell2010

Formatting.FromBuilder

Synopsis

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.

Methods

fromBuilder :: Builder -> a Source #

Instances

Instances details
FromBuilder Text Source # 
Instance details

Defined in Formatting.FromBuilder

FromBuilder Builder Source # 
Instance details

Defined in Formatting.FromBuilder

FromBuilder Text Source # 
Instance details

Defined in Formatting.FromBuilder

FromBuilder [Char] Source # 
Instance details

Defined in Formatting.FromBuilder

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"