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

Modulegeneric-data-1.1.0.2Haskell2010

Generic.Data.Internal.Traversable

Generic implementation of Foldable and Traversable.

There is already a naive implementation using the generic Rep's own instances of Foldable and Traversable. However, deriving then generates a lot of code that may not be simplified away by GHC, that results in unnecessary run-time overhead.

In contrast, this implementation guarantees that the generated code is identical to stock-derived instances of Foldable and Traversable, which have the following syntactic properties:

  • constructors with zero fields use pure once;

  • constructors with one field use fmap once;

  • constructors with n >= 2 fields use liftA2 once and (<*>) n-2 times.

The heavy lifting is actually done by the ap-normalize library.

  • 4 types
  • 6 classes
  • 6 values

Library

7 declarations

Foldable

datadata Maybe' m
#

Isomorphic to Maybe m, but we need to micromanage the use of Monoid vs Semigroup to match exactly the output of stock deriving, for inspection testing.

Constructors

classclass GFoldMap (t :: Type -> Type) where
#

Methods

Instances9GFoldMap, …
  • GFoldMap Par1Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Traversable
  • GFoldMap U1Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Traversable
  • GFoldMap V1Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Traversable
  • Foldable t => GFoldMap (Rec1 t)Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Traversable
  • GFoldMap (K1 i a)Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Traversable
  • (GFoldMap f, GFoldMap g) => GFoldMap (f :*: g)Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Traversable
  • (GFoldMap f, GFoldMap g) => GFoldMap (f :+: g)Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Traversable
  • GFoldMap f => GFoldMap (M1 i c f)Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Traversable
  • (Foldable t, Foldable f) => GFoldMap (t :.: f)Defined in generic-data-1.1.0.2 · Generic.Data.Internal.Traversable

Traversable

classclass GTraverse (arr :: (Type -> Type) -> Type -> Type -> Type) (t :: Type -> Type) where
#

Methods

Instances12GTraverse, …