1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 02:44:36 +03:00

Move FreeConvertible to Free.swift.

This commit is contained in:
Rob Rix 2015-10-14 13:34:29 -04:00
parent 01b32b010f
commit 6188a5a2d7
2 changed files with 17 additions and 14 deletions

View File

@ -96,20 +96,6 @@ extension Algorithm where Leaf: Equatable {
}
}
/// A hack to work around the unavailability of same-type requirements.
public protocol FreeConvertible {
typealias RollType
typealias PureType
init(free: Free<RollType, PureType>)
var free: Free<RollType, PureType> { get }
}
extension Free: FreeConvertible {
public init(free: Free<A, B>) { self = free }
public var free: Free { return self }
}
extension Algorithm where B: FreeConvertible, B.RollType == Leaf, B.PureType == Algorithm<Leaf, 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.
public init(_ a: Term, _ b: Term) {

View File

@ -197,4 +197,21 @@ extension Free where A: CustomJSONConvertible, B: PatchConvertible, B.Element ==
}
// MARK: - FreeConvertible
/// A hack to work around the unavailability of same-type requirements.
public protocol FreeConvertible {
typealias RollType
typealias PureType
init(free: Free<RollType, PureType>)
var free: Free<RollType, PureType> { get }
}
extension Free: FreeConvertible {
public init(free: Free<A, B>) { self = free }
public var free: Free { return self }
}
import Prelude