Skip to content

Commit 86d8c33

Browse files
committed
Move goal qualification types into D.Solver.Types.PackagePath
1 parent 35dda16 commit 86d8c33

19 files changed

+126
-108
lines changed

cabal-install/Distribution/Solver/Modular/Assignment.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Distribution.PackageDescription (FlagAssignment) -- from Cabal
2222
import Distribution.Solver.Types.ComponentDeps (ComponentDeps, Component)
2323
import qualified Distribution.Solver.Types.ComponentDeps as CD
2424
import Distribution.Solver.Types.OptionalStanza
25+
import Distribution.Solver.Types.PackagePath
2526

2627
import Distribution.Solver.Modular.Configured
2728
import Distribution.Solver.Modular.Dependency

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import qualified Distribution.Solver.Modular.PSQ as P
2929
import Distribution.Solver.Modular.Tree
3030

3131
import Distribution.Solver.Types.ComponentDeps (Component)
32+
import Distribution.Solver.Types.PackagePath
3233
import Distribution.Solver.Types.Settings
3334

3435
-- | The state needed during the build phase of the search tree.
@@ -187,4 +188,4 @@ buildTree idx (IndependentGoals ind) igs =
187188
topLevelGoal qpn = OpenGoal (Simple (Dep qpn (Constrained [])) ()) UserGoal
188189

189190
qpns | ind = makeIndependent igs
190-
| otherwise = L.map (Q (PP DefaultNamespace Unqualified)) igs
191+
| otherwise = L.map (Q (PackagePath DefaultNamespace Unqualified)) igs

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Distribution.Solver.Modular.Package
1414

1515
import Distribution.Solver.Types.ComponentDeps (ComponentDeps)
1616
import qualified Distribution.Solver.Types.PackageIndex as CI
17+
import Distribution.Solver.Types.PackagePath
1718
import Distribution.Solver.Types.ResolverPackage
1819
import Distribution.Solver.Types.SolverId
1920
import Distribution.Solver.Types.SolverPackage

cabal-install/Distribution/Solver/Modular/ConflictSet.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ import Data.Tree
3737
import GHC.Stack
3838
#endif
3939

40-
import Distribution.Solver.Modular.Package
4140
import Distribution.Solver.Modular.Var
41+
import Distribution.Solver.Types.PackagePath
4242

4343
-- | The set of variables involved in a solver conflict
4444
--

cabal-install/Distribution/Solver/Modular/Cycles.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import qualified Data.Graph as Gr
99
import qualified Data.Map as Map
1010

1111
import Distribution.Solver.Modular.Dependency
12-
import Distribution.Solver.Modular.Package
1312
import Distribution.Solver.Modular.Tree
1413
import qualified Distribution.Solver.Modular.ConflictSet as CS
14+
import Distribution.Solver.Types.PackagePath
1515

1616
-- | Find and reject any solutions that are cyclic
1717
detectCyclesPhase :: Tree QGoalReason -> Tree QGoalReason

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import Distribution.Solver.Modular.Version
6060
import qualified Distribution.Solver.Modular.ConflictSet as CS
6161

6262
import Distribution.Solver.Types.ComponentDeps (Component(..))
63+
import Distribution.Solver.Types.PackagePath
6364

6465
#ifdef DEBUG_CONFLICT_SETS
6566
import GHC.Stack (CallStack)
@@ -213,7 +214,7 @@ data QualifyOptions = QO {
213214
-- NOTE: It's the _dependencies_ of a package that may or may not be independent
214215
-- from the package itself. Package flag choices must of course be consistent.
215216
qualifyDeps :: QualifyOptions -> QPN -> FlaggedDeps Component PN -> FlaggedDeps Component QPN
216-
qualifyDeps QO{..} (Q pp@(PP ns q) pn) = go
217+
qualifyDeps QO{..} (Q pp@(PackagePath ns q) pn) = go
217218
where
218219
go :: FlaggedDeps Component PN -> FlaggedDeps Component QPN
219220
go = map go1
@@ -236,9 +237,9 @@ qualifyDeps QO{..} (Q pp@(PP ns q) pn) = go
236237
goD (Lang lang) _ = Lang lang
237238
goD (Pkg pkn vr) _ = Pkg pkn vr
238239
goD (Dep dep ci) comp
239-
| qBase dep = Dep (Q (PP ns (Base pn)) dep) (fmap (Q pp) ci)
240-
| qSetup comp = Dep (Q (PP ns (Setup pn)) dep) (fmap (Q pp) ci)
241-
| otherwise = Dep (Q (PP ns inheritedQ) dep) (fmap (Q pp) ci)
240+
| qBase dep = Dep (Q (PackagePath ns (Base pn)) dep) (fmap (Q pp) ci)
241+
| qSetup comp = Dep (Q (PackagePath ns (Setup pn)) dep) (fmap (Q pp) ci)
242+
| otherwise = Dep (Q (PackagePath ns inheritedQ) dep) (fmap (Q pp) ci)
242243

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

cabal-install/Distribution/Solver/Modular/Explore.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import Distribution.Solver.Modular.Assignment
1010
import Distribution.Solver.Modular.Dependency
1111
import Distribution.Solver.Modular.Log
1212
import Distribution.Solver.Modular.Message
13-
import Distribution.Solver.Modular.Package
1413
import qualified Distribution.Solver.Modular.PSQ as P
1514
import qualified Distribution.Solver.Modular.ConflictSet as CS
1615
import Distribution.Solver.Modular.Tree
16+
import Distribution.Solver.Types.PackagePath
1717
import Distribution.Solver.Types.Settings (EnableBackjumping(..))
1818
import qualified Distribution.Solver.Types.Progress as P
1919

cabal-install/Distribution/Solver/Modular/Flag.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Distribution.PackageDescription hiding (Flag) -- from Cabal
2222

2323
import Distribution.Solver.Modular.Package
2424
import Distribution.Solver.Types.OptionalStanza
25+
import Distribution.Solver.Types.PackagePath
2526

2627
-- | Flag name. Consists of a package instance and the flag identifier itself.
2728
data FN qpn = FN (PI qpn) Flag

cabal-install/Distribution/Solver/Modular/Linking.hs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ import qualified Distribution.Solver.Modular.PSQ as P
3232
import qualified Distribution.Solver.Modular.ConflictSet as CS
3333

3434
import Distribution.Solver.Types.OptionalStanza
35+
import Distribution.Solver.Types.PackagePath
3536
import Distribution.Solver.Types.ComponentDeps (Component)
3637

3738
{-------------------------------------------------------------------------------
3839
Add linking
3940
-------------------------------------------------------------------------------}
4041

41-
type RelatedGoals = Map (PN, I) [PP]
42+
type RelatedGoals = Map (PN, I) [PackagePath]
4243
type Linker = Reader RelatedGoals
4344

4445
-- | Introduce link nodes into tree tree
@@ -80,7 +81,7 @@ linkChoices :: RelatedGoals -> QPN -> (POption, Tree QGoalReason) -> [(POption,
8081
linkChoices related (Q _pp pn) (POption i Nothing, subtree) =
8182
map aux (M.findWithDefault [] (pn, i) related)
8283
where
83-
aux :: PP -> (POption, Tree QGoalReason)
84+
aux :: PackagePath -> (POption, Tree QGoalReason)
8485
aux pp = (POption i (Just pp), subtree)
8586
linkChoices _ _ (POption _ (Just _), _) =
8687
alreadyLinked
@@ -224,7 +225,7 @@ pickConcrete qpn@(Q pp _) i = do
224225
Just lg ->
225226
makeCanonical lg qpn i
226227

227-
pickLink :: QPN -> I -> PP -> FlaggedDeps Component QPN -> UpdateState ()
228+
pickLink :: QPN -> I -> PackagePath -> FlaggedDeps Component QPN -> UpdateState ()
228229
pickLink qpn@(Q _pp pn) i pp' deps = do
229230
vs <- get
230231

@@ -246,7 +247,7 @@ pickLink qpn@(Q _pp pn) i pp' deps = do
246247
-- Verify here that the member we add is in fact for the same package and
247248
-- matches the version of the canonical instance. However, violations of
248249
-- these checks would indicate a bug in the linker, not a true conflict.
249-
let sanityCheck :: Maybe (PI PP) -> Bool
250+
let sanityCheck :: Maybe (PI PackagePath) -> Bool
250251
sanityCheck Nothing = False
251252
sanityCheck (Just (PI _ canonI)) = pn == lgPackage lgTarget && i == canonI
252253
assert (sanityCheck (lgCanon lgTarget)) $ return ()
@@ -476,10 +477,10 @@ data LinkGroup = LinkGroup {
476477
--
477478
-- We may not know this yet (if we are constructing link groups
478479
-- for dependencies)
479-
, lgCanon :: Maybe (PI PP)
480+
, lgCanon :: Maybe (PI PackagePath)
480481

481482
-- | The members of the link group
482-
, lgMembers :: Set PP
483+
, lgMembers :: Set PackagePath
483484

484485
-- | The set of variables that should be added to the conflict set if
485486
-- something goes wrong with this link set (in addition to the members
@@ -509,19 +510,19 @@ showLinkGroup :: LinkGroup -> String
509510
showLinkGroup lg =
510511
"{" ++ intercalate "," (map showMember (S.toList (lgMembers lg))) ++ "}"
511512
where
512-
showMember :: PP -> String
513+
showMember :: PackagePath -> String
513514
showMember pp = case lgCanon lg of
514515
Just (PI pp' _i) | pp == pp' -> "*"
515516
_otherwise -> ""
516517
++ case lgInstance lg of
517518
Nothing -> showQPN (qpn pp)
518519
Just i -> showPI (PI (qpn pp) i)
519520

520-
qpn :: PP -> QPN
521+
qpn :: PackagePath -> QPN
521522
qpn pp = Q pp (lgPackage lg)
522523

523524
-- | Creates a link group that contains a single member.
524-
lgSingleton :: QPN -> Maybe (PI PP) -> LinkGroup
525+
lgSingleton :: QPN -> Maybe (PI PackagePath) -> LinkGroup
525526
lgSingleton (Q pp pn) canon = LinkGroup {
526527
lgPackage = pn
527528
, lgCanon = canon

cabal-install/Distribution/Solver/Modular/Log.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import Control.Applicative
1111
import Data.List as L
1212
import Data.Maybe (isNothing)
1313

14+
import Distribution.Solver.Types.PackagePath
1415
import Distribution.Solver.Types.Progress
1516

1617
import Distribution.Solver.Modular.Dependency
1718
import Distribution.Solver.Modular.Message
18-
import Distribution.Solver.Modular.Package
1919
import Distribution.Solver.Modular.Tree (FailReason(..))
2020
import qualified Distribution.Solver.Modular.ConflictSet as CS
2121

0 commit comments

Comments
 (0)