foreign exports not taken into account when calculating -fwarn-unused-imports
Here we have a program that imports and uses
Control.Monad, but only as a result of being used in the definition of a function that is foreign exported.
module Foo () where import Control.Monad (liftM) foo :: IO () foo = id `liftM` return () foreign export ccall "hs_foo" foo :: IO ()
GHC 6.6 and HEAD report:
foo.hs:3:0: Warning: Module `Control.Monad' is imported, but nothing from it is used, except perhaps instances visible in `Control.Monad' To suppress this warning, use: import Control.Monad()
So I suppose all that needs to happen is to add in foreign exports as roots when building the usage graph.