th-printf-0.4.0: Compile-time printf

Safe HaskellNone
LanguageHaskell2010

Text.Printf.TH

Contents

Synopsis

Formatting strings

s :: QuasiQuoter Source #

[s|Hello, %s! (%d people greeted)|] :: ... -> String

This formatter follows the guidelines listed here, with some caveats:

  • Hexadecimal floating point isn't supported. I'm not convinced anyone actually uses this and there doesn't appear to be anything in base to produce it.
  • %p (pointer) and %n (store number of printed characters) are not supported for obvious reasons.
  • %.0e shows at least one decimal place despite this special case not appearing anywhere in the spec. This is a bug in formatRealFloat. As a result, %e and %#e have identical behavior.
%c     :: Char
%s     :: String

%?     :: Show a => a

%u     :: Natural

%d, %i :: Integral i => i
%o     :: Integral i => i
%x, %X :: Integral i => i

%e, %E :: RealFloat f => f
%f, %F :: RealFloat f => f
%g, %G :: RealFloat f => f

st :: QuasiQuoter Source #

[st|Hello, %s! (%d people greeted)|] :: ... -> Text

sb :: QuasiQuoter Source #

[sb|Hello, %s! (%d people greeted)|] :: ... -> ByteString

The resulting string is UTF8-encoded.

Printing strings

hp :: QuasiQuoter Source #

[hp|Hello, %s! (%d people greeted)|] :: MonadIO m => Handle -> ... -> m ()

Prints the produced string to the provided Handle. Like C printf, newline is not appended.

p :: QuasiQuoter Source #

[p|Hello, %s! (%d people greeted)|] :: MonadIO m => ... -> m ()
[p|...|] arg1 arg2...

is equivalent to

[hp|...|] stdout arg1 arg2...