fromRight package:rebase

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