From a585ff39f5f95622c840ac5ab97faf6a1bbc78d6 Mon Sep 17 00:00:00 2001
From: sof <unknown>
Date: Tue, 19 Jan 1999 09:57:12 +0000
Subject: [PATCH] [project @ 1999-01-19 09:57:12 by sof] bracket and bracket_
 had a less general type than they should have. They now match what the docs
 says.

---
 ghc/lib/exts/Exception.lhs | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/ghc/lib/exts/Exception.lhs b/ghc/lib/exts/Exception.lhs
index f9f7e71b4dcd..935e7bf5b5a2 100644
--- a/ghc/lib/exts/Exception.lhs
+++ b/ghc/lib/exts/Exception.lhs
@@ -1,5 +1,5 @@
 % -----------------------------------------------------------------------------
-% $Id: Exception.lhs,v 1.4 1999/01/14 18:15:29 sof Exp $
+% $Id: Exception.lhs,v 1.5 1999/01/19 09:57:12 sof Exp $
 %
 % (c) The GRAP/AQUA Project, Glasgow University, 1998
 %
@@ -192,17 +192,21 @@ a `finally` sequel = do
    tryAllIO a
    sequel
 
-bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO ()
+bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c
 bracket before after thing = do
   a <- before 
   c <- tryAllIO (thing a)
   after a
-  return ()
+  case c of
+    Right r -> return r
+    Left  e -> throw e
 
-bracket_ :: IO a -> IO b -> IO c -> IO ()
+bracket_ :: IO a -> IO b -> IO c -> IO c
 bracket_ before after thing = do
   before 
   c <- tryAllIO thing
   after
-  return ()
+  case c of
+    Right r -> return r
+    Left  e -> throw e
 \end{code}
-- 
GitLab