HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

ModulePyF-0.11.5.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.

Contents
  1. Default formatting classification
  2. String formatting
  3. Real formatting (with optional fractional part)
  4. Integral formatting
Synopsis
  • PackagePyF-0.11.5.0
  • Exports5
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceClass.hs

Default formatting classification

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

classclass PyFToString t where

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

Methods

Instances7PyFToString, …

Real formatting (with optional fractional part)

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

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