Skip to content

Instantly share code, notes, and snippets.

@lovasoa
Created May 25, 2016 13:04
Show Gist options
  • Save lovasoa/f7ab1022ad28f823ca00bd6765d4bd96 to your computer and use it in GitHub Desktop.
Save lovasoa/f7ab1022ad28f823ca00bd6765d4bd96 to your computer and use it in GitHub Desktop.
Equivalent of Haskell's `sequence` function for Elm
sequenceResult : List (Result.Result a b) -> Result a (List b)
sequenceResult lst =
case lst of
x :: xs ->
x `Result.andThen` (\xval ->
(sequenceResult xs) `Result.andThen` (\xsval ->
Ok (xval::xsval)))
[] -> Ok []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment