Commit baef5a5b authored by bardur.arantsson's avatar bardur.arantsson

Move PackageConstraint to Distribution.Solver.* namespace

parent ae8e8ae8
......@@ -75,7 +75,6 @@ import Distribution.Client.Types
, enableStanzas )
import Distribution.Client.Dependency.Types
( PreSolver(..), Solver(..), DependencyResolver
, PackageConstraint(..), showPackageConstraint
, LabeledPackageConstraint(..), unlabelPackageConstraint
, PackagePreferences(..), InstalledPreference(..)
, PackagesPreferenceDefault(..) )
......@@ -117,6 +116,7 @@ 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 Distribution.Solver.Types.PackageConstraint
import qualified Distribution.Solver.Types.PackageIndex as PackageIndex
import Distribution.Solver.Types.PkgConfigDb (PkgConfigDb)
import Distribution.Solver.Types.Progress
......
......@@ -24,9 +24,10 @@ import Distribution.Client.Types
, UnresolvedSourcePackage, enableStanzas )
import Distribution.Client.Dependency.Types
( DependencyResolver
, PackageConstraint(..), unlabelPackageConstraint
, unlabelPackageConstraint
, PackagePreferences(..), InstalledPreference(..) )
import qualified Distribution.Simple.PackageIndex as InstalledPackageIndex
import Distribution.Simple.PackageIndex (InstalledPackageIndex)
import qualified Distribution.InstalledPackageInfo as InstalledPackageInfo
......@@ -53,10 +54,11 @@ import Distribution.Simple.Utils
import Distribution.Text
( display )
import Distribution.Solver.Types.ComponentDeps ( ComponentDeps )
import Distribution.Solver.Types.ComponentDeps (ComponentDeps)
import qualified Distribution.Solver.Types.ComponentDeps as CD
import Distribution.Solver.Types.PackageConstraint
import qualified Distribution.Solver.Types.PackageIndex as PackageIndex
import Distribution.Solver.Types.PackageIndex ( PackageIndex )
import Distribution.Solver.Types.PackageIndex (PackageIndex)
import Distribution.Solver.Types.Progress
import Distribution.Solver.Types.ResolverPackage
import Distribution.Solver.Types.SolverId
......
......@@ -17,8 +17,6 @@ module Distribution.Client.Dependency.Types (
DependencyResolver,
PackageConstraint(..),
showPackageConstraint,
PackagePreferences(..),
InstalledPreference(..),
PackagesPreferenceDefault(..),
......@@ -34,6 +32,7 @@ import Data.Char
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.OptionalStanza
import Distribution.Solver.Types.PkgConfigDb ( PkgConfigDb )
import Distribution.Solver.Types.PackageConstraint ( PackageConstraint )
import Distribution.Solver.Types.PackageIndex ( PackageIndex )
import Distribution.Solver.Types.Progress
import Distribution.Solver.Types.ResolverPackage
......@@ -41,19 +40,17 @@ import Distribution.Solver.Types.SourcePackage
import qualified Distribution.Compat.ReadP as Parse
( pfail, munch1 )
import Distribution.PackageDescription
( FlagAssignment, FlagName(..) )
import Distribution.Simple.PackageIndex ( InstalledPackageIndex )
import Distribution.Package
( PackageName )
import Distribution.Version
( VersionRange, simplifyVersionRange )
( VersionRange )
import Distribution.Compiler
( CompilerInfo )
import Distribution.System
( Platform )
import Distribution.Text
( Text(..), display )
( Text(..) )
import Text.PrettyPrint
( text )
......@@ -104,42 +101,6 @@ type DependencyResolver loc = Platform
-> [PackageName]
-> Progress String String [ResolverPackage loc]
-- | Per-package constraints. Package constraints must be respected by the
-- solver. Multiple constraints for each package can be given, though obviously
-- it is possible to construct conflicting constraints (eg impossible version
-- range or inconsistent flag assignment).
--
data PackageConstraint
= PackageConstraintVersion PackageName VersionRange
| PackageConstraintInstalled PackageName
| PackageConstraintSource PackageName
| PackageConstraintFlags PackageName FlagAssignment
| PackageConstraintStanzas PackageName [OptionalStanza]
deriving (Eq,Show,Generic)
instance Binary PackageConstraint
-- | Provide a textual representation of a package constraint
-- for debugging purposes.
--
showPackageConstraint :: PackageConstraint -> String
showPackageConstraint (PackageConstraintVersion pn vr) =
display pn ++ " " ++ display (simplifyVersionRange vr)
showPackageConstraint (PackageConstraintInstalled pn) =
display pn ++ " installed"
showPackageConstraint (PackageConstraintSource pn) =
display pn ++ " source"
showPackageConstraint (PackageConstraintFlags pn fs) =
"flags " ++ display pn ++ " " ++ unwords (map (uncurry showFlag) fs)
where
showFlag (FlagName f) True = "+" ++ f
showFlag (FlagName f) False = "-" ++ f
showPackageConstraint (PackageConstraintStanzas pn ss) =
"stanzas " ++ display pn ++ " " ++ unwords (map showStanza ss)
where
showStanza TestStanzas = "test"
showStanza BenchStanzas = "bench"
-- | Per-package preferences on the version. It is a soft constraint that the
-- 'DependencyResolver' should try to respect where possible. It consists of
-- an 'InstalledPreference' which says if we prefer versions of packages
......
......@@ -41,14 +41,13 @@ import Distribution.Verbosity (Verbosity)
import Distribution.Text
( Text(disp), display )
import Distribution.Solver.Types.PackageConstraint
import qualified Distribution.Solver.Types.PackageIndex as PackageIndex
import Distribution.Solver.Types.SourcePackage
import Distribution.Client.Types
( SourcePackageDb(..)
, UnresolvedSourcePackage )
import Distribution.Client.Dependency.Types
( PackageConstraint(..) )
import Distribution.Client.Targets
( UserTarget, resolveUserTargets, PackageSpecifier(..) )
import Distribution.Client.Setup
......
......@@ -58,11 +58,11 @@ import Distribution.Client.Types
( PackageLocation(..)
, ResolvedPkgLoc, UnresolvedSourcePackage )
import Distribution.Client.Dependency.Types
( PackageConstraint(..)
, LabeledPackageConstraint(..) )
( LabeledPackageConstraint(..) )
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.OptionalStanza
import Distribution.Solver.Types.PackageConstraint
import Distribution.Solver.Types.PackageIndex (PackageIndex)
import qualified Distribution.Solver.Types.PackageIndex as PackageIndex
import Distribution.Solver.Types.SourcePackage
......
......@@ -23,9 +23,10 @@ import Distribution.Solver.Modular.Package
( PN )
import Distribution.Solver.Modular.Solver
( SolverConfig(..), solve )
import Distribution.Solver.Types.PackageConstraint
import Distribution.Client.Dependency.Types
( DependencyResolver
, PackageConstraint(..), unlabelPackageConstraint )
, unlabelPackageConstraint )
import Distribution.System
( Platform(..) )
......
......@@ -29,10 +29,11 @@ import Data.Map (Map)
import Data.Traversable (sequence)
import Distribution.Client.Dependency.Types
( PackageConstraint(..), LabeledPackageConstraint(..)
( LabeledPackageConstraint(..)
, PackagePreferences(..), InstalledPreference(..) )
import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.OptionalStanza
import Distribution.Solver.Types.PackageConstraint
import Distribution.Solver.Modular.Dependency
import Distribution.Solver.Modular.Flag
......
{-# LANGUAGE DeriveGeneric #-}
module Distribution.Solver.Types.PackageConstraint (
PackageConstraint(..),
showPackageConstraint,
) where
import Distribution.Compat.Binary (Binary(..))
import Distribution.PackageDescription (FlagAssignment, FlagName(..))
import Distribution.Package (PackageName)
import Distribution.Solver.Types.OptionalStanza
import Distribution.Text (display)
import Distribution.Version (VersionRange, simplifyVersionRange)
import GHC.Generics (Generic)
-- | Per-package constraints. Package constraints must be respected by the
-- solver. Multiple constraints for each package can be given, though obviously
-- it is possible to construct conflicting constraints (eg impossible version
-- range or inconsistent flag assignment).
--
data PackageConstraint
= PackageConstraintVersion PackageName VersionRange
| PackageConstraintInstalled PackageName
| PackageConstraintSource PackageName
| PackageConstraintFlags PackageName FlagAssignment
| PackageConstraintStanzas PackageName [OptionalStanza]
deriving (Eq, Show, Generic)
instance Binary PackageConstraint
-- | Provide a textual representation of a package constraint
-- for debugging purposes.
--
showPackageConstraint :: PackageConstraint -> String
showPackageConstraint (PackageConstraintVersion pn vr) =
display pn ++ " " ++ display (simplifyVersionRange vr)
showPackageConstraint (PackageConstraintInstalled pn) =
display pn ++ " installed"
showPackageConstraint (PackageConstraintSource pn) =
display pn ++ " source"
showPackageConstraint (PackageConstraintFlags pn fs) =
"flags " ++ display pn ++ " " ++ unwords (map (uncurry showFlag) fs)
where
showFlag (FlagName f) True = "+" ++ f
showFlag (FlagName f) False = "-" ++ f
showPackageConstraint (PackageConstraintStanzas pn ss) =
"stanzas " ++ display pn ++ " " ++ unwords (map showStanza ss)
where
showStanza TestStanzas = "test"
showStanza BenchStanzas = "bench"
......@@ -224,6 +224,7 @@ executable cabal
Distribution.Solver.Types.ConstraintSource
Distribution.Solver.Types.Internal.Utils
Distribution.Solver.Types.OptionalStanza
Distribution.Solver.Types.PackageConstraint
Distribution.Solver.Types.PackageFixedDeps
Distribution.Solver.Types.PackageIndex
Distribution.Solver.Types.PkgConfigDb
......
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