ZVON > References > Haskell reference
| Indexes | Syntax | Prelude | Ratio | Complex | Numeric | Ix | Array | List | >> Maybe << | Char | Monad | IO | Directory | System | Time | Locale | CPUTime | Random

Module: Maybe
Function: fromMaybe
Type: a -> Maybe a -> a
Description: If the argument is Just, it returns the Just value, otherwise it returns the default value provided as the first argument
Related: fromJust, mapMaybe, maybeToList

Example 1

Input: fromMaybe 'X' (lookup 3 [(1,'A'),(2,'B'),(3,'C')])

Output: 'C'

Example 2

Input: fromMaybe 'X' (lookup 32 [(1,'A'),(2,'B'),(3,'C')])

Output: 'X'