Commit 625c1451 authored by quasicomputational's avatar quasicomputational Committed by Mikhail Glushenkov

Remove pre-7.6 compatibility code.

This code existed to support building Cabal with 7.4 and earlier, but
we have recently dropped support for 7.4.
parent f24c1947
......@@ -165,43 +165,28 @@ source-repository head
flag bundled-binary-generic
default: False
flag old-directory
description: Use directory < 1.2 and old-time
default: False
library
build-depends:
array >= 0.4 && < 0.6,
base >= 4.6 && < 5,
bytestring >= 0.9.2.1 && < 0.11,
containers >= 0.5.0.0 && < 0.7,
deepseq >= 1.3 && < 1.5,
filepath >= 1.3 && < 1.5,
pretty >= 1.1.1 && < 1.2,
process >= 1.1.0.1 && < 1.7,
time >= 1.4 && < 1.10
if flag(old-directory)
build-depends: directory >= 1.1.0.2 && < 1.2,
process >= 1.0.1.1 && < 1.1.0.2,
old-time >= 1.1 && < 1.2
else
build-depends: directory >= 1.2 && < 1.4,
process >= 1.1.0.2 && < 1.7
array >= 0.4.0.1 && < 0.6,
base >= 4.6 && < 5,
bytestring >= 0.10.0.0 && < 0.11,
containers >= 0.5.0.0 && < 0.7,
deepseq >= 1.3.0.1 && < 1.5,
directory >= 1.2 && < 1.4,
filepath >= 1.3.0.1 && < 1.5,
pretty >= 1.1.1 && < 1.2,
process >= 1.1.0.2 && < 1.7,
time >= 1.4.0.1 && < 1.10
if flag(bundled-binary-generic)
build-depends: binary >= 0.5.1 && < 0.7
build-depends: binary >= 0.5.1.1 && < 0.7
else
build-depends: binary >= 0.7 && < 0.9
-- Needed for GHC.Generics before GHC 7.6
if impl(ghc < 7.6)
build-depends: ghc-prim >= 0.2 && < 0.3
if os(windows)
build-depends: Win32 >= 2.2.2 && < 2.9
build-depends: Win32 >= 2.3.0.0 && < 2.9
else
build-depends: unix >= 2.5.1 && < 2.9
build-depends: unix >= 2.6.0.0 && < 2.9
ghc-options: -Wall -fno-ignore-asserts -fwarn-tabs
if impl(ghc >= 8.0)
......@@ -229,8 +214,6 @@ library
Distribution.Compat.Exception
Distribution.Compat.Graph
Distribution.Compat.Internal.TempFile
Distribution.Compat.Map.Lazy
Distribution.Compat.Map.Strict
Distribution.Compat.Newtype
Distribution.Compat.Prelude.Internal
Distribution.Compat.ReadP
......
......@@ -18,10 +18,6 @@ module Distribution.Compat.Binary
#endif
) where
#if __GLASGOW_HASKELL__ < 706
import Prelude hiding (catch)
#endif
import Control.Exception (catch, evaluate)
#if __GLASGOW_HASKELL__ >= 711
import Control.Exception (pattern ErrorCall)
......
......@@ -18,14 +18,10 @@ import Foreign.C.Error (throwErrnoIf_)
#endif
import qualified System.Environment as System
#if __GLASGOW_HASKELL__ >= 706
import System.Environment (lookupEnv)
#if __GLASGOW_HASKELL__ >= 708
import System.Environment (unsetEnv)
#endif
#else
import Distribution.Compat.Exception (catchIO)
#endif
import Distribution.Compat.Stack
......@@ -55,13 +51,6 @@ getEnvironment = fmap upcaseVars System.getEnvironment
getEnvironment = System.getEnvironment
#endif
#if __GLASGOW_HASKELL__ < 706
-- | @lookupEnv var@ returns the value of the environment variable @var@, or
-- @Nothing@ if there is no such value.
lookupEnv :: String -> IO (Maybe String)
lookupEnv name = (Just `fmap` System.getEnv name) `catchIO` const (return Nothing)
#endif /* __GLASGOW_HASKELL__ < 706 */
-- | @setEnv name value@ sets the specified environment variable to @value@.
--
-- Throws `Control.Exception.IOException` if either @name@ or @value@ is the
......
......@@ -83,13 +83,6 @@ module Distribution.Compat.Graph (
nodeValue,
) where
-- For bootstrapping GHC
#ifdef MIN_VERSION_containers
#if MIN_VERSION_containers(0,5,0)
#define HAVE_containers_050
#endif
#endif
import Prelude ()
import qualified Distribution.Compat.Prelude as Prelude
import Distribution.Compat.Prelude hiding (lookup, null, empty)
......@@ -97,11 +90,7 @@ import Distribution.Compat.Prelude hiding (lookup, null, empty)
import Data.Graph (SCC(..))
import qualified Data.Graph as G
#ifdef HAVE_containers_050
import qualified Data.Map.Strict as Map
#else
import qualified Data.Map as Map
#endif
import qualified Data.Set as Set
import qualified Data.Array as Array
import Data.Array ((!))
......@@ -148,11 +137,9 @@ instance Foldable.Foldable Graph where
foldr f z = Foldable.foldr f z . graphMap
foldl f z = Foldable.foldl f z . graphMap
foldMap f = Foldable.foldMap f . graphMap
#ifdef MIN_VERSION_base
#if MIN_VERSION_base(4,6,0)
foldl' f z = Foldable.foldl' f z . graphMap
foldr' f z = Foldable.foldr' f z . graphMap
#endif
#ifdef MIN_VERSION_base
#if MIN_VERSION_base(4,8,0)
length = Foldable.length . graphMap
null = Foldable.null . graphMap
......
{-# LANGUAGE CPP #-}
-- For bootstrapping GHC
#ifdef MIN_VERSION_containers
#if MIN_VERSION_containers(0,5,0)
#define HAVE_containers_050
#endif
#endif
module Distribution.Compat.Map.Lazy
( module X
#ifdef HAVE_containers_050
#else
, fromSet
#endif
) where
#ifdef HAVE_containers_050
import Data.Map.Lazy as X
#else
import Data.Map as X
import qualified Data.Map
import qualified Data.Set
fromSet :: (k -> a) -> Data.Set.Set k -> Map k a
fromSet f = Data.Map.fromDistinctAscList . Prelude.map (\k -> (k, f k)) . Data.Set.toList
#endif
{-# LANGUAGE CPP #-}
-- For bootstrapping GHC
#ifdef MIN_VERSION_containers
#if MIN_VERSION_containers(0,5,0)
#define HAVE_containers_050
#endif
#endif
module Distribution.Compat.Map.Strict
( module X
#ifdef HAVE_containers_050
#else
, insertWith
, fromSet
#endif
) where
#ifdef HAVE_containers_050
import Data.Map.Strict as X
#else
import Data.Map as X hiding (insertWith, insertWith')
import qualified Data.Map
import qualified Data.Set
insertWith :: Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
insertWith = Data.Map.insertWith'
fromSet :: (k -> a) -> Data.Set.Set k -> Map k a
fromSet f = Data.Map.fromDistinctAscList . Prelude.map (\k -> (k, f k)) . Data.Set.toList
#endif
......@@ -6,11 +6,9 @@
#ifdef MIN_VERSION_base
#define MINVER_base_48 MIN_VERSION_base(4,8,0)
#define MINVER_base_47 MIN_VERSION_base(4,7,0)
#define MINVER_base_46 MIN_VERSION_base(4,6,0)
#else
#define MINVER_base_48 (__GLASGOW_HASKELL__ >= 710)
#define MINVER_base_47 (__GLASGOW_HASKELL__ >= 708)
#define MINVER_base_46 (__GLASGOW_HASKELL__ >= 706)
#endif
-- | This module does two things:
......
......@@ -23,12 +23,8 @@ import System.FilePath
import Data.Time.Clock.POSIX ( POSIXTime, getPOSIXTime )
import Data.Time ( diffUTCTime, getCurrentTime )
#if MIN_VERSION_directory(1,2,0)
import Data.Time.Clock.POSIX ( posixDayLength )
#else
import System.Time ( getClockTime, diffClockTimes
, normalizeTimeDiff, tdDay, tdHour )
#endif
#if defined mingw32_HOST_OS
......@@ -135,12 +131,7 @@ getModTime path = do
return $! (extractFileTime st)
extractFileTime :: FileStatus -> ModTime
#if MIN_VERSION_unix(2,6,0)
extractFileTime x = posixTimeToModTime (modificationTimeHiRes x)
#else
extractFileTime x = posixSecondsToModTime $ fromIntegral $ fromEnum $
modificationTime x
#endif
#endif
......@@ -162,14 +153,8 @@ posixTimeToModTime p = ModTime $ (ceiling $ p * 1e7) -- 100 ns precision
getFileAge :: FilePath -> NoCallStackIO Double
getFileAge file = do
t0 <- getModificationTime file
#if MIN_VERSION_directory(1,2,0)
t1 <- getCurrentTime
return $ realToFrac (t1 `diffUTCTime` t0) / realToFrac posixDayLength
#else
t1 <- getClockTime
let dt = normalizeTimeDiff (t1 `diffClockTimes` t0)
return $ fromIntegral ((24 * tdDay dt) + tdHour dt) / 24.0
#endif
-- | Return the current time as 'ModTime'.
getCurTime :: NoCallStackIO ModTime
......
......@@ -31,7 +31,7 @@ module Distribution.FieldGrammar (
import Distribution.Compat.Prelude
import Prelude ()
import qualified Distribution.Compat.Map.Strict as Map
import qualified Data.Map.Strict as Map
import Distribution.FieldGrammar.Class
import Distribution.FieldGrammar.Parsec
......
......@@ -71,11 +71,11 @@ import Distribution.Compat.Prelude
import Distribution.Simple.Utils (fromUTF8BS)
import Prelude ()
import qualified Data.ByteString as BS
import qualified Data.Set as Set
import qualified Distribution.Compat.Map.Strict as Map
import qualified Text.Parsec as P
import qualified Text.Parsec.Error as P
import qualified Data.ByteString as BS
import qualified Data.Set as Set
import qualified Data.Map.Strict as Map
import qualified Text.Parsec as P
import qualified Text.Parsec.Error as P
import Distribution.CabalSpecVersion
import Distribution.FieldGrammar.Class
......
......@@ -58,7 +58,7 @@ import Distribution.Text
import Distribution.Version
import qualified Distribution.Compat.CharParsing as P
import qualified Distribution.Compat.Map.Strict as Map
import qualified Data.Map.Strict as Map
import qualified Distribution.Compat.ReadP as Parse
import qualified Distribution.SPDX as SPDX
import qualified Text.PrettyPrint as Disp
......
......@@ -63,8 +63,8 @@ import Distribution.Types.CondTree
import Distribution.Types.Condition
import Distribution.Types.DependencyMap
import qualified Distribution.Compat.Map.Strict as Map.Strict
import qualified Distribution.Compat.Map.Lazy as Map
import qualified Data.Map.Strict as Map.Strict
import qualified Data.Map.Lazy as Map
import Data.Tree ( Tree(Node) )
------------------------------------------------------------------------------
......
......@@ -74,7 +74,7 @@ import System.Directory (doesFileExist)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
import qualified Distribution.Compat.Map.Strict as Map
import qualified Data.Map.Strict as Map
import qualified Distribution.Compat.Newtype as Newtype
import qualified Distribution.Types.BuildInfo.Lens as L
import qualified Distribution.Types.GenericPackageDescription.Lens as L
......
......@@ -36,7 +36,7 @@ import Distribution.Compat.Prelude
import Distribution.Parsec.Common (PWarnType (..), PWarning (..), Position (..), showPos)
import Prelude ()
import qualified Distribution.Compat.Map.Strict as Map
import qualified Data.Map.Strict as Map
#ifdef CABAL_PARSEC_DEBUG
-- testing only:
......
......@@ -15,7 +15,7 @@ import Distribution.Pretty
import Distribution.Parsec.Class
import Distribution.Utils.Generic (isAsciiAlphaNum)
import qualified Distribution.Compat.Map.Strict as Map
import qualified Data.Map.Strict as Map
import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
......
......@@ -18,7 +18,7 @@ import Distribution.Pretty
import Distribution.Parsec.Class
import Distribution.Utils.Generic (isAsciiAlphaNum)
import qualified Distribution.Compat.Map.Strict as Map
import qualified Data.Map.Strict as Map
import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
......
......@@ -101,7 +101,7 @@ module Distribution.Simple.PackageIndex (
import Prelude ()
import Distribution.Compat.Prelude hiding (lookup)
import qualified Distribution.Compat.Map.Strict as Map
import qualified Data.Map.Strict as Map
import Distribution.Package
import Distribution.Backpack
......
{-# LANGUAGE CPP #-}
#ifdef MIN_VERSION_containers
#if MIN_VERSION_containers(0,5,0)
#define MIN_VERSION_containers_0_5_0
#endif
#endif
#ifndef MIN_VERSION_containers
#if __GLASGOW_HASKELL__ >= 706
#define MIN_VERSION_containers_0_5_0
#endif
#endif
module Distribution.Types.DependencyMap (
DependencyMap,
toDepMap,
......@@ -26,11 +12,7 @@ import Distribution.Types.Dependency
import Distribution.Types.PackageName
import Distribution.Version
#ifdef MIN_VERSION_containers_0_5_0
import qualified Data.Map.Lazy as Map
#else
import qualified Data.Map as Map
#endif
-- | A map of dependencies. Newtyped since the default monoid instance is not
-- appropriate. The monoid instance uses 'intersectVersionRanges'.
......@@ -61,13 +43,8 @@ constrainBy :: DependencyMap -- ^ Input map
-> DependencyMap
constrainBy left extra =
DependencyMap $
#ifdef MIN_VERSION_containers_0_5_0
Map.foldrWithKey tightenConstraint (unDependencyMap left)
(unDependencyMap extra)
#else
Map.foldWithKey tightenConstraint (unDependencyMap left)
(unDependencyMap extra)
#endif
where tightenConstraint n c l =
case Map.lookup n l of
Nothing -> l
......
{-# LANGUAGE CPP #-}
-- | @since 2.2.0
module Distribution.Utils.IOData
( -- * 'IOData' & 'IODataMode' type
......@@ -33,11 +31,7 @@ null (IODataBinary b) = BS.null b
instance NFData IOData where
rnf (IODataText s) = rnf s
#if MIN_VERSION_bytestring(0,10,0)
rnf (IODataBinary bs) = rnf bs
#else
rnf (IODataBinary bs) = rnf (BS.length bs)
#endif
data IODataMode = IODataModeText | IODataModeBinary
......
......@@ -88,7 +88,7 @@ parseIndex' predicate action path = do
fpath = Tar.entryPath entry
readFieldTest :: FilePath -> BSL.ByteString -> IO ()
readFieldTest fpath bsl = case Parsec.readFields $ bslToStrict bsl of
readFieldTest fpath bsl = case Parsec.readFields $ BSL.toStrict bsl of
Right _ -> return ()
Left err -> putStrLn $ fpath ++ "\n" ++ show err
......@@ -105,7 +105,7 @@ instance (NFData k, NFData v) => NFData (M k v) where
parseParsecTest :: FilePath -> BSL.ByteString -> IO (Sum Int)
parseParsecTest fpath bsl = do
let bs = bslToStrict bsl
let bs = BSL.toStrict bsl
let (_warnings, parsec) = Parsec.runParseResult $
Parsec.parseGenericPackageDescription bs
case parsec of
......@@ -116,7 +116,7 @@ parseParsecTest fpath bsl = do
parseCheckTest :: FilePath -> BSL.ByteString -> IO CheckResult
parseCheckTest fpath bsl = do
let bs = bslToStrict bsl
let bs = BSL.toStrict bsl
let (_warnings, parsec) = Parsec.runParseResult $
Parsec.parseGenericPackageDescription bs
case parsec of
......@@ -150,7 +150,7 @@ toCheckResult PackageDistInexcusable {} = CheckResult 0 0 0 0 0 1
roundtripTest :: FilePath -> BSL.ByteString -> IO (Sum Int)
roundtripTest fpath bsl = do
let bs = bslToStrict bsl
let bs = BSL.toStrict bsl
x0 <- parse "1st" bs
let bs' = showGenericPackageDescription x0
y0 <- parse "2nd" (toUTF8BS bs')
......@@ -248,18 +248,6 @@ main = join (O.execParser opts)
(O.info (p <**> O.helper) (O.progDesc desc))
subparser = O.subparser . mconcat
-------------------------------------------------------------------------------
--
-------------------------------------------------------------------------------
bslToStrict :: BSL.ByteString -> B.ByteString
#if MIN_VERSION_bytestring(0,10,0)
bslToStrict = BSL.toStrict
#else
-- Not effective!
bslToStrict = B.concat . BSL.toChunks
#endif
-------------------------------------------------------------------------------
-- Index shuffling
-------------------------------------------------------------------------------
......
{-# LANGUAGE CPP, StandaloneDeriving, DeriveDataTypeable #-}
{-# LANGUAGE StandaloneDeriving, DeriveDataTypeable #-}
{-# OPTIONS_GHC -fno-warn-orphans
-fno-warn-incomplete-patterns
-fno-warn-deprecations
......@@ -24,9 +24,7 @@ import Test.QuickCheck.Utils
import Data.Maybe (fromJust)
import Data.Function (on)
#if MIN_VERSION_base(4,6,0)
import Text.Read (readMaybe)
#endif
versionTests :: [TestTree]
versionTests =
......@@ -242,12 +240,7 @@ prop_VersionOrd2 (VersionArb v1) (VersionArb v2) =
(==) v1 v2 == ((==) `on` mkVersion) v1 v2
prop_ShowRead :: Version -> Property
#if MIN_VERSION_base(4,6,0)
prop_ShowRead v = Just v === readMaybe (show v)
#else
-- readMaybe is since base-4.6
prop_ShowRead v = v === read (show v)
#endif
prop_ShowRead_example :: Bool
prop_ShowRead_example = show (mkVersion [1,2,3]) == "mkVersion [1,2,3]"
......
......@@ -14,7 +14,7 @@ import Distribution.Pretty
import Distribution.Parsec.Class
import Distribution.Utils.Generic (isAsciiAlphaNum)
import qualified Distribution.Compat.Map.Strict as Map
import qualified Data.Map.Strict as Map
import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
......
......@@ -17,7 +17,7 @@ import Distribution.Pretty
import Distribution.Parsec.Class
import Distribution.Utils.Generic (isAsciiAlphaNum)
import qualified Distribution.Compat.Map.Strict as Map
import qualified Data.Map.Strict as Map
import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
......
{-# LANGUAGE CPP, NamedFieldPuns, RecordWildCards #-}
{-# LANGUAGE NamedFieldPuns, RecordWildCards #-}
-- | cabal-install CLI command: freeze
--
......@@ -209,7 +209,6 @@ projectFreezeConstraints plan =
:: Map PackageName [(UserConstraint, ConstraintSource)]
-> Map PackageName [(UserConstraint, ConstraintSource)]
deleteLocalPackagesVersionConstraints =
#if MIN_VERSION_containers(0,5,0)
Map.mergeWithKey
(\_pkgname () constraints ->
case filter (not . isVersionConstraint . fst) constraints of
......@@ -217,15 +216,6 @@ projectFreezeConstraints plan =
constraints' -> Just constraints')
(const Map.empty) id
localPackages
#else
Map.mapMaybeWithKey
(\pkgname constraints ->
if pkgname `Map.member` localPackages
then case filter (not . isVersionConstraint . fst) constraints of
[] -> Nothing
constraints' -> Just constraints'
else Just constraints)
#endif
isVersionConstraint (UserConstraint _ (PackagePropertyVersion _)) = True
isVersionConstraint _ = False
......
......@@ -35,25 +35,6 @@ import Foreign.Storable
import System.Posix.Internals
#endif
-- GHC 7.0.* compatibility. 'System.Posix.Internals' in base-4.3.* doesn't
-- provide 'peekFilePath' and 'peekFilePathLen'.
#if !MIN_VERSION_base(4,4,0)
#ifdef mingw32_HOST_OS
peekFilePath :: CWString -> IO FilePath
peekFilePath = peekCWString
#else
peekFilePath :: CString -> IO FilePath
peekFilePath = peekCString
peekFilePathLen :: CStringLen -> IO FilePath
peekFilePathLen = peekCStringLen
#endif
#endif
-- The exported function is defined outside any if-guard to make sure
-- every OS implements it with the same type.
......
{-# LANGUAGE CPP #-}
-- to suppress WARNING in "Distribution.Compat.Prelude.Internal"
{-# OPTIONS_GHC -fno-warn-deprecations #-}
......@@ -20,16 +18,5 @@ module Distribution.Client.Compat.Prelude
import Prelude (IO)
import Distribution.Compat.Prelude.Internal hiding (IO)
#if MIN_VERSION_base(4,6,0)
import Text.Read
( readMaybe )
#endif
#if !MIN_VERSION_base(4,6,0)
-- | An implementation of readMaybe, for compatibility with older base versions.
readMaybe :: Read a => String -> Maybe a
readMaybe s = case reads s of
[(x,"")] -> Just x
_ -> Nothing
#endif