@@ -24,13 +24,28 @@ isRight e = case e of { Right _ -> True ; _ -> False }
25-- Keep only the values held in `Left` values.
25-- Keep only the values held in `Left` values.
26lefts : [Either a b] -> [a]
26lefts : [Either a b] -> [a]
27−lefts es = List.filter isLeft es
27+lefts es = List.foldr consLeft [] es
29-- Keep only the values held in `Right` values.
29-- Keep only the values held in `Right` values.
30rights : [Either a b] -> [b]
30rights : [Either a b] -> [b]
31−rights es = List.filter isRight es
31+rights es = List.foldr consRight [] es
33-- Split into two lists, lefts on the left and rights on the right. So we
33-- Split into two lists, lefts on the left and rights on the right. So we
34-- have the equivalence: `(partition es == (lefts es, rights es))`
34-- have the equivalence: `(partition es == (lefts es, rights es))`
35partition : [Either a b] -> ([a],[b])
35partition : [Either a b] -> ([a],[b])
36−partition es = List.partition isLeft es
36+partition es = List.foldr consEither ([],[]) es
48+consEither e (ls,rs) =
51+ Right r -> (ls,r::rs)