[Haskell] Hierarchical module namespace extension not sufficiently flexible

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Sat Mar 5 12:03:38 EST 2005


On Fri, 2004-12-17 at 14:26 +0000, Duncan Coutts wrote: 
> All,
> 
> So here's the problem: we have a binding to a large foreign library (GTK) which
> we are trying to fit nicely into hierarchical module name space. It would live under
> 
> Graphics.UI.Gtk
> Graphics.UI.Gtk.Button
> Graphics.UI.Gtk.Frame
> ... etc
> 
> Now there are over 100 modules directly under Graphics.UI.Gtk and you don't want
> to have to import each one of them separately. Of course you will not use all of
> them in one module but you might reasonably use 20+ of them.
> 
> So it'd be nice to be able to say:

[snip]

Or as an alternative to exporting qualified names as I proposed before
(ie Graphics.UI.Gtk exports the qualified name "Button.label") how about
this:

import qualified Graphics.UI.Gtk.*

which just means import every module under Graphics.UI.Gtk qualified
with it's module name so that then you could reference:

Button.label

A downside to such a scheme is that it might make it too easy to import
internal modules or modules that are not supposed to be used together.

I think on balance I prefer putting the power in the hands of the
library author by letting modules export other modules' contents
qualified with the module name

module Graphics.UI.Gtk (
  qualified module Graphics.UI.Gtk.Button as Button,
  ...

Any other ideas of how to wrap large existing name spaces? The .Net and
Java people would have the same problem: to use nice qualified names
under the current module system, users would have to import 100's of
modules.

Duncan



More information about the Libraries mailing list