Skip to content

Commit e0cd302

Browse files
committed
Refactor 'Explore.backjumpInfo' after code review
1 parent 2854bcb commit e0cd302

File tree

1 file changed

+5
-11
lines changed
  • cabal-install/Distribution/Client/Dependency/Modular

1 file changed

+5
-11
lines changed

cabal-install/Distribution/Client/Dependency/Modular/Explore.hs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,20 @@ import qualified Distribution.Client.Dependency.Types as T
3232
-- return it immediately. If all children contain conflict sets, we can
3333
-- take the union as the combined conflict set.
3434
backjump :: F.Foldable t => Var QPN -> t (ConflictSetLog a) -> ConflictSetLog a
35-
backjump var xs = F.foldr combine backjumpInfo xs S.empty
35+
backjump var xs = F.foldr combine logBackjump xs S.empty
3636
where
3737
combine :: ConflictSetLog a
3838
-> (ConflictSet QPN -> ConflictSetLog a)
3939
-> ConflictSet QPN -> ConflictSetLog a
4040
combine (T.Done x) _ _ = T.Done x
4141
combine (T.Fail cs) f csAcc
42-
| not (simplifyVar var `S.member` cs) = backjumpInfo cs
42+
| not (simplifyVar var `S.member` cs) = logBackjump cs
4343
| otherwise = f (csAcc `S.union` cs)
4444
combine (T.Step m ms) f cs = T.Step m (combine ms f cs)
4545

46+
logBackjump :: ConflictSet QPN -> ConflictSetLog a
47+
logBackjump cs = failWith (Failure cs Backjump) cs
48+
4649
type ConflictSetLog = T.Progress Message (ConflictSet QPN)
4750

4851
-- | A tree traversal that simultaneously propagates conflict sets up
@@ -77,15 +80,6 @@ exploreLog = cata go
7780
(failWith (Failure S.empty EmptyGoalChoice) S.empty) -- empty goal choice is an internal error
7881
(\ k v _xs -> continueWith (Next (close k)) (v a)) -- commit to the first goal choice
7982

80-
-- | Add in information about pruned trees.
81-
--
82-
-- TODO: This isn't quite optimal, because we do not merely report the shape of the
83-
-- tree, but rather make assumptions about where that shape originated from. It'd be
84-
-- better if the pruning itself would leave information that we could pick up at this
85-
-- point.
86-
backjumpInfo :: ConflictSet QPN -> ConflictSetLog a
87-
backjumpInfo cs = failWith (Failure cs Backjump) cs
88-
8983
-- | Interface.
9084
backjumpAndExplore :: Tree a -> Log Message (Assignment, RevDepMap)
9185
backjumpAndExplore t = toLog $ exploreLog t (A M.empty M.empty M.empty)

0 commit comments

Comments
 (0)