mirror of
https://github.com/github/semantic.git
synced 2024-12-25 07:55:12 +03:00
Subscripting Prism<T, [U]> by Int produces Prism<T, U>.
This commit is contained in:
parent
4f97a6bc4a
commit
0eca419468
@ -73,6 +73,29 @@ extension Prism where To : DictionaryType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protocol ArrayType {
|
||||||
|
typealias Element
|
||||||
|
|
||||||
|
init(array: [Element])
|
||||||
|
var array: [Element] { get }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Array : ArrayType {
|
||||||
|
init(array: [Element]) {
|
||||||
|
self = array
|
||||||
|
}
|
||||||
|
|
||||||
|
var array: [Element] {
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Prism where To : ArrayType {
|
||||||
|
subscript (index: Int) -> Prism<From, To.Element> {
|
||||||
|
return self >>> Prism<To, To.Element>(forward: { $0.array[index] }, backward: { To(array: [ $0 ]) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func toJSON(object: AnyObject) -> JSON? {
|
private func toJSON(object: AnyObject) -> JSON? {
|
||||||
struct E: ErrorType {}
|
struct E: ErrorType {}
|
||||||
func die<T>() throws -> T {
|
func die<T>() throws -> T {
|
||||||
|
Loading…
Reference in New Issue
Block a user