Skip to content

Hlint: suggest nub alternative#11825

Merged
mergify[bot] merged 1 commit into
haskell:masterfrom
cabalism:hlint/suggest-nub-alternatives
May 26, 2026
Merged

Hlint: suggest nub alternative#11825
mergify[bot] merged 1 commit into
haskell:masterfrom
cabalism:hlint/suggest-nub-alternatives

Conversation

@philderbeast
Copy link
Copy Markdown
Collaborator

@philderbeast philderbeast commented May 14, 2026

Fixes #11824.

When fired, this suggestion renders as:

$ cabal-install-solver/src/Distribution/Solver/Modular/Assignment.hs:56:64-69: Suggestion: Use ordNub
Found:
  nub xs
Perhaps:
  ordNub xs
Note: The growth rate of nub is O(n^2) and for ordNub it is O(n log n).  May require adding import of either;
  - Distribution.Utils.Generic from Cabal-syntax, or
  - Distribution.Simple.Utils from Cabal.

I didn't correct O(n log n) to the O(n log d) from containers haddocks for nubOrd. Neither did I suggest using that equivalent function from containers. For that, I raised #11826.

I had to add Ord instances to a few data types, BuildTarget and MatchError. I changed the Eq constraint to an Ord constraint for findMatch and nubMatches.

I left a note in .hlint.yaml to only use single letter variables in rules.

I used a separate commit for changes to tests but on approval will squash all commits before adding the merge me label.


  • Patches conform to the coding conventions.
  • Is this a PR that fixes CI? If so, it will need to be backported to older cabal release branches (ask maintainers for directions).

Copy link
Copy Markdown
Collaborator

@jappeace jappeace left a comment

Choose a reason for hiding this comment

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

nice!

Comment thread Cabal-syntax/src/Distribution/PackageDescription/FieldGrammar.hs
Comment thread Cabal/src/Distribution/Simple/BuildTarget.hs Outdated
@philderbeast philderbeast force-pushed the hlint/suggest-nub-alternatives branch 2 times, most recently from a350dda to d7a010b Compare May 21, 2026 18:13
@philderbeast philderbeast force-pushed the hlint/suggest-nub-alternatives branch from d7a010b to 1d0950b Compare May 22, 2026 14:39
@philderbeast philderbeast added merge me Tell Mergify Bot to merge and removed attention: needs-review labels May 22, 2026
@philderbeast philderbeast force-pushed the hlint/suggest-nub-alternatives branch from 1d0950b to d1dcf19 Compare May 22, 2026 14:42
@mergify mergify Bot added the ready and waiting Mergify is waiting out the cooldown period label May 22, 2026
- Use single letter variables with hlint rules
- Only suggest ordNub
- Add growth rate note
- Include necessary imports
- Follow hlint suggestion: use ordNub
- Follow hlint suggestion: use ordNub in tests
- Satisfy hlint: use fewer imports
- Add @SInCE annotations for added Ord instances
@philderbeast philderbeast force-pushed the hlint/suggest-nub-alternatives branch from d1dcf19 to 64d8543 Compare May 24, 2026 00:16
@philderbeast
Copy link
Copy Markdown
Collaborator Author

@mergify queue

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 24, 2026

Merge Queue Status

This pull request spent 1 hour 34 minutes 47 seconds in the queue, including 1 hour 24 minutes 11 seconds running CI.

Waiting for any of
  • check-neutral = Validate post job
  • check-skipped = Validate post job
  • check-success = Validate post job
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Validate post job
    • check-skipped = Validate post job
    • check-success = Validate post job
  • #approved-reviews-by >= 2 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Doctest Cabal
    • check-neutral = Doctest Cabal
    • check-skipped = Doctest Cabal
  • any of [🛡 GitHub branch protection]:
    • check-success = Meta checks
    • check-neutral = Meta checks
    • check-skipped = Meta checks
  • any of [🛡 GitHub branch protection]:
    • check-success = docs/readthedocs.org:cabal
    • check-neutral = docs/readthedocs.org:cabal
    • check-skipped = docs/readthedocs.org:cabal
  • any of [🛡 GitHub branch protection]:
    • check-success = fourmolu
    • check-neutral = fourmolu
    • check-skipped = fourmolu
  • any of [🛡 GitHub branch protection]:
    • check-success = hlint
    • check-neutral = hlint
    • check-skipped = hlint
  • any of [🛡 GitHub branch protection]:
    • check-success = Bootstrap post job
    • check-neutral = Bootstrap post job
    • check-skipped = Bootstrap post job
  • any of [🛡 GitHub branch protection]:
    • check-success = whitespace
    • check-neutral = whitespace
    • check-skipped = whitespace
  • any of [🛡 GitHub branch protection]:
    • check-success = Check sdist post job
    • check-neutral = Check sdist post job
    • check-skipped = Check sdist post job
  • any of [🛡 GitHub branch protection]:
    • check-success = Changelogs
    • check-neutral = Changelogs
    • check-skipped = Changelogs

Reason

The merge conditions cannot be satisfied due to failing checks

Failing checks:

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

@mergify mergify Bot added the queued label May 24, 2026
mergify Bot added a commit that referenced this pull request May 24, 2026
@mergify mergify Bot added dequeued and removed queued labels May 24, 2026
@philderbeast
Copy link
Copy Markdown
Collaborator Author

@mergify queue

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 26, 2026

Merge Queue Status

This pull request spent 11 minutes 57 seconds in the queue, including 40 seconds running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Doctest Cabal
    • check-skipped = Doctest Cabal
    • check-success = Doctest Cabal
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Meta checks
    • check-skipped = Meta checks
    • check-success = Meta checks
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Validate post job
    • check-skipped = Validate post job
    • check-success = Validate post job
  • any of: [🛡 GitHub branch protection]
    • check-neutral = fourmolu
    • check-skipped = fourmolu
    • check-success = fourmolu
  • any of: [🛡 GitHub branch protection]
    • check-neutral = hlint
    • check-skipped = hlint
    • check-success = hlint
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Bootstrap post job
    • check-skipped = Bootstrap post job
    • check-success = Bootstrap post job
  • any of: [🛡 GitHub branch protection]
    • check-neutral = whitespace
    • check-skipped = whitespace
    • check-success = whitespace
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Changelogs
    • check-skipped = Changelogs
    • check-success = Changelogs
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Doctest Cabal
    • check-skipped = Doctest Cabal
    • check-success = Doctest Cabal
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Meta checks
    • check-skipped = Meta checks
    • check-success = Meta checks
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Validate post job
    • check-skipped = Validate post job
    • check-success = Validate post job
  • any of [🛡 GitHub branch protection]:
    • check-neutral = fourmolu
    • check-skipped = fourmolu
    • check-success = fourmolu
  • any of [🛡 GitHub branch protection]:
    • check-neutral = hlint
    • check-skipped = hlint
    • check-success = hlint
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Bootstrap post job
    • check-skipped = Bootstrap post job
    • check-success = Bootstrap post job
  • any of [🛡 GitHub branch protection]:
    • check-neutral = whitespace
    • check-skipped = whitespace
    • check-success = whitespace
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Changelogs
    • check-skipped = Changelogs
    • check-success = Changelogs
  • #approved-reviews-by >= 2 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = docs/readthedocs.org:cabal
    • check-neutral = docs/readthedocs.org:cabal
    • check-skipped = docs/readthedocs.org:cabal
  • any of [🛡 GitHub branch protection]:
    • check-success = Check sdist post job
    • check-neutral = Check sdist post job
    • check-skipped = Check sdist post job

Reason

The merge conditions cannot be satisfied due to failing checks

Failing checks:

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

@mergify mergify Bot added queued and removed dequeued labels May 26, 2026
mergify Bot added a commit that referenced this pull request May 26, 2026
@mergify mergify Bot added dequeued and removed queued labels May 26, 2026
@philderbeast
Copy link
Copy Markdown
Collaborator Author

philderbeast commented May 26, 2026

GitHub CI is being flaky:

Download action repository 'haskell-actions/setup@v2' (SHA:cd0d9bdd65b20557f41bea4dbe43d0b5fbbfe553)
Error: An action could not be found at the URI 'https://codeload.github.com/haskell-actions/setup/tar.gz/cd0d9bdd65b20557f41bea4dbe43d0b5fbbfe553' (45C0:240863:1DFA7A:262A5B:6A159299)
Error: Failed to download archive 'https://codeload.github.com/haskell-actions/setup/tar.gz/cd0d9bdd65b20557f41bea4dbe43d0b5fbbfe553' after 1 attempts.
Download action repository 'actions/checkout@v6' (SHA:de0fac2e4500dabe0009e67214ff5f5447ce83dd)
Download action repository 'haskell-actions/run-fourmolu@v12' (SHA:015e6ed9db2b3f344482792d42b7317c764eb30f)
Error: An action could not be found at the URI 'https://codeload.github.com/haskell-actions/run-fourmolu/tar.gz/015e6ed9db2b3f344482792d42b7317c764eb30f' (3C00:77229:1D52F0:258463:6A159299)
Error: Failed to download archive 'https://codeload.github.com/haskell-actions/run-fourmolu/tar.gz/015e6ed9db2b3f344482792d42b7317c764eb30f' after 1 attempts.

@philderbeast
Copy link
Copy Markdown
Collaborator Author

@mergify queue

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 26, 2026

Merge Queue Status

This pull request spent 1 hour 55 minutes 42 seconds in the queue, including 1 hour 44 minutes 11 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 2 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Doctest Cabal
    • check-neutral = Doctest Cabal
    • check-skipped = Doctest Cabal
  • any of [🛡 GitHub branch protection]:
    • check-success = Meta checks
    • check-neutral = Meta checks
    • check-skipped = Meta checks
  • any of [🛡 GitHub branch protection]:
    • check-success = docs/readthedocs.org:cabal
    • check-neutral = docs/readthedocs.org:cabal
    • check-skipped = docs/readthedocs.org:cabal
  • any of [🛡 GitHub branch protection]:
    • check-success = Validate post job
    • check-neutral = Validate post job
    • check-skipped = Validate post job
  • any of [🛡 GitHub branch protection]:
    • check-success = fourmolu
    • check-neutral = fourmolu
    • check-skipped = fourmolu
  • any of [🛡 GitHub branch protection]:
    • check-success = hlint
    • check-neutral = hlint
    • check-skipped = hlint
  • any of [🛡 GitHub branch protection]:
    • check-success = Bootstrap post job
    • check-neutral = Bootstrap post job
    • check-skipped = Bootstrap post job
  • any of [🛡 GitHub branch protection]:
    • check-success = whitespace
    • check-neutral = whitespace
    • check-skipped = whitespace
  • any of [🛡 GitHub branch protection]:
    • check-success = Check sdist post job
    • check-neutral = Check sdist post job
    • check-skipped = Check sdist post job
  • any of [🛡 GitHub branch protection]:
    • check-success = Changelogs
    • check-neutral = Changelogs
    • check-skipped = Changelogs

@mergify mergify Bot added queued and removed dequeued labels May 26, 2026
mergify Bot added a commit that referenced this pull request May 26, 2026
@mergify mergify Bot merged commit 1b187fd into haskell:master May 26, 2026
80 checks passed
@mergify mergify Bot removed the queued label May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge me Tell Mergify Bot to merge ready and waiting Mergify is waiting out the cooldown period

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an hlint rule not to use nub

3 participants