mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
Prism conjunction.
This commit is contained in:
parent
1d0a54d62a
commit
1e9be8b9b0
@ -28,6 +28,11 @@ infix operator >>- {
|
||||
precedence 100
|
||||
}
|
||||
|
||||
infix operator &&& {
|
||||
associativity left
|
||||
precedence 120
|
||||
}
|
||||
|
||||
prefix operator ^ {}
|
||||
|
||||
postfix operator * {}
|
||||
|
@ -39,3 +39,16 @@ extension Prism where To : ArrayConvertible {
|
||||
return map(transform(Prism<To.Element, To.Element>(forward: { $0 }, backward: { $0 })))
|
||||
}
|
||||
}
|
||||
|
||||
public func &&& <From, A, B> (left: Prism<From, A>, right: Prism<From, B>) -> Prism<From, (A, B)> {
|
||||
return Prism(
|
||||
forward: {
|
||||
if let a = left.forward($0), b = right.forward($0) {
|
||||
return (a, b)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
backward: {
|
||||
(left.backward($0), right.backward($1)).1
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user