[project @ 2002-07-04 16:22:02 by simonmar]
[ghc-base.git] / Data / Maybe.hs
index 4b7b67e..32101b7 100644 (file)
@@ -38,7 +38,18 @@ import GHC.Base
 -- ---------------------------------------------------------------------------
 -- The Maybe type, and instances
 
-data  Maybe a  =  Nothing | Just a     deriving (Eq, Ord)
+-- | The 'Maybe' type encapsulates an optional value.  A value of type
+-- @'Maybe' a@ either contains a value of type @a@ (represented as @'Just' a@), 
+-- or it is empty (represented as 'Nothing').  Using 'Maybe' is a good way to 
+-- deal with errors or exceptional cases without resorting to drastic
+-- measures such as 'error'.
+--
+-- The 'Maybe' type is also a monad.  It is a simple kind of error
+-- monad, where all errors are represented by 'Nothing'.  A richer
+-- error monad can be built using the 'Data.Either.Either' type.
+
+data  Maybe a  =  Nothing | Just a     
+  deriving (Eq, Ord)
 
 instance  Functor Maybe  where
     fmap _ Nothing       = Nothing