scope in ghci

Fri, 05 Oct 2001 15:14:15 +0400

Dear GHC,

Consider the following question concerning scopes in  
ghc -interpreted. 

A large application called  D  consists of 70 modules, 
it reexports all its public items via module  DExport.
It has also demonstration examples            Dm1.hs ... Dm9.hs.
Each example imports 4-5 modules from  D
and lists precisely the imported items, like this:
                                        import List (sort) 
                                        import Foo1 (f, g, Dt(..)) 

There also exists the total  Dm.hs  which reexports   
Dm1 ... Dm9  and adds the total `test' function.

All this compiles successfully (Dm* may skip compilation).

Then,          ghci -package D  Dm1
               Dm1> sort $ dm1 [1%2,1%3]    -- contrived example
is impossible.
Instead, it needs        
            Dm1> List.sort Prelude.$ dm1 [1 Ratio.% 2, 1 Ratio.% 3]

Also the user is expected to command     :m DExport
and work with other modules than  Dm*.

I try to improve this as follows. Add

  (...module Prelude, module List, module Ratio, module Random...)

  import Prelude; import List; import Ratio; import Random;
to  DExport.hs
and replace the import part in  Dm1.hs ... Dm9.hs
                       import DExport

Formally, everything works. But I doubt.
DExport imports and exports so many things that it looks natural 
to add all the standard Haskell library to it.
But the imports of  Dm1.hs ... Dm9.hs  are different.
I wonder, what is the difference between
                                 M.hs:  ...import Foo (f,g)
and                              N.hs:  ...import DExport 

First, suppose  M.hs  contains name clashes with  DExport  
and wants to avoid qualified names.
Second, when compiling  M.hs  the name search is smaller
(would it compile any essentially faster?). 
Third, how GHC will react at                 :load Dm
By occasion, would not it load 9 copies of DExport ?
Shortly: is this all right to set  import DExport
to all the above  Dm* ?

Thanks to everyone for possible advice.

Serge Mechveliani