Created
April 22, 2015 20:28
-
-
Save TheSeamau5/328eea964c440de3936f to your computer and use it in GitHub Desktop.
Perform a sequence of optional tasks in Elm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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