Skip to content

Commit e4aec8f

Browse files
committed
Use nodeKey in fromSolverInstallPlanWithProgress
1 parent 33b687e commit e4aec8f

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
@@ -601,36 +601,25 @@ fromSolverInstallPlanWithProgress
601601
-> SolverInstallPlan
602602
-> LogProgress (GenericInstallPlan ipkg srcpkg)
603603
fromSolverInstallPlanWithProgress f plan = do
604-
(_, _, pkgs'') <-
604+
(_, pkgs'') <-
605605
foldM
606606
f'
607-
(Map.empty, Map.empty, [])
607+
(Map.empty, [])
608608
(SolverInstallPlan.reverseTopologicalOrder plan)
609609
return $
610610
mkInstallPlan
611611
"fromSolverInstallPlanWithProgress"
612612
(Graph.fromDistinctList pkgs'')
613613
where
614-
f' (pidMap, ipiMap, pkgs) pkg = do
615-
pkgs' <- f (mapDep pidMap ipiMap) pkg
616-
let (pidMap', ipiMap') =
617-
case nodeKey pkg of
618-
-- FIXME: stage is ignored
619-
PreExistingId _stage _ uid -> (pidMap, Map.insert uid pkgs' ipiMap)
620-
PlannedId _stage pid -> (Map.insert pid pkgs' pidMap, ipiMap)
621-
return (pidMap', ipiMap', pkgs' ++ pkgs)
614+
f' (pMap, pkgs) pkg = do
615+
pkgs' <- f (mapDep pMap) pkg
616+
let pMap' = Map.insert (nodeKey pkg) pkgs' pMap
617+
return (pMap', pkgs' ++ pkgs)
622618

623619
-- The error below shouldn't happen, since mapDep should only
624620
-- be called on neighbor SolverId, which must have all been done
625621
-- already by the reverse top-sort (we assume the graph is not broken).
626-
--
627-
-- FIXME: stage is ignored
628-
mapDep _ ipiMap (PreExistingId _stage _pid uid)
629-
| Just pkgs <- Map.lookup uid ipiMap = pkgs
630-
| otherwise = error ("fromSolverInstallPlan: PreExistingId " ++ prettyShow uid)
631-
mapDep pidMap _ (PlannedId _stage pid)
632-
| Just pkgs <- Map.lookup pid pidMap = pkgs
633-
| otherwise = error ("fromSolverInstallPlan: PlannedId " ++ prettyShow pid)
622+
mapDep pMap key = fromMaybe (error ("fromSolverInstallPlan: " ++ prettyShow key)) (Map.lookup key pMap)
634623

635624
-- | Conversion of 'SolverInstallPlan' to 'InstallPlan'.
636625
-- Similar to 'elaboratedInstallPlan'

0 commit comments

Comments
 (0)