Skip to content

Instantly share code, notes, and snippets.

@adauguet
Last active November 10, 2020 21:36
Show Gist options
  • Save adauguet/c059b33a0254adf44665d11022f5580b to your computer and use it in GitHub Desktop.
Save adauguet/c059b33a0254adf44665d11022f5580b to your computer and use it in GitHub Desktop.
A function to handle a list of Result x a
partition : List (Result x a) -> ( List x, List a )
partition results =
let
helper : List (Result x a) -> ( List x, List a ) -> ( List x, List a )
helper list ( es, ss ) =
case list of
[] ->
( es, ss )
x :: xs ->
case x of
Err e ->
helper xs ( e :: es, ss )
Ok s ->
helper xs ( es, s :: ss )
in
helper results ( [], [] )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment