Last active
September 5, 2015 20:18
-
-
Save amitaibu/05be1345d8c12872e7ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The full code is here -- Gizra/elm-hedley#1