[swift-evolution] Currying and noescape/throws

Joe Groff jgroff at apple.com
Wed Feb 17 13:03:11 CST 2016


> On Feb 17, 2016, at 12:58 AM, Chris Eidhof via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 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?

Yeah, these seem like bugs to be fixed.

-Joe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160217/e88f8700/attachment.html>


More information about the swift-evolution mailing list