From: simonmar Date: Thu, 19 Jun 2003 10:42:26 +0000 (+0000) Subject: [project @ 2003-06-19 10:42:26 by simonmar] X-Git-Tag: nhc98-1-18-release~606 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=93fb89b406b738b64d652d17c7fb509344ff5d33;p=ghc-base.git [project @ 2003-06-19 10:42:26 by simonmar] Add raiseIO# primop. This is part of ensuring that exceptions are *precise* in the IO monad (as opposed to imprecise exceptions in the pure world). If we allow the strictness analyser to see the definition of throwIO: throwIO e = IO $ \s -> throw e then it might re-order evaluation in the IO monad, with the result that we get _|_ instead of an exception, or one kind of exception when we were expecting another. We therefore must prevent the strictness analyser from doing these reorderings in the IO monad. Hiding the definition of throwIO by making it a primop solves part of the problem (there's more to come). See SourceForge bug #752149. --- diff --git a/GHC/IOBase.lhs b/GHC/IOBase.lhs index d8e61d6..7b8fef5 100644 --- a/GHC/IOBase.lhs +++ b/GHC/IOBase.lhs @@ -733,11 +733,11 @@ throw exception = raise# exception -- raise an exception within the 'IO' monad because it guarantees -- ordering with respect to other 'IO' operations, whereas 'throw' -- does not. -throwIO :: Exception -> IO a -throwIO err = IO $ \s -> throw err s +throwIO :: Exception -> IO a +throwIO err = IO $ raiseIO# err ioException :: IOException -> IO a -ioException err = IO $ \s -> throw (IOException err) s +ioException err = IO $ raiseIO# (IOException err) ioError :: IOError -> IO a ioError = ioException