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

Moduleone-liner-2.1Haskell2010

Generics.OneLiner.Binary

These generic functions allow changing the types of the constant leaves. They require type classes with 2 parameters, the first for the input type and the second for the output type.

All functions without postfix are for instances of Generic, and functions with postfix 1 are for instances of Generic1 (with kind Type -> Type) which get an extra argument to specify how to deal with the parameter. Functions with postfix 01 are also for Generic1 but they get yet another argument that, like the Generic functions, allows handling of constant leaves.

  • 9 types
  • 11 classes
  • 25 values
  • Packageone-liner-2.1
  • Exports46
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceBinary.hs

Traversing values

9 declarations
valuegmap
  1. :: (ADT t t', Constraints t t' c)
  2. => forall s s'. c s s' => s -> s'
  3. -> t
  4. -> t'
#

Map over a structure, updating each component.

gmap is generic specialized to (->).

valueglmap
  1. :: (ADT t t', Constraints t t' c)
  2. => forall s s'. c s s' => s %1 -> s'
  3. -> t
  4. -> t'
#

Map over a structure linearly, updating each component.

glmap is generic specialized to the linear arrow.

Combining values

2 declarations
valuezipWithA
  1. :: (ADT t t', Constraints t t' c, Alternative f)
  2. => forall s s'. c s s' => s -> s -> f s'
  3. -> t
  4. -> t
  5. -> f t'
#

Combine two values by combining each component of the structures with the given function, under an applicative effect. Returns empty if the constructors don't match.

zipWithA is generic specialized to Zip

Functions for records

5 declarations

These functions only work for single constructor data types.

Generic programming with profunctors

9 declarations

All the above functions have been implemented using these functions, using different profunctors.

Classes

A generic function using a GenericRecordProfunctor works on any data type with exactly one constructor, a.k.a. records, with multiple fields (mult) or no fields (unit).

GenericRecordProfunctor is similar to ProductProfuctor from the product-profunctor package, but using types from GHC.Generics.

Instances1GenericRecordProfunctor
classclass Profunctor p => GenericUnitProfunctor (p :: Type -> Type -> Type) where
#

Methods

Instances13GenericUnitProfunctor, …
classclass Profunctor p => GenericProductProfunctor (p :: Type -> Type -> Type) where
#

Methods

  • mult :: p (f a) (f' a') -> p (g a) (g' a') -> p ((:*:) f g a) ((:*:) f' g' a')
Instances13GenericProductProfunctor, …
classclass Profunctor p => GenericSumProfunctor (p :: Type -> Type -> Type) where
#

Methods

  • plus :: p (f a) (f' a') -> p (g a) (g' a') -> p ((:+:) f g a) ((:+:) f' g' a')
Instances10GenericSumProfunctor, …
classclass Profunctor p => GenericEmptyProfunctor (p :: Type -> Type -> Type) where
#

Methods

Instances10GenericEmptyProfunctor, …
classclass Profunctor p => GenericConstantProfunctor (p :: Type -> Type -> Type) where
#

Methods

Instances10GenericConstantProfunctor, …

Types

12 declarations
classclass FunConstraints (c :: Type -> Constraint) t where
#

Automatically apply a lifted function to a polymorphic argument as many times as possible.

A constraint `FunConstraint c t` is equivalent to the conjunction of constraints `c s` for every argument type of t.

If r is not a function type:

c a :- FunConstraints c (a -> r)
(c a, c b) :- FunConstraints c (a -> b -> r)
(c a, c b, c d) :- FunConstraints c (a -> b -> d -> r)
Instances2FunConstraints
classclass AnyType (a :: k) (b :: k1)
#
Instances1AnyType
  • AnyType a bDefined in one-liner-2.1 · Generics.OneLiner.Internal