| Safe Haskell | Safe |
|---|
Eta.Types.Either
Description
The Either type represents values with two possibilities: a value of type Either a b is either Left a or Right b.
The Either type is sometimes used to represent a value which is either correct or an error; by convention, the Left constructor is used to hold an error value and the Right constructor is used to hold a correct value (mnemonic: "right" also means "correct").
- data Either a b :: * -> * -> *
- lefts :: [Either a b] -> [a]
- rights :: [Either a b] -> [b]
- isLeft :: Either a b -> Bool
- isRight :: Either a b -> Bool
- partitionEithers :: [Either a b] -> ([a], [b])
- fromLeftOrElse :: Either a b -> a -> a
- fromRightOrElse :: Either a b -> b -> b
- handleEither :: (a -> c) -> (b -> c) -> Either a b -> c
Documentation
data Either a b :: * -> * -> * #
Instances
| Monad (Either e) | |
| Functor (Either a) | |
| Applicative (Either e) | |
| Foldable (Either a) | |
| Traversable (Either a) | |
| Generic1 (Either a) | |
| (Eq b, Eq a) => Eq (Either a b) | |
| (Ord b, Ord a) => Ord (Either a b) | |
| (Read b, Read a) => Read (Either a b) | |
| (Show b, Show a) => Show (Either a b) | |
| Generic (Either a b) | |
| type Rep1 (Either a) | |
| type Rep (Either a b) | |
| type (==) (Either k k1) a b | |
partitionEithers :: [Either a b] -> ([a], [b]) #
fromLeftOrElse :: Either a b -> a -> a #
Return the contents of a Left or a default value
>>>Left 4 `fromLeftOrElse` 04>>>Right 4 `fromLeftOrElse` 00
fromRightOrElse :: Either a b -> b -> b #
Return the contents of a Right or a default value
>>>Right 4 `fromRightOrElse` 04>>>Left 4 `fromRightOrElse` 00
handleEither :: (a -> c) -> (b -> c) -> Either a b -> c #