elm / elm-lang.org

Server and client code for the Elm website.
http://elm-lang.org/
BSD 3-Clause "New" or "Revised" License
1.99k stars 366 forks source link

In model-the-problem, provide an example of a function w/ more than one arg #554

Closed toolness closed 8 years ago

toolness commented 8 years ago

The Elm Architecture Tutorial recommends reading the first two sections of the complete guide as a prerequisite, but neither section quite prepared me for this type signature in the architecture tutorial:

update : Action -> Model -> Model

Because the model-the-problem section only presents the type signatures for functions that take a single argument, I interpreted a -> b as meaning "a function that takes an argument of type a and returns a value of type b". So the above example broke my brain. :disappointed:

It wasn't until I found the Pragmatic Studio's Getting Started With Elm blog post that I learned how I should really be reading ->:

Notice that each parameter is separated with -> and there's nothing special indicating that the last item is the return type.

So I think that briefly explaining this in model-the-problem could help ease the hiccups between moving from it to the Elm Architecture Tutorial (or reading other existing Elm code/documentation in general).

Update: I actually ended up buying the Pragmatic Studio's Elm: Building Reactive Web Apps video series, and in an early video the author mentions this issue was confusing for him at first as well.

evancz commented 8 years ago

This page moved, and there is now http://guide.elm-lang.org/types/reading_types.html which gets much more into how to read types. Can add comments over on the guide if it's still messed up.