Data.Either (original) (raw)

Description

The Either type, and associated operations.

Synopsis

Documentation

data Either a b Source

The [Either](Data-Either.html#t:Either) type represents values with two possibilities: a value of type `[Either](Data-Either.html#t:Either)` a b is either `[Left](Data-Either.html#v:Left)` a or `[Right](Data-Either.html#v:Right)` b.

The [Either](Data-Either.html#t:Either) type is sometimes used to represent a value which is either correct or an error; by convention, the [Left](Data-Either.html#v:Left) constructor is used to hold an error value and the [Right](Data-Either.html#v:Right) constructor is used to hold a correct value (mnemonic: "right" also means "correct").

either :: (a -> c) -> (b -> c) -> Either a b -> cSource

Case analysis for the [Either](Data-Either.html#t:Either) type. If the value is `[Left](Data-Either.html#v:Left)` a, apply the first function to a; if it is `[Right](Data-Either.html#v:Right)` b, apply the second function to b.

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

Partitions a list of [Either](Data-Either.html#t:Either) into two lists All the [Left](Data-Either.html#v:Left) elements are extracted, in order, to the first component of the output. Similarly the [Right](Data-Either.html#v:Right) elements are extracted to the second component of the output.