The three categories of formatting in PyF
Constructors
PyFIntegralFormat as an integral, no fractional part, precise value
PyFFractionalFormat as a fractional, approximate value with a fractional part
PyFStringFormat as a string
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
ModulePyF-0.11.3.0Haskell2010
You want to add formatting support for your custom type. This is the right module.
In PyF, formatters are in three categories:
Integral numbers, which are numbers without fractional part
Fractional numbers, which are numbers with a fractional part
String, which represents text.
The formatting can be either explicit or implicit. For example:
let x = 10 in [fmt|{x}|]10
Is an implicit formatting to number, but:
let x = 10 in [fmt|{x:d}|]Is an explicit formatting to Integral numbers, using d.
Implicit formatting will only format to either Integral, Fractional or text,
and this choice is done by the (open) type family PyFCategory.
This modules also provides 3 type class for formatting.
PyfFormatFractional and PyfFormatIntegral are responsible for formatting integral and fractional numbers. Default instances are provided respectively for Real and Integral. PyFToString is in charge of formatting text.
The three categories of formatting in PyF
PyFIntegralFormat as an integral, no fractional part, precise value
PyFFractionalFormat as a fractional, approximate value with a fractional part
PyFStringFormat as a string
Classify a type to a PyFCategory This classification will be used to decide which formatting to use when no type specifier in provided.
type PyFClassify ByteString = 'PyFStringDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify ByteString = 'PyFStringDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Integer = 'PyFIntegralDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Natural = 'PyFIntegralDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify String = 'PyFStringDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Int16 = 'PyFIntegralDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Int32 = 'PyFIntegralDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Int64 = 'PyFIntegralDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Int8 = 'PyFIntegralDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Word16 = 'PyFIntegralDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Word32 = 'PyFIntegralDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Word64 = 'PyFIntegralDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Word8 = 'PyFIntegralDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Char = 'PyFStringDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Double = 'PyFFractionalDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Float = 'PyFFractionalDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Int = 'PyFIntegralDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Word = 'PyFIntegralDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Text = 'PyFStringDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify Text = 'PyFStringDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify DiffTime = 'PyFFractionalDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify NominalDiffTime = 'PyFFractionalDefined in PyF-0.11.3.0 · PyF.Classtype PyFClassify (Ratio i) = 'PyFFractionalDefined in PyF-0.11.3.0 · PyF.ClassConvert a type to string This is used for the string formatting.
pyfToString :: t -> StringPyFToString ByteStringDefined in PyF-0.11.3.0 · PyF.ClassPyFToString ByteStringDefined in PyF-0.11.3.0 · PyF.ClassPyFToString StringDefined in PyF-0.11.3.0 · PyF.ClassPyFToString CharDefined in PyF-0.11.3.0 · PyF.ClassPyFToString TextDefined in PyF-0.11.3.0 · PyF.ClassPyFToString TextDefined in PyF-0.11.3.0 · PyF.ClassShow t => PyFToString tDefined in PyF-0.11.3.0 · PyF.ClassDefault instance. Convert any type with a 'Show instance.
Apply a fractional formatting to any type.
A default instance for any Real is provided which internally converts to Double, which may not be efficient or results in rounding errors.
You can provide your own instance and internally use formatFractional which does have the same signatures as pyfFormatFractional but with a RealFrac constraint.
PyfFormatFractional DoubleDefined in PyF-0.11.3.0 · PyF.ClassThis instance does not do any conversion.
PyfFormatFractional FloatDefined in PyF-0.11.3.0 · PyF.ClassThis instance does not do any conversion.
Real t => PyfFormatFractional tDefined in PyF-0.11.3.0 · PyF.ClassApply an integral formatting to any type.
A default instance for any Integral is provided.
You can provide your own instance and internally use formatIntegral which does have the same signatures as pyfFormatIntegral but with an Integral constraint.
PyfFormatIntegral CharDefined in PyF-0.11.3.0 · PyF.ClassReturns the numerical value of a Char
>>> [fmt|{a:d}|]
97
Integral t => PyfFormatIntegral tDefined in PyF-0.11.3.0 · PyF.ClassDefault instance for any Integral.