1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 02:44:36 +03:00

Implement merge on Free.

This commit is contained in:
Rob Rix 2015-10-19 13:05:09 -04:00
parent 0e8272fa6f
commit 415822c1af

View File

@ -118,6 +118,10 @@ public enum Free<A, B>: CustomDebugStringConvertible, SyntaxConvertible {
extension Free where B: PatchType, B.Element == Cofree<A, ()> {
public typealias Term = B.Element
public func merge(transform: B -> Term) -> Free {
return flatMap(transform >>> Free.init)
}
private func discardNullTerms(syntax: Syntax<Term?, A>) -> Term? {
switch syntax {
case let .Leaf(a):