Commit 996b8096 authored by simonpj's avatar simonpj
Browse files

Tests for unused imports

parent 33ea1e21
{-# OPTIONS_GHC -fwarn-unused-imports #-}
module Test where
import qualified Control.Monad (ap)
import qualified Control.Monad.Reader
foo :: IO ()
foo = return id `Control.Monad.ap` return ()
T1074.hs:5:0:
Warning: The import of `Control.Monad.Reader' is redundant
except perhaps to import instances from `Control.Monad.Reader'
To import instances alone, use: import Control.Monad.Reader()
{-# OPTIONS_GHC -fwarn-unused-imports #-}
module Test where
import qualified System.FilePath as FilePath.Native
( joinPath )
import qualified System.FilePath.Posix as FilePath.Posix
( joinPath, splitDirectories )
import qualified System.FilePath.Windows as FilePath.Windows
( joinPath )
data TarPath = TarPath FilePath -- path name, 100 characters max.
FilePath -- path prefix, 155 characters max.
fromTarPath, fromTarPathToPosixPath
, fromTarPathToWindowsPath :: TarPath -> FilePath
fromTarPath (TarPath name prefix) =
FilePath.Native.joinPath $ FilePath.Posix.splitDirectories prefix
++ FilePath.Posix.splitDirectories name
fromTarPathToPosixPath (TarPath name prefix) =
FilePath.Posix.joinPath $ FilePath.Posix.splitDirectories prefix
++ FilePath.Posix.splitDirectories name
fromTarPathToWindowsPath (TarPath name prefix) =
FilePath.Windows.joinPath $ FilePath.Posix.splitDirectories prefix
++ FilePath.Posix.splitDirectories name
{-# OPTIONS_GHC -XFlexibleContexts -fwarn-unused-imports #-}
module ArrayBoundedU
( T
, create
, at
) where
import Data.Ix
import qualified Data.Array.Unboxed as Array
import Data.Array.Base (unsafeAt)
newtype T i e = T (Array.UArray i e)
create :: (Ix i, Bounded i, Array.IArray Array.UArray e) => [(i,e)] -> T i e
create ies = T (Array.array (minBound, maxBound) ies)
at :: (Ix i, Bounded i, Array.IArray Array.UArray e) => T i e -> i -> e
at (T a) i = unsafeAt a (index (minBound, maxBound) i)
{-# OPTIONS_GHC -fwarn-unused-imports -Werror #-}
module T2267 where
import qualified Data.ByteString as B
import qualified Data.ByteString.UTF8 as BU
toString :: B.ByteString -> String
toString = BU.toString
fromString :: String -> B.ByteString
fromString = BU.fromString
......@@ -325,3 +325,8 @@ test('mod179', extra_clean(['Mod179_A.hi', 'Mod179_A.o']),
test('mod180', extra_clean(['Mod180_A.hi', 'Mod180_A.o', 'Mod180_B.hi', 'Mod180_B.o']),
multimod_compile_fail, ['mod180', '-v0'])
test('T1148', normal, compile, [''])
test('T1074', normal, compile, [''])
test('T1074a', normal, compile, [''])
test('T2267', normal, compile, [''])
module ShouldCompile where
import Prelude ()
import Control.Monad( Monad(return), mapM )
-- Should report Monad and return as unused imports
import GHC.Base
......
mod176.hs:3:22:
Warning: Imported from `Control.Monad' but not used: `return'
mod176.hs:3:22:
Warning: Imported from `Control.Monad' but not used:
type constructor or class `Monad'
mod176.hs:4:0:
Warning: The import of `return, Monad'
from module `Control.Monad' is redundant
module ShouldCompile where
import Prelude ()
import Data.Maybe( Maybe(..) )
import Data.Maybe
......
mod177.hs:3:19:
Warning: Redundant import of: `Maybe'
It is also imported from Data.Maybe at mod177.hs:4:0-16
mod177.hs:4:0:
Warning: The import of `Data.Maybe' is redundant
except perhaps to import instances from `Data.Maybe'
To import instances alone, use: import Data.Maybe()
rn037.hs:3:0:
Warning: Module `Time' is imported, but nothing from it is used,
except perhaps instances visible in `Time'
To suppress this warning, use: import Time()
Warning: The import of `Time' is redundant
except perhaps to import instances from `Time'
To import instances alone, use: import Time()
rn046.hs:2:0:
Warning: Module `List' is imported, but nothing from it is used,
except perhaps instances visible in `List'
To suppress this warning, use: import List()
Warning: The import of `List' is redundant
except perhaps to import instances from `List'
To import instances alone, use: import List()
rn046.hs:3:13: Warning: Imported from `Char' but not used: `ord'
rn046.hs:3:0:
Warning: The import of `ord' from module `Char' is redundant
......@@ -3,6 +3,8 @@
module Bug ( Structure (..) ) where
import Prelude hiding( Rational )
-- Rational is exported by Prelude
import Data.Ratio ( Rational )
data Structure a where
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment