[swift-evolution] Currying and noescape/throws
Chris Eidhof
chris at eidhof.nl
Wed Feb 17 02:58:56 CST 2016
Now that currying syntax is about to be removed, I changed one of my libraries. It uses currying a lot (I don’t use it all the time, but for this library, it really helps). However, I seem to have hit a limitation, and I’m not sure if it’s intended or not. Without built-in currying syntax, it looks like we cannot use noescape and/or rethrows anymore. Would people be interested in adding this back in?
For a very simple example, consider creating a curried variant of flatMap:
func curriedFlatMap<A, B>(x: [A]) -> (@noescape A -> [B]) -> [B] {
return { f in
x.flatMap(f)
}
}
or one that works with throws/rethrows:
func curriedFlatMap<A, B>(x: [A]) -> (A throws -> [B]) rethrows -> [B] {
return { f in
try x.flatMap(f)
}
}
I’m not sure how to make this concept work again when using currying. I’m also not sure if it is a big deal. I would personally love to have this functionality back. Seems like it’s mostly a type-system limitation?
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160217/b4fb15ab/attachment.html>
More information about the swift-evolution
mailing list