@@ -18,43 +18,60 @@ import Distribution.Solver.Compat.Prelude
18
18
import qualified Data.Map as M
19
19
import Data.Set (isSubsetOf )
20
20
import Distribution.Compat.Graph
21
- ( IsNode (.. ) )
21
+ ( IsNode (.. ) )
22
22
import Distribution.Compiler
23
- ( CompilerInfo )
23
+ ( CompilerInfo )
24
24
import Distribution.Solver.Modular.Assignment
25
- ( Assignment , toCPs )
25
+ ( Assignment , toCPs )
26
26
import Distribution.Solver.Modular.ConfiguredConversion
27
- ( convCP )
27
+ ( convCP )
28
28
import qualified Distribution.Solver.Modular.ConflictSet as CS
29
29
import Distribution.Solver.Modular.Dependency
30
- import Distribution.Solver.Modular.Flag
31
- import Distribution.Solver.Modular.Index
30
+ ( Var (.. ),
31
+ showVar ,
32
+ ConflictMap ,
33
+ ConflictSet ,
34
+ showConflictSet ,
35
+ RevDepMap )
36
+ import Distribution.Solver.Modular.Flag ( SN (SN ), FN (FN ) )
37
+ import Distribution.Solver.Modular.Index ( Index )
32
38
import Distribution.Solver.Modular.IndexConversion
33
- ( convPIs )
39
+ ( convPIs )
34
40
import Distribution.Solver.Modular.Log
35
- ( SolverFailure (.. ), displayLogMessages )
41
+ ( SolverFailure (.. ), displayLogMessages )
36
42
import Distribution.Solver.Modular.Package
37
- ( PN )
43
+ ( PN )
38
44
import Distribution.Solver.Modular.RetryLog
45
+ ( RetryLog ,
46
+ toProgress ,
47
+ fromProgress ,
48
+ retry ,
49
+ failWith ,
50
+ continueWith )
39
51
import Distribution.Solver.Modular.Solver
40
- ( SolverConfig (.. ), PruneAfterFirstSuccess (.. ), solve )
52
+ ( SolverConfig (.. ), PruneAfterFirstSuccess (.. ), solve )
41
53
import Distribution.Solver.Types.DependencyResolver
54
+ ( DependencyResolver )
42
55
import Distribution.Solver.Types.LabeledPackageConstraint
56
+ ( LabeledPackageConstraint , unlabelPackageConstraint )
43
57
import Distribution.Solver.Types.PackageConstraint
44
- import Distribution.Solver.Types.PackagePath
58
+ ( PackageConstraint (.. ), scopeToPackageName )
59
+ import Distribution.Solver.Types.PackagePath ( QPN )
45
60
import Distribution.Solver.Types.PackagePreferences
61
+ ( PackagePreferences )
46
62
import Distribution.Solver.Types.PkgConfigDb
47
- ( PkgConfigDb )
63
+ ( PkgConfigDb )
48
64
import Distribution.Solver.Types.Progress
49
- import Distribution.Solver.Types.Variable
65
+ ( Progress (.. ), foldProgress , SummarizedMessage (ErrorMsg ) )
66
+ import Distribution.Solver.Types.Variable ( Variable (.. ) )
50
67
import Distribution.System
51
- ( Platform (.. ) )
68
+ ( Platform (.. ) )
52
69
import Distribution.Simple.Setup
53
- ( BooleanFlag (.. ) )
70
+ ( BooleanFlag (.. ) )
54
71
import Distribution.Simple.Utils
55
- ( ordNubBy )
56
- import Distribution.Verbosity
57
- import Distribution.Solver.Modular.Message (SolverTrace ( .. ) )
72
+ ( ordNubBy )
73
+ import Distribution.Verbosity ( normal , verbose )
74
+ import Distribution.Solver.Modular.Message ( renderSummarizedMessage )
58
75
59
76
-- | Ties the two worlds together: classic cabal-install vs. the modular
60
77
-- solver. Performs the necessary translations before and after.
@@ -120,19 +137,19 @@ solve' :: SolverConfig
120
137
-> (PN -> PackagePreferences )
121
138
-> Map PN [LabeledPackageConstraint ]
122
139
-> Set PN
123
- -> Progress SolverTrace String (Assignment , RevDepMap )
140
+ -> Progress SummarizedMessage String (Assignment , RevDepMap )
124
141
solve' sc cinfo idx pkgConfigDB pprefs gcs pns =
125
- toProgress $ retry (runSolver printFullLog sc) handleFailure
142
+ toProgress $ retry (runSolver printFullLog sc) createErrorMsg
126
143
where
127
144
runSolver :: Bool -> SolverConfig
128
- -> RetryLog SolverTrace SolverFailure (Assignment , RevDepMap )
145
+ -> RetryLog SummarizedMessage SolverFailure (Assignment , RevDepMap )
129
146
runSolver keepLog sc' =
130
147
displayLogMessages keepLog $
131
148
solve sc' cinfo idx pkgConfigDB pprefs gcs pns
132
149
133
- handleFailure :: SolverFailure
134
- -> RetryLog SolverTrace String (Assignment , RevDepMap )
135
- handleFailure failure@ (ExhaustiveSearch cs _cm) =
150
+ createErrorMsg :: SolverFailure
151
+ -> RetryLog SummarizedMessage String (Assignment , RevDepMap )
152
+ createErrorMsg failure@ (ExhaustiveSearch cs _cm) =
136
153
if asBool $ minimizeConflictSet sc
137
154
then continueWith (mkErrorMsg (" Found no solution after exhaustively searching the "
138
155
++ " dependency tree. Rerunning the dependency solver "
@@ -153,7 +170,7 @@ solve' sc cinfo idx pkgConfigDB pprefs gcs pns =
153
170
++ finalErrorMsg sc failure
154
171
else
155
172
fromProgress $ Fail $ rerunSolverForErrorMsg cs ++ finalErrorMsg sc failure
156
- handleFailure failure@ BackjumpLimitReached =
173
+ createErrorMsg failure@ BackjumpLimitReached =
157
174
continueWith
158
175
(mkErrorMsg (" Backjump limit reached. Rerunning dependency solver to generate "
159
176
++ " a final conflict set for the search tree containing the "
@@ -181,14 +198,14 @@ solve' sc cinfo idx pkgConfigDB pprefs gcs pns =
181
198
-- original goal order.
182
199
goalOrder' = preferGoalsFromConflictSet cs <> fromMaybe mempty (goalOrder sc)
183
200
184
- in unlines (" Could not resolve dependencies:" : map show (messages (toProgress (runSolver True sc'))))
201
+ in unlines (" Could not resolve dependencies:" : map renderSummarizedMessage (messages (toProgress (runSolver True sc'))))
185
202
186
203
printFullLog = solverVerbosity sc >= verbose
187
204
188
205
messages :: Progress step fail done -> [step ]
189
206
messages = foldProgress (:) (const [] ) (const [] )
190
207
191
- mkErrorMsg :: String -> SolverTrace
208
+ mkErrorMsg :: String -> SummarizedMessage
192
209
mkErrorMsg msg = ErrorMsg msg
193
210
194
211
-- | Try to remove variables from the given conflict set to create a minimal
@@ -222,13 +239,13 @@ mkErrorMsg msg = ErrorMsg msg
222
239
-- solver to add new unnecessary variables to the conflict set. This function
223
240
-- discards the result from any run that adds new variables to the conflict
224
241
-- set, but the end result may not be completely minimized.
225
- tryToMinimizeConflictSet :: forall a . (SolverConfig -> RetryLog SolverTrace SolverFailure a )
242
+ tryToMinimizeConflictSet :: forall a . (SolverConfig -> RetryLog SummarizedMessage SolverFailure a )
226
243
-> SolverConfig
227
244
-> ConflictSet
228
245
-> ConflictMap
229
- -> RetryLog SolverTrace SolverFailure a
246
+ -> RetryLog SummarizedMessage SolverFailure a
230
247
tryToMinimizeConflictSet runSolver sc cs cm =
231
- foldl (\ r v -> retryMap mkErrorMsg $ retryNoSolution (retryMap show r) $ tryToRemoveOneVar v)
248
+ foldl (\ r v -> retryMap mkErrorMsg $ retryNoSolution (retryMap renderSummarizedMessage r) $ tryToRemoveOneVar v)
232
249
(fromProgress $ Fail $ ExhaustiveSearch cs cm)
233
250
(CS. toList cs)
234
251
where
@@ -261,7 +278,7 @@ tryToMinimizeConflictSet runSolver sc cs cm =
261
278
| otherwise =
262
279
continueWith (" Trying to remove variable " ++ varStr ++ " from the "
263
280
++ " conflict set." ) $
264
- retry (retryMap show $ runSolver sc') $ \ case
281
+ retry (retryMap renderSummarizedMessage $ runSolver sc') $ \ case
265
282
err@ (ExhaustiveSearch cs' _)
266
283
| CS. toSet cs' `isSubsetOf` CS. toSet smallestKnownCS ->
267
284
let msg = if not $ CS. member v cs'
0 commit comments