Explicit import lookup for ghc -Wmissing-import-lists

GHC generates warnings when there is an implicit import (see below). The goal is to replace them with explicit imports. Is there an automatic way to create a list (instead of manually finding it in the 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
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+6
source share
3 answers

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

+5
source

There is an open tool here importifythat I am working on. After that, you can automatically convert the implicit import to explicit:

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

+1
source

Haskell Tools . -, Atom, - macOS. . . Main.hs :

module Main where

import System.Environment

doMain = print =<< getEnvironment

main = doMain

, Haskell Tools :

$ stack install haskell-tools-daemon haskell-tools-cli fswatch

:

$ ht-refact -e 'ProjectOrganizeImports' .

git , diff:

-import System.Environment
+import System.Environment (getEnvironment)

- Haskell Tools , . .

0

All Articles