2015-10-08 02:32:02 +03:00
|
|
|
import Cocoa
|
2015-10-14 21:17:56 +03:00
|
|
|
import Doubt
|
2015-10-16 00:40:57 +03:00
|
|
|
import Either
|
2015-10-14 21:17:56 +03:00
|
|
|
import Prelude
|
2015-10-16 00:40:57 +03:00
|
|
|
import Madness
|
2015-10-08 02:20:40 +03:00
|
|
|
|
2015-10-08 02:43:22 +03:00
|
|
|
|
|
|
|
let arguments = BoundsCheckedArray(array: Process.arguments)
|
2015-10-16 00:40:57 +03:00
|
|
|
|
2015-10-16 21:43:23 +03:00
|
|
|
let empty = "{}"
|
|
|
|
print(parse(json, input: empty))
|
2015-10-16 20:08:49 +03:00
|
|
|
let dict = "{\"hello\":\"world\"}"
|
|
|
|
print(parse(json, input: dict))
|
|
|
|
let dictWithSpaces = "{ \"hello\" : \"world\" }"
|
|
|
|
print(parse(json, input: dictWithSpaces))
|
|
|
|
|
2015-10-16 21:43:23 +03:00
|
|
|
let dictWithMembers = "{\"hello\":\"world\",\"sup\":\"cat\"}"
|
|
|
|
print(parse(json, input: dictWithMembers))
|
|
|
|
|
2015-10-16 21:52:03 +03:00
|
|
|
let dictWithArray = "{\"hello\": [\"world\"],\"sup\": [\"cat\", \"dog\", \"keith\"] }"
|
|
|
|
print(parse(json, input: dictWithArray))
|
|
|
|
|
2015-10-16 22:41:35 +03:00
|
|
|
if let a = arguments[1].flatMap(JSON.init), b = arguments[2].flatMap(JSON.init) {
|
2015-10-16 01:16:02 +03:00
|
|
|
let diff = Interpreter(comparable: const(true), cost: Diff.sum(Patch.difference)).run(a.term, b.term)
|
2015-10-16 22:41:35 +03:00
|
|
|
if let JSON = NSString(data: diff.JSON(ifPure: { $0.JSON { $0.JSON } }, ifLeaf: { $0.JSON }).serialize(), encoding: NSUTF8StringEncoding) {
|
|
|
|
print(JSON)
|
|
|
|
}
|
|
|
|
}
|