infelicity in module imports

Simon Peyton-Jones simonpj@microsoft.com
Wed, 11 Jul 2001 04:14:59 -0700


Folks

It seems that I forgot to send this message a couple of weeks ago.
Assuming that silence meant assent, I implemented the proposal below
in the report I put out yesterday.  But in this case silence meant you
hadn't=20
been asked (an excellent way to reach consensus that I must remember
for the future).

So here's the message anyway.  I don't think it's controversial, since
it's
the outcome the cognoscenti were seeking, and no one else will care.
Well, so I hope!

Simon


| > In short, an import *always* brings the entire *qualified*=20
| > set of names into scope. Hiding and revealing applies only
| > to unqualified names.  I must say that I thought GHC implemented
| > this rule; if not I should fix it.
|=20
| That's not my reading of the report, and it's not what GHC implements.
|=20
| 	import A (f)
|=20
| brings only f and A.f into scope.


How embarassing.  Now I look at it (yet) again, the report is certainly
ambiguous about whether=20
	import A(f)
imports A.g as well.  But SimonM is right to say that the implication
is that it does *not*  (contrary to my earlier message).  But if it does
not,
then the treatment of hiding and explicit-listing is inconsistent, which
is
a Bug.


There are two consistent positions

1. Every import of module A (no matter how constrained) imports=20
all of A's exports with qualified names.  Import of qualified names is
unaffected by both hiding clauses and the explicit entity list

2. The explicit entity list, or hiding clause, for an import determines
which
entities are imported.  The qualified names of all these entities are
brought
into scope; in addition, for an unqualified import the unqualified names
are
brought into scope too.


Everyone who has spoken favours (2), and indeed GHC implements it.
So I propose to change the report to say that much more explicitly.

Any objections? =20

Simon