mirror of
https://github.com/github/semantic.git
synced 2024-12-26 16:33:03 +03:00
Define hylomorphism through Syntax.
This commit is contained in:
parent
f4966684a5
commit
521e253240
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user