{-# LANGUAGE OverloadedStrings #-}
module Formatting.Examples where
import Data.Text.Lazy (Text)
import Data.Text.Lazy.Builder (Builder)
import Formatting
hello :: Text
hello = format ("Hello, World!")
strings :: Text
strings =
format ("Here comes a string: " % string % " and another " % string)
"Hello, World!"
"Ahoy!"
texts :: Text
texts =
format ("Here comes a string: " % text % " and another " % text)
"Hello, World!"
"Ahoy!"
builders :: Text
builders =
format ("Here comes a string: " % builder % " and another " % text)
("Hello, World!" :: Builder)
"Ahoy!"
integers :: Text
integers =
format ("Here comes an integer: " % int % " and another: " % int)
(23 :: Int)
(0 :: Integer)
floats :: Text
floats =
format ("Here comes a float: " % float)
(123.2342 :: Float)
hexes :: Text
hexes =
format ("Here comes a hex: " % hex)
(123 :: Int)
padding :: Text
padding =
format ("A left-padded number: " % left 3 '0')
(9 :: Int)