Commit 70e2f902 authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺

Reduce use of CPP and some imports via new Prelude module

parent 82a22706
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Client.Configure
......@@ -22,6 +21,9 @@ module Distribution.Client.Configure (
writeConfigFlagsTo, writeConfigFlags,
) where
import Prelude ()
import Distribution.Client.Compat.Prelude
import Distribution.Client.Dependency
import qualified Distribution.Client.InstallPlan as InstallPlan
import Distribution.Client.SolverInstallPlan (SolverInstallPlan)
......@@ -83,11 +85,6 @@ import Distribution.Verbosity as Verbosity
import Distribution.Version
( Version(..), VersionRange, orLaterVersion )
import Control.Monad (unless)
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid (Monoid(..))
#endif
import Data.Maybe (isJust, fromMaybe)
import System.FilePath ( (</>) )
-- | Choose the Cabal version such that the setup scripts compiled against this
......
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Client.Exec
......@@ -12,7 +11,8 @@
module Distribution.Client.Exec ( exec
) where
import Control.Monad (unless)
import Prelude ()
import Distribution.Client.Compat.Prelude
import qualified Distribution.Simple.GHC as GHC
import qualified Distribution.Simple.GHCJS as GHCJS
......@@ -34,10 +34,6 @@ import Distribution.Verbosity (Verbosity)
import System.Directory ( doesDirectoryExist )
import System.FilePath (searchPathSeparator, (</>))
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative ((<$>))
import Data.Monoid (mempty)
#endif
-- | Execute the given command in the package's environment.
......
......@@ -35,23 +35,18 @@ module Distribution.Client.FileMonitor (
beginUpdateFileMonitor,
) where
import Prelude ()
import Distribution.Client.Compat.Prelude
#if MIN_VERSION_containers(0,5,0)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
#else
import Data.Map (Map)
import qualified Data.Map as Map
#endif
import qualified Data.ByteString.Lazy as BS
import Distribution.Compat.Binary
import qualified Distribution.Compat.Binary as Binary
import qualified Data.Hashable as Hashable
import Data.List (sort)
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
#endif
import Control.Monad
import Control.Monad.Trans (MonadIO, liftIO)
import Control.Monad.State (StateT, mapStateT)
......@@ -68,8 +63,6 @@ import Distribution.Client.Utils (mergeBy, MergeResult(..))
import System.FilePath
import System.Directory
import System.IO
import GHC.Generics (Generic)
------------------------------------------------------------------------------
-- Types for specifying files to monitor
......
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Client.Freeze
......@@ -16,6 +15,9 @@ module Distribution.Client.Freeze (
freeze, getFreezePkgs
) where
import Prelude ()
import Distribution.Client.Compat.Prelude
import Distribution.Client.Config ( SavedConfig(..) )
import Distribution.Client.Types
import Distribution.Client.Targets
......@@ -58,13 +60,7 @@ import Distribution.Text
import Distribution.Verbosity
( Verbosity )
import Control.Monad
( when )
import qualified Data.ByteString.Lazy.Char8 as BS.Char8
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid
( mempty )
#endif
import Data.Version
( showVersion )
import Distribution.Version
......
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Client.Get
......@@ -18,6 +17,9 @@ module Distribution.Client.Get (
get
) where
import Prelude ()
import Distribution.Client.Compat.Prelude hiding (get)
import Distribution.Package
( PackageId, packageId, packageName )
import Distribution.Simple.Setup
......@@ -48,16 +50,8 @@ import Distribution.Solver.Types.SourcePackage
import Control.Exception
( finally )
import Control.Monad
( filterM, forM_, unless, when )
import Data.List
( sortBy )
( forM_, mapM_ )
import qualified Data.Map
import Data.Maybe
( listToMaybe, mapMaybe )
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid
( mempty )
#endif
import Data.Ord
( comparing )
import System.Directory
......
{-# LANGUAGE CPP, DeriveGeneric #-}
{-# LANGUAGE DeriveGeneric #-}
--TODO: [code cleanup] plausibly much of this module should be merged with
-- similar functionality in Cabal.
......@@ -15,14 +15,11 @@ module Distribution.Client.Glob
, getFilePathRootDirectory
) where
import Data.Char (toUpper)
import Prelude ()
import Distribution.Client.Compat.Prelude
import Data.List (stripPrefix)
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
#endif
import Control.Monad
import Distribution.Compat.Binary
import GHC.Generics (Generic)
import Control.Monad (mapM)
import Distribution.Text
import Distribution.Compat.ReadP (ReadP, (<++), (+++))
......
{-# LANGUAGE CPP, BangPatterns #-}
{-# LANGUAGE BangPatterns #-}
-----------------------------------------------------------------------------
-- | Separate module for HTTP actions, using a proxy server if one exists.
-----------------------------------------------------------------------------
......@@ -14,6 +14,9 @@ module Distribution.Client.HttpUtils (
isOldHackageURI
) where
import Prelude ()
import Distribution.Client.Compat.Prelude
import Network.HTTP
( Request (..), Response (..), RequestMethod (..)
, Header(..), HeaderName(..), lookupHeader )
......@@ -23,21 +26,14 @@ import Network.URI
import Network.Browser
( browse, setOutHandler, setErrHandler, setProxy
, setAuthorityGen, request, setAllowBasicAuth, setUserAgent )
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
#endif
import qualified Control.Exception as Exception
import Control.Exception
( evaluate )
import Control.DeepSeq
( force )
import Control.Monad
( when, guard )
( guard )
import qualified Data.ByteString.Lazy.Char8 as BS
import Data.List
( isPrefixOf, find, intercalate )
import Data.Maybe
( listToMaybe, maybeToList, fromMaybe )
import qualified Paths_cabal_install (version)
import Distribution.Verbosity (Verbosity)
import Distribution.Simple.Utils
......@@ -52,8 +48,6 @@ import Distribution.System
( buildOS, buildArch )
import Distribution.Text
( display )
import Data.Char
( isSpace )
import qualified System.FilePath.Posix as FilePath.Posix
( splitDirectories )
import System.FilePath
......
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE BangPatterns #-}
......@@ -37,6 +36,9 @@ module Distribution.Client.IndexUtils (
BuildTreeRefType(..), refTypeFromTypeCode, typeCodeFromRefType
) where
import Prelude ()
import Distribution.Client.Compat.Prelude
import qualified Codec.Archive.Tar as Tar
import qualified Codec.Archive.Tar.Entry as Tar
import qualified Codec.Archive.Tar.Index as Tar
......@@ -77,16 +79,7 @@ import Distribution.Solver.Types.PackageIndex (PackageIndex)
import qualified Distribution.Solver.Types.PackageIndex as PackageIndex
import Distribution.Solver.Types.SourcePackage
import GHC.Generics (Generic)
import Data.Char (isAlphaNum)
import Data.Maybe (mapMaybe, catMaybes, maybeToList, fromMaybe)
import Data.List (isPrefixOf)
import Data.Word
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid (Monoid(..))
import Control.Applicative
#endif
import qualified Data.Map as Map
import Control.DeepSeq
import Control.Monad
......
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Client.Init
......@@ -23,6 +22,9 @@ module Distribution.Client.Init (
) where
import Prelude ()
import Distribution.Client.Compat.Prelude hiding (empty)
import System.IO
( hSetBuffering, stdout, BufferMode(..) )
import System.Directory
......@@ -33,23 +35,13 @@ import System.FilePath
import Data.Time
( getCurrentTime, utcToLocalTime, toGregorian, localDay, getCurrentTimeZone )
import Data.Char
( toUpper )
import Data.List
( intercalate, nub, groupBy, (\\) )
import Data.Maybe
( fromMaybe, isJust, catMaybes, listToMaybe )
( groupBy, (\\) )
import Data.Function
( on )
import qualified Data.Map as M
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
( (<$>) )
import Data.Traversable
( traverse )
#endif
import Control.Monad
( when, unless, (>=>), join, forM_ )
( (>=>), join, forM_, mapM, mapM_ )
import Control.Arrow
( (&&&), (***) )
......@@ -932,9 +924,9 @@ generateCabalFile fileName c =
(True, _, _) -> (showComment com $$) . ($$ text "")
(False, _, _) -> ($$ text "")
$
comment f <> text s <> colon
<> text (replicate (20 - length s) ' ')
<> text (fromMaybe "" . flagToMaybe $ f)
comment f <<>> text s <<>> colon
<<>> text (replicate (20 - length s) ' ')
<<>> text (fromMaybe "" . flagToMaybe $ f)
comment NoFlag = text "-- "
comment (Flag "") = text "-- "
comment _ = text ""
......
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Client.Init.Heuristics
......@@ -20,6 +19,10 @@ module Distribution.Client.Init.Heuristics (
guessAuthorNameMail,
knownCategories,
) where
import Prelude ()
import Distribution.Client.Compat.Prelude
import Distribution.Text (simpleParse)
import Distribution.Simple.Setup (Flag(..), flagToMaybe)
import Distribution.ModuleName
......@@ -27,8 +30,6 @@ import Distribution.ModuleName
import qualified Distribution.Package as P
import qualified Distribution.PackageDescription as PD
( category, packageDescription )
import Distribution.Simple.Utils
( intercalate )
import Distribution.Client.Utils
( tryCanonicalizePath )
import Language.Haskell.Extension ( Extension )
......@@ -39,16 +40,10 @@ import Distribution.Solver.Types.SourcePackage
( packageDescription )
import Distribution.Client.Types ( SourcePackageDb(..) )
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative ( pure, (<$>), (<*>) )
import Data.Monoid ( mempty, mappend, mconcat )
#endif
import Control.Arrow ( first )
import Control.Monad ( liftM )
import Data.Char ( isAlphaNum, isNumber, isUpper, isLower, isSpace )
import Control.Monad ( mapM )
import Data.Char ( isNumber, isLower )
import Data.Either ( partitionEithers )
import Data.List ( isInfixOf, isPrefixOf, isSuffixOf, sortBy )
import Data.Maybe ( mapMaybe, catMaybes, maybeToList )
import Data.List ( isInfixOf )
import Data.Ord ( comparing )
import qualified Data.Set as Set ( fromList, toList )
import System.Directory ( getCurrentDirectory, getDirectoryContents,
......
......@@ -29,14 +29,13 @@ module Distribution.Client.Install (
pruneInstallPlan
) where
import Data.Foldable
( traverse_ )
import Prelude ()
import Distribution.Client.Compat.Prelude
import Data.List
( isPrefixOf, nub, sort, (\\), find )
( (\\) )
import qualified Data.Map as Map
import qualified Data.Set as S
import Data.Maybe
( catMaybes, isJust, isNothing, fromMaybe, mapMaybe )
import Control.Exception as Exception
( Exception(toException), bracket, catches
, Handler(Handler), handleJust, IOException, SomeException )
......@@ -48,15 +47,9 @@ import System.Exit
( ExitCode(..) )
import Distribution.Compat.Exception
( catchIO, catchExit )
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
( (<$>) )
import Data.Traversable
( traverse )
#endif
import Control.Exception ( assert )
import Control.Monad
( filterM, forM_, when, unless )
( forM_, mapM )
import System.Directory
( getTemporaryDirectory, doesDirectoryExist, doesFileExist,
createDirectoryIfMissing, removeFile, renameDirectory,
......@@ -165,7 +158,7 @@ import Distribution.Version
( Version, VersionRange, foldVersionRange )
import Distribution.Simple.Utils as Utils
( notice, info, warn, debug, debugNoWrap, die
, intercalate, withTempDirectory )
, withTempDirectory )
import Distribution.Client.Utils
( determineNumJobs, logDirChange, mergeBy, MergeResult(..)
, tryCanonicalizePath )
......
......@@ -43,6 +43,9 @@ module Distribution.Client.ProjectConfig (
BadPerPackageCompilerPaths(..)
) where
import Prelude ()
import Distribution.Client.Compat.Prelude
import Distribution.Client.ProjectConfig.Types
import Distribution.Client.ProjectConfig.Legacy
import Distribution.Client.RebuildMonad
......@@ -96,21 +99,14 @@ import Distribution.Text
import Distribution.ParseUtils
( ParseResult(..), locatedErrorMsg, showPWarning )
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
#endif
import Control.Monad
import Control.Monad.Trans (liftIO)
import Control.Exception
import Data.Typeable
import Data.List (intercalate)
import Data.Maybe
import Data.Either
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Set (Set)
import qualified Data.Set as Set
import Distribution.Compat.Semigroup
import System.FilePath hiding (combine)
import System.Directory
import Network.URI (URI(..), URIAuth(..), parseAbsoluteURI)
......
{-# LANGUAGE CPP, RecordWildCards, NamedFieldPuns, DeriveGeneric #-}
{-# LANGUAGE RecordWildCards, NamedFieldPuns, DeriveGeneric #-}
-- | Project configuration, implementation in terms of legacy types.
--
......@@ -20,6 +20,9 @@ module Distribution.Client.ProjectConfig.Legacy (
renderPackageLocationToken,
) where
import Prelude ()
import Distribution.Client.Compat.Prelude
import Distribution.Client.ProjectConfig.Types
import Distribution.Client.Types
( RemoteRepo(..), emptyRemoteRepo )
......@@ -76,14 +79,7 @@ import Distribution.Simple.Command
( CommandUI(commandOptions), ShowOrParseArgs(..)
, OptionField, option, reqArg' )
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
#endif
import Control.Monad
import qualified Data.Map as Map
import Data.Char (isSpace)
import Distribution.Compat.Semigroup
import GHC.Generics (Generic)
------------------------------------------------------------------
-- Representing the project config file in terms of legacy types
......@@ -1106,11 +1102,11 @@ packageSpecificOptionsSectionDescr =
programOptionsFieldDescrs :: (a -> [(String, [String])])
-> ([(String, [String])] -> a -> a)
-> [FieldDescr a]
programOptionsFieldDescrs get set =
programOptionsFieldDescrs get' set =
commandOptionsToFields
$ programDbOptions
defaultProgramDb
ParseArgs get set
ParseArgs get' set
programOptionsSectionDescr :: SectionDescr LegacyPackageConfig
programOptionsSectionDescr =
......@@ -1169,7 +1165,7 @@ programDbOptions
-> (flags -> [(String, [String])])
-> ([(String, [String])] -> (flags -> flags))
-> [OptionField flags]
programDbOptions progDb showOrParseArgs get set =
programDbOptions progDb showOrParseArgs get' set =
case showOrParseArgs of
-- we don't want a verbose help text list so we just show a generic one:
ShowArgs -> [programOptions "PROG"]
......@@ -1179,7 +1175,7 @@ programDbOptions progDb showOrParseArgs get set =
programOptions prog =
option "" [prog ++ "-options"]
("give extra options to " ++ prog)
get set
get' set
(reqArg' "OPTS" (\args -> [(prog, splitArgs args)])
(\progArgs -> [ joinsArgs args
| (prog', args) <- progArgs, prog==prog' ]))
......@@ -1238,11 +1234,11 @@ newLineListField = listFieldWithSep Disp.sep
-- of parseOptCommaList below
listFieldWithSep :: ([Doc] -> Doc) -> String -> (a -> Doc) -> ReadP [a] a
-> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr b
listFieldWithSep separator name showF readF get set =
liftField get set' $
listFieldWithSep separator name showF readF get' set =
liftField get' set' $
ParseUtils.field name showF' (parseOptCommaList readF)
where
set' xs b = set (get b ++ xs) b
set' xs b = set (get' b ++ xs) b
showF' = separator . map showF
--TODO: [code cleanup] local redefinition that should replace the version in
......
......@@ -51,6 +51,9 @@ module Distribution.Client.ProjectPlanning (
createPackageDBIfMissing
) where
import Prelude ()
import Distribution.Client.Compat.Prelude
import Distribution.Client.ProjectPlanning.Types
import Distribution.Client.PackageHash
import Distribution.Client.RebuildMonad
......@@ -114,21 +117,14 @@ import Distribution.Text
import qualified Distribution.Compat.Graph as Graph
import Distribution.Compat.Graph(IsNode(..))
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Set (Set)
import qualified Data.Set as Set
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
#endif
import Control.Monad
import Control.Monad.State as State
import Control.Exception
import Data.Typeable
import Data.List
import Data.Maybe
import Data.List (groupBy, mapAccumL)
import Data.Either
import Data.Monoid
import Data.Function
import System.FilePath
......@@ -1502,8 +1498,8 @@ elaborateInstallPlan platform compiler compilerprogdb pkgConfigDB
-- the project config specifies values that apply to packages local to
-- but by default non-local packages get all default config values
-- the project, and can specify per-package values for any package,
| isLocalToProject pkg = local <> perpkg
| otherwise = perpkg
| isLocalToProject pkg = local `mappend` perpkg
| otherwise = perpkg
where
local = f localPackagesConfig
perpkg = maybe mempty f (Map.lookup (packageName pkg) perPackageConfig)
......
{-# LANGUAGE CPP #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-- | An abstraction for re-running actions if values or files have changed.
......@@ -47,6 +46,9 @@ module Distribution.Client.RebuildMonad (
monitorDirectoryStatus,
) where
import Prelude ()
import Distribution.Client.Compat.Prelude
import Distribution.Client.FileMonitor
import Distribution.Client.Glob hiding (matchFileGlob)
import qualified Distribution.Client.Glob as Glob (matchFileGlob)
......@@ -54,12 +56,8 @@ import qualified Distribution.Client.Glob as Glob (matchFileGlob)
import Distribution.Simple.Utils (debug)
import Distribution.Verbosity (Verbosity)
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
#endif
import Control.Monad.State as State
import Control.Monad.Reader as Reader
import Distribution.Compat.Binary (Binary)
import System.FilePath (takeFileName)
import System.Directory
......
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Client.Run
......@@ -11,6 +10,9 @@
module Distribution.Client.Run ( run, splitRunArgs )
where
import Prelude ()
import Distribution.Client.Compat.Prelude
import Distribution.Types.TargetInfo (targetCLBI)
import Distribution.Types.LocalBuildInfo (componentNameTargets')
......@@ -35,11 +37,6 @@ import Distribution.Verbosity (Verbosity)
import qualified Distribution.Simple.GHCJS as GHCJS
#if !MIN_VERSION_base(4,8,0)
import Data.Functor ((<$>))
#endif
import Data.List (find)
import Data.Foldable (traverse_)
import System.Directory (getCurrentDirectory)
import Distribution.Compat.Environment (getEnvironment)
import System.FilePath ((<.>), (</>))
......
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
-----------------------------------------------------------------------------
-- |
......@@ -42,6 +41,9 @@ module Distribution.Client.Sandbox (
getPersistOrConfigCompiler
) where
import Prelude ()
import Distribution.Client.Compat.Prelude
import Distribution.Client.Setup
( SandboxFlags(..), ConfigFlags(..), ConfigExFlags(..), InstallFlags(..)
, GlobalFlags(..), configCompilerAux', configPackageDB'
......@@ -92,7 +94,7 @@ import Distribution.Simple.Setup ( Flag(..), HaddockFlags(..)
import Distribution.Simple.SrcDist ( prepareTree )
import Distribution.Simple.Utils ( die, debug, notice, info, warn
, debugNoWrap, defaultPackageDesc
, intercalate, topHandlerWith
, topHandlerWith
, createDirectoryIfMissingVerbose )
import Distribution.Package ( Package(..) )
import Distribution.System ( Platform )
......@@ -111,19 +113,12 @@ import qualified Data.Map as M
import qualified Data.Set as S
import Data.Either (partitionEithers)
import Control.Exception ( assert, bracket_ )
import Control.Monad ( forM, liftM, liftM2, unless, when )
import Control.Monad ( forM, mapM, mapM_ )
import Data.Bits ( shiftL, shiftR, xor )
import Data.Char ( ord )
import Data.IORef ( newIORef, writeIORef, readIORef )