:: Maybe Int -> Int -> Int package:verset

An infix form of fromMaybe with arguments flipped.
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 GHC.Internal.Text.Read ( readMaybe )

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

>>> fromMaybe 0 (readMaybe "")
0
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.
Flipped version of <$.

Examples

Replace the contents of a Maybe Int with a constant String:
>>> Nothing $> "foo"
Nothing
>>> Just 90210 $> "foo"
Just "foo"
Replace the contents of an Either Int Int with a constant String, resulting in an Either Int String:
>>> Left 8675309 $> "foo"
Left 8675309
>>> Right 8675309 $> "foo"
Right "foo"
Replace each element of a list with a constant String:
>>> [1,2,3] $> "foo"
["foo","foo","foo"]
Replace the second element of a pair with a constant String:
>>> (1,2) $> "foo"
(1,"foo")