Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
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 {}"
- data FormatArg
- data Format = Format {
- formatString :: String
- formatArgs :: [FormatArg]
- data Formatter = Formatter {}
- prebuild :: Format -> Text
- build :: Format -> Text
- class FormatBuild a where
- class Hole a where
- fmt :: FormatBuild a => a -> FormatArg
- class FormatResult r where
- format :: FormatResult r => String -> r
- formats :: FormatResult r => String -> [FormatArg] -> r
- (~~) :: (Hole a, FormatResult r) => Format -> a -> r
- (~%) :: FormatBuild a => String -> a -> FormatArg
Documentation
Format | |
|
class FormatBuild a where Source #
FormatBuild class, by default using show
formatBuild :: a -> Builder Source #
formatBuild :: Show a => a -> Builder Source #
fmt :: FormatBuild a => a -> FormatArg Source #
class FormatResult r where Source #
formatResult :: Format -> r Source #
format :: FormatResult r => String -> r Source #