diff --git a/prototype/Doubt/Diff.swift b/prototype/Doubt/Diff.swift index c2e531cb7..c319d5899 100644 --- a/prototype/Doubt/Diff.swift +++ b/prototype/Doubt/Diff.swift @@ -105,8 +105,8 @@ public enum Diff: Comparable, CustomDebugStringConvertible, CustomDocConvertible case let (.Leaf(v1), .Leaf(v2)) where v1 == v2: self = .Copy(.Leaf(v2)) - case let (.Branch(v1), .Branch(v2)): - self = .Copy(.Branch(Diff.diff(v1, v2))) + case let (.Indexed(v1), .Indexed(v2)): + self = .Copy(.Indexed(Diff.diff(v1, v2))) default: self = .Patch(a, b) diff --git a/prototype/Doubt/Syntax.swift b/prototype/Doubt/Syntax.swift index 82fa59e47..8d21d127d 100644 --- a/prototype/Doubt/Syntax.swift +++ b/prototype/Doubt/Syntax.swift @@ -32,21 +32,21 @@ public func == (left: Term, right: Term) -> Bool { /// A node in a syntax tree. Expressed algebraically to enable representation of both normal syntax trees and their diffs. public enum Syntax: CustomDebugStringConvertible, CustomDocConvertible { case Leaf(A) - case Branch([Recur]) + case Indexed([Recur]) public func map(@noescape transform: Recur -> T) -> Syntax { switch self { case let .Leaf(n): return .Leaf(n) - case let .Branch(x): - return .Branch(x.map(transform)) + case let .Indexed(x): + return .Indexed(x.map(transform)) } } // fixme: 🔥 public func reduce(initial: T, @noescape combine: (T, Recur) throws -> T) rethrows -> T { switch self { - case let .Branch(x): + case let .Indexed(x): return try x.reduce(initial, combine: combine) default: @@ -58,7 +58,7 @@ public enum Syntax: CustomDebugStringConvertible, CustomDocConvertible switch self { case let .Leaf(n): return ".Leaf(\(n))" - case let .Branch(x): + case let .Indexed(x): return ".Branch(\(String(reflecting: x)))" } } @@ -67,7 +67,7 @@ public enum Syntax: CustomDebugStringConvertible, CustomDocConvertible switch self { case let .Leaf(n): return Doc(n) - case let .Branch(x): + case let .Indexed(x): return x.map(Doc.init).joinWithSeparator(", ").bracket("[", "]") } } @@ -81,7 +81,7 @@ extension Syntax { switch (left, right) { case let (.Leaf(l1), .Leaf(l2)): return ifLeaf(l1, l2) - case let (.Branch(v1), .Branch(v2)): + case let (.Indexed(v1), .Indexed(v2)): return v1.count == v2.count && zip(v1, v2).lazy.map(ifRecur).reduce(true) { $0 && $1 } default: return false @@ -105,8 +105,8 @@ extension Syntax { switch self { case let .Leaf(n): return Hash("Leaf", ifLeaf(n)) - case let .Branch(x): - return Hash("Branch", .Ordered(x.map(ifRecur))) + case let .Indexed(x): + return Hash("Indexed", .Ordered(x.map(ifRecur))) } } }