refactor: make Graph.broken return NonEmpty missing deps#12057
Open
andreabedini wants to merge 1 commit into
Open
refactor: make Graph.broken return NonEmpty missing deps#12057andreabedini wants to merge 1 commit into
andreabedini wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens the Distribution.Compat.Graph.broken API to make “missing dependency” information non-empty by construction, and propagates that stronger type (NonEmpty) through cabal-install plan problem reporting and related error formatting.
Changes:
- Change
Graph.broken/graphBrokento returnNonEmptymissing neighbor keys. - Update
PackageMissingDepsinInstallPlanandSolverInstallPlanto carryNonEmptyand adjust rendering/consumption withtoList. - Update callers that iterate missing deps to use
toList(e.g., Backpack configure diagnostics, pruning logic).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Cabal/src/Distribution/Backpack/Configure.hs | Adjust broken-package diagnostics to render NonEmpty missing deps via toList. |
| Cabal-syntax/src/Distribution/Compat/Graph.hs | Refactor Graph.broken to return NonEmpty missing neighbor keys and adjust graph construction accordingly. |
| cabal-install/src/Distribution/Client/SolverInstallPlan.hs | Make PackageMissingDeps carry NonEmpty and simplify missing-dep extraction/printing. |
| cabal-install/src/Distribution/Client/ProjectPlanning.hs | Convert NonEmpty missing dep ids to lists for lookup when reporting prune failures. |
| cabal-install/src/Distribution/Client/InstallPlan.hs | Make PlanProblem missing deps NonEmpty and avoid lossy lookups of already-missing keys. |
| cabal-install/src/Distribution/Client/Install.hs | Update iteration over missing deps to use toList with NonEmpty. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+355
to
359
| , graphBroken = | ||
| map (\ns'' -> (fst (NE.head ns''), NE.map snd ns'')) $ | ||
| NE.groupWith (nodeKey . fst) $ | ||
| brokenEdges' | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
Bogus, Data.List.NonEmpty.groupWith does not take a NonEmpty input but []. The code type-checks.
Distribution.Compat.Graph.broken now returns [(a, NonEmpty (Key a))] and only includes nodes that actually have missing dependencies. PackageMissingDeps in both Client.InstallPlan and Client.SolverInstallPlan carry NonEmpty accordingly.
aac7033 to
2bd1b3a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Distribution.Compat.Graph.brokennow returns[(a, NonEmpty (Key a))]and onlyincludes nodes that actually have missing dependencies.
PackageMissingDepsin bothClient.InstallPlanandClient.SolverInstallPlancarryNonEmptyaccordingly.Why
Besides tightening the type (a node reported as "broken" has at least one missing
dependency, so
NonEmptyis more honest than[]), this fixes a latent bug: the oldInstallPlan.problemsdidmapMaybe (Graph.lookup graph) missingDepson keys that areabsent from the graph by construction, so it always produced
[]— missingdependencies were never actually surfaced.
QA notes
cabal build allis green.cabal-install/InstallPlan/unit tests pass.