import Prelude hiding (catch)
-#if __GLASGOW_HASKELL__ < 609
-import Control.Exception.Extensible as Control.Exception
-#else
import Control.Exception
-#endif
catchIO :: IO a -> (IOException -> IO a) -> IO a
catchIO = catch
gblock (do
a <- before
r <- gunblock (thing a) `gonException` after a
- after a
+ _ <- after a
return r)
a `gfinally` sequel =
gblock (do
r <- gunblock a `gonException` sequel
- sequel
+ _ <- sequel
return r)
instance ExceptionMonad IO where
-- second argument is executed and the exception is raised again.
gonException :: (ExceptionMonad m) => m a -> m b -> m a
gonException ioA cleanup = ioA `gcatch` \e ->
- do cleanup
+ do _ <- cleanup
throw (e :: SomeException)