[elm-discuss] New to Elm, need help understanding type Node msg = Node in source code

2017-02-15 Thread Will Tian
Hi,

I'm trying to understand how the Html module works. I see many methods with 
return type Html msg, which is a type alias for Node msg. 

After tracking down the source code and reading into it, I am confused by 
the following line: 

type Node msg = Node

what is the purpose of the above line? 

Furthermore, I don't understand the use of the type parameter msg.

For example I can see that type Property msg = Property

and 

property : String -> Json.Value -> Property msg
property = Native.VirtualDom.property

when looking into the implementation of VirtualDom.property, I see 

function property(key, value)
{
return {
key: key,
value: value
};
}

Does that mean the return value of calling: property "className" 
(Json.string "myClass") is of type Property msg where msg = { key: 
"className", value: "myClass" }?
does the property function actually use a type constructor and return the 
type?

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.


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.


[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.