Hi Will, If you think about currying <https://en.wikipedia.org/wiki/Currying> it starts to make more sense — at least that worked for me:
In add = x + y, for example, add 2 + 40 actually returns 42 (an Int) but add 2 returns function that takes one argument (Int -> Int). In other words: add takes only one argument, and returns a function that waits for the next argument… so Int -> Int -> Int If you pass just the first Int, it returns Int -> Int: > add x y = x + y <function> : number -> number -> number > addTwo = add 2 <function> : number -> number > add 40 2 42 : number > addTwo 40 42 : number Does that make sense? Eduardo Cuducos http://cuducos.me On Mon, Feb 13, 2017 at 4:42 PM Will Tian <[email protected]> wrote: Hi, I am having trouble understanding the -> syntax in elm. For example if we have the function: plusTwo x = x + 2 it's type definition will be as follows: <function> : number -> number this is pretty straight forward however, if we have the function add x y = x + y its type definition is: <function> : number -> number -> number why is it not <function> number number -> number? What does -> denote exactly. Thanks in advance. -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
