Skip to content

Commit e80cdcb

Browse files
committed
fix: use nodeKey in fromSolverInstallPlanWithProgress
1 parent 9b7301c commit e80cdcb

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

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

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -588,36 +588,25 @@ fromSolverInstallPlanWithProgress
588588
-> SolverInstallPlan
589589
-> LogProgress (GenericInstallPlan ipkg srcpkg)
590590
fromSolverInstallPlanWithProgress f plan = do
591-
(_, _, pkgs'') <-
591+
(_, pkgs'') <-
592592
foldM
593593
f'
594-
(Map.empty, Map.empty, [])
594+
(Map.empty, [])
595595
(SolverInstallPlan.reverseTopologicalOrder plan)
596596
return $
597597
mkInstallPlan
598598
"fromSolverInstallPlanWithProgress"
599599
(Graph.fromDistinctList pkgs'')
600600
where
601-
f' (pidMap, ipiMap, pkgs) pkg = do
602-
pkgs' <- f (mapDep pidMap ipiMap) pkg
603-
let (pidMap', ipiMap') =
604-
case nodeKey pkg of
605-
-- FIXME: stage is ignored
606-
PreExistingId _stage _ uid -> (pidMap, Map.insert uid pkgs' ipiMap)
607-
PlannedId _stage pid -> (Map.insert pid pkgs' pidMap, ipiMap)
608-
return (pidMap', ipiMap', pkgs' ++ pkgs)
601+
f' (pMap, pkgs) pkg = do
602+
pkgs' <- f (mapDep pMap) pkg
603+
let pMap' = Map.insert (nodeKey pkg) pkgs' pMap
604+
return (pMap', pkgs' ++ pkgs)
609605

610606
-- The error below shouldn't happen, since mapDep should only
611607
-- be called on neighbor SolverId, which must have all been done
612608
-- already by the reverse top-sort (we assume the graph is not broken).
613-
--
614-
-- FIXME: stage is ignored
615-
mapDep _ ipiMap (PreExistingId _stage _pid uid)
616-
| Just pkgs <- Map.lookup uid ipiMap = pkgs
617-
| otherwise = error ("fromSolverInstallPlan: PreExistingId " ++ prettyShow uid)
618-
mapDep pidMap _ (PlannedId _stage pid)
619-
| Just pkgs <- Map.lookup pid pidMap = pkgs
620-
| otherwise = error ("fromSolverInstallPlan: PlannedId " ++ prettyShow pid)
609+
mapDep pMap key = fromMaybe (error ("fromSolverInstallPlanWithProgress: " ++ prettyShow key)) (Map.lookup key pMap)
621610

622611
-- | Conversion of 'SolverInstallPlan' to 'InstallPlan'.
623612
-- Similar to 'elaboratedInstallPlan'

0 commit comments

Comments
 (0)