HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

ModulePyF-0.11.3.0Haskell2010

PyF.Class

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:

Example1 expression
let x = 10 in [fmt|{x}|]10

Is an implicit formatting to number, but:

Example1 expression
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.

  • 1 type
  • 3 classes
  • PackagePyF-0.11.3.0
  • Exports5
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceClass.hs

Default formatting classification

2 declarations
datadata PyFCategory
#

The three categories of formatting in PyF

Constructors

  • PyFIntegral

    Format as an integral, no fractional part, precise value

  • PyFFractional

    Format as a fractional, approximate value with a fractional part

  • PyFString

    Format as a string

familytype family PyFClassify t :: PyFCategory
#

Classify a type to a PyFCategory This classification will be used to decide which formatting to use when no type specifier in provided.

Instances23PyFClassify, …

String formatting

1 declaration
classclass PyFToString t where
#

Convert a type to string This is used for the string formatting.

Methods

Instances7PyFToString, …

Real formatting (with optional fractional part)

1 declaration
classclass PyfFormatFractional a where
#

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.

Methods

Instances3PyfFormatFractional

Integral formatting

1 declaration
classclass PyfFormatIntegral i where
#

Apply 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.

Methods

Instances2PyfFormatIntegral