haskell / haskell/cabal

Ability to warn on `reexported-modules`

Open
#10,384 1 comment 2 reactions 0 assignees View on GitHub
type: enhancement
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**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](https://github.com/haskell/core-libraries-committee/issues/289#issuecomment-2379409348). 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.

Contributor guide

Open the contributing guide

Research direction

Start by tracing how Cabal reads the reexported-modules field in a cabal file and how imports are resolved when a module is re-exported. Use the old-package/new-package example and the GHC.RTS.Flags relocation context to define the warning conditions and confirm that imports from new-package are not warned.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.