Commit febf9530 authored by Edsko de Vries's avatar Edsko de Vries
Browse files

Replace OpenGoal with Goal in GoalChoice

OpenGoal contains a FlaggedDep which contains a lot more information than we
actually need in the tree; we just need to know, which choice are we
introducing: package, flag, or stanza? We don't need the full FlaggedDep tree.
parent 3df087b4
...@@ -111,8 +111,9 @@ build = ana go ...@@ -111,8 +111,9 @@ build = ana go
-- it from the queue of open goals. -- it from the queue of open goals.
go bs@(BS { rdeps = rds, open = gs, next = Goals }) go bs@(BS { rdeps = rds, open = gs, next = Goals })
| P.null gs = DoneF rds | P.null gs = DoneF rds
| otherwise = GoalChoiceF (P.mapWithKey (\ g (_sc, gs') -> bs { next = OneGoal g, open = gs' }) | otherwise = GoalChoiceF $ P.mapKeys close
(P.splits gs)) $ P.mapWithKey (\ g (_sc, gs') -> bs { next = OneGoal g, open = gs' })
$ P.splits gs
-- If we have already picked a goal, then the choice depends on the kind -- If we have already picked a goal, then the choice depends on the kind
-- of goal. -- of goal.
......
...@@ -90,7 +90,7 @@ exploreLog enableBj = cata go ...@@ -90,7 +90,7 @@ exploreLog enableBj = cata go
go (GoalChoiceF ts) a = go (GoalChoiceF ts) a =
P.casePSQ ts P.casePSQ ts
(failWith (Failure CS.empty EmptyGoalChoice) CS.empty) -- empty goal choice is an internal error (failWith (Failure CS.empty EmptyGoalChoice) CS.empty) -- empty goal choice is an internal error
(\ k v _xs -> continueWith (Next (close k)) (v a)) -- commit to the first goal choice (\ k v _xs -> continueWith (Next k) (v a)) -- commit to the first goal choice
-- | Build a conflict set corresponding to the (virtual) option not to -- | Build a conflict set corresponding to the (virtual) option not to
-- choose a solution for a goal at all. -- choose a solution for a goal at all.
......
...@@ -295,9 +295,9 @@ preferBaseGoalChoice = trav go ...@@ -295,9 +295,9 @@ preferBaseGoalChoice = trav go
go (GoalChoiceF xs) = GoalChoiceF (P.preferByKeys isBase xs) go (GoalChoiceF xs) = GoalChoiceF (P.preferByKeys isBase xs)
go x = x go x = x
isBase :: OpenGoal comp -> Bool isBase :: Goal QPN -> Bool
isBase (OpenGoal (Simple (Dep (Q _pp pn) _) _) _) | unPN pn == "base" = True isBase (Goal (P (Q _pp pn)) _) = unPN pn == "base"
isBase _ = False isBase _ = False
-- | Deal with setup dependencies after regular dependencies, so that we can -- | Deal with setup dependencies after regular dependencies, so that we can
-- will link setup depencencies against package dependencies when possible -- will link setup depencencies against package dependencies when possible
...@@ -307,9 +307,9 @@ deferSetupChoices = trav go ...@@ -307,9 +307,9 @@ deferSetupChoices = trav go
go (GoalChoiceF xs) = GoalChoiceF (P.preferByKeys noSetup xs) go (GoalChoiceF xs) = GoalChoiceF (P.preferByKeys noSetup xs)
go x = x go x = x
noSetup :: OpenGoal comp -> Bool noSetup :: Goal QPN -> Bool
noSetup (OpenGoal (Simple (Dep (Q (PP _ns (Setup _)) _) _) _) _) = False noSetup (Goal (P (Q (PP _ns (Setup _)) _)) _) = False
noSetup _ = True noSetup _ = True
-- | Transformation that tries to avoid making weak flag choices early. -- | Transformation that tries to avoid making weak flag choices early.
-- Weak flags are trivial flags (not influencing dependencies) or such -- Weak flags are trivial flags (not influencing dependencies) or such
......
...@@ -30,10 +30,10 @@ import Distribution.Solver.Types.ConstraintSource ...@@ -30,10 +30,10 @@ import Distribution.Solver.Types.ConstraintSource
-- | Type of the search tree. Inlining the choice nodes for now. -- | Type of the search tree. Inlining the choice nodes for now.
data Tree a = data Tree a =
PChoice QPN a (PSQ POption (Tree a)) PChoice QPN a (PSQ POption (Tree a))
| FChoice QFN a Bool Bool (PSQ Bool (Tree a)) -- Bool indicates whether it's weak/trivial, second Bool whether it's manual | FChoice QFN a Bool Bool (PSQ Bool (Tree a)) -- Bool indicates whether it's weak/trivial, second Bool whether it's manual
| SChoice QSN a Bool (PSQ Bool (Tree a)) -- Bool indicates whether it's trivial | SChoice QSN a Bool (PSQ Bool (Tree a)) -- Bool indicates whether it's trivial
| GoalChoice (PSQ (OpenGoal ()) (Tree a)) -- PSQ should never be empty | GoalChoice (PSQ (Goal QPN) (Tree a)) -- PSQ should never be empty
| Done RevDepMap | Done RevDepMap
| Fail (ConflictSet QPN) FailReason | Fail (ConflictSet QPN) FailReason
deriving (Eq, Show, Functor) deriving (Eq, Show, Functor)
...@@ -87,10 +87,10 @@ data FailReason = InconsistentInitialConstraints ...@@ -87,10 +87,10 @@ data FailReason = InconsistentInitialConstraints
-- | Functor for the tree type. -- | Functor for the tree type.
data TreeF a b = data TreeF a b =
PChoiceF QPN a (PSQ POption b) PChoiceF QPN a (PSQ POption b)
| FChoiceF QFN a Bool Bool (PSQ Bool b) | FChoiceF QFN a Bool Bool (PSQ Bool b)
| SChoiceF QSN a Bool (PSQ Bool b) | SChoiceF QSN a Bool (PSQ Bool b)
| GoalChoiceF (PSQ (OpenGoal ()) b) | GoalChoiceF (PSQ (Goal QPN) b)
| DoneF RevDepMap | DoneF RevDepMap
| FailF (ConflictSet QPN) FailReason | FailF (ConflictSet QPN) FailReason
deriving (Functor, Foldable, Traversable) deriving (Functor, Foldable, Traversable)
......
Supports Markdown
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