Portability | non-portable |
---|---|

Stability | experimental |

Maintainer | generics@haskell.org |

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)

# Generic folding

The class fold explains how to convert an algebra
`Alg`

into a function from functor to result.

fold :: (Regular a, Fold (PF a), Functor (PF a)) => Algebra a r -> a -> rSource

Fold with convenient algebras.

# Generic unfolding

The class unfold explains how to convert a coalgebra `CoAlg`

and a seed
into a representation.