either-list-functions-0.0.0.2: Functions involving lists of Either

Data.List.EitherFunctions

Synopsis

# Documentation

partlyMap :: (a -> Maybe b) -> [a] -> [Either a b] Source #

>>> import Prelude (even, show)

>>> partlyMap (\x -> if even x then Just (show x) else Nothing) [1..5]
[Left 1,Right "2",Left 3,Right "4",Left 5]


groupEither :: [Either a b] -> [Either [a] [b]] Source #

>>> groupEither [Left 1, Left 2, Right 'a', Left 3, Right 'b', Right 'c']
[Left [1,2],Right "a",Left [3],Right "bc"]


spanLeft :: [Either a b] -> ([a], [Either a b]) Source #

>>> spanLeft [Left 1, Left 2, Right 'a', Left 3, Right 'b', Right 'c']
([1,2],[Right 'a',Left 3,Right 'b',Right 'c'])

>>> spanLeft [Right 'a', Left 3, Right 'b', Right 'c']
([],[Right 'a',Left 3,Right 'b',Right 'c'])


spanRight :: [Either a b] -> ([b], [Either a b]) Source #

>>> spanRight [Left 1, Left 2, Right 'a', Left 3, Right 'b', Right 'c']
("",[Left 1,Left 2,Right 'a',Left 3,Right 'b',Right 'c'])

>>> spanRight [Right 'a', Left 3, Right 'b', Right 'c']
("a",[Left 3,Right 'b',Right 'c'])