protolude-0.3.0: A small prelude.
Safe Haskell Safe
Language Haskell2010

Protolude.Either

Synopsis

Documentation

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

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 Source #

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