> On Mar 15, 2016, at 6:03 PM, Stephen Celis <[email protected]> wrote:
>
>
>> On Mar 14, 2016, at 1:09 PM, Joe Groff via swift-evolution
>> <[email protected]> wrote:
>>
>> Note that there's a proposal open to flatten away the currying altogether:
>>
>> https://github.com/apple/swift-evolution/blob/master/proposals/0042-flatten-method-types.md
>>
>> I agree that it would often be more useful to bind the non-self arguments
>> first. Maybe we could provide a different shorthand for that, though; a
>> number of people for instance have suggested `.insetBy(10.0, 10.0)` as a
>> possibility.
>
> Interesting proposal! Is there a migration path for code that takes advantage
> of the current currying? The following is a convoluted example, but I've
> appreciated the flexibility in actual code:
>
> func flip<A, B, C>(input: A -> B -> C) -> B -> A -> C {
> return { b in { a in input(a)(b) } }
> }
> let insetBy = flip(CGRect.insetBy)
> let grow = { insetBy((-$0, -$0)) }
> grow(50)(.zero)
Well, you could still write a `curry` transform to turn (T, U) -> V into T -> U
-> V. IMO, it's much clearer to express these kinds of transforms directly as
closure literals than in terms of abstract dataflow transforms like `flip`. {
$0.insetBy(-$1, -$1) } is more readily understandable than the above.
-Joe
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution