Swap part6 and part7

This commit is contained in:
Richard Feldman
2018-08-13 07:36:10 -04:00
parent bc62d92609
commit 59ad6c4c0a
4 changed files with 28 additions and 28 deletions

View File

@@ -206,14 +206,17 @@ toggleFollowButton txt extraClasses msgWhenClicked uname =
decoder : Maybe Cred -> Decoder Author
decoder maybeCred =
Decode.succeed Tuple.pair
{- 👉 TODO: Use this `Profile` and `Username` to decode an `Author`!
💡 HINT: `decoderHelp` will help here, but slightly altering its type may make things easier...
-}
Decode.succeed "..."
|> custom Profile.decoder
|> required "username" Username.decoder
|> Decode.andThen (decodeFromPair maybeCred)
decodeFromPair : Maybe Cred -> ( Profile, Username ) -> Decoder Author
decodeFromPair maybeCred ( prof, uname ) =
decoderHelp : Maybe Cred -> Profile -> Username -> Decoder Author
decoderHelp maybeCred prof uname =
case maybeCred of
Nothing ->
-- If you're logged out, you can't be following anyone!

View File

@@ -24,18 +24,17 @@ view timeZone timestamp =
-}
iso8601Decoder : Decoder Time.Posix
iso8601Decoder =
Decode.string
|> Decode.andThen fromString
{- 👉 TODO: Use the following function to decode this Time.Posix value:
fromString : String -> Decoder Time.Posix
fromString str =
case Iso8601.toTime str of
Ok successValue ->
succeed successValue
Iso8601.toTime : String -> Result (List DeadEnd) Time.Posix
Err _ ->
fail ("Invalid date: " ++ str)
NOTE: You can disregard the (List DeadEnd) here. No need to use it to complete this exercise!
💡 HINT: Decode.andThen will be useful here.
-}
"..."