|Ilya Portnov a7ca43ebcf Update to lts-11.2.||1 year ago|
|Data||1 year ago|
|examples||2 years ago|
|.gitignore||2 years ago|
|ChangeLog.md||2 years ago|
|LICENSE||2 years ago|
|README.md||2 years ago|
|Setup.hs||2 years ago|
|stack.yaml||1 year ago|
|text-format-heavy.cabal||1 year ago|
This is Haskell string formatting library, which prefers functionality and extendability over light weight and (probably, in some cases) performance. This library is more or less analog of Python's string.format function, and has similar syntax. It also exposes all required interfaces to extend and customize it.
Most notable features are:
Formatting strings are present by
Format type. Values of this type can be
parsed from lazy Text, or can be entered as string literals, since
There are two syntaxes of formatting strings defined by this package:
instance IsString Formatuses this syntax.
It is possible to implement custom syntaxes of format strings: you just need to
parse instances of
Format type from some sort of strings.
format function takes a
Format specification and a container with
variables. Container types are generalized by
VarContainer type class.
Standard container implementations include:
Singletype for case when you need to pass only one variable.
Map Text a. These contain named variables, i.e.
One can implement custom variable containers, for example some record types.
Types of variables that can be used for subsitiution are generalized by
Formatable type class. Each implementation defines default value formatting
rules, and a syntax of variable format specification. For example, for
integers, floats and strings, python-like syntax is used. Standard set of
variable types includes:
Word8..64, others can be easily added);
String, lazy and strict
ByteString, lazy and strict
Showtype class can be used by packing it into
One can implement custom variable types.
For examples, please refer to GitHub wiki and
directory in this repo. There are also some examples in haddock documentation.