mirror of
https://github.com/github/semantic.git
synced 2024-11-29 02:44:36 +03:00
Define coiterate
so as to reflect its symmetry with ana
.
This commit is contained in:
parent
f0379f421b
commit
090406aafe
@ -25,7 +25,7 @@ public enum Cofree<Leaf, Annotation> {
|
||||
///
|
||||
/// 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: Annotation -> Syntax<Annotation, Leaf>)(_ seed: Annotation) -> Cofree {
|
||||
return .Unroll(seed, annotate(seed).map(coiterate(annotate)))
|
||||
return (curry(Unroll)(seed) <<< { $0.map(coiterate(annotate)) } <<< annotate) <| seed
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user