Remove the (very) old strictness analyser
[ghc-hetmet.git] / compiler / utils / MonadUtils.hs
index 733eda1..5e01a22 100644 (file)
@@ -8,6 +8,8 @@ module MonadUtils
         
         , MonadFix(..)
         , MonadIO(..)
+       
+       , ID, runID
         
         , liftIO1, liftIO2, liftIO3, liftIO4
 
@@ -18,10 +20,12 @@ module MonadUtils
         , concatMapM
         , mapMaybeM
         , anyM, allM
-        , foldlM, foldrM
+        , foldlM, foldlM_, foldrM
         , maybeMapM
         ) where
 
+import Outputable 
+
 ----------------------------------------------------------------------------------------
 -- Detection of available libraries
 ----------------------------------------------------------------------------------------
@@ -43,6 +47,20 @@ import Control.Monad
 import Control.Monad.Fix
 
 ----------------------------------------------------------------------------------------
+-- The ID monad
+----------------------------------------------------------------------------------------
+
+newtype ID a = ID a
+instance Monad ID where
+  return x     = ID x
+  (ID x) >>= f = f x
+  _ >> y       = y
+  fail s       = panic s
+
+runID :: ID a -> a
+runID (ID x) = x
+
+----------------------------------------------------------------------------------------
 -- MTL
 ----------------------------------------------------------------------------------------
 
@@ -146,6 +164,10 @@ allM f (b:bs) = (f b) >>= (\bv -> if bv then allM f bs else return False)
 foldlM :: (Monad m) => (a -> b -> m a) -> a -> [b] -> m a
 foldlM = foldM
 
+-- | Monadic version of foldl that discards its result
+foldlM_ :: (Monad m) => (a -> b -> m a) -> a -> [b] -> m ()
+foldlM_ = foldM_
+
 -- | Monadic version of foldr
 foldrM        :: (Monad m) => (b -> a -> m a) -> a -> [b] -> m a
 foldrM _ z []     = return z