From 383b20bb3170ce0f0424c5094fc9bd368ca87e75 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 23 Oct 2015 11:40:03 -0400 Subject: [PATCH] Document mapping a term into a diff. --- prototype/Doubt/Interpreter.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/prototype/Doubt/Interpreter.swift b/prototype/Doubt/Interpreter.swift index 788ffb9e6..57ebe90e0 100644 --- a/prototype/Doubt/Interpreter.swift +++ b/prototype/Doubt/Interpreter.swift @@ -42,6 +42,9 @@ public struct Interpreter { /// 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 }