never executed always true always false
1 module Data.Either.Extra (collectErrors) where 2 3 import Prelude () 4 import Relude 5 6 7 collectErrors :: [Either l r] -> Either [l] [r] 8 collectErrors list = 9 let 10 step acc next = 11 case (next, acc) of 12 (Left l, Right _) -> 13 Left [l] 14 15 (Left l, Left ls) -> 16 Left (l : ls) 17 18 (Right r, Right rs) -> 19 Right (r : rs) 20 21 (Right _, Left ls) -> 22 Left ls 23 in 24 foldl' step (Right []) list