| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Text.Printf.Safe.QQ
- fmt :: QuasiQuoter
Documentation
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
%. %d- formats
value in decimal.Integral %nd- same as above, but padding with
' '(space) to n digits. %0nd- same as above, but padding with
'0'to n digits. %b,%o,%h,%H- formats
s in binary, octet, hex and HEX resp. Padding options can be specified asIntegral%d. %f- formats
value withRealfunction.show %s- embeds
value.String %S- embeds
instances.Show %{expr}, whereexpris a Haskell expression of typea -> String- Antiquote. This formats corresponding argument by passing to
expr.