I'm getting strange behavior from both GHC and Hugs w.r.t. module
exportations.  They disagree with each other somewhat and both seem wrong,
although I'm not certain I understand the report on this matter.

Here are two test programs.  First Test1.hs:

    module Test1 (module Test1) where
    main = putStrLn "Test1's main"
    foo = "Test1 foo"

In Test2.hs, I want to modify and extend Test1, keeping "foo" but
replacing main.

    module Test2 (module Test1, module Test2) where
    import Test1 hiding (main)
    main = putStrLn "Test2's main"
    bar = foo ++ " plus Test2 bar"

I also have test programs TMain1.hs:

    module Main where
    import qualified Test1 as Test
    main = Test.main

and TMain2.hs:

    module Main where
    import qualified Test2 as Test
    main = Test.main

and makefile rules:

    test1.exe : Test1.o TMain1.o
    test2.exe : Test2.o Test1.o TMain2.o

Compiling and running these guys under GHC, I get:

    c:\Users\conal\Fran\demos\CurveEditor>test1
    test1
    Test1's main

    c:\Users\conal\Fran\demos\CurveEditor>test2
    test2
    Test1's main

Under Hugs, I get this same behavior

    c:\Users\conal\Fran\demos\CurveEditor>runhugs TMain1
    Test1's main

    c:\Users\conal\Fran\demos\CurveEditor>runhugs TMain2
    Test1's main

Swapping the export order in Test2 gives me what I want in Hugs:

    c:\Users\conal\Fran\demos\CurveEditor>runhugs TMain2
    Test2's main

but no change in GHC.

    c:\Users\conal\Fran\demos\CurveEditor>make test2.exe
    rm -f Test2.o
    /fptools/bin/i386-unknown-cygwin32/ghc-2.09/ghc  -fglasgow-exts
-concurrent -recomp -cpp
-i../../src:../../src/GHC:../../gc/GHC:/fptools/lib/i386-unknown-cygwin32/gh
c-2.09/win32 -c Test2.hs -o Test2.o -ohi Test2.hi
    Module version unchanged at 3
    /fptools/bin/i386-unknown-cygwin32/ghc-2.09/ghc  -fglasgow-exts
-concurrent -recomp -cpp
-i../../src:../../src/GHC:../../gc/GHC:/fptools/lib/i386-unknown-cygwin32/gh
c-2.09/win32 -optl-u -optl_NoRunnableThreadsHook -o test2 \
      Test2.o Test1.o TMain2.o -L../../src
-L/fptools/lib/i386-unknown-cygwin32/ghc-2.09/win32 -lFran -lWin32
-L../../SpriteLib -lSpriteLib -luser32 -lgdi32

    c:\Users\conal\Fran\demos\CurveEditor>test2
    Test1's main

Section 5.1.1 of the Haskell 1.4 report says:

    The set of all entities brought into scope from a module m by one or
    more unqualified import declarations may be named by the form `module
    m', which is equivalent to listing all of the entities imported from
    the module.

- Conal

Reply via email to