Skip to content

Commit 3003d06

Browse files
sebrightezyang
authored andcommitted
Remove 'Namespace' from qualified constraints.
This commit changes the meaning of constraints like 'pkg > 5'. Previously, 'pkg > 5' only applied to the top-level 'pkg' goal without a 'Namespace', but now it applies to any top-level goal for 'pkg'. However, the 'Namespace' field is currently only used by --independent-goals, so this change has no effect on behavior.
1 parent 5cb0408 commit 3003d06

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

cabal-install/Distribution/Client/Targets.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -731,9 +731,7 @@ userConstraintPackageName (UserConstraint _ name _) = name
731731

732732
userToPackageConstraint :: UserConstraint -> PackageConstraint
733733
userToPackageConstraint (UserConstraint qual name prop) =
734-
PackageConstraint (ScopeQualified $ Q path name) prop
735-
where
736-
path = PackagePath DefaultNamespace (fromUserQualifier qual)
734+
PackageConstraint (ScopeQualified (fromUserQualifier qual) name) prop
737735

738736
readUserConstraint :: String -> Either String UserConstraint
739737
readUserConstraint str =

cabal-install/Distribution/Solver/Types/PackageConstraint.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ import qualified Text.PrettyPrint as Disp
3636
-- | Determines to what packages and in what contexts a
3737
-- constraint applies.
3838
data ConstraintScope
39-
-- | The package with the specified qualified name.
40-
= ScopeQualified QPN
39+
-- | The package with the specified name and qualifier.
40+
= ScopeQualified Qualifier PackageName
4141
-- | The package with the specified name regardless of
4242
-- qualifier.
4343
| ScopeAnyQualifier PackageName
@@ -47,16 +47,16 @@ data ConstraintScope
4747
-- the package with the specified name when that package is a
4848
-- top-level dependency in the default namespace.
4949
scopeToplevel :: PackageName -> ConstraintScope
50-
scopeToplevel = ScopeQualified . Q (PackagePath DefaultNamespace QualToplevel)
50+
scopeToplevel = ScopeQualified QualToplevel
5151

5252
-- | Returns the package name associated with a constraint scope.
5353
scopeToPackageName :: ConstraintScope -> PackageName
54-
scopeToPackageName (ScopeQualified (Q _ pn)) = pn
54+
scopeToPackageName (ScopeQualified _ pn) = pn
5555
scopeToPackageName (ScopeAnyQualifier pn) = pn
5656

5757
-- | Pretty-prints a constraint scope.
5858
dispConstraintScope :: ConstraintScope -> Disp.Doc
59-
dispConstraintScope (ScopeQualified qpn) = dispQPN qpn
59+
dispConstraintScope (ScopeQualified q pn) = dispQualifier q <<>> disp pn
6060
dispConstraintScope (ScopeAnyQualifier pn) = Disp.text "any." <<>> disp pn
6161

6262
-- | A package property is a logical predicate on packages.

0 commit comments

Comments
 (0)