Comments (1)
Correct me if I'm wrong, but my understanding of this is that lowercase 'msg' is a type variable. It could just as easily be 'a' or 'insertSomeMsgHere' for all intents and purposes. Unless Elm knows what specific type is going to be returned there, it doesn't actually care what that type is.
'Msg' on the other hand is specifically a type that someone has declared in the program. It's the type that gets passed into your update function, and if it doesn't match the message that your Html in your view wants to output, it won't compile.
In this specific example, neither viewInput or viewValidation actually output a 'Msg' which allows us to use a type variable. It might seem like viewInput is returning a 'Msg' at first glance, but it's actually asking for the 'Msg' to be passed in as an argument (toMsg) and as such needs to use a 'msg' (type variable) in its type declaration, just in case a 'Msg' is not the intended output.
If I were to rewrite the Msg definition as this:
type OtherMsg
= Name String
| Password String
| PasswordAgain String
With viewInput defined as it is, only the type annotations for the view and update functions would need to be changed from
view: Model -> Html Msg
update: Msg -> Model -> Model
to
view: Model -> Html OtherMsg
update: OtherMsg -> Model -> Model
I hope that helps!
from elm-lang.org.
Related Issues (20)
- ASCII codes are seven bit HOT 1
- google search preview of the site is a little bit scary for new visitors
- delete account on discourse? HOT 2
- Add permalink feature in Try Elm
- Elm executable package is considered to be 'Dangerous' by Windows Smart Screen
- SEO meta description tag HOT 1
- Hover causing layout changes HOT 3
- links to examples on the A Farewell to FRP page are broken
- The landing page is quite user hostile HOT 6
- New playground design feedback
- Inaccuracy: Elm does not enforce semantic versioning
- Main page logo effects competely broken in Firefox HOT 10
- Cat-gifs not showing gifs of cats
- Blank website when JavaScript disabled
- font color issues on elm-lang.org/docs/syntax with chrome based browsers on MacOS
- Out-of-the-box experience.
- None of the default Elm examples show how to use CSS or give any CSS-related advice
- Explain `import` early on guide.elm-lang.org
- Add "How to uninstall elm" section HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elm-lang.org.