mirror of
https://github.com/github/semantic.git
synced 2024-11-25 11:04:00 +03:00
Add an elimination form for Cofree.
This commit is contained in:
parent
6423d5817f
commit
3a1ced9786
@ -116,6 +116,10 @@ extension CofreeType {
|
||||
return Self(annotation, syntax)
|
||||
}
|
||||
|
||||
public static func eliminate(term: Self) -> (Annotation, Syntax<Self, Leaf>) {
|
||||
return (term.extract, term.unwrap)
|
||||
}
|
||||
|
||||
/// Constructs a cofree by coiteration.
|
||||
///
|
||||
/// 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.
|
||||
|
Loading…
Reference in New Issue
Block a user