[GHC] #3992: Redundant import warning is sometimes not correct
GHC
cvs-ghc at haskell.org
Thu Apr 15 18:05:54 EDT 2010
#3992: Redundant import warning is sometimes not correct
---------------------------------+------------------------------------------
Reporter: basvandijk | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 6.12.1 | Keywords:
Os: Unknown/Multiple | Testcase:
Architecture: Unknown/Multiple | Failure: Incorrect warning at compile-time
---------------------------------+------------------------------------------
When working on my usb-safe library I just discovered a warning message
that doesn't seem right.
Suppose you have the following three modules:
(I tried to trim down the problem so I simplified and changed most types,
classes, instances and functions. They don't matter for this discussion.
The only things that matter are the names that are in- and exported)
{{{Resource.hs:}}}
{{{
{-# LANGUAGE TypeFamilies #-}
module Resource ( Resource, Handle, open, close ) where
class Resource r where
data Handle r :: *
open :: r -> IO (Handle r)
close :: Handle r -> IO ()
}}}
{{{Region.hs:}}}
{{{
module Region ( open, run ) where
open :: Char -> String
open = (:[])
run :: Maybe a -> Bool
run = maybe False (const True)
}}}
{{{USB.hs:}}}
{{{
{-# LANGUAGE TypeFamilies #-}
module USB ( Device(..)
, claim
, foo
, module Region
) where
import Resource ( Resource, Handle, open, close )
import Region
import qualified Region as QualifiedRegion ( open )
newtype Device = Device {unDevice :: Int}
instance Resource Device where
data Handle Device = DeviceHandle Int
open = return . DeviceHandle . unDevice
close = const $ return ()
claim :: Char -> String
claim = QualifiedRegion.open
foo :: Maybe a -> Bool
foo = run
}}}
When I load USB.hs in ghci with all warnings on I get the following
warning:
{{{$ ghci -Wall USB.hs}}}
{{{
USB.hs:9:0:
Warning: The import of `Resource.open'
from module `Resource' is redundant
Ok, modules loaded: USB, Region, Resource.
}}}
Why is {{{Resource.open}}} redundant while I use it in an instance
declaration?
If the warning is correct so {{{Resource.open}}} is redundant we can just
as well remove the import. However when I remove it I get the following
error:
{{{
USB.hs:18:4: `open' is not a (visible) method of class `Resource'
Failed, modules loaded: Region, Resource.
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3992>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list