Commit 33c0d90e authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

Merge 'D.Compat.Exception' and 'D.Client.Compat.Exception'.

parent 6a90f7d1
......@@ -141,6 +141,7 @@ library
exposed-modules:
Distribution.Compat.Environment
Distribution.Compat.Exception
Distribution.Compat.ReadP
Distribution.Compiler
Distribution.InstalledPackageInfo
......@@ -208,7 +209,6 @@ library
other-modules:
Distribution.Compat.CopyFile
Distribution.Compat.Exception
Distribution.Compat.TempFile
Distribution.GetOpt
Distribution.Simple.GHC.IPI641
......
{-# LANGUAGE CPP #-}
module Distribution.Compat.Exception (
catchIO,
catchExit,
tryIO,
mask,
mask_,
catchIO,
catchExit,
tryIO,
) where
import System.Exit
import qualified Control.Exception as Exception
#if MIN_VERSION_base(4,3,0)
-- it's much less of a headache if we re-export the "real" mask and mask_
-- so there's never more than one definition to conflict
import Control.Exception (mask, mask_)
#else
import Control.Exception (block, unblock)
#endif
#if !MIN_VERSION_base(4,3,0)
-- note: less polymorphic than 'real' mask, to avoid RankNTypes
-- we don't need the full generality where we use it
mask :: ((IO a -> IO a) -> IO b) -> IO b
mask handler = block (handler unblock)
mask_ :: IO a -> IO a
mask_ = block
#endif
tryIO :: IO a -> IO (Either Exception.IOException a)
tryIO = Exception.try
......
......@@ -33,7 +33,7 @@ import Foreign.C.Error (throwErrnoIfMinus1_)
import System.Environment (lookupEnv)
#else
import System.Environment (getEnv)
import Distribution.Client.Compat.Exception (catchIO)
import Distribution.Compat.Exception (catchIO)
#endif
import System.Posix.Internals ( withFilePath )
......
{-# LANGUAGE CPP #-}
{-# OPTIONS_HADDOCK hide #-}
module Distribution.Client.Compat.Exception (
mask,
mask_,
catchIO,
catchExit,
) where
import System.Exit
import qualified Control.Exception as Exception
#if MIN_VERSION_base(4,3,0)
-- it's much less of a headache if we re-export the "real" mask and mask_
-- so there's never more than one definition to conflict
import Control.Exception (mask, mask_)
#else
import Control.Exception (block, unblock)
#endif
#if !MIN_VERSION_base(4,3,0)
-- note: less polymorphic than 'real' mask, to avoid RankNTypes
-- we don't need the full generality where we use it
mask :: ((IO a -> IO a) -> IO b) -> IO b
mask handler = block (handler unblock)
mask_ :: IO a -> IO a
mask_ = block
#endif
catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
catchIO = Exception.catch
catchExit :: IO a -> (ExitCode -> IO a) -> IO a
catchExit = Exception.catch
......@@ -13,7 +13,7 @@ import Control.Exception (onException)
import Control.Monad (join, when)
import Data.Typeable (Typeable)
import Distribution.Client.Compat.Exception (mask_)
import Distribution.Compat.Exception (mask_)
-- | 'QSem' is a quantity semaphore in which the resource is aqcuired
-- and released in units of one. It provides guaranteed FIFO ordering
......
......@@ -100,11 +100,11 @@ import Network.URI
( URI(..), URIAuth(..) )
import System.FilePath
( (<.>), (</>), takeDirectory )
import Distribution.Compat.Environment
( getEnvironment )
import System.IO.Error
( isDoesNotExistError )
import Distribution.Client.Compat.Exception
import Distribution.Compat.Environment
( getEnvironment )
import Distribution.Compat.Exception
( catchIO )
--
......
......@@ -70,7 +70,7 @@ import qualified Data.ByteString.Char8 as BSS
import Data.ByteString.Lazy (ByteString)
import Distribution.Client.GZipUtils (maybeDecompress)
import Distribution.Client.Utils (byteStringToFilePath)
import Distribution.Client.Compat.Exception (catchIO)
import Distribution.Compat.Exception (catchIO)
import Distribution.Client.Compat.Time
import System.FilePath ((</>), takeExtension, splitDirectories, normalise)
import System.FilePath.Posix as FilePath.Posix
......
......@@ -37,7 +37,7 @@ import Control.Exception as Exception
, IOException, SomeException )
import System.Exit
( ExitCode )
import Distribution.Client.Compat.Exception
import Distribution.Compat.Exception
( catchIO, catchExit )
import Control.Monad
( when, unless )
......
......@@ -65,7 +65,7 @@ import System.FilePath
import Prelude hiding (ioError)
import System.IO.Error
( isDoesNotExistError, ioError )
import Distribution.Client.Compat.Exception ( catchIO )
import Distribution.Compat.Exception ( catchIO )
import Control.Exception
( assert )
import Data.Maybe
......
......@@ -29,7 +29,7 @@ module Distribution.Client.JobControl (
import Control.Monad
import Control.Concurrent hiding (QSem, newQSem, waitQSem, signalQSem)
import Control.Exception (SomeException, bracket_, throw, try)
import Distribution.Client.Compat.Exception (mask)
import Distribution.Compat.Exception (mask)
import Distribution.Client.Compat.Semaphore
data JobControl m a = JobControl {
......
......@@ -53,8 +53,7 @@ import Distribution.Verbosity ( Verbosity, normal )
import Control.Monad ( foldM, when, unless )
import Data.List ( partition )
import Data.Monoid ( Monoid(..) )
import Distribution.Client.Compat.Exception
( catchIO )
import Distribution.Compat.Exception ( catchIO )
import System.Directory ( doesDirectoryExist, doesFileExist,
renameFile )
import System.FilePath ( (<.>), (</>), takeDirectory )
......
......@@ -50,7 +50,7 @@ import Distribution.Client.SetupWrapper (SetupScriptOptions (..),
import Distribution.Client.Utils (inDir, removeExistingFile,
tryCanonicalizePath)
import Distribution.Client.Compat.Exception (catchIO)
import Distribution.Compat.Exception (catchIO)
import Distribution.Client.Compat.Time (EpochTime, getCurTime,
getModTime)
......
......@@ -78,7 +78,7 @@ import Distribution.Text
( display )
import Distribution.Verbosity
( Verbosity )
import Distribution.Client.Compat.Exception
import Distribution.Compat.Exception
( catchIO )
import System.Directory ( doesFileExist )
......
......@@ -9,7 +9,7 @@ module Distribution.Client.Utils ( MergeResult(..)
, canonicalizePathNoThrow )
where
import Distribution.Client.Compat.Exception ( catchIO )
import Distribution.Compat.Exception ( catchIO )
import qualified Data.ByteString.Lazy as BS
import Control.Monad
( when )
......
......@@ -40,7 +40,7 @@ import Distribution.Simple.Utils
import Distribution.Text
( Text(..), display, simpleParse )
import qualified Distribution.Compat.ReadP as Parse
import Distribution.Client.Compat.Exception ( catchIO )
import Distribution.Compat.Exception ( catchIO )
import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ( (<>), (<+>) )
......
......@@ -105,7 +105,6 @@ executable cabal
Distribution.Client.Utils
Distribution.Client.World
Distribution.Client.Win32SelfUpgrade
Distribution.Client.Compat.Exception
Distribution.Client.Compat.Environment
Distribution.Client.Compat.FilePerms
Distribution.Client.Compat.Semaphore
......
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