remove kludges, now that Control.Exception is imported
authorRoss Paterson <ross@soi.city.ac.uk>
Mon, 11 Aug 2008 18:03:28 +0000 (18:03 +0000)
committerRoss Paterson <ross@soi.city.ac.uk>
Mon, 11 Aug 2008 18:03:28 +0000 (18:03 +0000)
System/IO.hs

index 58b3e20..b414fba 100644 (file)
@@ -161,7 +161,7 @@ module System.IO (
     openBinaryTempFile,
   ) where
 
-import Control.Exception hiding (bracket)
+import Control.Exception
 
 #ifndef __NHC__
 import Data.Bits
@@ -173,13 +173,6 @@ import System.Posix.Internals
 #endif
 
 #ifdef __GLASGOW_HASKELL__
-import GHC.IOBase       as ExceptionBase
-#endif
-#ifdef __HUGS__
-import Hugs.Exception   as ExceptionBase
-#endif
-
-#ifdef __GLASGOW_HASKELL__
 import GHC.Base
 import GHC.IOBase       -- Together these four Prelude modules define
 import GHC.Handle       -- all the stuff exported by IO for the GHC version
@@ -194,8 +187,6 @@ import GHC.Show
 import Hugs.IO
 import Hugs.IOExts
 import Hugs.IORef
-import Hugs.Prelude     ( throw, Exception(NonTermination) )
-import Control.Exception ( bracket )
 import System.IO.Unsafe ( unsafeInterleaveIO )
 #endif
 
@@ -491,8 +482,7 @@ openTempFile' loc tmp_dir template binary = do
          -- XXX We want to tell fdToHandle what the filepath is,
          -- as any exceptions etc will only be able to report the
          -- fd currently
-         h <- fdToHandle fd
-                `ExceptionBase.catchAny` \e -> do c_close fd; throw e
+         h <- fdToHandle fd `onException` c_close fd
          return (filepath, h)
 #endif
       where
@@ -550,24 +540,3 @@ foreign import ccall "getpid" c_getpid :: IO Int
 -- It follows that an attempt to write to a file (using 'writeFile', for
 -- example) that was earlier opened by 'readFile' will usually result in
 -- failure with 'System.IO.Error.isAlreadyInUseError'.
-
--- -----------------------------------------------------------------------------
--- Utils
-
-#ifdef __GLASGOW_HASKELL__
--- Copied here to avoid recursive dependency with Control.Exception
-bracket
-        :: IO a         -- ^ computation to run first (\"acquire resource\")
-        -> (a -> IO b)  -- ^ computation to run last (\"release resource\")
-        -> (a -> IO c)  -- ^ computation to run in-between
-        -> IO c         -- returns the value from the in-between computation
-bracket before after thing =
-  block (do
-    a <- before
-    r <- catchAny
-           (unblock (thing a))
-           (\e -> do { after a; throw e })
-    after a
-    return r
- )
-#endif