mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Add a phantom type parameter to Syntax.
This commit is contained in:
parent
308f81853d
commit
1f253f4e12
@ -1,6 +1,6 @@
|
||||
public enum Diff: Comparable, CustomDebugStringConvertible, CustomDocConvertible {
|
||||
case Patch(Term, Term)
|
||||
indirect case Copy(Syntax<Diff>)
|
||||
indirect case Copy(Syntax<Diff, String>)
|
||||
|
||||
public static func Insert(term: Term) -> Diff {
|
||||
return .Patch(.Empty, term)
|
||||
|
@ -2,7 +2,7 @@ public func == (left: Term, right: Term) -> Bool {
|
||||
return left.syntax == right.syntax
|
||||
}
|
||||
|
||||
public func == <F: Equatable> (left: Syntax<F>, right: Syntax<F>) -> Bool {
|
||||
public func == <F: Equatable, A: Equatable> (left: Syntax<F, A>, right: Syntax<F, A>) -> Bool {
|
||||
switch (left, right) {
|
||||
case (.Empty, .Empty):
|
||||
return true
|
||||
|
@ -1,11 +1,11 @@
|
||||
public enum Term: CustomDebugStringConvertible, CustomDocConvertible, CustomStringConvertible, AlgebraicHashable {
|
||||
public init(_ out: Syntax<Term>) {
|
||||
public init(_ out: Syntax<Term, String>) {
|
||||
self = .Roll(out)
|
||||
}
|
||||
|
||||
indirect case Roll(Syntax<Term>)
|
||||
indirect case Roll(Syntax<Term, String>)
|
||||
|
||||
public var syntax: Syntax<Term> {
|
||||
public var syntax: Syntax<Term, String> {
|
||||
switch self {
|
||||
case let .Roll(syntax):
|
||||
return syntax
|
||||
@ -124,7 +124,7 @@ public enum Term: CustomDebugStringConvertible, CustomDocConvertible, CustomStri
|
||||
}
|
||||
|
||||
|
||||
public enum Syntax<Recur>: CustomDebugStringConvertible, CustomDocConvertible {
|
||||
public enum Syntax<Recur, A>: CustomDebugStringConvertible, CustomDocConvertible {
|
||||
case Empty
|
||||
case Apply(Recur, [Recur])
|
||||
case Abstract([Recur], [Recur])
|
||||
@ -133,7 +133,7 @@ public enum Syntax<Recur>: CustomDebugStringConvertible, CustomDocConvertible {
|
||||
case Literal(String)
|
||||
case Group(Recur, [Recur])
|
||||
|
||||
public func map<T>(@noescape transform: Recur -> T) -> Syntax<T> {
|
||||
public func map<T>(@noescape transform: Recur -> T) -> Syntax<T, A> {
|
||||
switch self {
|
||||
case .Empty:
|
||||
return .Empty
|
||||
|
Loading…
Reference in New Issue
Block a user