[Haskell] Hierarchical module namespace
extensionnotsufficiently flexible
Simon Marlow
simonmar at microsoft.com
Wed Mar 9 04:53:35 EST 2005
On 09 March 2005 08:46, Simon Peyton-Jones wrote:
> That wasn't what I intended (though it would be possible) At present
> module M( module A ) where ...
> does not cause qualified names in the importing scope:
> import M as T -- introduces only f, g, T.f, T.g
> Simply using "as" on the export clause would not change that, would
> it?
> In fact, as John M says, it'd be a non-op.
>
> In short, my suggestion is that using "qualified" in an export list
> is the *only* way to introduce extra module qualifiers in an
> importing scope. Using "as" in an export item would serve only to
> change what the qualifier is, and is therefore irrelevant if you
> don't have "qualified".
Yes.
I'd like to question whether specifying the entities in a qualified
module export is really necessary. Most examples can be rewritten using
restricted imports instead, eg.:
module A ( qualified module B (f,g) ) where
import B
rewrites as:
module A ( qualfied module B' as B ) where
import B (f,g) as B'
import B
and I'm sure you can see how to rewrite the others.
Sure, the first version is more readable, but I question whether we need
the extra generality. It's extra rules in the syntax and extra work
that the implementation has to do.
The exception (as Simon already pointed out to me) is when you're
exporting entities defined by the current module, with a qualifier. You
can't rewrite that unless the implementation supports self-imports,
which I believe is tricky to implement (GHC doesn't support it).
Cheers,
Simon
More information about the Libraries
mailing list