1
1
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:
Rob Rix 2015-10-22 17:09:00 -04:00
parent f0379f421b
commit 090406aafe

View File

@ -25,7 +25,7 @@ public enum Cofree<Leaf, Annotation> {
///
/// As this is the dual of `Free.iterate`, its 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
}
}