Skip to content

Commit

Permalink
Apply some @grayjay comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yvan-sraka committed Dec 5, 2023
1 parent c9d30ba commit 913cd7d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions cabal-install-solver/src/Distribution/Solver/Modular.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,17 @@ solve' :: SolverConfig
-> Set PN
-> Progress SolverTrace String (Assignment, RevDepMap)
solve' sc cinfo idx pkgConfigDB pprefs gcs pns =
toProgress $ retry (runSolver printFullLog sc) handleFailure
toProgress $ retry (runSolver printFullLog sc) createErrorMsg
where
runSolver :: Bool -> SolverConfig
-> RetryLog SolverTrace SolverFailure (Assignment, RevDepMap)
runSolver keepLog sc' =
displayLogMessages keepLog $
solve sc' cinfo idx pkgConfigDB pprefs gcs pns

handleFailure :: SolverFailure
createErrorMsg :: SolverFailure
-> RetryLog SolverTrace String (Assignment, RevDepMap)
handleFailure failure@(ExhaustiveSearch cs _cm) =
createErrorMsg failure@(ExhaustiveSearch cs _cm) =
if asBool $ minimizeConflictSet sc
then continueWith (mkErrorMsg ("Found no solution after exhaustively searching the "
++ "dependency tree. Rerunning the dependency solver "
Expand All @@ -153,7 +153,7 @@ solve' sc cinfo idx pkgConfigDB pprefs gcs pns =
++ finalErrorMsg sc failure
else
fromProgress $ Fail $ rerunSolverForErrorMsg cs ++ finalErrorMsg sc failure
handleFailure failure@BackjumpLimitReached =
createErrorMsg failure@BackjumpLimitReached =
continueWith
(mkErrorMsg ("Backjump limit reached. Rerunning dependency solver to generate "
++ "a final conflict set for the search tree containing the "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ displayLogMessages :: Bool
-> RetryLog SolverTrace SolverFailure a
displayLogMessages keepLog lg = fromProgress $
if keepLog
then groupMessages progress
then summarizeMessages progress
else foldProgress (const id) Fail Done progress
where
progress = toProgress lg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Distribution.Solver.Modular.Message (
Message(..),
SolverTrace(..),
groupMessages,
summarizeMessages,
) where

import qualified Data.List as L
Expand Down Expand Up @@ -78,7 +78,7 @@ displayMessage :: Log -> String
displayMessage (PackageGoal qpn gr) = "next goal: " ++ showQPN qpn ++ showGR gr
displayMessage (RejectF qfn b c fr) = "rejecting: " ++ showQFNBool qfn b ++ showFR c fr
displayMessage (RejectS qsn b c fr) = "rejecting: " ++ showQSNBool qsn b ++ showFR c fr
displayMessage (Skipping' cs) = showConflicts cs
displayMessage (Skipping' cs) = "skipping: " ++ showConflicts cs
displayMessage (TryingF qfn b) = "trying: " ++ showQFNBool qfn b
displayMessage (TryingP qpn i mgr) = "trying: " ++ showQPNPOpt qpn i ++ maybe "" showGR mgr
displayMessage (TryingS qsn b) = "trying: " ++ showQSNBool qsn b
Expand Down Expand Up @@ -123,8 +123,8 @@ displayMessage (RejectMany qpn is c fr) = "rejecting: " ++ L.intercalate ", " (m
-- The log contains level numbers, which are useful for any trace that involves
-- backtracking, because only the level numbers will allow to keep track of
-- backjumps.
groupMessages :: Progress Message a b -> Progress SolverTrace a b
groupMessages = go 0
summarizeMessages :: Progress Message a b -> Progress SolverTrace a b
summarizeMessages = go 0
where
-- 'go' increments the level for a recursive call when it encounters
-- 'TryP', 'TryF', or 'TryS' and decrements the level when it encounters 'Leave'.
Expand Down

0 comments on commit 913cd7d

Please sign in to comment.