Hacker News new | past | comments | ask | show | jobs | submit login

It seems pretty consistent with functions in a set-notation sense, with functions that map a tuple of stuff to something else. The mapping being indicated by an arrow instead of a colon.



The functional mapping also makes sense. Thanks for the pointer.


I was thinking more about Types here

var name : String

func nameMe(name: String) : String


I was half-thinking the same, but types and sets feel interchangeable on an intuitive level in such cases.

Having both `: String` and `: String` seems to suggest that they are the same type, which they are not. `nameMe(_)` is a function type, while `name` is a "plain value", so to speak. I think that using arrows more clearly indicates that it's a mapping from something to something else -- in the case of Swift, I guess a mapping from a tuple to something else.

And think about anonymous functions, in general since I haven't looked into Swift anonymous functions. If you indicate a function like this:

`func nameMe(name: String) : String`

How are you supposed to indicate an anonymous function? Like this:

`(name: String) : String`

Then it seems to say that name is a type of String, which in turn is a type of String. I guess you could add something like a lambda to distinguish it:

`(λ name => name): String`

But now you've still effectively said that both `name` (a value of type string) is the same type as the anonymous function (a function with one argument). That's clearly wrong.

Using arrows for functions seems to be better when you start to want to talk about types and values by themselves, like:

`1: Int`, `"hello": String`, `(λx => x) : a -> a`


Point well received.

BTW

Fat arrow looks more appealing than simple arrow.

All the other pieces look very well designed.


The single-line arrow has both precedent in set theory, type theory, and mathematical logic.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: