Skip to content

Commit e47a668

Browse files
committed
Remove debug-conflict-sets flag from solver package
Fixes #8937. The debug-conflict-sets build flag probably hasn't been used for a long time, and it isn't currently tested. This commit removes the flag, converts the ConflictSet type back to a newtype, and removes an unnecessary instance.
1 parent 976f86a commit e47a668

File tree

7 files changed

+11
-115
lines changed

7 files changed

+11
-115
lines changed

bootstrap/linux-8.10.7.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@
337337
"cabal_sha256": null,
338338
"component": "lib:cabal-install-solver",
339339
"flags": [
340-
"-debug-conflict-sets",
341340
"-debug-expensive-assertions",
342341
"-debug-tracetree"
343342
],

bootstrap/linux-9.0.2.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@
337337
"cabal_sha256": null,
338338
"component": "lib:cabal-install-solver",
339339
"flags": [
340-
"-debug-conflict-sets",
341340
"-debug-expensive-assertions",
342341
"-debug-tracetree"
343342
],

bootstrap/linux-9.2.7.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@
300300
"cabal_sha256": null,
301301
"component": "lib:cabal-install-solver",
302302
"flags": [
303-
"-debug-conflict-sets",
304303
"-debug-expensive-assertions",
305304
"-debug-tracetree"
306305
],

bootstrap/linux-9.4.4.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@
290290
"cabal_sha256": null,
291291
"component": "lib:cabal-install-solver",
292292
"flags": [
293-
"-debug-conflict-sets",
294293
"-debug-expensive-assertions",
295294
"-debug-tracetree"
296295
],

cabal-install-solver/cabal-install-solver.cabal

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ flag debug-expensive-assertions
2727
default: False
2828
manual: True
2929

30-
flag debug-conflict-sets
31-
description: Add additional information to ConflictSets
32-
default: False
33-
manual: True
34-
3530
flag debug-tracetree
3631
description: Compile in support for tracetree (used to debug the solver)
3732
default: False
@@ -119,10 +114,6 @@ library
119114
if flag(debug-expensive-assertions)
120115
cpp-options: -DDEBUG_EXPENSIVE_ASSERTIONS
121116

122-
if flag(debug-conflict-sets)
123-
cpp-options: -DDEBUG_CONFLICT_SETS
124-
build-depends: base >=4.9
125-
126117
if flag(debug-tracetree)
127118
cpp-options: -DDEBUG_TRACETREE
128119
build-depends: tracetree ^>=0.1
Lines changed: 10 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
{-# LANGUAGE CPP #-}
2-
#ifdef DEBUG_CONFLICT_SETS
3-
{-# LANGUAGE ImplicitParams #-}
4-
#endif
51
-- | Conflict sets
62
--
73
-- Intended for double import
@@ -13,9 +9,6 @@ module Distribution.Solver.Modular.ConflictSet (
139
, Conflict(..)
1410
, ConflictMap
1511
, OrderedVersionRange(..)
16-
#ifdef DEBUG_CONFLICT_SETS
17-
, conflictSetOrigin
18-
#endif
1912
, showConflictSet
2013
, showCSSortedByFrequency
2114
, showCSWithFrequency
@@ -44,36 +37,17 @@ import Data.Function (on)
4437
import qualified Data.Map.Strict as M
4538
import qualified Data.Set as S
4639

47-
#ifdef DEBUG_CONFLICT_SETS
48-
import Data.Tree
49-
import GHC.Stack
50-
#endif
51-
5240
import Distribution.Solver.Modular.Var
5341
import Distribution.Solver.Modular.Version
5442
import Distribution.Solver.Types.PackagePath
5543

5644
-- | The set of variables involved in a solver conflict, each paired with
5745
-- details about the conflict.
58-
data ConflictSet = CS {
46+
newtype ConflictSet = CS {
5947
-- | The set of variables involved in the conflict
60-
conflictSetToMap :: !(Map (Var QPN) (Set Conflict))
61-
62-
#ifdef DEBUG_CONFLICT_SETS
63-
-- | The origin of the conflict set
64-
--
65-
-- When @DEBUG_CONFLICT_SETS@ is defined @(-f debug-conflict-sets)@,
66-
-- we record the origin of every conflict set. For new conflict sets
67-
-- ('empty', 'fromVars', ..) we just record the 'CallStack'; for operations
68-
-- that construct new conflict sets from existing conflict sets ('union',
69-
-- 'filter', ..) we record the 'CallStack' to the call to the combinator
70-
-- as well as the 'CallStack's of the input conflict sets.
71-
--
72-
-- Requires @GHC >= 7.10@.
73-
, conflictSetOrigin :: Tree CallStack
74-
#endif
48+
conflictSetToMap :: Map (Var QPN) (Set Conflict)
7549
}
76-
deriving (Show)
50+
deriving (Eq, Show)
7751

7852
-- | More detailed information about how a conflict set variable caused a
7953
-- conflict. This information can be used to determine whether a second value
@@ -112,12 +86,6 @@ newtype OrderedVersionRange = OrderedVersionRange VR
11286
instance Ord OrderedVersionRange where
11387
compare = compare `on` show
11488

115-
instance Eq ConflictSet where
116-
(==) = (==) `on` conflictSetToMap
117-
118-
instance Ord ConflictSet where
119-
compare = compare `on` conflictSetToMap
120-
12189
showConflictSet :: ConflictSet -> String
12290
showConflictSet = intercalate ", " . map showVar . toList
12391

@@ -147,76 +115,37 @@ toSet = M.keysSet . conflictSetToMap
147115
toList :: ConflictSet -> [Var QPN]
148116
toList = M.keys . conflictSetToMap
149117

150-
union ::
151-
#ifdef DEBUG_CONFLICT_SETS
152-
(?loc :: CallStack) =>
153-
#endif
154-
ConflictSet -> ConflictSet -> ConflictSet
118+
union :: ConflictSet -> ConflictSet -> ConflictSet
155119
union cs cs' = CS {
156120
conflictSetToMap = M.unionWith S.union (conflictSetToMap cs) (conflictSetToMap cs')
157-
#ifdef DEBUG_CONFLICT_SETS
158-
, conflictSetOrigin = Node ?loc (map conflictSetOrigin [cs, cs'])
159-
#endif
160121
}
161122

162-
unions ::
163-
#ifdef DEBUG_CONFLICT_SETS
164-
(?loc :: CallStack) =>
165-
#endif
166-
[ConflictSet] -> ConflictSet
123+
unions :: [ConflictSet] -> ConflictSet
167124
unions css = CS {
168125
conflictSetToMap = M.unionsWith S.union (map conflictSetToMap css)
169-
#ifdef DEBUG_CONFLICT_SETS
170-
, conflictSetOrigin = Node ?loc (map conflictSetOrigin css)
171-
#endif
172126
}
173127

174-
insert ::
175-
#ifdef DEBUG_CONFLICT_SETS
176-
(?loc :: CallStack) =>
177-
#endif
178-
Var QPN -> ConflictSet -> ConflictSet
128+
insert :: Var QPN -> ConflictSet -> ConflictSet
179129
insert var cs = CS {
180130
conflictSetToMap = M.insert var (S.singleton OtherConflict) (conflictSetToMap cs)
181-
#ifdef DEBUG_CONFLICT_SETS
182-
, conflictSetOrigin = Node ?loc [conflictSetOrigin cs]
183-
#endif
184131
}
185132

186133
delete :: Var QPN -> ConflictSet -> ConflictSet
187134
delete var cs = CS {
188135
conflictSetToMap = M.delete var (conflictSetToMap cs)
189136
}
190137

191-
empty ::
192-
#ifdef DEBUG_CONFLICT_SETS
193-
(?loc :: CallStack) =>
194-
#endif
195-
ConflictSet
138+
empty :: ConflictSet
196139
empty = CS {
197140
conflictSetToMap = M.empty
198-
#ifdef DEBUG_CONFLICT_SETS
199-
, conflictSetOrigin = Node ?loc []
200-
#endif
201141
}
202142

203-
singleton ::
204-
#ifdef DEBUG_CONFLICT_SETS
205-
(?loc :: CallStack) =>
206-
#endif
207-
Var QPN -> ConflictSet
143+
singleton :: Var QPN -> ConflictSet
208144
singleton var = singletonWithConflict var OtherConflict
209145

210-
singletonWithConflict ::
211-
#ifdef DEBUG_CONFLICT_SETS
212-
(?loc :: CallStack) =>
213-
#endif
214-
Var QPN -> Conflict -> ConflictSet
146+
singletonWithConflict :: Var QPN -> Conflict -> ConflictSet
215147
singletonWithConflict var conflict = CS {
216148
conflictSetToMap = M.singleton var (S.singleton conflict)
217-
#ifdef DEBUG_CONFLICT_SETS
218-
, conflictSetOrigin = Node ?loc []
219-
#endif
220149
}
221150

222151
size :: ConflictSet -> Int
@@ -228,17 +157,9 @@ member var = M.member var . conflictSetToMap
228157
lookup :: Var QPN -> ConflictSet -> Maybe (Set Conflict)
229158
lookup var = M.lookup var . conflictSetToMap
230159

231-
fromList ::
232-
#ifdef DEBUG_CONFLICT_SETS
233-
(?loc :: CallStack) =>
234-
#endif
235-
[Var QPN] -> ConflictSet
160+
fromList :: [Var QPN] -> ConflictSet
236161
fromList vars = CS {
237162
conflictSetToMap = M.fromList [(var, S.singleton OtherConflict) | var <- vars]
238-
#ifdef DEBUG_CONFLICT_SETS
239-
, conflictSetOrigin = Node ?loc []
240-
#endif
241163
}
242164

243165
type ConflictMap = Map (Var QPN) Int
244-

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
22
{-# LANGUAGE MultiParamTypeClasses #-}
3-
{-# LANGUAGE CPP #-}
4-
#ifdef DEBUG_CONFLICT_SETS
5-
{-# LANGUAGE ImplicitParams #-}
6-
#endif
73
module Distribution.Solver.Modular.Validate (validateTree) where
84

95
-- Validation of the tree.
@@ -40,10 +36,6 @@ import Distribution.Solver.Types.PkgConfigDb (PkgConfigDb, pkgConfigPkgIsPresent
4036
import Distribution.Types.LibraryName
4137
import Distribution.Types.PkgconfigVersionRange
4238

43-
#ifdef DEBUG_CONFLICT_SETS
44-
import GHC.Stack (CallStack)
45-
#endif
46-
4739
-- In practice, most constraints are implication constraints (IF we have made
4840
-- a number of choices, THEN we also have to ensure that). We call constraints
4941
-- that for which the preconditions are fulfilled ACTIVE. We maintain a set
@@ -450,11 +442,7 @@ extendWithPackageChoice (PI qpn i) ppa =
450442
-- set in the sense the it contains variables that allow us to backjump
451443
-- further. We might apply some heuristics here, such as to change the
452444
-- order in which we check the constraints.
453-
merge ::
454-
#ifdef DEBUG_CONFLICT_SETS
455-
(?loc :: CallStack) =>
456-
#endif
457-
MergedPkgDep -> PkgDep -> Either (ConflictSet, (ConflictingDep, ConflictingDep)) MergedPkgDep
445+
merge :: MergedPkgDep -> PkgDep -> Either (ConflictSet, (ConflictingDep, ConflictingDep)) MergedPkgDep
458446
merge (MergedDepFixed comp1 vs1 i1) (PkgDep vs2 (PkgComponent p comp2) ci@(Fixed i2))
459447
| i1 == i2 = Right $ MergedDepFixed comp1 vs1 i1
460448
| otherwise =

0 commit comments

Comments
 (0)