Commit 80a2226a authored by Ben Millwood's avatar Ben Millwood
Browse files

Slim down exception compatibility modules

handleIO and throwIOIO in the cabal-install compat module were
completely unused, so they're just binned.

IOException, SomeException and onException are now just used from
Control.Exception, since these days it's available on all supported
build configurations.

There are some more functions which can be removed, but these are the
easiest and least invasive.
parent b89d8949
module Distribution.Compat.Exception (
Exception.IOException,
onException,
catchIO,
catchExit,
throwIOIO,
......@@ -10,9 +8,6 @@ module Distribution.Compat.Exception (
import System.Exit
import qualified Control.Exception as Exception
onException :: IO a -> IO b -> IO a
onException = Exception.onException
throwIOIO :: Exception.IOException -> IO a
throwIOIO = Exception.throwIO
......
......@@ -19,7 +19,8 @@ import System.IO.Error (isAlreadyExistsError)
import System.Posix.Internals (withFilePath)
import Foreign.C (CInt)
import GHC.IO.Handle.FD (fdToHandle)
import Distribution.Compat.Exception (onException, tryIO)
import Distribution.Compat.Exception (tryIO)
import Control.Exception (onException)
import Foreign.C (getErrno, errnoToIOError)
import System.Posix.Internals (c_getpid)
......
......@@ -187,7 +187,7 @@ import qualified Distribution.ModuleName as ModuleName
import Distribution.Version
(Version(..))
import Control.Exception (evaluate)
import Control.Exception (IOException, evaluate)
import System.Process (runProcess)
import Control.Concurrent (forkIO)
......@@ -202,7 +202,7 @@ import Distribution.Compat.CopyFile
import Distribution.Compat.TempFile
( openTempFile, createTempDirectory )
import Distribution.Compat.Exception
( IOException, throwIOIO, tryIO, catchIO, catchExit )
( throwIOIO, tryIO, catchIO, catchExit )
import Distribution.Verbosity
#ifdef VERSION_base
......
......@@ -32,13 +32,12 @@ import Data.List
import Data.Maybe
( isJust, fromMaybe, maybeToList )
import Control.Exception as Exception
( bracket, handleJust )
import Control.Exception as Exception
( Exception(toException), catches, Handler(Handler), IOException )
( Exception(toException), bracket, catches, Handler(Handler), handleJust
, IOException, SomeException )
import System.Exit
( ExitCode )
import Distribution.Compat.Exception
( SomeException, catchIO, catchExit )
( catchIO, catchExit )
import Control.Monad
( when, unless )
import System.Directory
......
......@@ -30,7 +30,7 @@ import Distribution.Version
import Data.Map (Map)
import Network.URI (URI)
import Data.ByteString.Lazy (ByteString)
import Distribution.Compat.Exception
import Control.Exception
( SomeException )
newtype Username = Username { unUsername :: String }
......
{-# LANGUAGE CPP #-}
{-# OPTIONS_HADDOCK hide #-}
module Distribution.Compat.Exception (
SomeException,
mask,
mask_,
onException,
catchIO,
handleIO,
catchExit,
throwIOIO
) where
import System.Exit
import qualified Control.Exception as Exception
import Control.Exception (SomeException)
#if MIN_VERSION_base(4,3,0)
-- it's much less of a headache if we re-export the "real" mask and mask_
......@@ -33,17 +28,8 @@ mask_ :: IO a -> IO a
mask_ = block
#endif
onException :: IO a -> IO b -> IO a
onException = Exception.onException
throwIOIO :: Exception.IOException -> IO a
throwIOIO = Exception.throwIO
catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
catchIO = Exception.catch
handleIO :: (Exception.IOException -> IO a) -> IO a -> IO a
handleIO = flip catchIO
catchExit :: IO a -> (ExitCode -> IO a) -> IO a
catchExit = Exception.catch
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment