Skip to content

Commit f8cec88

Browse files
committed
refactor(cabal-install-solver): refactor modularResolver
1 parent ca8828f commit f8cec88

File tree

1 file changed

+7
-8
lines changed
  • cabal-install-solver/src/Distribution/Solver

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Distribution.Compat.Graph
2222
import Distribution.Compiler
2323
( CompilerInfo )
2424
import Distribution.Solver.Modular.Assignment
25-
( Assignment, toCPs )
25+
( Assignment(..), toCPs )
2626
import Distribution.Solver.Modular.ConfiguredConversion
2727
( convCP )
2828
import qualified Distribution.Solver.Modular.ConflictSet as CS
@@ -81,7 +81,12 @@ import Distribution.Verbosity ( normal, verbose )
8181
-- solver. Performs the necessary translations before and after.
8282
modularResolver :: SolverConfig -> DependencyResolver loc
8383
modularResolver sc toolchains pkgConfigDbs iidx sidx pprefs pcs pns = do
84-
uncurry postprocess <$> solve' sc cinfo pkgConfigDbs idx pprefs gcs pns
84+
(assignment, revdepmap) <- solve' sc cinfo pkgConfigDbs idx pprefs gcs pns
85+
86+
-- Results have to be converted into an install plan. 'convCP' removes
87+
-- package qualifiers, which means that linked packages become duplicates
88+
-- and can be removed.
89+
return $ ordNubBy nodeKey $ map (convCP iidx sidx) (toCPs assignment revdepmap)
8590
where
8691
cinfo = fst <$> toolchains
8792

@@ -92,12 +97,6 @@ modularResolver sc toolchains pkgConfigDbs iidx sidx pprefs pcs pns = do
9297
where
9398
pair lpc = (pcName $ unlabelPackageConstraint lpc, [lpc])
9499

95-
-- Results have to be converted into an install plan. 'convCP' removes
96-
-- package qualifiers, which means that linked packages become duplicates
97-
-- and can be removed.
98-
postprocess a rdm = ordNubBy nodeKey $
99-
map (convCP iidx sidx) (toCPs a rdm)
100-
101100
-- Helper function to extract the PN from a constraint.
102101
pcName :: PackageConstraint -> PN
103102
pcName (PackageConstraint scope _) = scopeToPackageName scope

0 commit comments

Comments
 (0)