1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 16:33:03 +03:00

Define a reiterate function.

This commit is contained in:
Rob Rix 2015-10-22 17:25:58 -04:00
parent d0aeedeb52
commit 4195edc469

View File

@ -126,6 +126,11 @@ public func hylo<A, B, Leaf>(down: Syntax<B, Leaf> -> B, _ up: A -> Syntax<A, Le
return up >>> { $0.map(hylo(down, up)) } >>> down
}
public func reiterate<A, B, Leaf, Annotation>(down: (Annotation, Syntax<B, Leaf>) -> B, _ up: A -> (Annotation, Syntax<A, Leaf>)) -> A -> B {
return up >>> { ($0, $1.map(reiterate(down, up))) } >>> down
}
extension Free where Value: PatchType, Value.Element == Cofree<Leaf, ()> {
public typealias Term = Value.Element