+
+partitionWith :: (a -> Either b c) -> [a] -> ([b], [c])
+partitionWith f [] = ([],[])
+partitionWith f (x:xs) = case f x of
+ Left b -> (b:bs, cs)
+ Right c -> (bs, c:cs)
+ where
+ (bs,cs) = partitionWith f xs
+
+splitEithers :: [Either a b] -> ([a], [b])
+splitEithers [] = ([],[])
+splitEithers (e : es) = case e of
+ Left x -> (x:xs, ys)
+ Right y -> (xs, y:ys)
+ where
+ (xs,ys) = splitEithers es