safe-printf- Well-typed, flexible and variadic printf for Haskell

Safe HaskellNone




fmt :: QuasiQuoter Source

Quasiquoter for formatter. It supprots escape sequence. Formatter is prefixed by % and you can use %{hoge} to antiquotation.

>>> :set -XQuasiQuotes
>>> printf [fmt|Answer is: %d and %S|] 42 True
"Answer is: 42 and True"
>>> printf [fmt|%02d%% of people answers %{show . not}.\n|] 4 False
"04% of people answers True.\n"

Predefined formatters:

outputs %.
formats Integral value in decimal.
same as above, but padding with ' ' (space) to n digits.
same as above, but padding with '0' to n digits.
%b, %o, %h, %H
formats Integrals in binary, octet, hex and HEX resp. Padding options can be specified as %d.
formats Real value with show function.
embeds String value.
embeds Show instances.
%{expr}, where expr is a Haskell expression of type a -> String
Antiquote. This formats corresponding argument by passing to expr.