Warning about redundant import is wrong when hiding identifiers in order to avoid export ambiguities
Although warnings about redundant imports are almost perfect since GHC-6.12, I have a corner case, where the warning about a redundant import is wrong. Consider the module
module Data.Monoid.HT (cycle, ) where
import Data.Monoid (Monoid, mappend, )
import Data.Function (fix, )
import Prelude hiding (cycle, )
{- |
Generalization of 'Data.List.cycle' to any monoid.
-}
cycle :: Monoid m => m -> m
cycle x =
fix (mappend x)
GHC says:
src/Data/Monoid/HT.hs:6:1:
Warning: The import of `Prelude' is redundant
except perhaps to import instances from `Prelude'
To import instances alone, use: import Prelude()
I have to hide 'cycle' from Prelude if I want to export it unqualified.
I have several work-arounds: Export 'cycle' with qualification, use no export list at all, import from Prelude by enumeration of needed functions. I think this problem has low priority. I report it just for the case that someone claims that Haskell's module system is simple and could be more complicated. ;-)
Trac metadata
Trac field | Value |
---|---|
Version | 7.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |