TheCriticalImperitive
TheCriticalImperitive

Reputation: 1457

Warning: The import of `Module` is redundant except perhaps to import instances from `Module`

I've recently started coding in Sublime Text. This has brought to my attention some warnings I didn't notice when I used Leksah. So I got this one:

import qualified Data.Set as S

Gives:

Warning:
  The qualified import of `Data.Set' is redundant
    except perhaps to import instances from `Data.Set'
  To import instances alone, use: import Data.Set()

On the other hand, either of these two imports from Data.Foldable don't give any warnings:

import Data.Foldable (foldrM, mapM_,foldr,foldl',concat)
-- or
import Data.Foldable

So I'm not really sure what the warning for Data.Set means. I would expect "redundant" means that it's not necessary. If I remove the import it doesn't compile because I'm using a lot of things for Data.Set.

Meanwhile sitting next to it is import qualified Data.Map as M which also gives no warnings.

So I'm completely confused about what that warning is saying.

Upvotes: 5

Views: 2591

Answers (1)

zigazou
zigazou

Reputation: 1755

It generally means either :

  • you import a module but you don’t use it at all,
  • you import a module that is already imported by another module you import.

It may be the effect of some refactoring where you don’t use the module anymore. Or maybe you’ve anticipated the future use of this module by importing it.

This message is generated when you compile your project using the -Wall option.

Try to delete the line which shows the error, it often works ;-)

Upvotes: 7

Related Questions