fromRight package:extra

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

Examples

Basic usage:
>>> fromRight 1 (Right 3)
3

>>> fromRight 1 (Left "foo")
1
The fromRight' function extracts the element out of a Right and throws an error if its argument is Left. Much like fromJust, using this function in polished code is usually a bad idea.
\x -> fromRight' (Right x) == x
\x -> fromRight' (Left  x) == undefined