multirec-0.2: Generic programming with systems of recursive datatypesSource codeContentsIndex
Generics.MultiRec.Fold
Portabilitynon-portable
Stabilityexperimental
Maintainergenerics@haskell.org
Contents
Generic fold and unfold
Creating an algebra
Description

The definition of generic fold, unfold, paramorphisms. In addition, some combinators that facilitate the construction of algebras.

There are several variants of fold in other modules that are probably easier to use:

Synopsis
type Algebra' s f r = forall ix. Ix s ix => s ix -> f s r ix -> r ix
type Algebra s r = Algebra' s (PF s) r
type AlgebraF' s f g r = forall ix. Ix s ix => s ix -> f s r ix -> g (r ix)
type AlgebraF s g r = AlgebraF' s (PF s) g r
fold :: (Ix s ix, HFunctor (PF s)) => Algebra s r -> ix -> r ix
foldM :: (Ix s ix, HFunctor (PF s), Monad m) => AlgebraF s m r -> ix -> m (r ix)
type CoAlgebra' s f r = forall ix. Ix s ix => s ix -> r ix -> f s r ix
type CoAlgebra s r = CoAlgebra' s (PF s) r
type CoAlgebraF' s f g r = forall ix. Ix s ix => s ix -> r ix -> g (f s r ix)
type CoAlgebraF s g r = CoAlgebraF' s (PF s) g r
unfold :: (Ix s ix, HFunctor (PF s)) => CoAlgebra s r -> r ix -> ix
unfoldM :: (Ix s ix, HFunctor (PF s), Monad m) => CoAlgebraF s m r -> r ix -> m ix
type ParaAlgebra' s f r = forall ix. Ix s ix => s ix -> f s r ix -> ix -> r ix
type ParaAlgebra s r = ParaAlgebra' s (PF s) r
type ParaAlgebraF' s f g r = forall ix. Ix s ix => s ix -> f s r ix -> ix -> g (r ix)
type ParaAlgebraF s g r = ParaAlgebraF' s (PF s) g r
para :: (Ix s ix, HFunctor (PF s)) => ParaAlgebra s r -> ix -> r ix
paraM :: (Ix s ix, HFunctor (PF s), Monad m) => ParaAlgebraF s m r -> ix -> m (r ix)
type AlgPart a s r ix = a s r ix -> r ix
type :-> f g s r ix = f s r ix -> g s r ix
(&) :: (AlgPart a :-> (AlgPart b :-> AlgPart (a :+: b))) s r ix
tag :: AlgPart a s r ix -> AlgPart (a :>: ix) s r ix'
con :: AlgPart a s r ix -> AlgPart (C c a) s r ix
Generic fold and unfold
type Algebra' s f r = forall ix. Ix s ix => s ix -> f s r ix -> r ixSource
type Algebra s r = Algebra' s (PF s) rSource
type AlgebraF' s f g r = forall ix. Ix s ix => s ix -> f s r ix -> g (r ix)Source
type AlgebraF s g r = AlgebraF' s (PF s) g rSource
fold :: (Ix s ix, HFunctor (PF s)) => Algebra s r -> ix -> r ixSource
foldM :: (Ix s ix, HFunctor (PF s), Monad m) => AlgebraF s m r -> ix -> m (r ix)Source
type CoAlgebra' s f r = forall ix. Ix s ix => s ix -> r ix -> f s r ixSource
type CoAlgebra s r = CoAlgebra' s (PF s) rSource
type CoAlgebraF' s f g r = forall ix. Ix s ix => s ix -> r ix -> g (f s r ix)Source
type CoAlgebraF s g r = CoAlgebraF' s (PF s) g rSource
unfold :: (Ix s ix, HFunctor (PF s)) => CoAlgebra s r -> r ix -> ixSource
unfoldM :: (Ix s ix, HFunctor (PF s), Monad m) => CoAlgebraF s m r -> r ix -> m ixSource
type ParaAlgebra' s f r = forall ix. Ix s ix => s ix -> f s r ix -> ix -> r ixSource
type ParaAlgebra s r = ParaAlgebra' s (PF s) rSource
type ParaAlgebraF' s f g r = forall ix. Ix s ix => s ix -> f s r ix -> ix -> g (r ix)Source
type ParaAlgebraF s g r = ParaAlgebraF' s (PF s) g rSource
para :: (Ix s ix, HFunctor (PF s)) => ParaAlgebra s r -> ix -> r ixSource
paraM :: (Ix s ix, HFunctor (PF s), Monad m) => ParaAlgebraF s m r -> ix -> m (r ix)Source
Creating an algebra
type AlgPart a s r ix = a s r ix -> r ixSource
type :-> f g s r ix = f s r ix -> g s r ixSource
(&) :: (AlgPart a :-> (AlgPart b :-> AlgPart (a :+: b))) s r ixSource
tag :: AlgPart a s r ix -> AlgPart (a :>: ix) s r ix'Source
con :: AlgPart a s r ix -> AlgPart (C c a) s r ixSource
Produced by Haddock version 2.4.2