| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Language.Haskell.Printf
Description
Text.Printf is a useful module, but due to the typeclass hacks it uses, it can be hard to tell if the format string you wrote is well-formed or not. This package provides a mechanism to create formatting functions at compile time.
Note that, to maintain consistency with other printf implementations, negative ints that are printed as unsigned will "underflow". (Text.Printf does this too.)
>>>[s|%u|] (-1 :: Int32)WAS "4294967295" NOW Not in scope: type constructor or class `Int32'
Thus, any time you want to print a number using the unsigned, octal, or hex specifiers, your input must be an instance of Bounded.
Synopsis
- s :: QuasiQuoter
- t :: QuasiQuoter
- p :: QuasiQuoter
- hp :: QuasiQuoter
Documentation
s :: QuasiQuoter Source #
[s|Hello, %s! (%d people greeted)|] :: ... ->String
This formatter follows the guidelines listed
here, except for
%n (store number of printed characters) for obvious
reasons.
%c ::Char%s ::String%q ::Text-- lazy text %Q ::Text-- strict text -- datatypes with Show instances %? ::Showa => a -- signed integer types %d, %i ::Integrali => i -- unsigned integer types %u :: (Boundedi,Integrali) => i %o :: (Boundedi,Integrali) => i %x, %X :: (Boundedi,Integrali) => i -- floats %a, %A ::RealFloatf => f %e, %E ::RealFloatf => f %f, %F ::RealFloatf => f %g, %G ::RealFloatf => f %p ::Ptra
p :: QuasiQuoter Source #