1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

Don’t bother with Iso.

This commit is contained in:
Rob Rix 2015-09-21 16:46:32 -04:00
parent 13f1d70071
commit 5daa7d4398

View File

@ -28,24 +28,10 @@ extension Prism where To : ArrayConvertible {
},
backward: { To(array: [ $0 ]) })
}
}
public struct Iso<Here, There> {
public init(forward: Here -> There, backward: There -> Here) {
self.forward = forward
self.backward = backward
}
public let forward: Here -> There
public let backward: There -> Here
}
extension Prism where To : ArrayConvertible {
public func map<A>(transform: Iso<To.Element, A>) -> Prism<From, [A]> {
public func map<A>(transform: Prism<To.Element, A>) -> Prism<From, [A]> {
return Prism<From, [A]>(
forward: { self.forward($0)?.array.map(transform.forward) },
forward: { self.forward($0)?.array.flatMap(transform.forward) },
backward: { self.backward(To(array: $0.map(transform.backward))) })
}
}