regular-0.2: Generic programming library for regular datatypes.Source codeContentsIndex
Generics.Regular.Functions.Fold
Portabilitynon-portable
Stabilityexperimental
Maintainergenerics@haskell.org
Contents
Generic folding
Generic unfolding
Construction of algebras
Description
Summary: Generic folding and unfolding.
Synopsis
type family Alg f r :: *
type Algebra a r = Alg (PF a) r
class Fold f where
alg :: Alg f r -> f r -> r
fold :: (Regular a, Fold (PF a), Functor (PF a)) => Algebra a r -> a -> r
type family CoAlg f s :: *
type CoAlgebra a s = s -> CoAlg (PF a) s
class Unfold f where
coalg :: (s -> a) -> CoAlg f s -> f a
unfold :: (Unfold (PF a), Regular a) => CoAlgebra a s -> s -> a
(&) :: a -> b -> (a, b)
Generic folding
type family Alg f r :: *Source
type Algebra a r = Alg (PF a) rSource
class Fold f whereSource
The class fold explains how to convert an algebra Alg into a function from functor to result.
Methods
alg :: Alg f r -> f r -> rSource
show/hide Instances
Fold U
Fold I
Fold (K a)
Fold f => Fold (S s f)
Fold f => Fold (C c f)
Fold g => Fold (I :*: g)
Fold g => Fold (K a :*: g)
(Fold f, Fold g) => Fold (f :+: g)
fold :: (Regular a, Fold (PF a), Functor (PF a)) => Algebra a r -> a -> rSource
Fold with convenient algebras.
Generic unfolding
type family CoAlg f s :: *Source
type CoAlgebra a s = s -> CoAlg (PF a) sSource
class Unfold f whereSource
The class unfold explains how to convert a coalgebra CoAlg and a seed into a representation.
Methods
coalg :: (s -> a) -> CoAlg f s -> f aSource
show/hide Instances
Unfold U
Unfold I
Unfold (K a)
Unfold f => Unfold (S s f)
Unfold f => Unfold (C c f)
(Unfold f, Unfold g) => Unfold (f :*: g)
(Unfold f, Unfold g) => Unfold (f :+: g)
unfold :: (Unfold (PF a), Regular a) => CoAlgebra a s -> s -> aSource
Construction of algebras
(&) :: a -> b -> (a, b)Source
For constructing algebras it is helpful to use this pairing combinator.
Produced by Haddock version 2.4.2