[Haskell] Re: Hierarchical module namespace extension not sufficiently flexible

Andre Pang ozone at algorithm.com.au
Mon Mar 7 01:39:33 EST 2005


On 06/03/2005, at 11:23 PM, Duncan Coutts wrote:

> We can do it too except that to use qualified names, users would have 
> to
> import dozens of modules:
> import Graphics.UI.Gtk.This
> import Graphics.UI.Gtk.That
> import Graphics.UI.Gtk.TheOther.

Not that this is a fantastic solution (and perhaps you're doing this 
already), but one technique is to make a module named Graphics.UI.Gtk 
(i.e. Graphics/UI/Gtk.hs), which imports all the submodules for you and 
re-exports all of them:

     module Graphics.UI.Gtk
       ( Graphics.UI.Gtk.This
       , Graphics.UI.Gtk.That
       , Graphics.UI.Gtk.TheOther
       )

     where

     import Graphics.UI.Gtk.This
     import Graphics.UI.Gtk.That
     import Graphics.UI.Gtk.TheOther

(or you can call the module Graphics.UI.Gtk.all, or something.)  It's 
somewhat feasible to do if you're machine-generating it, but obviously 
pretty unmaintainable if you have to write it all by hand ...


-- 
% Andre Pang : trust.in.love.to.save



More information about the Haskell mailing list