hformat-0.3.0.0: Simple Haskell formatting

Safe HaskellSafe
LanguageHaskell2010

Text.Format

Description

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 {}"

Synopsis

Documentation

data FormatArg #

Instances

Hole FormatArg # 

Methods

hole :: FormatArg -> [FormatArg] #

Hole [[FormatArg]] # 

Methods

hole :: [[FormatArg]] -> [FormatArg] #

Hole [FormatArg] # 

Methods

hole :: [FormatArg] -> [FormatArg] #

data Format #

Constructors

Format 

class Hole a where #

Minimal complete definition

hole

Methods

hole :: a -> [FormatArg] #

Instances

Formattable a => Hole a # 

Methods

hole :: a -> [FormatArg] #

Hole FormatArg # 

Methods

hole :: FormatArg -> [FormatArg] #

Hole Formatted # 

Methods

hole :: Formatted -> [FormatArg] #

Hole [[FormatArg]] # 

Methods

hole :: [[FormatArg]] -> [FormatArg] #

Hole [FormatArg] # 

Methods

hole :: [FormatArg] -> [FormatArg] #

fmt :: Formattable a => a -> FormatArg #

class FormatResult r where #

Minimal complete definition

formatResult

Methods

formatResult :: Format -> r #

(~~) :: (Hole a, FormatResult r) => Format -> a -> r infixl 7 #

(~%) :: Formattable a => String -> a -> FormatArg infixr 8 #