Big tidy-up of deriving code
[ghc-hetmet.git] / compiler / utils / IOEnv.hs
index e1dfdb4..c0277ae 100644 (file)
@@ -1,4 +1,5 @@
--- (c) The University of Glasgow 2002
+--
+-- (c) The University of Glasgow 2002-2006
 --
 -- The IO Monad with an environment
 --
@@ -17,7 +18,7 @@ module IOEnv (
        getEnv, setEnv, updEnv,
 
        runIOEnv, unsafeInterleaveM,                    
-       tryM, tryAllM, fixM, 
+       tryM, tryAllM, tryMostM, fixM, 
 
        -- I/O operations
        ioToIOEnv,
@@ -25,10 +26,11 @@ module IOEnv (
   ) where
 #include "HsVersions.h"
 
-import Panic           ( try, tryUser, Exception(..) )
-import DATA_IOREF      ( IORef, newIORef, readIORef, writeIORef )
-import UNSAFE_IO       ( unsafeInterleaveIO )
-import FIX_IO          ( fixIO )
+import Panic           ( try, tryUser, tryMost, Exception(..) )
+
+import Data.IORef      ( IORef, newIORef, readIORef, writeIORef )
+import System.IO.Unsafe        ( unsafeInterleaveIO )
+import System.IO       ( fixIO )
 
 
 ----------------------------------------------------------------------
@@ -100,6 +102,9 @@ tryAllM :: IOEnv env r -> IOEnv env (Either Exception r)
 -- even a pattern-match failure is a programmer error
 tryAllM (IOEnv thing) = IOEnv (\ env -> try (thing env))
 
+tryMostM :: IOEnv env r -> IOEnv env (Either Exception r)
+tryMostM (IOEnv thing) = IOEnv (\ env -> tryMost (thing env))
+
 ---------------------------
 unsafeInterleaveM :: IOEnv env a -> IOEnv env a
 unsafeInterleaveM (IOEnv m) = IOEnv (\ env -> unsafeInterleaveIO (m env))