[project @ 2002-12-12 13:42:48 by ross] Changes to the exception interface, as discussed on the libraries list.
[project @ 2002-12-12 13:42:48 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.

rimmington/unix,jimenezrick/unix,rimmington/unix,rimmington/unix,jimenezrick/unix,thomie/unix,rimmington/unix,thomie/unix