th-format-0.1.2.0: Template Haskell based support for format strings

Copyright(c) Moritz Clasmeier 2017-2018
LicenseBSD3
Maintainermtesseract@silverratio.net
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Data.Format

Description

 

Synopsis

Documentation

fmt :: QuasiQuoter Source #

Quasi Quoter for format strings. Examples:

Examples:

>>> let answer = 42 in [fmt|What is the answer to universe, life and everything? It's $answer!|]
"What is the answer to universe, life and everything? It's 42!"
>>> let toggle = True in [fmt|The toggle is switched ${if toggle then ("on" :: Text) else "off"}|]
"The toggle is switched on"
>>> let timeDelta = 60 in [fmt|Request latency: ${timeDelta}ms|]
"Request latency: 60ms"

fmtConcat :: [Text] -> Text Source #

This is just specialized mconcat, reexported under a specialized name in order to avoid namespace clashes.

class Format a where Source #

Type class which needs to be implemented by types that should be usable for format string interpolation. For most types the this class is simply implemented in terms of show. But for human-readable strings (e.g. String, Text), the format representation is simply the string itself, not its show-image (which adds quotation characters).

Minimal complete definition

formatText

Methods

formatText :: a -> Text Source #