Module Either

Library with some useful operations for the Either data type.

Author: Bjoern Peemoeller

Version: March 2015

Summary of exported operations:

lefts :: [Either a b] -> [a]   
Extracts from a list of Either all the Left elements in order.
rights :: [Either a b] -> [b]   
Extracts from a list of Either all the Right elements in order.
isLeft :: Either a b -> Bool   
Return True if the given value is a Left-value, False otherwise.
isRight :: Either a b -> Bool   
Return True if the given value is a Right-value, False otherwise.
fromLeft :: Either a b -> a   
Extract the value from a Left constructor.
fromRight :: Either a b -> b   
Extract the value from a Right constructor.
partitionEithers :: [Either a b] -> ([a],[b])   
Partitions a list of Either into two lists.

Exported operations:

lefts :: [Either a b] -> [a]   

Extracts from a list of Either all the Left elements in order.

rights :: [Either a b] -> [b]   

Extracts from a list of Either all the Right elements in order.

isLeft :: Either a b -> Bool   

Return True if the given value is a Left-value, False otherwise.

Further infos:
  • solution complete, i.e., able to compute all solutions

isRight :: Either a b -> Bool   

Return True if the given value is a Right-value, False otherwise.

Further infos:
  • solution complete, i.e., able to compute all solutions

fromLeft :: Either a b -> a   

Extract the value from a Left constructor.

Further infos:
  • partially defined
  • solution complete, i.e., able to compute all solutions

fromRight :: Either a b -> b   

Extract the value from a Right constructor.

Further infos:
  • partially defined
  • solution complete, i.e., able to compute all solutions

partitionEithers :: [Either a b] -> ([a],[b])   

Partitions a list of Either into two lists. All the Left elements are extracted, in order, to the first component of the output. Similarly the Right elements are extracted to the second component of the output.