Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding explicit imports for ghc's -Wmissing-import-lists

GHC generates warnings when there are implicit imports (see below). The goal is to replace these with explicit imports. Is there an automated way to generated the list (instead of manually finding it in code)?

/Users/srid/code/slownews/backend/src/SlowNews/Main.hs:10:1: warning: [-Wmissing-import-lists]
    The module ‘Control.Exception’ does not have an explicit import list
   |
10 | import           Control.Exception
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/Users/srid/code/slownews/backend/src/SlowNews/Main.hs:13:1: warning: [-Wmissing-import-lists]
    The module ‘Control.Monad.IO.Class’ does not have an explicit import list
   |
13 | import           Control.Monad.IO.Class
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
like image 207
Sridhar Ratnakumar Avatar asked Dec 23 '17 17:12

Sridhar Ratnakumar


2 Answers

GHC has a -ddump-minimal-imports flag which will do the trick.

like image 186
Daniel Wagner Avatar answered Sep 20 '22 01:09

Daniel Wagner


There's an open pull request un importify tool which I'm working on. After this is done you will be able to convert implicit imports to explicit automatically:

https://github.com/serokell/importify/pull/82

like image 40
Shersh Avatar answered Sep 21 '22 01:09

Shersh