Portability | GHC |
---|---|

Stability | experimental |

Maintainer | Simon Meier <iridcode@gmail.com> |

Safe Haskell | None |

The strict variant of the standard Haskell `Maybe`

type and the
corresponding variants of the functions from Data.Maybe.

Note that in contrast to the standard lazy `Maybe`

type, the strict
`Maybe`

type is not an applicative functor, and therefore also not a monad.
The problem is the *homomorphism* law, which states that

`pure`

f`<*>`

`pure`

x =`pure`

(f x) -- must hold for all f

This law does not hold for the expected applicative functor instance of
`Maybe`

, as this instance does not satisfy ```
pure f <*> pure _|_ = pure (f
_|_)
```

for `f = const`

.

- data Maybe a
- maybe :: b -> (a -> b) -> Maybe a -> b
- isJust :: Maybe a -> Bool
- isNothing :: Maybe a -> Bool
- fromJust :: Maybe a -> a
- fromMaybe :: a -> Maybe a -> a
- listToMaybe :: [a] -> Maybe a
- maybeToList :: Maybe a -> [a]
- catMaybes :: [Maybe a] -> [a]
- mapMaybe :: (a -> Maybe b) -> [a] -> [b]
- _Just :: Prism (Maybe a) (Maybe b) a b
- _Nothing :: Prism' (Maybe a) ()

# Documentation

data Maybe a

The type of strict optional values.

Functor Maybe | |

Typeable1 Maybe | |

Foldable Maybe | |

Traversable Maybe | |

Eq a => Eq (Maybe a) | |

Data a => Data (Maybe a) | |

Ord a => Ord (Maybe a) | |

Read a => Read (Maybe a) | |

Show a => Show (Maybe a) | |

Generic (Maybe a) | |

Arbitrary a => Arbitrary (Maybe a) | |

ToJSON a => ToJSON (Maybe a) | |

FromJSON a => FromJSON (Maybe a) | |

Monoid a => Monoid (Maybe a) | |

Binary a => Binary (Maybe a) | |

NFData a => NFData (Maybe a) | |

Strict (Maybe a) (Maybe a) |

listToMaybe :: [a] -> Maybe aSource

Analogous to `listToMaybe`

in Data.Maybe.

maybeToList :: Maybe a -> [a]Source

Analogous to `maybeToList`

in Data.Maybe.

catMaybes :: [Maybe a] -> [a]Source

Analogous to `catMaybes`

in Data.Maybe.

mapMaybe :: (a -> Maybe b) -> [a] -> [b]Source

Analogous to `mapMaybe`

in Data.Maybe.