-ddump-minimal-imports confused if first line is an import
On reddit, Chris Done posted this example:
chris@midnight:~$ cat > x.hs
import Control.Applicative
main = show <$> pure 1 >>= print
chris@midnight:~$ ghc x.hs -ddump-minimal-imports
[1 of 1] Compiling Main ( x.hs, x.o )
Linking x ...
cachris@midnight:~$ cat Main.imports
import Control.Applicative
( print, (>>=), show, Applicative(pure), (<$>) )
I noted that this is wrong, for example print isn't exported from Control.Applicative:
>>> import Control.Applicative (print)
<interactive>:1:29:
Module `Control.Applicative' does not export `print'
hvr explains: for some reason GHC gets confused if the very first string in the .hs file is import; try adding anything, such as a newline or module Main where and it works as expected...
I couldn't find a relevant bug for this.
Trac metadata
| Trac field | Value |
|---|---|
| Version | |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |