special handling of "Main.hs" contradicts Report
Mark Tullsen
mtullsen at cse.ogi.edu
Thu Apr 24 17:26:31 EDT 2003
Simon Marlow wrote:
>>The problem comes when I try to import the module.
>>Note:
>> tests $ cat X.hs
>> module X where t1 = t1
>>
>> tests $ cp X.hs Main.hs
>>
>> tests $ ghc -c X.hs Main.hs
>>
>> tests $ ghc --show-iface X.hi
>> __interface "Main" X 2 where
>> __export X t1;
>> import GHC.Base ! :: 1;
>> import Foreign.Ptr !;
>> ;
>> 1 t1 :: forall t. t;
>> (1, [])
>>
>> tests $ ghc --show-iface Main.hi
>> __interface "Main" Main 5 where
>> import GHC.IOBase :: 1;
>> import GHC.TopHandler :: 1;
>> import GHC.Base ! :: 1;
>> import Foreign.Ptr !;
>> import System.IO :: 1;
>> ;
>> 1 ($main) :: GHC.IOBase.IO ();
>> (1, [])
>>
>>
>
>You shouldn't have a Main.hi at all: it must be left over from a
>previous compilation of a Main module. The interface filename always
>follows the module name (unless you've used any obscure flags), not the
>source filename.
>
>Cheers,
> Simon
>
Oops, your right. Unfortunately this is just a bug in my "bug report",
there still
seems to be a contradiction with the report:
The report leads one to believe "module Main where ..." should export
all top-level entitities just the same as if we were defining a module
by another name.
Note this:
$ cat > Main.hs
module Main where {t1 = t1 ; main = main }
$ ghc -c Main.hs; ghc --show-iface Main.hi
__interface "Main" Main 2 where
import GHC.IOBase :: 1;
import GHC.TopHandler :: 1;
import GHC.Base ! :: 1;
import Foreign.Ptr !;
;
1 ($main) :: GHC.IOBase.IO ();
(1, [])
$ cat > Main.hs
module Main (module Main) where {t1 = t1 ; main = main }
$ ghc -c Main.hs; ghc --show-iface Main.hi
__interface "Main" Main 3 where
__export Main main t1;
import GHC.IOBase :: 1;
import GHC.TopHandler :: 1;
import GHC.Base ! :: 1;
import Foreign.Ptr !;
;
1 ($main) :: GHC.IOBase.IO ();
1 t1 :: forall t. t;
1 main :: forall t. t;
(1, [])
I would expect that the first Main.hs would export t1 just as the second
does.
Thanks,
Mark
More information about the Glasgow-haskell-bugs
mailing list