mirror of
https://github.com/github/semantic.git
synced 2024-11-29 02:44:36 +03:00
Document coiterate
as an anamorphism.
This commit is contained in:
parent
f145bb4293
commit
6bcbccfe08
@ -21,7 +21,7 @@ public enum Cofree<A, B> {
|
||||
|
||||
/// Constructs a cofree by coiteration.
|
||||
///
|
||||
/// The initial seed is used as the annotation of the returned value. The continuation of the structure is unpacked by applying `annotate` to the seed and mapping the resulting syntax’s values recursively. In this manner, the structure is unfolded bottom-up, starting with `seed` and ending at the leaves.
|
||||
/// This is an _anamorphism_ (from the Greek “ana,” “upwards”; compare “anabolism”), a generalization of unfolds over regular trees (and datatypes isomorphic to them). The initial seed is used as the annotation of the returned value. The continuation of the structure is unpacked by applying `annotate` to the seed and mapping the resulting syntax’s values recursively. In this manner, the structure is unfolded bottom-up, starting with `seed` and ending at the leaves.
|
||||
///
|
||||
/// As this is the dual of `Free.iterate`, it’s unsurprising that we have a similar guarantee: coiteration is linear in the size of the constructed tree.
|
||||
public static func coiterate(annotate: B -> Syntax<B, A>)(_ seed: B) -> Cofree {
|
||||
|
Loading…
Reference in New Issue
Block a user