, MonadFix(..)
, MonadIO(..)
+
+ , ID, runID
, liftIO1, liftIO2, liftIO3, liftIO4
, concatMapM
, mapMaybeM
, anyM, allM
- , foldlM, foldrM
+ , foldlM, foldlM_, foldrM
, maybeMapM
) where
+import Outputable
+
----------------------------------------------------------------------------------------
-- Detection of available libraries
----------------------------------------------------------------------------------------
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
----------------------------------------------------------------------------------------
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