Opened 19 months ago

Last modified 19 months ago

#14049 new feature request

relax -Wmissing-import-lists to allow one module with implicit imports when using NoImplicitPrelude

Reported by: cdepillabout Owned by:
Priority: normal Milestone:
Component: Compiler Version:
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


It would be nice to modify the -Wmissing-import-lists warning flag to allow one module with implicit imports when using the NoImplicitPrelude pragma.

For example, imagine the following program:

{-# LANGUAGE NoImplicitPrelude #-}

module Main where

import MyCustomPrelude

import Control.Monad.Trans.Reader (Reader, runReader)

what :: Reader Int String -> String
what x = runReader x 3

main :: IO ()
main = print "hello"

If this program is compiled with the -Wmissing-import-lists flag, the following warning will be produced:

example.hs:5:1: warning: [-Wmissing-import-lists]
    The module ‘MyCustomPrelude’ does not have an explicit import list

I think it would be nice if this warning did not appear.

Ideally, when using NoImplicitPrelude and -Wmissing-import-lists together, I would want one import per module to be permitted not to be explicit. This would make it possible to use an alternative Prelude and -Wmissing-import-lists at the same time.

Alternatively, a new warning flag could be created with the above behavior. Maybe it could be called something like -Wmulti-implicit-imports or -Wmulti-open-imports. I would appreciate feedback/suggestions for the name.

PureScript currently works like I have described above. By default the Prelude module is not imported (so you must explicitly import it), and the compiler will warn you if you have more than one implicit import. I really like this combination and it would be nice to be able to get the same thing in Haskell.

In case anyone is interested, here is the issue for PureScript where they talked about making this change.

If it seems like this is a good idea and other people are onboard, I'd be willing to implement it. I think it would be a relatively easy change, so it would be good for a first-time contributor.

Change History (1)

comment:1 Changed 19 months ago by cdepillabout

Summary: relax -Wmissing-import-lists to allow one module without implicit imports when using NoImplicitPreluderelax -Wmissing-import-lists to allow one module with implicit imports when using NoImplicitPrelude
Note: See TracTickets for help on using tickets.