multirec-0.4: Generic programming for families of recursive datatypesSource codeContentsIndex
Generics.MultiRec.FoldAlg
Portabilitynon-portable
Stabilityexperimental
Maintainergenerics@haskell.org
Contents
The type family of convenient algebras.
The class to turn convenient algebras into standard algebras.
Interface
Construction of algebras
Description
A variant of fold that allows the specification of the algebra in a convenient way.
Synopsis
type family Alg f r ix :: *
type Algebra phi r = forall ix. phi ix -> Alg (PF phi) r ix
class Fold f where
alg :: Alg f r ix -> f r ix -> r ix
fold :: forall phi ix r. (Fam phi, HFunctor phi (PF phi), Fold (PF phi)) => Algebra phi r -> phi ix -> ix -> r ix
(&) :: a -> b -> (a, b)
The type family of convenient algebras.
type family Alg f r ix :: *Source
The type family we use to describe the convenient algebras.
type Algebra phi r = forall ix. phi ix -> Alg (PF phi) r ixSource
The algebras passed to the fold have to work for all index types in the family. The additional witness argument is required only to make GHC's typechecker happy.
The class to turn convenient algebras into standard algebras.
class Fold f whereSource
The class fold explains how to convert a convenient algebra Alg back into a function from functor to result, as required by the standard fold function.
Methods
alg :: Alg f r ix -> f r ix -> r ixSource
show/hide Instances
Fold U
Fold (K a)
Fold (I xi)
Fold f => Fold (C c f)
Fold f => Fold (f :>: xi)
Fold g => Fold (K a :*: g)
Fold g => Fold (I xi :*: g)
(Fold f, Fold g) => Fold (f :+: g)
Interface
fold :: forall phi ix r. (Fam phi, HFunctor phi (PF phi), Fold (PF phi)) => Algebra phi r -> phi ix -> ix -> r ixSource
Fold with convenient algebras.
Construction of algebras
(&) :: a -> b -> (a, b)Source
For constructing algebras that are made of nested pairs rather than n-ary tuples, it is helpful to use this pairing combinator.
Produced by Haddock version 2.4.2