1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 17:59:10 +03:00

Add a typealias representing the type of patches.

This commit is contained in:
Rob Rix 2015-10-14 11:56:30 -04:00
parent c97b0ec9f5
commit ef5720ad17

View File

@ -7,8 +7,11 @@ public enum Algorithm<A, B> {
/// The type of `Term`s over which `Algorithm`s operate. /// The type of `Term`s over which `Algorithm`s operate.
public typealias Term = Fix<A> public typealias Term = Fix<A>
/// The type of `Patch`es produced by `Algorithm`s.
public typealias Patch = Doubt.Patch<A>
/// The type of `Diff`s which `Algorithm`s produce. /// The type of `Diff`s which `Algorithm`s produce.
public typealias Diff = Free<A, Patch<A>> public typealias Diff = Free<A, Patch>
/// The injection of a value of type `B` into an `Operation`. /// The injection of a value of type `B` into an `Operation`.
/// ///
@ -104,7 +107,7 @@ extension Free: FreeConvertible {
public var free: Free { return self } public var free: Free { return self }
} }
extension Algorithm where B: FreeConvertible, B.RollType == A, B.PureType == Patch<A> { extension Algorithm where B: FreeConvertible, B.RollType == A, B.PureType == Algorithm<A, B>.Patch {
/// `Algorithm<A, Diff>`s can be constructed from a pair of `Term`s using `ByKey` when `Keyed`, `ByIndex` when `Indexed`, and `Recursive` otherwise. /// `Algorithm<A, Diff>`s can be constructed from a pair of `Term`s using `ByKey` when `Keyed`, `ByIndex` when `Indexed`, and `Recursive` otherwise.
public init(_ a: Term, _ b: Term) { public init(_ a: Term, _ b: Term) {
switch (a.out, b.out) { switch (a.out, b.out) {
@ -122,7 +125,7 @@ extension Algorithm where B: FreeConvertible, B.RollType == A, B.PureType == Pat
} }
} }
extension Algorithm where A: Equatable, B: FreeConvertible, B.RollType == A, B.PureType == Patch<A> { extension Algorithm where A: Equatable, B: FreeConvertible, B.RollType == A, B.PureType == Algorithm<A, B>.Patch {
public func evaluate() -> B { public func evaluate() -> B {
return evaluate(==) return evaluate(==)
} }