Re: [elm-discuss] Starting Elm, need help understanding -> syntax

2017-02-13 Thread Max Goldstein
Yes, exactly, functions always take exactly one argument and return exactly one 
result. 

A few caveats, though. Either that argument or result can be a tuple or record 
that holds multiple values. And the result may itself be a function, hence 
currying.

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Starting Elm, need help understanding -> syntax

2017-02-13 Thread Will Tian
Yep, that makes perfect sense. I did not realize that in Elm all functions 
take exactly one argument and return a result

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Starting Elm, need help understanding -> syntax

2017-02-13 Thread Eduardo Cuducos
Hi Will,

If you think about 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
 : number -> number -> number
> addTwo = add 2
 : 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  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:
 : number -> number

this is pretty straight forward

however, if we have the function

add x y = x + y

its type definition is:
 : number -> number -> number

why is it not

 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 elm-discuss+unsubscr...@googlegroups.com.
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Starting Elm, need help understanding -> syntax

2017-02-13 Thread Will Tian
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: 
 : number -> number

this is pretty straight forward

however, if we have the function

add x y = x + y

its type definition is:
 : number -> number -> number

why is it not 

 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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.