protolude-0.2.3: A small prelude.

Safe HaskellSafe
LanguageHaskell2010

Protolude.Either

Synopsis

Documentation

maybeToLeft :: r -> Maybe l -> Either l r Source #

maybeToRight :: l -> Maybe r -> Either l r Source #

maybeEmpty :: Monoid b => (a -> b) -> Maybe a -> b Source #

maybeToEither :: e -> Maybe a -> Either e a Source #

fromLeft :: a -> Either a b -> a #

Return the contents of a Left-value or a default value otherwise.

Examples

Expand

Basic usage:

>>> fromLeft 1 (Left 3)
3
>>> fromLeft 1 (Right "foo")
1

Since: base-4.10.0.0

fromRight :: b -> Either a b -> b #

Return the contents of a Right-value or a default value otherwise.

Examples

Expand

Basic usage:

>>> fromRight 1 (Right 3)
3
>>> fromRight 1 (Left "foo")
1

Since: base-4.10.0.0