Skip to content

Solver: Deduplicate LinkGroup's potential conflict set #3267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cabal-install/Distribution/Client/Dependency/Modular/Linking.hs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ makeCanonical lg qpn@(Q pp _) i =
case lgCanon lg of
-- There is already a canonical member. Fail.
Just _ ->
conflict ( S.fromList (P qpn : lgBlame lg)
conflict ( P qpn `S.insert` lgBlame lg
, "cannot make " ++ showQPN qpn
++ " canonical member of " ++ showLinkGroup lg
)
Expand Down Expand Up @@ -452,7 +452,7 @@ data LinkGroup = LinkGroup {
-- | The set of variables that should be added to the conflict set if
-- something goes wrong with this link set (in addition to the members
-- of the link group itself)
, lgBlame :: [Var QPN]
, lgBlame :: Set (Var QPN)
}
deriving Show

Expand Down Expand Up @@ -483,7 +483,7 @@ lgSingleton (Q pp pn) canon = LinkGroup {
lgPackage = pn
, lgCanon = canon
, lgMembers = S.singleton pp
, lgBlame = []
, lgBlame = S.empty
}

lgMerge :: [Var QPN] -> LinkGroup -> LinkGroup -> Either Conflict LinkGroup
Expand All @@ -493,7 +493,7 @@ lgMerge blame lg lg' = do
lgPackage = lgPackage lg
, lgCanon = canon
, lgMembers = lgMembers lg `S.union` lgMembers lg'
, lgBlame = blame ++ lgBlame lg ++ lgBlame lg'
, lgBlame = S.fromList blame `S.union` lgBlame lg `S.union` lgBlame lg'
}
where
pick :: Eq a => Maybe a -> Maybe a -> Either Conflict (Maybe a)
Expand All @@ -512,7 +512,7 @@ lgMerge blame lg lg' = do
)

lgConflictSet :: LinkGroup -> ConflictSet QPN
lgConflictSet lg = S.fromList (map aux (S.toList (lgMembers lg)) ++ lgBlame lg)
lgConflictSet lg = S.map aux (lgMembers lg) `S.union` lgBlame lg
where
aux pp = P (Q pp (lgPackage lg))

Expand Down