:: Either a a -> a -package:extra
Take an Either, and return the value inside it
Get the a from an Either a a
Collapses a
Partial structure to a value (probably requiring
unsafe instances).
Extract the value from either side of an
Either.
Collapse an
Either a a to an
a. Defined as
fromEither id.
Note: Other libraries export this function as
fromEither, but
our
fromEither function is slightly more general.
>>> collapseEither (Right 3)
3
>>> collapseEither (Left "hello")
"hello"
Extracts the element out of a
Left and throws an error if its
argument take the form
Right _.
Using
Control.Lens:
fromLeft' x ≡ x^?!_Left
>>> fromLeft' (Left 12)
12
Take a Left to a value, crashes on a Right
Extracts the element out of a
Left and throws an error if the
argument is a
Right.
The
fromLeft function extracts the element out of a
Left
and throws an error if its argument take the form
Right _.
fromLeft but with a better error message if it fails. Use
this only where it shouldn't fail!
Extracts the element out of a
Right and throws an error if its
argument take the form
Left _.
Using
Control.Lens:
fromRight' x ≡ x^?!_Right
>>> fromRight' (Right 12)
12
Take a Right to a value, crashes on a Left
Extracts the element out of a
Right and throws an error if the
argument is a
Left.
The
fromRight function extracts the element out of a
Right and throws an error if its argument take the form
Left _.
fromRight but with a better error message if it fails. Use
this only where it shouldn't fail!
Pulls a
Right value out of an Either value. If the Either value
is Left, raises an exception with "error".