fromRight is:exact

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
Extract the right value or a default.
fromRight b ≡ either (const b) id
>>> fromRight "hello" (Right "world")
"world"
>>> fromRight "hello" (Left 42)
"hello"
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.
Return the contents of a Right-value or a default value otherwise. @since base-4.10.0.0

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 take the form Left _.
Extracts value from Right or return given default value.
>>> fromRight 0 (Left 3)
0

>>> fromRight 0 (Right 5)
5
Return the value from the right component. The behavior is undefined if passed a left value, i.e., it can return any value.
>>> fromRight (sRight (literal 'a') :: SEither Integer Char)
'a' :: SChar

>>> prove $ \x -> fromRight (sRight x :: SEither Char Integer) .== (x :: SInteger)
Q.E.D.

>>> sat $ \x -> x .== (fromRight (sLeft (literal 2) :: SEither Integer Char))
Satisfiable. Model:
s0 = 'A' :: Char
Note how we get a satisfying assignment in the last case: The behavior is unspecified, thus the SMT solver picks whatever satisfies the constraints, if there is one.
Analogue of fromMaybe.
Construct a VEither from an a. Exists for symmetry with fromLeft. Indeed, this is just another name for VRight (and for pure).