Skip to content

Instantly share code, notes, and snippets.

@TheSeamau5
Created April 22, 2015 20:28
Show Gist options
  • Save TheSeamau5/328eea964c440de3936f to your computer and use it in GitHub Desktop.
Save TheSeamau5/328eea964c440de3936f to your computer and use it in GitHub Desktop.
Perform a sequence of optional tasks in Elm
optional : List (Task error value) -> Task error (List value)
optional list = case list of
[] -> succeed []
task :: tasks -> task
`andThen` (\value -> Task.map ((::) value) (optional tasks))
`onError` (\_ -> optional tasks)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment