> > But are Cmd/Sub/Html also types ?
They are type constructors. List Int is a type, but List is not a type. It's a thing that makes a type when you give it a type. A type constructor! What these are is types which take a parameter. In this case, the parameter is the message type. For example, Html Msg means that this is an Html value, which produces values of type Msg, that will eventually make their way to your update function. type Msg = MorePlease | NewGif (Result Http.Error String) Result is also a Type Constructor! Specifically, a Result Error String is a value which, when successful, produces a string, and on error, produces an Http.Error. You can see more in the Result library. Particularly interesting are Result.map and Result.andThen, for chaining possible failing computations together, and Result.withDefault, which extracts the result from a successful result, or produces the default value. You can also pattern match on them, with the Ok and Err constructors. http://package.elm-lang.org/packages/elm-lang/core/latest/Result Why does complier fail if I change Msg to 'type Msg = NewGif | MorePlease > (Result Http.Error String)' ? What the declaration of the tagged union here is saying is "NewGif is a constructor that takes 0 arguments, and MorePlease takes one argument, which is a Result that is either a String, or an Error). In your original version, MorePlease took no arguments, and NewGif took 1 argument. So wherever you're using them in your code, they probably are either taking the wrong number of arguments, or you're pattern matching on the wrong number of values. There's a lot of information, so feel free to ask more questions if this leaves anything unclear! On Thu, Nov 24, 2016 at 5:17 AM, Justin <justin.worr...@gmail.com> wrote: > Hi, > > Looking at the following > > http://elm-lang.org/examples/http > > I pretty much grok this, but have a couple of (likely dumb) questions - > > 1) When a function returns 'Cmd Msg', or 'Sub Msg', or 'Html Msg', what > kind of a 'thing' is being returned ? > > Obviously Msg is a type. But are Cmd/Sub/Html also types ? (I suspect > not). And when you prefix then to Msg is the resulting thing also a type ? > (suspect not). A list of types ?? (suspect not). A closure or a deferred or > something ? Am guessing more likely > > 2) type Msg = MorePlease | NewGif (Result Http.Error String) > > What's with the '(Result Http.Error String)' at the end ? I read the bit > about union types but couldn't find anything relating to args in round > brackets. If someone could point me to the relevant docs that would be > great. > > 3) Why does complier fail if I change Msg to 'type Msg = NewGif | > MorePlease (Result Http.Error String)' ? > > Don't NewGif and MorePlease require the same HTTP calls ? > > Elm looks great. Thanks in advance for any help and suggestions > > Justin > > -- > 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.