hask.Data.Either – The Data.Either

hask.Data.Either.Either

The ADT Either:

data.Either == d.Left('a') | d.Right('b') & deriving(Read, Show, Eq, Ord)
hask.Data.Either.Left(a)
hask.Data.Either.Right(b)
hask.Data.Either.either(*args, **kwargs)

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

Case analysis for the Either type. If the value is Left(a), apply the first function to a; if it is Right(b), apply the second function to b.

hask.Data.Either.in_either(fn)[source]

Decorator for monadic error handling. If the decorated function raises an exception, return the exception inside Left. Otherwise, take the result and wrap it in Right.

hask.Data.Either.lefts(*args, **kwargs)

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

Extracts from a List of Either all the Left elements. All the Left elements are extracted in order.

hask.Data.Either.rights(*args, **kwargs)

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

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

hask.Data.Either.isLeft(*args, **kwargs)

isLeft :: Either a b -> bool

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

hask.Data.Either.isRight(*args, **kwargs)

isRight :: Either a b -> bool

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

hask.Data.Either.partitionEithers(*args, **kwargs)

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.