-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple Haskell formatting -- -- Simple Haskell formatting @package hformat @version 0.1.0.0 -- | Format string with named args -- --
-- -- Named args
-- "My name is {name}, I am {age} years old" ~~ ("name" %= "Joe") ~~ ("age" %= 24) ≡ "My name is Joe, I am 24 years old"
-- -- Arg can have default value
-- "{var:x} = {val:10}" ~~ ("var" %= y) ≡ "y = 10"
-- -- Numeric position can be used
-- "{0} {1} {0}" ~~ "foo" ~~ "bar" ≡ "foo bar foo"
-- -- Positions can be omitted
-- "{} {}" ~~ "foo" ~~ 10 ≡ "foo 10"
-- -- Double braces to escape them
-- "{} and {{}}" ~~ 10 ≡ "10 and {}"
--
module Text.Format
data FormatArg
FormatNamed :: String -> Builder -> FormatArg
FormatPos :: Builder -> FormatArg
data Format
Format :: String -> [FormatArg] -> Format
[formatString] :: Format -> String
[formatArgs] :: Format -> [FormatArg]
data Formatter
Formatter :: Either String Int -> Maybe String -> Formatter
[formatter] :: Formatter -> Either String Int
[formatterDefault] :: Formatter -> Maybe String
build :: Format -> Text
-- | FormatBuild class, by default using show
class FormatBuild a where formatBuild = fromString ∘ show
formatBuild :: FormatBuild a ⇒ a -> Builder
class Hole a
hole :: Hole a ⇒ a -> [FormatArg]
fmt :: Hole a ⇒ a -> [FormatArg]
class FormatResult r
formatResult :: FormatResult r ⇒ Format -> r
format :: FormatResult r ⇒ String -> r
(~~) :: (Hole a, FormatResult r) ⇒ Format -> a -> r
(%=) :: FormatBuild a ⇒ String -> a -> [FormatArg]
instance Data.String.IsString Text.Format.Format
instance GHC.Show.Show Text.Format.Formatter
instance GHC.Read.Read Text.Format.Formatter
instance Text.Format.FormatBuild GHC.Base.String
instance Text.Format.FormatBuild GHC.Types.Char
instance Text.Format.FormatBuild GHC.Types.Int
instance Text.Format.FormatBuild GHC.Integer.Type.Integer
instance Text.Format.FormatBuild GHC.Types.Double
instance Text.Format.FormatBuild GHC.Types.Float
instance Text.Format.FormatBuild GHC.Types.Bool
instance Text.Format.FormatBuild Data.Text.Internal.Lazy.Text
instance Text.Format.FormatBuild Data.Text.Internal.Text
instance Text.Format.Hole Data.Text.Internal.Builder.Builder
instance Text.Format.Hole [Text.Format.FormatArg]
instance Text.Format.Hole [[Text.Format.FormatArg]]
instance Text.Format.FormatBuild a ⇒ Text.Format.Hole a
instance Text.Format.FormatResult Text.Format.Format
instance Text.Format.FormatResult Data.Text.Internal.Lazy.Text
instance Data.String.IsString s ⇒ Text.Format.FormatResult s