1
1
mirror of https://github.com/github/semantic.git synced 2024-11-25 11:04:00 +03:00

Define hylomorphism through Syntax.

This commit is contained in:
Rob Rix 2015-10-22 17:11:35 -04:00
parent f4966684a5
commit 521e253240

View File

@ -120,6 +120,13 @@ extension Free {
}
// MARK: - Hylomorphism
public func hylo<A, B, Leaf>(down: Syntax<B, Leaf> -> B, _ up: A -> Syntax<A, Leaf>) -> A -> B {
return up >>> { $0.map(hylo(down, up)) } >>> down
}
extension Free where Value: PatchType, Value.Element == Cofree<Leaf, ()> {
public typealias Term = Value.Element