@hackage th-format0.1.3.0
Template Haskell based support for format strings
Categories
License
BSD-3-Clause
Maintainer
mtesseract@silverratio.net
Links
Versions
Installation
Dependencies (5)
- Earley >=0.12.1.0 && <0.14
- base >=4.7 && <5
- haskell-src-meta >=0.8.0.2 && <0.9
- template-haskell >=2.12.0.0 && <2.15
- text >=1.2.3.0 && <1.3 Show all…
Dependents (2)
@hackage/access-token-provider, @hackage/planb-token-introspection
th-format

About
This is th-format, a Haskell package implementing support for format
strings using Template Haskell quasi quoters. It requires the GHC
extension QuasiQuotes to be enabled. Parsing is implemented using
Earley.
This package is BSD3 licensed.
Examples
Using th-format, you can use naive variable interpolation instead of
verbosely concatenating strings manually. Thus, instead of
putStrLn $ "Client \"" ++ show client ++ "\" has requested resource \"" ++ show resource ++ "\" at date " ++ show date ++ "."
one can directly write:
putStrLn $ [fmt|Client "$client" has requested resource "$resource" at date $date|]
There are currently two supported ways of interpolation:
- Simple interpolation, as in
[fmt|Variable foo contains $foo|]. - Expression interpolation, as in
[fmt|The toggle is ${if toggle then ("on" :: Text) else "off"}|]