[swift-evolution] [pitch] Eliminate the "T1 -> T2" syntax, require "(T1) -> T2"

Erica Sadun erica at ericasadun.com
Wed Apr 20 12:11:17 CDT 2016


On Apr 20, 2016, at 9:46 AM, BJ Homer via swift-evolution <swift-evolution at swift.org> wrote:
> 
> How would this proposal affect curried functions? Would this:
> 
>  func foo(int: Int) -> Int -> String -> String
> 
> become this?
> 
>  func foo(int: Int) -> (((Int) -> String) -> String)
> 
> As I understand, that transformation is an accurate representation of the actual return type of “foo”, but it’s certainly going to raise some complaints among the functional Swift community if required.
> 
> -BJ

To the best of my understanding, either:

func foo(i: Int) -> (j: Int) -> (s: String) -> String { ... }
let x = foo // let x: (Int) -> (j: Int) -> (s: String) -> String
let a = x(2); let b = a(j: 3); let c = b(s: "glob"); print(c)

or

func blort(i: Int) -> (Int) -> (String) -> String
let z = blort // let z: (Int) -> (Int) -> (String) -> String
let aa = z(2); let bb = aa(3); let cc = bb("glob"); print(cc)

would still work (although x(2) would become x(i: 2) because of the new first label rules) vs the following which currently works but would not after adoption:

func bar(i: Int) -> Int -> String -> String { ... }
let y = bar // let y: (Int) -> Int -> String -> String

-- E, who is often wrong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160420/766f16c7/attachment.html>


More information about the swift-evolution mailing list