[Haskell] Hierarchical module namespaceextensionnotsufficiently flexible

Simon Marlow simonmar at microsoft.com
Fri Mar 11 08:45:25 EST 2005

On 11 March 2005 10:56, Simon Peyton-Jones wrote:

>> module A (qualified module A) where { f = 'f' }
>> module B (module A) where { import A; ... }
>> module C  where { import B; ... }
>> How do we refer to 'f' in B?  I think the proposal suggests "A.f" or
>> "A.A.f". How do we refer to 'f' in C?  I think the proposal suggests
>> that "f" 
>> is not in scope in C.
>> The reason is that "B" does not export "f",  because there is no "f"
>> and "A.f" in scope.
> Correct, according to the rules I suggested.
>> It seems that we cannot re-export qualified exports using
>> module-style exports.   Is this the intended design choice, or am I
>> missing 
>> something?
> Hmm.  If you said
> 	module B( module A.A ) where { import A; ... }
> then since A.A.f and A.f are in scope, presumably A.f is exported,
> just as it was from A. 

I'm not sure about that... the exact wording of the report is:

  The form "module M" names the set of all entities that are in scope
  with both an unqualified name e and a qualified name M.e

If M is A.A, then both A.A.f and f need to be in scope, which they
aren't in this example.

But, going back to the original example:

  module A (qualified module A) where { f = 'f' }
  module B (module A) where { import A; ... }

if we take e==A.f, then by the report's rule, module B exports A.f.  So,
the rule in the report works if we allow e to scope over qualified
names.  This is a bit of a hack, and it changes the meaning slightly
even in the absence of 'qualified module' exports, so this might have
some undesirable consequences.

On the other hand, this interpretation does allow you to re-export
*everything* from an imported module, including any names it exported
via 'qualified module', which is what we want.

To avoid confusion, here's a concrete proposal:

  'qualified module A as B' exports the set of all entities e that are
  in scope as both e and A.e, as B.e. [John Meacham/SimonPJ suggestion]

  'module A' exports the set of all entities e that are in scope
  as both e and A.e, as e.  [Haskell 98]

  In both cases, e can scope over qualified names. [new addition]

(restricting the exports with (..) or hiding (..) can be added too; I
just left it out for simplicity).

Here are some useful past threads:


unfortunately I can't find exactly what I was looking for, namely the
motivation that lead to the current clever rule for 'module M' exports.


More information about the Libraries mailing list