| Start |
|---|
| Fixed points
Inside a Here is how a typical recursive datatype can be translated into our framework of templates and fixed points. We remove recursive occurrences of the type and mark their positions using the |
| Folding up a structure one layer at a time Catamorphisms, or folds, model primitive recursion. |
| Unfolding a structure one layer at a time Anamorphisms, or unfolds, model primitive corecursion. Note that |
| Unfolding and then folding, fused It's common to structure a program as building up a data structure and then collapsing it to a single value. This is called a hylomorphism or refold. It's possible to elide the intermediate structure altogether for improved efficiency. Derivation: |
| Primitive recursion Paramorphisms model primitive recursion. At each iteration of the fold, the folding function receives the subtree for further processing. The Prelude's |
| Primitive corecursion Apomorphisms model primitive corecursion. At each iteration of the unfold, the unfolding function may return either a new seed or a whole subtree. Note that RemarksFunctions mentioned here in examples are defined with varying degrees of abstraction in several packages, for example, |
Read Article
https://develop.horje.com/learn/1434/reference