[swift-evolution] SE-0066 Reaction
Chris Lattner
clattner at apple.com
Tue Apr 26 13:23:19 CDT 2016
On Apr 26, 2016, at 10:52 AM, Mishal Awadah via swift-evolution <swift-evolution at swift.org> wrote:
> Concern 1:
> I feel like we're forgetting about the functional programming syntax of declaring function types like this:
>
> A -> B -> C
>
> for a function foo(a: A, b: B) -> C
This analogy doesn’t exist in Swift, languages like Haskell have auto-currying behavior like this, but Swift does not.
>
> This eliminates the ambiguity of what the parameter types are, and is more legible (less paren hell) than adding parens like this:
>
> (A,B) -> C
>
> which for a function
>
> foo(a: (A, B)) -> C
>
> would look like this after the implementation of SE-0066:
>
> ((A,B)) -> C
>
> instead of
>
> (A,B) -> C
I’m not sure what the actual concern you’re pointing out here. However, you are forgetting the argument labels. Your foo example will have type:
(a: (A,B)) -> C
More to the point thought, this example is *exactly* why SE-0066 is the right thing to do. You cannot currently write the type of “foo” as "(A,B) -> C”. (with or without labels), because of the grammar ambiguities that SE-0066 fixes.
That said, it is likely that I’m totally missing your point here, can you please restate your concern?
> Concern 2:
>
> There's also the potential to transform a function like this
>
> A -> B -> C
>
> into this
>
> B -> C
>
> after partial application, something which might not be totally irrelevant to Swift in its future.
This isn’t affected by SE-0066 - what is your concern? With SE-0066, the transformation is:
(A) -> (B) -> C
into:
(B) -> C
Please keep in mind that SE-0066 doesn’t change the type system, it just adds parens in a very narrow case.
>
>
> Here are a few contrived examples of function types showing the paren version (order 66), the parens on the return type too, and the generic functional programming version (right). I want to preface this with, "Remember that Swift is an enjoyable experience because reading Swift is pleasant.”
0066 does not affect the return type of a function.
-Chris
More information about the swift-evolution
mailing list