infelicity in module imports

Simon Marlow
Thu, 5 Jul 2001 10:12:42 +0100

Simon Peyton Jones writes:

> 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.

That's not my reading of the report, and it's not what GHC implements.

	import A (f)

brings only f and A.f into scope.

Relevant quotes from the report, section 5.3.1:

   "An import declaration that uses the qualified keyword brings
    into scope only the qualified names of the imported entities
    (Section 5.5.1); if the qualified keyword is omitted, both
    qualified and unqualified names are brought into scope"

and section 5.5.1:

   "An import declaration, whether qualified or not, always brings
    into scope the qualified names of the imported entity."=20

[ aside: should that last word be "entities"? ]

I'm taking the term "the imported entities" to mean those entities
specified in the import list, or all the exported entities if the import
list is omitted.  If it doesn't mean this, what's the point of allowing
import specifications on a qualified import?  If it does mean this, then
GHC is correct, but the report's comments about the effect of hiding on
qualified names is inconsistent and should be removed (GHC doesn't
implement this rule either).

Perhaps this is the wrong interpretation, and Simon's is the correct
one.  But no where that I can find does the report say that an import
always brings into scope *all* the qualified names from the imported
module regardless of the import list.