From 34b7e6e52e54a4704796c71bf3e5b88b3adb5fc3 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 14 Aug 2018 02:23:20 -0400 Subject: [PATCH] Solution for intro/part7 --- intro/part7/src/Article.elm | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/intro/part7/src/Article.elm b/intro/part7/src/Article.elm index d0bbfa8..04a23ed 100644 --- a/intro/part7/src/Article.elm +++ b/intro/part7/src/Article.elm @@ -182,26 +182,12 @@ type alias Metadata = metadataDecoder : Decoder Metadata metadataDecoder = - {- 👉 TODO: replace the calls to `hardcoded` with calls to `required` - in order to decode these fields: - - --- "description" -------> description : String - --- "title" -------------> title : String - --- "tagList" -----------> tags : List String - --- "favorited" ---------> favorited : Bool - --- "favoritesCount" ----> favoritesCount : Int - - Once this is done, the articles in the feed should look normal again. - - 💡 HINT: Order matters! These must be decoded in the same order - as the order of the fields in `type alias Metadata` above. ☝️ - -} Decode.succeed Metadata - |> hardcoded "(needs decoding!)" - |> hardcoded "(needs decoding!)" - |> hardcoded [] - |> hardcoded False - |> hardcoded 0 + |> required "description" string + |> required "title" string + |> required "tagList" (list string) + |> required "favorited" bool + |> required "favoritesCount" int |> required "createdAt" Timestamp.iso8601Decoder