Summary: Generic folding and unfolding.
- type family Alg f r :: *
- type Algebra a r = Alg (PF a) r
- class Fold f where
- 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
- unfold :: (Unfold (PF a), Regular a) => CoAlgebra a s -> s -> a
- (&) :: a -> b -> (a, b)
The class fold explains how to convert an algebra
Alg into a function from functor to result.
Fold with convenient algebras.
The class unfold explains how to convert a coalgebra
CoAlg and a seed
into a representation.