hformat-0.3.3.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

newtype Formatted Source #

Constructors

Formatted 
Instances
Eq Formatted Source # 
Instance details

Defined in Text.Format

Ord Formatted Source # 
Instance details

Defined in Text.Format

Show Formatted Source # 
Instance details

Defined in Text.Format

IsString Formatted Source # 
Instance details

Defined in Text.Format

Semigroup Formatted Source # 
Instance details

Defined in Text.Format

Monoid Formatted Source # 
Instance details

Defined in Text.Format

FormatResult Formatted Source # 
Instance details

Defined in Text.Format

Hole Formatted Source # 
Instance details

Defined in Text.Format

data FormatArg Source #

Instances
Hole FormatArg Source # 
Instance details

Defined in Text.Format

Hole [[FormatArg]] Source # 
Instance details

Defined in Text.Format

Methods

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

Hole [FormatArg] Source # 
Instance details

Defined in Text.Format

Methods

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

data Format Source #

Constructors

Format 
Instances
Show Format Source # 
Instance details

Defined in Text.Format

IsString Format Source # 
Instance details

Defined in Text.Format

Methods

fromString :: String -> Format #

FormatResult Format Source # 
Instance details

Defined in Text.Format

class Formattable a where Source #

Formattable class, by default using show

Instances
Formattable Bool Source # 
Instance details

Defined in Text.Format

Formattable Char Source # 
Instance details

Defined in Text.Format

Formattable Double Source # 
Instance details

Defined in Text.Format

Formattable Float Source # 
Instance details

Defined in Text.Format

Formattable Int Source # 
Instance details

Defined in Text.Format

Formattable Integer Source # 
Instance details

Defined in Text.Format

Formattable String Source # 
Instance details

Defined in Text.Format

Formattable Text Source # 
Instance details

Defined in Text.Format

Formattable Text Source # 
Instance details

Defined in Text.Format

Formattable Formatter Source # 
Instance details

Defined in Text.Format

class Hole a where Source #

Minimal complete definition

hole

Methods

hole :: a -> [FormatArg] Source #

Instances
Formattable a => Hole a Source # 
Instance details

Defined in Text.Format

Methods

hole :: a -> [FormatArg] Source #

Hole FormatArg Source # 
Instance details

Defined in Text.Format

Hole Formatted Source # 
Instance details

Defined in Text.Format

Hole [[FormatArg]] Source # 
Instance details

Defined in Text.Format

Methods

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

Hole [FormatArg] Source # 
Instance details

Defined in Text.Format

Methods

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

class FormatResult r where Source #

Minimal complete definition

formatResult

Methods

formatResult :: Format -> r Source #

Instances
IsString s => FormatResult s Source # 
Instance details

Defined in Text.Format

Methods

formatResult :: Format -> s Source #

FormatResult String Source # 
Instance details

Defined in Text.Format

FormatResult Format Source # 
Instance details

Defined in Text.Format

FormatResult Formatted Source # 
Instance details

Defined in Text.Format

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

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