Re-exporting namespaces

Malcolm Wallace Malcolm.Wallace at
Tue Jul 11 09:22:25 EDT 2006

Simon Marlow <simonmarhaskell at> wrote:

> Consider that at the moment, an import declaration can be considered
> completely  independently of the rest of the module.  Imports do not
> affect each other.                                      Under your
> proposal, all imports have to be considered  together to determine
> whether any are ambiguous.  We can't do Hugs-style  one-at-a-time
> import chasing, for example.

Ah, now I see what you are getting at.

Program P imports modules M and N.  How do the compiler know where M is
located?  It must presume the default namespace.  But then later, module
N might re-export a different namespace which means that M is now
ambiguous.  Conversely, let's say M is not available in the default
namespace.  So we must wait until module N has been imported, to see if
it brings a namespace into scope that does contain a module M.

Very nasty.

> I accept that the GhcPackages proposal has a serious shortcoming that
> your  proposal addresses, namely that there's no way to name a package
> in just one  place if you're using package-qualified imports.  I don't
> yet know of a good way  to fix this, but I'm fairly sure that
> generalising the module system with  namespaces is not a good
> power/weight tradeoff.

OK, I accept that my proposal for first-class namespaces is rather too
heavy a solution.  (But I still think the problem is a real one, and we
should keep thinking about other ways to solve it.)


More information about the Libraries mailing list