mirror of
https://github.com/github/semantic.git
synced 2024-11-25 11:04:00 +03:00
Interpret Fixed cases recursively
This commit is contained in:
parent
20e2a520e6
commit
f2aeae9e4b
@ -51,19 +51,15 @@ public struct Interpreter<Term: CofreeType> {
|
||||
let algorithm: Algorithm<Term, Diff>
|
||||
let annotations = (a.extract, b.extract)
|
||||
|
||||
let rollByIndex = { (a, b) -> Algorithm<Term, Diff> in
|
||||
.Roll(.ByIndex(a, b, Syntax.Indexed >>> Diff.Introduce(annotations) >>> Algorithm.Pure))
|
||||
}
|
||||
|
||||
switch (a.unwrap, b.unwrap) {
|
||||
case let (.Leaf, .Leaf(leaf)) where equal(a, b):
|
||||
return .Roll(annotations, .Leaf(leaf))
|
||||
case let (.Keyed(a), .Keyed(b)):
|
||||
algorithm = .Roll(.ByKey(a, b, Syntax.Keyed >>> Diff.Introduce(annotations) >>> Algorithm.Pure))
|
||||
case let (.Indexed(a), .Indexed(b)):
|
||||
algorithm = rollByIndex(a, b)
|
||||
case let (.Fixed(a), .Fixed(b)):
|
||||
algorithm = rollByIndex(a, b)
|
||||
algorithm = .Roll(.ByIndex(a, b, Syntax.Indexed >>> Diff.Introduce(annotations) >>> Algorithm.Pure))
|
||||
case (.Fixed(_), .Fixed(_)):
|
||||
fallthrough
|
||||
default:
|
||||
algorithm = .Roll(.Recursive(a, b, Algorithm.Pure))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user