1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 07:55:12 +03:00

Rewrite hylo without composition.

This commit is contained in:
Rob Rix 2015-11-03 11:03:57 -05:00
parent 022de3c657
commit b6436e91f6

View File

@ -48,8 +48,8 @@ public enum Syntax<Recur, A>: CustomDebugStringConvertible {
/// Hylomorphisms are used to construct diffs corresponding to equal terms; see also `CofreeType.zip`.
///
/// `hylo` can be used with arbitrary functors which can eliminate to and introduce with `Syntax` values.
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
public func hylo<A, B, Leaf>(down: Syntax<B, Leaf> -> B, _ up: A -> Syntax<A, Leaf>)(_ a: A) -> B {
return down(up(a).map(hylo(down, up)))
}
/// Reiteration through `Syntax`.