[project @ 1999-06-03 08:19:13 by simonmar]
[ghc-hetmet.git] / ghc / compiler / utils / Util.lhs
index 5b4200b..c4ee1f4 100644 (file)
@@ -47,6 +47,12 @@ module Util (
        IF_NOT_GHC(cfst COMMA applyToPair COMMA applyToFst COMMA)
        IF_NOT_GHC(applyToSnd COMMA foldPair COMMA)
        unzipWith
+
+       -- I/O
+#if __GLASGOW_HASKELL__ < 402
+       , bracket
+#endif
+
     ) where
 
 #include "HsVersions.h"
@@ -768,7 +774,8 @@ f $! x  = x `seq` f x
 bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c
 bracket before after thing = do
   a <- before 
-  (thing a) `catch` (\err -> after a >>= fail err)
+  r <- (thing a) `catch` (\err -> after a >> fail err)
   after a
+  return r
 #endif
 \end{code}