Skip to content

Commit b494c66

Browse files
committed
refactor!: remove independent goals
remove independent goals
1 parent 407db8f commit b494c66

File tree

28 files changed

+88
-596
lines changed

28 files changed

+88
-596
lines changed

cabal-install-solver/src/Distribution/Solver/Modular/Builder.hs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import qualified Distribution.Solver.Modular.WeightedPSQ as W
3535

3636
import Distribution.Solver.Types.ComponentDeps
3737
import Distribution.Solver.Types.PackagePath
38-
import Distribution.Solver.Types.Settings
3938

4039
-- | All state needed to build and link the search tree. It has a type variable
4140
-- because the linking phase doesn't need to know about the state used to build
@@ -246,8 +245,8 @@ alreadyLinked = error "addLinking called on tree that already contains linked no
246245

247246
-- | Interface to the tree builder. Just takes an index and a list of package names,
248247
-- and computes the initial state and then the tree from there.
249-
buildTree :: Index -> IndependentGoals -> [PN] -> Tree () QGoalReason
250-
buildTree idx (IndependentGoals ind) igs =
248+
buildTree :: Index -> [PN] -> Tree () QGoalReason
249+
buildTree idx igs =
251250
build Linker {
252251
buildState = BS {
253252
index = idx
@@ -260,8 +259,7 @@ buildTree idx (IndependentGoals ind) igs =
260259
where
261260
topLevelGoal qpn = PkgGoal qpn UserGoal
262261

263-
qpns | ind = L.map makeIndependent igs
264-
| otherwise = L.map (Q (PackagePath DefaultNamespace QualToplevel)) igs
262+
qpns = L.map (Q (PackagePath QualToplevel)) igs
265263

266264
{-------------------------------------------------------------------------------
267265
Goals

cabal-install-solver/src/Distribution/Solver/Modular/ConfiguredConversion.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ convPI (PI _ (I _ (Inst pi))) = Left pi
5555
convPI pi = Right (packageId (either id id (convConfId pi)))
5656

5757
convConfId :: PI QPN -> Either SolverId {- is lib -} SolverId {- is exe -}
58-
convConfId (PI (Q (PackagePath _ q) pn) (I v loc)) =
58+
convConfId (PI (Q (PackagePath q) pn) (I v loc)) =
5959
case loc of
6060
Inst pi -> Left (PreExistingId sourceId pi)
6161
_otherwise

cabal-install-solver/src/Distribution/Solver/Modular/Dependency.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ showDependencyReason (DependencyReason qpn flags stanzas) =
166166
-- NOTE: It's the _dependencies_ of a package that may or may not be independent
167167
-- from the package itself. Package flag choices must of course be consistent.
168168
qualifyDeps :: QPN -> FlaggedDeps PN -> FlaggedDeps QPN
169-
qualifyDeps (Q pp@(PackagePath ns q) pn) = go
169+
qualifyDeps (Q pp@(PackagePath q) pn) = go
170170
where
171171
go :: FlaggedDeps PN -> FlaggedDeps QPN
172172
go = map go1
@@ -192,10 +192,10 @@ qualifyDeps (Q pp@(PackagePath ns q) pn) = go
192192
goD (Lang lang) _ = Lang lang
193193
goD (Pkg pkn vr) _ = Pkg pkn vr
194194
goD (Dep dep@(PkgComponent qpn (ExposedExe _)) ci) _ =
195-
Dep (Q (PackagePath ns (QualExe pn qpn)) <$> dep) ci
195+
Dep (Q (PackagePath (QualExe pn qpn)) <$> dep) ci
196196
goD (Dep dep@(PkgComponent _qpn (ExposedLib _)) ci) comp
197-
| comp == ComponentSetup = Dep (Q (PackagePath ns (QualSetup pn)) <$> dep) ci
198-
| otherwise = Dep (Q (PackagePath ns inheritedQ) <$> dep) ci
197+
| comp == ComponentSetup = Dep (Q (PackagePath (QualSetup pn)) <$> dep) ci
198+
| otherwise = Dep (Q (PackagePath inheritedQ) <$> dep) ci
199199

200200
-- If P has a setup dependency on Q, and Q has a regular dependency on R, then
201201
-- we say that the 'Setup' qualifier is inherited: P has an (indirect) setup

cabal-install-solver/src/Distribution/Solver/Modular/Package.hs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module Distribution.Solver.Modular.Package
1010
, PN
1111
, QPV
1212
, instI
13-
, makeIndependent
1413
, showI
1514
, showPI
1615
, unPN
@@ -74,8 +73,3 @@ showPI (PI qpn i) = showQPN qpn ++ "-" ++ showI i
7473
instI :: I -> Bool
7574
instI (I _ (Inst _)) = True
7675
instI _ = False
77-
78-
-- | Qualify a target package with its own name so that its dependencies are not
79-
-- required to be consistent with other targets.
80-
makeIndependent :: PN -> QPN
81-
makeIndependent pn = Q (PackagePath (Independent pn) QualToplevel) pn

cabal-install-solver/src/Distribution/Solver/Modular/Preference.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ deferSetupExeChoices = go
420420
go x = x
421421

422422
noSetupOrExe :: Goal QPN -> Bool
423-
noSetupOrExe (Goal (P (Q (PackagePath _ns (QualSetup _)) _)) _) = False
424-
noSetupOrExe (Goal (P (Q (PackagePath _ns (QualExe _ _)) _)) _) = False
423+
noSetupOrExe (Goal (P (Q (PackagePath (QualSetup _)) _)) _) = False
424+
noSetupOrExe (Goal (P (Q (PackagePath (QualExe _ _)) _)) _) = False
425425
noSetupOrExe _ = True
426426

427427
-- | Transformation that tries to avoid making weak flag choices early.

cabal-install-solver/src/Distribution/Solver/Modular/Solver.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ data SolverConfig = SolverConfig {
6262
countConflicts :: CountConflicts,
6363
fineGrainedConflicts :: FineGrainedConflicts,
6464
minimizeConflictSet :: MinimizeConflictSet,
65-
independentGoals :: IndependentGoals,
6665
avoidReinstalls :: AvoidReinstalls,
6766
shadowPkgs :: ShadowPkgs,
6867
strongFlags :: StrongFlags,
@@ -144,7 +143,8 @@ solve sc cinfo idx pkgConfigDB userPrefs userConstraints userGoals =
144143
P.onlyConstrained pkgIsExplicit
145144
OnlyConstrainedNone ->
146145
id)
147-
buildPhase = buildTree idx (independentGoals sc) (S.toList userGoals)
146+
147+
buildPhase = buildTree idx (S.toList userGoals)
148148

149149
allExplicit = M.keysSet userConstraints `S.union` userGoals
150150

@@ -250,5 +250,5 @@ _removeGR = trav go
250250
dummy =
251251
DependencyGoal $
252252
DependencyReason
253-
(Q (PackagePath DefaultNamespace QualToplevel) (mkPackageName "$"))
253+
(Q (PackagePath QualToplevel) (mkPackageName "$"))
254254
M.empty S.empty

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,13 @@ scopeToPackageName (ScopeAnySetupQualifier pn) = pn
6868
scopeToPackageName (ScopeAnyQualifier pn) = pn
6969

7070
constraintScopeMatches :: ConstraintScope -> QPN -> Bool
71-
constraintScopeMatches (ScopeTarget pn) (Q (PackagePath ns q) pn') =
72-
let namespaceMatches DefaultNamespace = True
73-
namespaceMatches (Independent namespacePn) = pn == namespacePn
74-
in namespaceMatches ns && q == QualToplevel && pn == pn'
75-
constraintScopeMatches (ScopeQualified q pn) (Q (PackagePath _ q') pn') =
71+
constraintScopeMatches (ScopeTarget pn) (Q (PackagePath q) pn') =
72+
q == QualToplevel && pn == pn'
73+
constraintScopeMatches (ScopeQualified q pn) (Q (PackagePath q') pn') =
7674
q == q' && pn == pn'
7775
constraintScopeMatches (ScopeAnySetupQualifier pn) (Q pp pn') =
78-
let setup (PackagePath _ (QualSetup _)) = True
79-
setup _ = False
76+
let setup (PackagePath (QualSetup _)) = True
77+
setup _ = False
8078
in setup pp && pn == pn'
8179
constraintScopeMatches (ScopeAnyQualifier pn) (Q _ pn') = pn == pn'
8280

cabal-install-solver/src/Distribution/Solver/Types/PackagePath.hs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module Distribution.Solver.Types.PackagePath
22
( PackagePath(..)
3-
, Namespace(..)
43
, Qualifier(..)
54
, dispQualifier
65
, Qualified(..)
@@ -15,29 +14,9 @@ import Distribution.Package (PackageName)
1514
import Distribution.Pretty (pretty, flatStyle)
1615
import qualified Text.PrettyPrint as Disp
1716

18-
-- | A package path consists of a namespace and a package path inside that
19-
-- namespace.
20-
data PackagePath = PackagePath Namespace Qualifier
17+
data PackagePath = PackagePath Qualifier
2118
deriving (Eq, Ord, Show)
2219

23-
-- | Top-level namespace
24-
--
25-
-- Package choices in different namespaces are considered completely independent
26-
-- by the solver.
27-
data Namespace =
28-
-- | The default namespace
29-
DefaultNamespace
30-
31-
-- | A namespace for a specific build target
32-
| Independent PackageName
33-
deriving (Eq, Ord, Show)
34-
35-
-- | Pretty-prints a namespace. The result is either empty or
36-
-- ends in a period, so it can be prepended onto a qualifier.
37-
dispNamespace :: Namespace -> Disp.Doc
38-
dispNamespace DefaultNamespace = Disp.empty
39-
dispNamespace (Independent i) = pretty i <<>> Disp.text "."
40-
4120
-- | Qualifier of a package within a namespace (see 'PackagePath')
4221
data Qualifier =
4322
-- | Top-level dependency in this namespace
@@ -82,8 +61,8 @@ type QPN = Qualified PackageName
8261

8362
-- | Pretty-prints a qualified package name.
8463
dispQPN :: QPN -> Disp.Doc
85-
dispQPN (Q (PackagePath ns qual) pn) =
86-
dispNamespace ns <<>> dispQualifier qual <<>> pretty pn
64+
dispQPN (Q (PackagePath qual) pn) =
65+
dispQualifier qual <<>> pretty pn
8766

8867
-- | String representation of a qualified package name.
8968
showQPN :: QPN -> String

cabal-install-solver/src/Distribution/Solver/Types/Settings.hs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
33
module Distribution.Solver.Types.Settings
44
( ReorderGoals(..)
5-
, IndependentGoals(..)
65
, PreferOldest(..)
76
, MinimizeConflictSet(..)
87
, AvoidReinstalls(..)
@@ -38,9 +37,6 @@ newtype FineGrainedConflicts = FineGrainedConflicts Bool
3837
newtype MinimizeConflictSet = MinimizeConflictSet Bool
3938
deriving (BooleanFlag, Eq, Generic, Show)
4039

41-
newtype IndependentGoals = IndependentGoals Bool
42-
deriving (BooleanFlag, Eq, Generic, Show)
43-
4440
newtype PreferOldest = PreferOldest Bool
4541
deriving (BooleanFlag, Eq, Generic, Show)
4642

@@ -72,7 +68,6 @@ newtype SolveExecutables = SolveExecutables Bool
7268
instance Binary ReorderGoals
7369
instance Binary CountConflicts
7470
instance Binary FineGrainedConflicts
75-
instance Binary IndependentGoals
7671
instance Binary PreferOldest
7772
instance Binary MinimizeConflictSet
7873
instance Binary AvoidReinstalls
@@ -85,7 +80,6 @@ instance Binary SolveExecutables
8580
instance Structured ReorderGoals
8681
instance Structured CountConflicts
8782
instance Structured FineGrainedConflicts
88-
instance Structured IndependentGoals
8983
instance Structured PreferOldest
9084
instance Structured MinimizeConflictSet
9185
instance Structured AvoidReinstalls

cabal-install/src/Distribution/Client/Config.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ instance Semigroup SavedConfig where
423423
, installCountConflicts = combine installCountConflicts
424424
, installFineGrainedConflicts = combine installFineGrainedConflicts
425425
, installMinimizeConflictSet = combine installMinimizeConflictSet
426-
, installIndependentGoals = combine installIndependentGoals
427426
, installPreferOldest = combine installPreferOldest
428427
, installShadowPkgs = combine installShadowPkgs
429428
, installStrongFlags = combine installStrongFlags

0 commit comments

Comments
 (0)