haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.62k stars 691 forks source link

Ability to warn on `reexported-modules` #10384

Open parsonsmatt opened 4 weeks ago

parsonsmatt commented 4 weeks ago

Describe the feature request

When declaring reexported-modules in a cabal file, it would be useful to communicate deprecation and relocation notices when that module is imported and only provided by that package.

Additional context

The idea was surfaced by @adamgundry in this comment about relocating the GHC.RTS.Flags module. We want to move the module from base to another package. If we only move the module, then users that depend on base but not ghc-rts-flags will face an unhelpful error message: "Module GHC.RTS.Flags not found." If we re-export the module, then it's still part of the public API of base. This means we can't offer a nice deprecation cycle with messaging on how to fix the resulting issue.

Let's imagine that we do this:

-- old-package.cabal
name: old-package

build-depends: new-package

reexported-modules:
  new-package:MovedModule deprecated:"This module has been removed from old-package and will be available from new-package."

If someone imports MovedModule and it comes from old-package as a re-exported module, then we emit a warning at the import site. If they import MovedModule and they depend on new-package as well, then we don't need to issue the warning.

Ericson2314 commented 2 weeks ago

See also

https://github.com/ghc-proposals/ghc-proposals/discussions/489

https://gitlab.haskell.org/ghc/ghc/-/issues/22489

this really need to happen (I thought it did already?)