evancz/elm-architecture-tutorial

HTTP example contains errors

pentaphobe opened this issue · 1 comments

Errors reported in-browser via elm-reactor

All installation was using standard installation on MacOS

All other examples work fine (except for JSON #128 )

-- TYPE MISMATCH ------------------------------------------ examples/05-http.elm

Something is off with the body of the `init` definition:

31|>  ( Loading
32|>  , Http.get
33|>      { url = "https://elm-lang.org/assets/public-opinion.txt"
34|>      , expect = Http.expectString GotText
35|>      }
36|>  )

The body is a tuple of type:

    ( Model, Json.Decode.Decoder a -> Http.Request a )

But the type annotation on `init` says it should be:

    ( Model, Cmd Msg )


-- TYPE MISMATCH ------------------------------------------ examples/05-http.elm

The 1st argument to `get` is not what I expect:

32|   , Http.get
33|>      { url = "https://elm-lang.org/assets/public-opinion.txt"
34|>      , expect = Http.expectString GotText
35|>      }

This argument is a record of type:

    { expect : b, url : String }

But `get` needs the 1st argument to be:

    String


-- TOO MANY ARGS ------------------------------------------ examples/05-http.elm

The `expectString` value is not a function, but it was given 1 argument.

34|       , expect = Http.expectString GotText
                     ^^^^^^^^^^^^^^^^^
Are there any missing commas? Or missing parentheses?

Ah, I forgot to update the elm.json to point to the new dependencies! I just updated it, so if you git pull you should be able to mess with these examples!

Sorry for the trouble, and thank you for letting me know!