Maybe
monadicon.icon
Overview
The Maybe datatype is often used to encode failure or an exceptional value.
The datatype Maybe can encode exceptional function results (i.e., failure), but no information can be associated with
Nothing. We cannot distinguish different kinds of errors.
code:monadinstance.hs
instance Monad Maybe where
(>>=) :: Maybe a -> (a -> Maybe b) -> Maybe b
f >>= g = case f of
Nothing -> Nothing
Just x -> g x