Discussion:
[elm-discuss] main : Program Never Model Msg -- What does it mean?
Eeek
2017-07-21 05:39:37 UTC
Permalink
I am beginner in Elm, and going through elm-tutorial.org. I have problem in
understanding the declaration of main function in
https://www.elm-tutorial.org/en/02-elm-arch/02-structure.html. It says

main : Program Never Model Msg

What does it represent? I read under functions tutorial that, arguments
are separated with ->. If there are no arguments then I would expect only
one return. This don't belong to any of it. What is this way of declaring
the function types?
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Peter Damoc
2017-07-21 06:02:42 UTC
Permalink
The main is a *value* of type `Program Never Model Msg`, it is not a
function.

The 3 types after Program, (Never, Model and Msg) are the arguments of the
type in the same way that String is an argument for List in `List String`

You can read that as "a Program that does not take any flags (Never) has
the type `Model` as it's main data type and `Msg` as the main type of
messages flowing through the app", that's the actual, full type.

You can also thing of the `Program` as a container type for the 3 types
that follow it, the same way List is a container type or Maybe is a
container type.
Post by Eeek
I am beginner in Elm, and going through elm-tutorial.org. I have problem
in understanding the declaration of main function in
https://www.elm-tutorial.org/en/02-elm-arch/02-structure.html. It says
main : Program Never Model Msg
What does it represent? I read under functions tutorial that, arguments
are separated with ->. If there are no arguments then I would expect only
one return. This don't belong to any of it. What is this way of declaring
the function types?
--
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
For more options, visit https://groups.google.com/d/optout.
--
There is NO FATE, we are the creators.
blog: http://damoc.ro/
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Андрей Коппель
2017-07-21 05:46:41 UTC
Permalink
This means that main returns Program type (http://package.elm-lang.org/packages/elm-lang/core/5.1.1/Platform#Program <http://package.elm-lang.org/packages/elm-lang/core/5.1.1/Platform#Program>). It has three arguments which are flags, model and msg. Never means there will no always no flags. Model is your defined Model type. Msg is your defined Msg type.



Best,
Andrey
I am beginner in Elm, and going through elm-tutorial.org. I have problem in understanding the declaration of main function in https://www.elm-tutorial.org/en/02-elm-arch/02-structure.html. It says
main : Program Never Model Msg
What does it represent? I read under functions tutorial that, arguments are separated with ->. If there are no arguments then I would expect only one return. This don't belong to any of it. What is this way of declaring the function types?
--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
For more options, visit https://groups.google.com/d/optout <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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...