2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 \section[PrelMaybe]{Module @PrelMaybe@}
9 {-# OPTIONS -fno-implicit-prelude #-}
11 module PrelMaybe where
15 data Maybe a = Nothing | Just a deriving (Eq, Ord, Show {- Read -})
17 maybe :: b -> (a -> b) -> Maybe a -> b
19 maybe n f (Just x) = f x
21 instance Functor Maybe where
22 map f Nothing = Nothing
23 map f (Just a) = Just (f a)
25 instance Monad Maybe where
27 Nothing >>= k = Nothing
30 Nothing >> k = Nothing
34 instance MonadZero Maybe where
37 instance MonadPlus Maybe where