[Haskell-cafe] No warning for unused import on first line

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Sat Dec 6 20:01:13 UTC 2014


Using GHC 7.6.3, if I have

```

import Data.List

main :: IO ()
main = return ()
```

then I get a warning as expected.

```
% ghc -fforce-recomp -Wall test1.hs
[1 of 1] Compiling Main             ( test1.hs, test1.o )

test1.hs:2:1: Warning:
    The import of `Data.List' is redundant
      except perhaps to import instances from `Data.List'
    To import instances alone, use: import Data.List()
Linking test1 ...
```

However, if `import Data.List` appears on the first line, i.e. with no blank
line at the top of the file

```
import Data.List

main :: IO ()
main = return ()
```

then I get no warning.

```
% ghc -fforce-recomp -Wall test1.hs
[1 of 1] Compiling Main             ( test1.hs, test1.o )
Linking test1 ...
```

Can anyone explain this?

Tom


More information about the Haskell-Cafe mailing list