:: Maybe a -> a

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.
Pulls a Just value out of a Maybe value. If the Maybe value is Nothing, raises an exception with error. Alias of fromJust.
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
...
fromJust but with a better error message if it fails. Use this only where it shouldn't fail!
Converts a Maybe into a value or throws an error if the Maybe is Nothing.
Converts exceptional divergence to non-termination.
O(1) First element
O(1) Last element
O(1) First element without checking if the vector is empty
O(1) Last element without checking if the vector is empty
First element of vector. Examples:
>>> import Data.Vector.Fixed.Boxed (Vec3)

>>> let x = mk3 1 2 3 :: Vec3 Int

>>> head x
1
Extracts Monoid value from Maybe returning mempty if Nothing.
>>> maybeToMonoid (Just [1,2,3] :: Maybe [Int])
[1,2,3]

>>> maybeToMonoid (Nothing :: Maybe [Int])
[]
Extracts Monoid value from Maybe returning mempty if Nothing.
>>> maybeToMonoid (Just [1,2,3] :: Maybe [Int])
[1,2,3]

>>> maybeToMonoid (Nothing :: Maybe [Int])
[]
The largest element of a non-empty structure. This function is equivalent to foldr1 max, and its behavior on structures with multiple largest elements depends on the relevant implementation of max. For the default implementation of max (max x y = if x <= y then y else x), structure order is used as a tie-breaker: if there are multiple largest elements, the rightmost of them is chosen (this is equivalent to maximumBy compare). This function is non-total and will raise a runtime exception if the structure happens to be empty. A structure that supports random access and maintains its elements in order should provide a specialised implementation to return the maximum in faster than linear time.

Examples

Basic usage:
>>> maximum [1..10]
10
>>> maximum []
*** Exception: Prelude.maximum: empty list
>>> maximum Nothing
*** Exception: maximum: empty structure
WARNING: This function is partial for possibly-empty structures like lists.
The least element of a non-empty structure. This function is equivalent to foldr1 min, and its behavior on structures with multiple largest elements depends on the relevant implementation of min. For the default implementation of min (min x y = if x <= y then x else y), structure order is used as a tie-breaker: if there are multiple least elements, the leftmost of them is chosen (this is equivalent to minimumBy compare). This function is non-total and will raise a runtime exception if the structure happens to be empty. A structure that supports random access and maintains its elements in order should provide a specialised implementation to return the minimum in faster than linear time.

Examples

Basic usage:
>>> minimum [1..10]
1
>>> minimum []
*** Exception: Prelude.minimum: empty list
>>> minimum Nothing
*** Exception: minimum: empty structure
WARNING: This function is partial for possibly-empty structures like lists.
The largest element of a non-empty structure. This function is non-total and will raise a runtime exception if the structure happens to be empty. A structure that supports random access and maintains its elements in order should provide a specialised implementation to return the maximum in faster than linear time.

Examples

Basic usage:
>>> maximum [1..10]
10
>>> maximum []
*** Exception: Prelude.maximum: empty list
>>> maximum Nothing
*** Exception: maximum: empty structure
WARNING: This function is partial for possibly-empty structures like lists.
The least element of a non-empty structure. This function is non-total and will raise a runtime exception if the structure happens to be empty. A structure that supports random access and maintains its elements in order should provide a specialised implementation to return the minimum in faster than linear time.

Examples

Basic usage:
>>> minimum [1..10]
1
>>> minimum []
*** Exception: Prelude.minimum: empty list
>>> minimum Nothing
*** Exception: minimum: empty structure
WARNING: This function is partial for possibly-empty structures like lists.