Skip to content

refactor: make Graph.broken return NonEmpty missing deps#12057

Open
andreabedini wants to merge 1 commit into
haskell:masterfrom
andreabedini:andrea/wip/prep/p11-graph-broken
Open

refactor: make Graph.broken return NonEmpty missing deps#12057
andreabedini wants to merge 1 commit into
haskell:masterfrom
andreabedini:andrea/wip/prep/p11-graph-broken

Conversation

@andreabedini

@andreabedini andreabedini commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

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.

Why

Besides tightening the type (a node reported as "broken" has at least one missing
dependency, so NonEmpty is more honest than []), this fixes a latent bug: the old
InstallPlan.problems did mapMaybe (Graph.lookup graph) missingDeps on keys that are
absent from the graph by construction, so it always produced [] — missing
dependencies were never actually surfaced.

QA notes

  • cabal build all is green.
  • cabal-install /InstallPlan/ unit tests pass.

Copilot AI review requested due to automatic review settings June 29, 2026 08:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / graphBroken to return NonEmpty missing neighbor keys.
  • Update PackageMissingDeps in InstallPlan and SolverInstallPlan to carry NonEmpty and adjust rendering/consumption with toList.
  • 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'
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bogus, Data.List.NonEmpty.groupWith does not take a NonEmpty input but []. The code type-checks.

Comment thread Cabal-syntax/src/Distribution/Compat/Graph.hs Outdated
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants