fromJust is:exact

The fromJust function extracts the element out of a Just and throws an error if its argument is Nothing.

Examples

Basic usage:
>>> fromJust (Just 1)
1
>>> 2 * (fromJust (Just 10))
20
>>> 2 * (fromJust Nothing)
*** Exception: Maybe.fromJust: Nothing
...
WARNING: This function is partial. You can use case-matching instead.
Extracts the element out of a Just and throws an error if the argument is Nothing.
The fromJust function extracts the element out of a Just and throws an error if its argument is Nothing.

Examples

Basic usage:
>>> fromJust (Just 1)
1
>>> 2 * (fromJust (Just 10))
20
>>> 2 * (fromJust Nothing)
*** Exception: Maybe.fromJust: Nothing
...
Return the value of an optional value. The behavior is undefined if passed Nothing, i.e., it can return any value. Compare to fromMaybe.
>>> sat $ \x -> fromJust (sJust (literal 'a')) .== x
Satisfiable. Model:
s0 = 'a' :: Char

>>> prove $ \x -> fromJust (sJust x) .== (x :: SChar)
Q.E.D.

>>> sat $ \x -> x .== (fromJust sNothing :: SChar)
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.
Convert between Just and its value.
The fromJust function extracts the element out of a Just and throws an error if its argument is Nothing.

Examples

Basic usage:
>>> fromJust (Just 1)
1
>>> 2 * (fromJust (Just 10))
20
>>> 2 * (fromJust Nothing)
*** Exception: Maybe.fromJust: Nothing
Converts a Maybe into a value or throws an error if the Maybe is Nothing.