HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulefmt-0.6.3.0Haskell2010

Fmt.Internal.Generic

  • 1 type
  • 3 classes
  • 1 value
  • Packagefmt-0.6.3.0
  • Exports5
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceGeneric.hs
Example1 expression
import Fmt
valuegenericF :: (Generic a, GBuildable (Rep a)) => a -> Builder
#

Format an arbitrary value without requiring a Buildable instance:

Example1 expression
data Foo = Foo { x :: Bool, y :: [Int] } deriving Generic
Example1 expression
fmt (genericF (Foo True [1,2,3]))Foo:  x: True  y: [1, 2, 3]

It works for non-record constructors too:

Example1 expression
data Bar = Bar Bool [Int] deriving Generic
Example1 expression
fmtLn (genericF (Bar True [1,2,3]))<Bar: True, [1, 2, 3]>

Any fields inside the type must either be Buildable or one of the following types:

The exact format of genericF might change in future versions, so don't rely on it. It's merely a convenience function.

newtypenewtype GenericBuildable a
#

A newtype for deriving a generic Buildable instance for any type using DerivingVia.

Example2 expressions
:set -XDerivingVia:{data Bar = Bar { x :: Bool, y :: [Int] }  deriving stock Generic  deriving Buildable via GenericBuildable Bar:}
Example1 expression
pretty (Bar True [1,2,3])Bar:  x: True  y: [1, 2, 3]

Constructors

Instances1Buildable
classclass Buildable' a where
#

A more powerful Buildable used for genericF. Can build functions, tuples, lists, maps, etc., as well as combinations thereof.

Methods

Instances20Buildable', …
classclass GetFields (f :: Type -> Type) where
#

Methods

Instances5GetFields