From fa7dc4ca9125b9b6c183d3fd97165704ec506662 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sat, 2 Apr 2016 10:07:14 -0700 Subject: [PATCH] Update part5 and part6 --- part5/Main.elm | 13 +++++++------ part5/elm-package.json | 1 + part6/ElmHub.elm | 12 ++++++------ part6/elm-package.json | 4 +++- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/part5/Main.elm b/part5/Main.elm index d7de77e..d838db6 100644 --- a/part5/Main.elm +++ b/part5/Main.elm @@ -9,6 +9,7 @@ import Http import Task exposing (Task) import Effects exposing (Effects) import Json.Decode exposing (Decoder, (:=)) +import Json.Decode.Pipeline exposing (..) import Json.Encode import Signal exposing (Address) @@ -54,12 +55,12 @@ responseDecoder = searchResultDecoder : Decoder SearchResult searchResultDecoder = - Json.Decode.object3 - SearchResult - -- See https://developer.github.com/v3/search/#example - ("TODO what field goes here?" := Json.Decode.int) - ("TODO what field goes here?" := Json.Decode.string) - ("TODO what field goes here?" := Json.Decode.int) + -- See https://developer.github.com/v3/search/#example + -- TODO replace these `hardcoded` with calls to `require` + decode SearchResult + |> hardcoded 0 + |> hardcoded "" + |> hardcoded 0 performAction : (a -> b) -> (y -> b) -> Task y a -> Task x b diff --git a/part5/elm-package.json b/part5/elm-package.json index ba40466..6667bd8 100644 --- a/part5/elm-package.json +++ b/part5/elm-package.json @@ -8,6 +8,7 @@ ], "exposed-modules": [], "dependencies": { + "NoRedInk/elm-decode-pipeline": "1.0.0 <= v < 2.0.0", "elm-lang/core": "3.0.0 <= v < 4.0.0", "evancz/elm-effects": "2.0.0 <= v < 3.0.0", "evancz/elm-html": "4.0.0 <= v < 5.0.0", diff --git a/part6/ElmHub.elm b/part6/ElmHub.elm index d0ab1db..3f9f564 100644 --- a/part6/ElmHub.elm +++ b/part6/ElmHub.elm @@ -2,12 +2,13 @@ module ElmHub (..) where import Auth import Html exposing (..) -import Html.Attributes exposing (..) +import Html.Attributes exposing (class, target, href, property) import Html.Events exposing (..) import Http import Task exposing (Task) import Effects exposing (Effects) import Json.Decode exposing (Decoder, (:=)) +import Json.Decode.Pipeline exposing (..) import Json.Encode import Signal exposing (Address) @@ -37,11 +38,10 @@ responseDecoder = searchResultDecoder : Decoder SearchResult searchResultDecoder = - Json.Decode.object3 - SearchResult - ("id" := Json.Decode.int) - ("full_name" := Json.Decode.string) - ("stargazers_count" := Json.Decode.int) + decode SearchResult + |> required "id" Json.Decode.int + |> required "full_name" Json.Decode.string + |> required "stargazers_count" Json.Decode.int type alias Model = diff --git a/part6/elm-package.json b/part6/elm-package.json index ba40466..6968946 100644 --- a/part6/elm-package.json +++ b/part6/elm-package.json @@ -4,10 +4,12 @@ "repository": "https://github.com/rtfeldman/elm-workshop.git", "license": "BSD-3-Clause", "source-directories": [ - ".", ".." + ".", + ".." ], "exposed-modules": [], "dependencies": { + "NoRedInk/elm-decode-pipeline": "1.0.0 <= v < 2.0.0", "elm-lang/core": "3.0.0 <= v < 4.0.0", "evancz/elm-effects": "2.0.0 <= v < 3.0.0", "evancz/elm-html": "4.0.0 <= v < 5.0.0",