infelicity in module imports
Thu, 12 Jul 2001 10:06:44 +0200
Brian Boutel wrote
> Option 2 is closer to what the syntax of imports, read as English, sugg=
> is intended, but, if it wasn't for that, I'd be promoting option 1.
> The primary purpose of being able to restrict imports is to avoid name
> clashes, and with qualified import there is no risk of a clash, so no n=
> for restrictions.
This is not true since Haskell allows for the renaming of modules on =
imports. If you look at the example in section 5.3.2 of the report, =
there is the example
module M where
import qualified Foo as A
import qualified Bar as A
x =3D A.f
Obviously there is a name clash if both, Foo and Bar export symbol f.
> Even with option 2, there is scope for confusion. "Import" without
> "qualified", imports both qualified and unqualified names, but adding t=
> word "qualified" doesn't make any difference to the position of qualifi=
> names, but instead silently fails to import unqualified names.
I don't understand what confusion you see here. What do you mean by the =
"position of names"?
> There is still a strange asymmetry, too. Whereas adding "qualified" to
> "import Modname ( a, b, c)" doesn't change which entities are imported,=
> the ability to refer to them by unqualified names, adding qualified" to=
> "import Modname hiding ( a, b, c)" has the effect of importing everythi=
> that was previously hidden.
I don't see that this applies to option 2. Maybe the formulation is =
still not clear enough, but in my reading (and I think this is the =
intended one) it says that the list of imported entities is the same =
regardless of whether you use qualified on the import or not. The =
qualified keyword only prevents the use of unqualified references to =
these entities. So if in your example the module Modname exports =
entities a, b, c, d, and e, then after import Modname hiding (a,b,c) =
only d and e are imported and then same is true for import qualified =
Modname hiding (a,b,c)
> Simon Peyton-Jones wrote:
> [...] =
> > There are two consistent positions
> > 1. Every import of module A (no matter how constrained) imports
> > all of A's exports with qualified names. Import of qualified names i=
> > unaffected by both hiding clauses and the explicit entity list
> > 2. The explicit entity list, or hiding clause, for an import determin=
> > which
> > entities are imported. The qualified names of all these entities are=
> > brought
> > into scope; in addition, for an unqualified import the unqualified na=
> > are
> > brought into scope too.
Wolfgang Lux Phone: +49-251-83-38263
Institut fuer Wirtschaftinformatik FAX: +49-251-83-38259
Universitaet Muenster Email: email@example.com