Skip to content

Add -Wcompat-unqualified-imports to -Wall (transitively?)

This ticket is to track the first step of the plan in CLC proposal 22: "Clarify the situation around Data.List" (link to the plan), which amounts to enabling -Wcompat-unqualified-imports as a part of -Wall. Old discussions for some context: #20025 (closed).

In the first comment of the CLC thread @mpickering says:

Wait for -Wcompat to become part of -Wall (which is happening and will be a part of 9.4)

I could not find any trace of it, unfortunately. Matt, is there any prior work on this? Currently, with 9.4.1-alpha3 I get no warning, as shown below.

❯ cat Main.hs
import Data.List

main :: IO Int
main = pure . sum $ sort []

❯ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.4.0.20220623

❯ ghc Main.hs -fforce-recomp -Wall
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking Main [Objects changed]

❯ ghc Main.hs -fforce-recomp -Wcompat
[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:1:8: warning: [-Wcompat-unqualified-imports]
    To ensure compatibility with future core libraries changes
    imports to Data.List should be
    either qualified or have an explicit import list.
  |
1 | import Data.List
  |        ^^^^^^^^^
[2 of 2] Linking Main [Objects changed]

Question: how do we do it?

There were talks to include -Wcompat into -Wall altogether. But this idea has been considered before, see #11494 (closed) (championed by @bgamari), and rejected. Should it be pursued anyway? Or should -Wcompat-unqualified-imports enter -Wall solely?

/cc @Bodigrim

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information