[project @ 1996-07-19 18:36:04 by partain]
[ghc-hetmet.git] / ghc / compiler / utils / Maybes.lhs
index 3a29c7f..5ed4ac3 100644 (file)
@@ -24,11 +24,9 @@ module Maybes (
        failMaB,
        failMaybe,
        seqMaybe,
-       mapMaybe,
        returnMaB,
        returnMaybe,
-       thenMaB,
-       thenMaybe
+       thenMaB
 
 #if ! defined(COMPILING_GHC)
        , findJust
@@ -41,6 +39,8 @@ module Maybes (
 
 CHK_Ubiq() -- debugging consistency check
 
+import Unique (Unique) -- only for specialising
+
 #endif
 \end{code}
 
@@ -52,14 +52,6 @@ CHK_Ubiq() -- debugging consistency check
 %************************************************************************
 
 \begin{code}
-#if __HASKELL1__ < 3
-data Maybe a
-  = Nothing
-  | Just a
-#endif
-\end{code}
-
-\begin{code}
 maybeToBool :: Maybe a -> Bool
 maybeToBool Nothing  = False
 maybeToBool (Just x) = True
@@ -112,13 +104,6 @@ expectJust err Nothing  = error ("expectJust " ++ err)
 The Maybe monad
 ~~~~~~~~~~~~~~~
 \begin{code}
-#if __HASKELL1__ < 3
-thenMaybe :: Maybe a -> (a -> Maybe b) -> Maybe b
-m `thenMaybe` k = case m of
-                 Nothing -> Nothing
-                 Just a  -> k a
-#endif
-
 seqMaybe :: Maybe a -> Maybe a -> Maybe a
 seqMaybe (Just x) _  = Just x
 seqMaybe Nothing  my = my
@@ -128,12 +113,6 @@ returnMaybe = Just
 
 failMaybe :: Maybe a
 failMaybe = Nothing
-
-mapMaybe :: (a -> Maybe b) -> [a] -> Maybe [b]
-mapMaybe f []    = returnMaybe []
-mapMaybe f (x:xs) = f x                        `thenMaybe` \ x' ->
-                   mapMaybe f xs       `thenMaybe` \ xs' ->
-                   returnMaybe (x':xs')
 \end{code}
 
 Lookup functions
@@ -152,14 +131,11 @@ assocMaybe alist key
     lookup ((tv,ty):rest) = if key == tv then Just ty else lookup rest
 
 #if defined(COMPILING_GHC)
-{-? SPECIALIZE assocMaybe
-       :: [(String,        b)] -> String        -> Maybe b,
-          [(Id,            b)] -> Id            -> Maybe b,
-          [(Class,         b)] -> Class         -> Maybe b,
-          [(Int,           b)] -> Int           -> Maybe b,
-          [(Name,          b)] -> Name          -> Maybe b,
-          [(TyVar,         b)] -> TyVar         -> Maybe b,
-          [(TyVarTemplate, b)] -> TyVarTemplate -> Maybe b
+{-# SPECIALIZE assocMaybe
+       :: [(FAST_STRING,   b)] -> FAST_STRING -> Maybe b
+        , [(Int,           b)] -> Int         -> Maybe b
+        , [(Unique,        b)] -> Unique      -> Maybe b
+        , [(RdrName,       b)] -> RdrName     -> Maybe b
   #-}
 #endif
 \end{code}