Commit 5ee010b3 authored by bardur.arantsson's avatar bardur.arantsson

Move ConstraintSource to Distribution.Solver.* namespace

parent d1d503a9
......@@ -48,8 +48,6 @@ import Distribution.Client.Types
( RemoteRepo(..), Username(..), Password(..), emptyRemoteRepo )
import Distribution.Client.BuildReports.Types
( ReportLevel(..) )
import Distribution.Client.Dependency.Types
( ConstraintSource(..) )
import Distribution.Client.Setup
( GlobalFlags(..), globalCommand, defaultGlobalFlags
, ConfigExFlags(..), configureExOptions, defaultConfigExFlags
......@@ -99,6 +97,8 @@ import Distribution.Compiler
import Distribution.Verbosity
( Verbosity, normal )
import Distribution.Solver.Types.ConstraintSource
import Data.List
( partition, find, foldl' )
import Data.Maybe
......
......@@ -20,8 +20,7 @@ module Distribution.Client.Configure (
import Distribution.Client.Dependency
import Distribution.Client.Dependency.Types
( ConstraintSource(..)
, LabeledPackageConstraint(..), showConstraintSource )
( LabeledPackageConstraint(..) )
import qualified Distribution.Client.InstallPlan as InstallPlan
import Distribution.Client.InstallPlan (SolverInstallPlan)
import Distribution.Client.IndexUtils as IndexUtils
......@@ -38,6 +37,7 @@ import Distribution.Package (PackageId)
import Distribution.Client.JobControl (Lock)
import qualified Distribution.Solver.Types.ComponentDeps as CD
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.OptionalStanza
import Distribution.Solver.Types.PackageIndex
( PackageIndex, elemByPackageName )
......
......@@ -77,7 +77,6 @@ import Distribution.Client.Dependency.Types
( PreSolver(..), Solver(..), DependencyResolver, ResolverPackage(..)
, PackageConstraint(..), showPackageConstraint
, LabeledPackageConstraint(..), unlabelPackageConstraint
, ConstraintSource(..), showConstraintSource
, PackagePreferences(..), InstalledPreference(..)
, PackagesPreferenceDefault(..) )
import Distribution.Client.Sandbox.Types
......@@ -116,6 +115,7 @@ import Distribution.Verbosity
import Distribution.Solver.Types.ComponentDeps (ComponentDeps)
import qualified Distribution.Solver.Types.ComponentDeps as CD
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.OptionalStanza
import qualified Distribution.Solver.Types.PackageIndex as PackageIndex
import Distribution.Solver.Types.PkgConfigDb (PkgConfigDb)
......
......@@ -27,15 +27,14 @@ module Distribution.Client.Dependency.Types (
PackagesPreferenceDefault(..),
LabeledPackageConstraint(..),
ConstraintSource(..),
unlabelPackageConstraint,
showConstraintSource
unlabelPackageConstraint
) where
import Data.Char
( isAlpha, toLower )
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.OptionalStanza
import Distribution.Solver.Types.PkgConfigDb ( PkgConfigDb )
import Distribution.Solver.Types.PackageIndex ( PackageIndex )
......@@ -206,65 +205,3 @@ data LabeledPackageConstraint
unlabelPackageConstraint :: LabeledPackageConstraint -> PackageConstraint
unlabelPackageConstraint (LabeledPackageConstraint pc _) = pc
-- | Source of a 'PackageConstraint'.
data ConstraintSource =
-- | Main config file, which is ~/.cabal/config by default.
ConstraintSourceMainConfig FilePath
-- | Local cabal.project file
| ConstraintSourceProjectConfig FilePath
-- | Sandbox config file, which is ./cabal.sandbox.config by default.
| ConstraintSourceSandboxConfig FilePath
-- | User config file, which is ./cabal.config by default.
| ConstraintSourceUserConfig FilePath
-- | Flag specified on the command line.
| ConstraintSourceCommandlineFlag
-- | Target specified by the user, e.g., @cabal install package-0.1.0.0@
-- implies @package==0.1.0.0@.
| ConstraintSourceUserTarget
-- | Internal requirement to use installed versions of packages like ghc-prim.
| ConstraintSourceNonUpgradeablePackage
-- | Internal requirement to use the add-source version of a package when that
-- version is installed and the source is modified.
| ConstraintSourceModifiedAddSourceDep
-- | Internal constraint used by @cabal freeze@.
| ConstraintSourceFreeze
-- | Constraint specified by a config file, a command line flag, or a user
-- target, when a more specific source is not known.
| ConstraintSourceConfigFlagOrTarget
-- | The source of the constraint is not specified.
| ConstraintSourceUnknown
deriving (Eq, Show, Generic)
instance Binary ConstraintSource
-- | Description of a 'ConstraintSource'.
showConstraintSource :: ConstraintSource -> String
showConstraintSource (ConstraintSourceMainConfig path) =
"main config " ++ path
showConstraintSource (ConstraintSourceProjectConfig path) =
"project config " ++ path
showConstraintSource (ConstraintSourceSandboxConfig path) =
"sandbox config " ++ path
showConstraintSource (ConstraintSourceUserConfig path)= "user config " ++ path
showConstraintSource ConstraintSourceCommandlineFlag = "command line flag"
showConstraintSource ConstraintSourceUserTarget = "user target"
showConstraintSource ConstraintSourceNonUpgradeablePackage =
"non-upgradeable package"
showConstraintSource ConstraintSourceModifiedAddSourceDep =
"modified add-source dependency"
showConstraintSource ConstraintSourceFreeze = "cabal freeze"
showConstraintSource ConstraintSourceConfigFlagOrTarget =
"config file, command line flag, or user target"
showConstraintSource ConstraintSourceUnknown = "unknown source"
......@@ -21,7 +21,7 @@ import Distribution.Client.Types
import Distribution.Client.Targets
import Distribution.Client.Dependency
import Distribution.Client.Dependency.Types
( ConstraintSource(..), LabeledPackageConstraint(..) )
( LabeledPackageConstraint(..) )
import Distribution.Client.IndexUtils as IndexUtils
( getSourcePackages, getInstalledPackages )
import Distribution.Client.InstallPlan
......@@ -36,6 +36,7 @@ import Distribution.Client.Sandbox.PackageEnvironment
import Distribution.Client.Sandbox.Types
( SandboxPackageInfo(..) )
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.OptionalStanza
import Distribution.Solver.Types.PkgConfigDb
( PkgConfigDb, readPkgConfigDb )
......
......@@ -72,7 +72,7 @@ import Distribution.Client.Configure
( chooseCabalVersion, configureSetupScript, checkConfigExFlags )
import Distribution.Client.Dependency
import Distribution.Client.Dependency.Types
( Solver(..), ConstraintSource(..), LabeledPackageConstraint(..) )
( Solver(..), LabeledPackageConstraint(..) )
import Distribution.Client.FetchUtils
import Distribution.Client.HttpUtils
( HttpTransport (..) )
......@@ -110,6 +110,7 @@ import Distribution.Client.Compat.ExecutablePath
import Distribution.Client.JobControl
import qualified Distribution.Solver.Types.ComponentDeps as CD
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.OptionalStanza
import qualified Distribution.Solver.Types.PackageIndex as SourcePackageIndex
import Distribution.Solver.Types.PackageFixedDeps
......
......@@ -23,11 +23,11 @@ module Distribution.Client.ProjectConfig.Legacy (
import Distribution.Client.ProjectConfig.Types
import Distribution.Client.Types
( RemoteRepo(..), emptyRemoteRepo )
import Distribution.Client.Dependency.Types
( ConstraintSource(..) )
import Distribution.Client.Config
( SavedConfig(..), remoteRepoFields )
import Distribution.Solver.Types.ConstraintSource
import Distribution.Package
import Distribution.PackageDescription
( SourceRepo(..), RepoKind(..) )
......
......@@ -22,14 +22,14 @@ module Distribution.Client.ProjectConfig.Types (
import Distribution.Client.Types
( RemoteRepo )
import Distribution.Client.Dependency.Types
( PreSolver, ConstraintSource )
( PreSolver )
import Distribution.Client.Targets
( UserConstraint )
import Distribution.Client.BuildReports.Types
( ReportLevel(..) )
import Distribution.Solver.Types.Settings
( ReorderGoals, StrongFlags )
import Distribution.Solver.Types.ConstraintSource
import Distribution.Package
( PackageName, PackageId, UnitId, Dependency )
......
......@@ -78,6 +78,7 @@ import Distribution.Utils.NubList
import qualified Distribution.Solver.Types.ComponentDeps as CD
import Distribution.Solver.Types.ComponentDeps (ComponentDeps)
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.OptionalStanza
import Distribution.Solver.Types.PackageFixedDeps
import qualified Distribution.Solver.Types.PackageIndex as SourcePackageIndex
......
......@@ -36,7 +36,6 @@ import Distribution.Client.Config ( SavedConfig(..), commentSavedConfig
, installDirsFields, withProgramsFields
, withProgramOptionsFields
, defaultCompiler )
import Distribution.Client.Dependency.Types ( ConstraintSource (..) )
import Distribution.Client.ParseUtils ( parseFields, ppFields, ppSection )
import Distribution.Client.Setup ( GlobalFlags(..), ConfigExFlags(..)
, InstallFlags(..)
......@@ -51,6 +50,7 @@ import Distribution.Simple.Setup ( Flag(..)
, ConfigFlags(..), HaddockFlags(..)
, fromFlagOrDefault, toFlag, flagToMaybe )
import Distribution.Simple.Utils ( die, info, notice, warn )
import Distribution.Solver.Types.ConstraintSource
import Distribution.ParseUtils ( FieldDescr(..), ParseResult(..)
, commaListField, commaNewLineListField
, liftField, lineNo, locatedErrorMsg
......
......@@ -59,7 +59,7 @@ import Distribution.Client.Types
import Distribution.Client.BuildReports.Types
( ReportLevel(..) )
import Distribution.Client.Dependency.Types
( PreSolver(..), ConstraintSource(..) )
( PreSolver(..) )
import qualified Distribution.Client.Init.Types as IT
( InitFlags(..), PackageType(..) )
import Distribution.Client.Targets
......@@ -67,6 +67,7 @@ import Distribution.Client.Targets
import Distribution.Utils.NubList
( NubList, toNubList, fromNubList)
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.Settings
import Distribution.Simple.Compiler (PackageDB)
......
......@@ -58,9 +58,10 @@ import Distribution.Client.Types
( PackageLocation(..)
, ResolvedPkgLoc, UnresolvedSourcePackage )
import Distribution.Client.Dependency.Types
( PackageConstraint(..), ConstraintSource(..)
( PackageConstraint(..)
, LabeledPackageConstraint(..) )
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.OptionalStanza
import Distribution.Solver.Types.PackageIndex (PackageIndex)
import qualified Distribution.Solver.Types.PackageIndex as PackageIndex
......
......@@ -15,9 +15,8 @@ import Distribution.Solver.Modular.Flag
import Distribution.Solver.Modular.Package
import Distribution.Solver.Modular.Tree
( FailReason(..), POption(..) )
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.Progress
import Distribution.Client.Dependency.Types
( ConstraintSource(..), showConstraintSource )
data Message =
Enter -- ^ increase indentation level
......
......@@ -29,8 +29,9 @@ import Data.Map (Map)
import Data.Traversable (sequence)
import Distribution.Client.Dependency.Types
( PackageConstraint(..), LabeledPackageConstraint(..), ConstraintSource(..)
( PackageConstraint(..), LabeledPackageConstraint(..)
, PackagePreferences(..), InstalledPreference(..) )
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.OptionalStanza
import Distribution.Solver.Modular.Dependency
......
......@@ -26,7 +26,7 @@ import Distribution.Solver.Modular.Package
import Distribution.Solver.Modular.PSQ (PSQ)
import qualified Distribution.Solver.Modular.PSQ as P
import Distribution.Solver.Modular.Version
import Distribution.Client.Dependency.Types ( ConstraintSource(..) )
import Distribution.Solver.Types.ConstraintSource
-- | Type of the search tree. Inlining the choice nodes for now.
data Tree a =
......
{-# LANGUAGE DeriveGeneric #-}
module Distribution.Solver.Types.ConstraintSource
( ConstraintSource(..)
, showConstraintSource
) where
import GHC.Generics (Generic)
import Distribution.Compat.Binary (Binary(..))
import Prelude hiding (fail)
-- | Source of a 'PackageConstraint'.
data ConstraintSource =
-- | Main config file, which is ~/.cabal/config by default.
ConstraintSourceMainConfig FilePath
-- | Local cabal.project file
| ConstraintSourceProjectConfig FilePath
-- | Sandbox config file, which is ./cabal.sandbox.config by default.
| ConstraintSourceSandboxConfig FilePath
-- | User config file, which is ./cabal.config by default.
| ConstraintSourceUserConfig FilePath
-- | Flag specified on the command line.
| ConstraintSourceCommandlineFlag
-- | Target specified by the user, e.g., @cabal install package-0.1.0.0@
-- implies @package==0.1.0.0@.
| ConstraintSourceUserTarget
-- | Internal requirement to use installed versions of packages like ghc-prim.
| ConstraintSourceNonUpgradeablePackage
-- | Internal requirement to use the add-source version of a package when that
-- version is installed and the source is modified.
| ConstraintSourceModifiedAddSourceDep
-- | Internal constraint used by @cabal freeze@.
| ConstraintSourceFreeze
-- | Constraint specified by a config file, a command line flag, or a user
-- target, when a more specific source is not known.
| ConstraintSourceConfigFlagOrTarget
-- | The source of the constraint is not specified.
| ConstraintSourceUnknown
deriving (Eq, Show, Generic)
instance Binary ConstraintSource
-- | Description of a 'ConstraintSource'.
showConstraintSource :: ConstraintSource -> String
showConstraintSource (ConstraintSourceMainConfig path) =
"main config " ++ path
showConstraintSource (ConstraintSourceProjectConfig path) =
"project config " ++ path
showConstraintSource (ConstraintSourceSandboxConfig path) =
"sandbox config " ++ path
showConstraintSource (ConstraintSourceUserConfig path)= "user config " ++ path
showConstraintSource ConstraintSourceCommandlineFlag = "command line flag"
showConstraintSource ConstraintSourceUserTarget = "user target"
showConstraintSource ConstraintSourceNonUpgradeablePackage =
"non-upgradeable package"
showConstraintSource ConstraintSourceModifiedAddSourceDep =
"modified add-source dependency"
showConstraintSource ConstraintSourceFreeze = "cabal freeze"
showConstraintSource ConstraintSourceConfigFlagOrTarget =
"config file, command line flag, or user target"
showConstraintSource ConstraintSourceUnknown = "unknown source"
......@@ -216,6 +216,7 @@ executable cabal
Distribution.Client.Compat.Process
Distribution.Client.Compat.Semaphore
Distribution.Solver.Types.ComponentDeps
Distribution.Solver.Types.ConstraintSource
Distribution.Solver.Types.Internal.Utils
Distribution.Solver.Types.OptionalStanza
Distribution.Solver.Types.PackageFixedDeps
......
......@@ -31,6 +31,7 @@ import Distribution.Client.Targets
import Distribution.Utils.NubList
import Network.URI
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.OptionalStanza
import Distribution.Solver.Types.Settings
......
......@@ -48,6 +48,7 @@ import qualified Distribution.Client.InstallPlan as CI.InstallPlan
import Distribution.Solver.Types.ComponentDeps (ComponentDeps)
import qualified Distribution.Solver.Types.ComponentDeps as CD
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.OptionalStanza
import qualified Distribution.Solver.Types.PackageIndex as CI.PackageIndex
import qualified Distribution.Solver.Types.PkgConfigDb as PC
......
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