1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 11:02:26 +03:00
semantic/prototype/Doubt/TermType.swift

25 lines
449 B
Swift

/// The type of terms.
public protocol TermType {
typealias LeafType
var out: Syntax<Self, LeafType> { get }
}
extension Fix: TermType {}
extension Cofree: TermType {
public var out: Syntax<Cofree, A> {
return unwrap
}
}
// MARK: - Equality
extension TermType {
public static func equals(leaf: (LeafType, LeafType) -> Bool)(_ a: Self, _ b: Self) -> Bool {
return Syntax.equals(ifLeaf: leaf, ifRecur: equals(leaf))(a.out, b.out)
}
}