mirror of
https://github.com/github/semantic.git
synced 2024-11-25 11:04:00 +03:00
Document mapping a term into a diff.
This commit is contained in:
parent
180cc41f6c
commit
383b20bb31
@ -42,6 +42,9 @@ public struct Interpreter<Term: CofreeType> {
|
||||
|
||||
/// Diff `a` against `b`, if comparable.
|
||||
private func recur(a: Term, _ b: Term) -> Diff? {
|
||||
// If both terms are equal, we don’t need to bother diffing.
|
||||
//
|
||||
// In that case, zip the two terms together (to pair their annotations), and then map the resulting `Term` (which, since the terms are equal, will be non-nil) into a `Diff`.
|
||||
if equal(a, b) { return hylo(Diff.Roll, Cofree.eliminate)(Term.zip(a, b)!) }
|
||||
guard comparable(a, b) else { return nil }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user