Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,354
    • Issues 5,354
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 569
    • Merge requests 569
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #21879
Closed
Open
Issue created Jul 18, 2022 by Andreas Abel@abel

The logic behind the `unused-imports` warning is nonsense and a plague to the Haskell community

With -Wunused-imports, included in -Wall, GHC warns me (1) if I explicitly import an identifier from somewhere that is already implicitly imported from somewhere else, typically Prelude.

That is in most cases not what I want to be warned of. What I want to be warned of is this:

(2) I am explicitly importing an identifier that is unused, i.e., never referenced in my code.

But (1) is what we are all spending (wasting) our time on when it is triggered by changes in the Haskell ecosystem, that is, reexporting more things from Prelude etc.

To have (1) esp. in -Wall (combined with the volatility of base) is causing a lot of friction in the development process and wasting developer time of talented people on silly trivialities.

Something has to be done about this. Most urgently, (1) has to be removed from -Wall.

  1. Drop (1) from -Wunused-imports altogether. If this is too drastic:
  2. Package (2) in a new warning -Wactually-unused-imports and use this new warning in -Wall rather than -Wunused-imports.

Trigger: The process around adding liftA2 to Prelude.

  • https://github.com/haskell/containers/pull/841#issuecomment-1186732698
  • https://github.com/haskell/core-libraries-committee/issues/50
  • !8449 (merged)

Prior art: https://www.snoyman.com/blog/2020/11/haskell-bad-parts-2/

Haskell has a dumb set of default warnings enabled. [...]

So of course, we all turn on -Wall. Because we're good kids. We want to do the right thing. And this, of course, turns on unused import warnings. And because each new release of GHC and every library on Hackage likes to mess with us, we are constantly exporting new identifiers from different modules.

The amount of time I have spent adding weird hacks to account for the fact that <> is suddenly exposed from Prelude, and therefore my import Data.Monoid ((<>)) isn't necessary, is obscene. The introduction of fiddly CPP to work around this sucks. In fact, this all sucks. It's horrible.

I didn't realize how bad it was until I spent more time writing Rust. It reminded me that I never had these problems back as a Java developer. Or C++. This has been a Haskell-only problem for me.

Related issues:

  • #8363
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking