Skip to content

Instantly share code, notes, and snippets.

@amitaibu
Last active September 5, 2015 20:18
Show Gist options
  • Save amitaibu/05be1345d8c12872e7ad to your computer and use it in GitHub Desktop.
Save amitaibu/05be1345d8c12872e7ad to your computer and use it in GitHub Desktop.
update : Action -> Model -> (Model, Effects Action)
update action model =
case action of
UpdateDataFromServer result ->
case result of
Ok (id, name) -> ({nodel | id <- id}, Effects.none)
Err msg -> (newModel, Effects.none)
getJson : String -> Effects Action
getJson url =
Http.get decodeData url
|> Http.fromJson decodeData
|> Task.toResult
|> Task.map UpdateDataFromServer
|> Effects.task
decodeData : Json.Decoder (Id, String)
decodeData =
Json.object2 (,)
("label" := Json.string)
("id" := Json.int)
# Compile error
The right argument of (|>) is causing a type mismatch.
80| Http.send Http.defaultSettings
81| { verb = "GET"
82| , headers = [("access-token", accessToken)]
83| , url = url
84| , body = Http.empty
85| }
86| |> Http.fromJson decodeData
87| |> Task.toResult
88|> |> Task.map UpdateDataFromServer
As I infer the type of values flowing through your program, I see a conflict
between these two types:
(Int, String)
String
@amitaibu
Copy link
Author

amitaibu commented Sep 5, 2015

The full code is here -- Gizra/elm-hedley#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment