1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 00:12:29 +03:00

Compute JSON diffs with Interpreter.

This commit is contained in:
Rob Rix 2015-10-15 15:50:46 -04:00
parent 5c85adaab0
commit 7871169f8d

View File

@ -101,7 +101,7 @@ extension JSON {
let arguments = BoundsCheckedArray(array: Process.arguments)
if let a = arguments[1].flatMap(JSON.init), b = arguments[2].flatMap(JSON.init) {
let diff = Algorithm<Term, Diff>(a.term, b.term).evaluate(Cofree.equals(annotation: const(true), leaf: ==))
let diff = Interpreter(comparable: const(true), cost: { $0.map(Patch.difference).reduce(0, combine: +) }).run(a.term, b.term)
if let JSON = NSString(data: diff.JSON(ifPure: { $0.JSON { $0.JSON } }, ifLeaf: { $0.JSON }).serialize(), encoding: NSUTF8StringEncoding) {
print(JSON)
}