Skip to content

Instantly share code, notes, and snippets.

@jasondew
Last active April 8, 2018 01:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jasondew/e1172220dfbfd98845e2 to your computer and use it in GitHub Desktop.
Save jasondew/e1172220dfbfd98845e2 to your computer and use it in GitHub Desktop.
type Response
= ...
type Action
= Updated (Maybe Response)
decoder : Decoder Response -- implementation elided
url : String -- ditto
update : Action -> Model -> ( Model, Effects Action )
update action model =
case action of
Updated maybeResponse ->
case maybeResponse of
Just response -> -- do things
Nothing -> -- /shrug
requestUpdate : Effects Action
requestUpdate =
Http.get decoder url -- Task Error Response
|> Task.toMaybe -- Task never (Maybe Response)
|> Task.map Updated -- Task never Action
|> Effects.task -- Effects Action
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment