[project @ 2002-12-12 13:42:46 by ross]
authorross <unknown>
Thu, 12 Dec 2002 13:42:47 +0000 (13:42 +0000)
committerross <unknown>
Thu, 12 Dec 2002 13:42:47 +0000 (13:42 +0000)
commita3e56f82973d7117fe4544e5702d1c0180ae7d79
tree98613f89d46925a72aafe34c0b45948090c1dedf
parent13e2f599e470e1ea2025b5f97258b8489285e800
[project @ 2002-12-12 13:42:46 by ross]
Changes to the exception interface, as discussed on the libraries list.

1) Move bracket and bracket_ from GHC.Exception (and hence System.IO)
   to haskell98/IO.hs.  These two should now never be used (except in
   all-H98 programs), and this will save users of the new libraries from
   having to hide them.  Use the ones in Control.Exception instead.

2) Define

        type IOError = IOException      -- was Exception

   leaving the type of Prelude.ioError as IOError -> IO a,
   but adding to Control.Exception

        throwIO :: Exception -> IO a

The result is a type distinction between the variants of catch and try:

Prelude.catch           :: IO a -> (IOError -> IO a) -> IO a
Control.Exception.catch :: IO a -> (Exception -> IO a) -> IO a
System.IO.Error.try     :: IO a -> IO (Either IOError a)
Control.Exception.try   :: IO a -> IO (Either Exception a)

These are breaking changes: the first one affects only import lists,
but the second will bite in the following situations:

- using ioError on general Exceptions: use throwIO instead.

- using throw on IOErrors: if in the IO monad, use ioError instead.
  Otherwise, use throw (IOException e), but why are you throwing
  IO exceptions outside of the IO monad?

Minor changes:
- System.IO.Error now exports catch and try
- moved try from GHC.Exception to System.IO.Error, because it's
  portable and can be shared by Hugs.
Control/Exception.hs
Foreign/C/Error.hs
Foreign/Marshal/Alloc.hs
GHC/Exception.lhs
GHC/Handle.hs
GHC/IO.hs
GHC/IOBase.lhs
System/Directory.hs
System/Environment.hs
System/IO.hs
System/IO/Error.hs