Last active
November 10, 2020 21:36
-
-
Save adauguet/c059b33a0254adf44665d11022f5580b to your computer and use it in GitHub Desktop.
A function to handle a list of Result x a
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
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