mirror of
https://github.com/github/semantic.git
synced 2025-01-02 12:23:08 +03:00
Add a function computing the FreeAlgorithm for two terms.
This commit is contained in:
parent
81e80eae50
commit
00ae25a932
@ -94,3 +94,14 @@ extension FreeAlgorithm where A: Equatable {
|
||||
return evaluate(==)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func diff<A>(a: Fix<A>, _ b: Fix<A>) -> FreeAlgorithm<A, Free<A, Patch<A>>> {
|
||||
switch (a.out, b.out) {
|
||||
case let (.Keyed(a), .Keyed(b)):
|
||||
return .Roll(.ByKey(a, b, Syntax.Keyed >>> Free.Roll >>> FreeAlgorithm.Pure))
|
||||
|
||||
default:
|
||||
return .Roll(.Recursive(a, b, FreeAlgorithm.Pure))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user