fromJust -package:type-fun
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
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.
>>> fromJust (sJust (literal 'a'))
'a' :: SChar
>>> 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.
Converts a Maybe into a value or throws an error if the Maybe is
Nothing.
An alternative name for
fromMaybe, to fit the naming scheme of
this package. Generally using
fromMaybe directly would be
considered better style.
Convert a possibly-incomplete specification for what to convert into
one which can be executed. Calls error when data is missing.
Extract the element out of a Just' and throws an error if its argument
is Nothing'.
Same as
fromJust, but returns a bottom/undefined value that
other Clash constructs are aware of.
Extract value from Just, failing with AuthOtherFailure on Nothing.
fromJust but with a better error message if it fails. Use
this only where it shouldn't fail!