Skip to content

Commit 429f7de

Browse files
committed
Apply some @mpickering comments
1 parent 77d085c commit 429f7de

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import Distribution.Simple.Setup
5454
import Distribution.Simple.Utils
5555
( ordNubBy )
5656
import Distribution.Verbosity
57-
import Distribution.Solver.Modular.Message (SolverTrace (..))
57+
import Distribution.Solver.Modular.Message (SolverTrace (..), renderSolverTrace)
5858

5959
-- | Ties the two worlds together: classic cabal-install vs. the modular
6060
-- solver. Performs the necessary translations before and after.
@@ -181,7 +181,7 @@ solve' sc cinfo idx pkgConfigDB pprefs gcs pns =
181181
-- original goal order.
182182
goalOrder' = preferGoalsFromConflictSet cs <> fromMaybe mempty (goalOrder sc)
183183

184-
in unlines ("Could not resolve dependencies:" : map show (messages (toProgress (runSolver True sc'))))
184+
in unlines ("Could not resolve dependencies:" : map renderSolverTrace (messages (toProgress (runSolver True sc'))))
185185

186186
printFullLog = solverVerbosity sc >= verbose
187187

@@ -228,7 +228,7 @@ tryToMinimizeConflictSet :: forall a . (SolverConfig -> RetryLog SolverTrace Sol
228228
-> ConflictMap
229229
-> RetryLog SolverTrace SolverFailure a
230230
tryToMinimizeConflictSet runSolver sc cs cm =
231-
foldl (\r v -> retryMap mkErrorMsg $ retryNoSolution (retryMap show r) $ tryToRemoveOneVar v)
231+
foldl (\r v -> retryMap mkErrorMsg $ retryNoSolution (retryMap renderSolverTrace r) $ tryToRemoveOneVar v)
232232
(fromProgress $ Fail $ ExhaustiveSearch cs cm)
233233
(CS.toList cs)
234234
where
@@ -261,7 +261,7 @@ tryToMinimizeConflictSet runSolver sc cs cm =
261261
| otherwise =
262262
continueWith ("Trying to remove variable " ++ varStr ++ " from the "
263263
++ "conflict set.") $
264-
retry (retryMap show $ runSolver sc') $ \case
264+
retry (retryMap renderSolverTrace $ runSolver sc') $ \case
265265
err@(ExhaustiveSearch cs' _)
266266
| CS.toSet cs' `isSubsetOf` CS.toSet smallestKnownCS ->
267267
let msg = if not $ CS.member v cs'

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module Distribution.Solver.Modular.Message (
44
Message(..),
55
SolverTrace(..),
66
groupMessages,
7+
renderSolverTrace,
78
) where
89

910
import qualified Data.List as L
@@ -62,9 +63,9 @@ type Trace = AtLevel Log
6263

6364
data SolverTrace = SolverTrace Trace | ErrorMsg String
6465

65-
instance Show SolverTrace where
66-
show (SolverTrace i) = displayMessageAtLevel i
67-
show (ErrorMsg s) = show s
66+
renderSolverTrace :: SolverTrace -> String
67+
renderSolverTrace (SolverTrace i) = displayMessageAtLevel i
68+
renderSolverTrace (ErrorMsg s) = s
6869

6970
instance Show Log where
7071
show = displayMessage

cabal-install/src/Distribution/Client/Dependency.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ import Data.List
160160
)
161161
import qualified Data.Map as Map
162162
import qualified Data.Set as Set
163-
import Distribution.Solver.Modular.Message (SolverTrace)
163+
import Distribution.Solver.Modular.Message (SolverTrace, renderSolverTrace)
164164

165165
-- ------------------------------------------------------------
166166

@@ -838,7 +838,7 @@ resolveDependencies platform comp pkgConfigDB params =
838838
formatProgress :: Progress SolverTrace String a -> Progress String String a
839839
formatProgress p = foldProgress (\x xs -> Step (formatter x) xs) Fail Done p
840840
where
841-
formatter = if outputJson then error "FIXME: To be implemented ..." else show
841+
formatter = if outputJson then error "FIXME: To be implemented ..." else renderSolverTrace
842842

843843
preferences :: PackageName -> PackagePreferences
844844
preferences = interpretPackagesPreference targets defpref prefs

0 commit comments

Comments
 (0)