Skip to content

Commit ca8828f

Browse files
committed
chore(cabal-install-solver): remove traceTree
1 parent 4015ef0 commit ca8828f

File tree

1 file changed

+5
-84
lines changed
  • cabal-install-solver/src/Distribution/Solver/Modular

1 file changed

+5
-84
lines changed

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

Lines changed: 5 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
{-# LANGUAGE CPP #-}
2-
#ifdef DEBUG_TRACETREE
3-
{-# LANGUAGE FlexibleInstances #-}
4-
{-# OPTIONS_GHC -Wno-orphans #-}
5-
#endif
61
module Distribution.Solver.Modular.Solver
72
( SolverConfig(..)
83
, solve
@@ -46,16 +41,6 @@ import qualified Distribution.Solver.Modular.PSQ as PSQ
4641
import Distribution.Simple.Setup (BooleanFlag(..))
4742
import Distribution.Solver.Types.Stage (Staged, Stage(..))
4843

49-
#ifdef DEBUG_TRACETREE
50-
import qualified Distribution.Solver.Modular.ConflictSet as CS
51-
import qualified Distribution.Solver.Modular.WeightedPSQ as W
52-
import Distribution.Solver.Modular.Version (showVer)
53-
54-
import Debug.Trace.Tree (gtraceJson)
55-
import Debug.Trace.Tree.Simple
56-
import Debug.Trace.Tree.Generic
57-
import Debug.Trace.Tree.Assoc (Assoc(..))
58-
#endif
5944

6045
-- | Various options for the modular solver.
6146
data SolverConfig = SolverConfig {
@@ -98,19 +83,14 @@ solve :: SolverConfig -- ^ solver parameters
9883
-> RetryLog Message SolverFailure (Assignment, RevDepMap)
9984
solve sc cinfo pkgConfigDB idx userPrefs userConstraints userGoals =
10085
explorePhase .
101-
traceTree "cycles.json" id .
10286
detectCycles .
103-
traceTree "heuristics.json" id .
10487
trav (
105-
heuristicsPhase .
106-
preferencesPhase .
107-
validationPhase
108-
) .
109-
traceTree "semivalidated.json" id .
88+
heuristicsPhase .
89+
preferencesPhase .
90+
validationPhase
91+
) $
11092
validationCata .
111-
traceTree "pruned.json" id .
112-
trav prunePhase .
113-
traceTree "build.json" id $
93+
trav prunePhase $
11494
buildPhase
11595
where
11696
explorePhase = backjumpAndExplore (maxBackjumps sc)
@@ -168,65 +148,6 @@ solve sc cinfo pkgConfigDB idx userPrefs userConstraints userGoals =
168148
| asBool (reorderGoals sc) = P.preferReallyEasyGoalChoices
169149
| otherwise = id {- P.firstGoal -}
170150

171-
-- | Dump solver tree to a file (in debugging mode)
172-
--
173-
-- This only does something if the @debug-tracetree@ configure argument was
174-
-- given; otherwise this is just the identity function.
175-
{- FOURMOLU_DISABLE -}
176-
traceTree ::
177-
#ifdef DEBUG_TRACETREE
178-
GSimpleTree a =>
179-
#endif
180-
FilePath -- ^ Output file
181-
-> (a -> a) -- ^ Function to summarize the tree before dumping
182-
-> a -> a
183-
#ifdef DEBUG_TRACETREE
184-
traceTree = gtraceJson
185-
#else
186-
traceTree _ _ = id
187-
#endif
188-
{- FOURMOLU_ENABLE -}
189-
190-
#ifdef DEBUG_TRACETREE
191-
instance GSimpleTree (Tree d c) where
192-
fromGeneric = go
193-
where
194-
go :: Tree d c -> SimpleTree
195-
go (PChoice qpn _ _ psq) = Node "P" $ Assoc $ L.map (uncurry (goP qpn)) $ psqToList psq
196-
go (FChoice _ _ _ _ _ _ psq) = Node "F" $ Assoc $ L.map (uncurry goFS) $ psqToList psq
197-
go (SChoice _ _ _ _ psq) = Node "S" $ Assoc $ L.map (uncurry goFS) $ psqToList psq
198-
go (GoalChoice _ psq) = Node "G" $ Assoc $ L.map (uncurry goG) $ PSQ.toList psq
199-
go (Done _rdm _s) = Node "D" $ Assoc []
200-
go (Fail cs _reason) = Node "X" $ Assoc [("CS", Leaf $ goCS cs)]
201-
202-
psqToList :: W.WeightedPSQ w k v -> [(k, v)]
203-
psqToList = L.map (\(_, k, v) -> (k, v)) . W.toList
204-
205-
-- Show package choice
206-
goP :: QPN -> POption -> Tree d c -> (String, SimpleTree)
207-
goP _ (POption (I _stage ver _loc) Nothing) subtree = (showVer ver, go subtree)
208-
goP (Q _ pn) (POption _ (Just pp)) subtree = (showQPN (Q pp pn), go subtree)
209-
210-
-- Show flag or stanza choice
211-
goFS :: Bool -> Tree d c -> (String, SimpleTree)
212-
goFS val subtree = (show val, go subtree)
213-
214-
-- Show goal choice
215-
goG :: Goal QPN -> Tree d c -> (String, SimpleTree)
216-
goG (Goal var gr) subtree = (showVar var ++ " (" ++ shortGR gr ++ ")", go subtree)
217-
218-
-- Variation on 'showGR' that produces shorter strings
219-
-- (Actually, QGoalReason records more info than necessary: we only need
220-
-- to know the variable that introduced the goal, not the value assigned
221-
-- to that variable)
222-
shortGR :: QGoalReason -> String
223-
shortGR UserGoal = "user"
224-
shortGR (DependencyGoal dr) = showDependencyReason dr
225-
226-
-- Show conflict set
227-
goCS :: ConflictSet -> String
228-
goCS cs = "{" ++ (intercalate "," . L.map showVar . CS.toList $ cs) ++ "}"
229-
#endif
230151

231152
-- | Replace all goal reasons with a dummy goal reason in the tree
232153
--

0 commit comments

Comments
 (0)