:: a -> Maybe a -> a -package:stack

The fromMaybe function takes a default value and a Maybe value. If the Maybe is Nothing, it returns the default value; otherwise, it returns the value contained in the Maybe.

Examples

Basic usage:
>>> fromMaybe "" (Just "Hello, World!")
"Hello, World!"
>>> fromMaybe "" Nothing
""
Read an integer from a string using readMaybe. If we fail to parse an integer, we want to return 0 by default:
>>> import Text.Read ( readMaybe )

>>> fromMaybe 0 (readMaybe "5")
5

>>> fromMaybe 0 (readMaybe "")
0
An alternative name for fromMaybe, to fit the naming scheme of this package. Generally using fromMaybe directly would be considered better style.
Given a default value and a Maybe, yield the default value if the Maybe argument is Nothing and extract the value out of the Just otherwise.
The fromMaybe function takes a default value and and Maybe value. If the Maybe is Nothing, it returns the default values; otherwise, it returns the value contained in the Maybe.

Examples

Basic usage:
>>> fromMaybe "" (Just "Hello, World!")
"Hello, World!"
>>> fromMaybe "" Nothing
""
Read an integer from a string using readMaybe. If we fail to parse an integer, we want to return 0 by default:
>>> import Text.Read ( readMaybe )

>>> fromMaybe 0 (readMaybe "5")
5

>>> fromMaybe 0 (readMaybe "")
0
The fromMaybe function takes a default value and and Maybe value. If the Maybe is Nothing, it returns the default values; otherwise, it returns the value contained in the Maybe.

Examples

Basic usage:
>>> fromMaybe "" (Just "Hello, World!")
"Hello, World!"
>>> fromMaybe "" Nothing
""
Read an integer from a string using readMaybe. If we fail to parse an integer, we want to return 0 by default:
>>> import Text.Read ( readMaybe )

>>> fromMaybe 0 (readMaybe "5")
5

>>> fromMaybe 0 (readMaybe "")
0
Left bracket of the conditional choice operator. This is equivalent to fromMaybe
Unicode rebinding of <|.
The fromMaybe function takes a default value and and Maybe value. If the Maybe is Nothing, it returns the default values; otherwise, it returns the value contained in the Maybe.

Examples

Basic usage:
>>> fromMaybe "" (Just "Hello, World!")
"Hello, World!"
>>> fromMaybe "" Nothing
""
Read an integer from a string using readMaybe. If we fail to parse an integer, we want to return 0 by default:
>>> import Text.Read ( readMaybe )

>>> fromMaybe 0 (readMaybe "5")
5

>>> fromMaybe 0 (readMaybe "")
0
asProxyTypeOf is a type-restricted version of const. It is usually used as an infix operator, and its typing forces its first argument (which is usually overloaded) to have the same type as the tag of the second.
>>> import Data.Word

>>> :type asProxyTypeOf 123 (Proxy :: Proxy Word8)
asProxyTypeOf 123 (Proxy :: Proxy Word8) :: Word8
Note the lower-case proxy in the definition. This allows any type constructor with just one argument to be passed to the function, for example we could also write
>>> import Data.Word

>>> :type asProxyTypeOf 123 (Just (undefined :: Word8))
asProxyTypeOf 123 (Just (undefined :: Word8)) :: Word8
Hint the type system about the type.
The largest element of a foldable structure. The result is bounded by the value given as the first argument.
The smallest element of a foldable structure. The result is bounded by the value given as the first argument.
New users are recommended to use minimumBound or maximumBound instead.
New users are recommended to use minimumBound or maximumBound instead.
Evaluate polynomial using Horner's method. Coefficients starts from lowest. In pseudocode:
evaluateOddPolynomial x [1,2,3] = 1 + 2*x + 3*x^2
Evaluate polynomial with only even powers using Horner's method. Coefficients starts from lowest. In pseudocode:
evaluateOddPolynomial x [1,2,3] = 1 + 2*x^2 + 3*x^4
Evaluate polynomial with only odd powers using Horner's method. Coefficients starts from lowest. In pseudocode:
evaluateOddPolynomial x [1,2,3] = 1*x + 2*x^3 + 3*x^5
Flipped version of fromMaybe, useful for chaining.
An infix form of fromMaybe with arguments flipped.
Similar to fromMaybe but with flipped arguments.
>>> readMaybe "True" ?: False
True
>>> readMaybe "Tru" ?: False
False
A fliped version of fromMaybe.