1
1
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:
Rob Rix 2015-10-23 11:40:03 -04:00
parent 180cc41f6c
commit 383b20bb31

View File

@ -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 dont 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 }