[Haskell] Re: Data.Set whishes

Alastair Reid alastair at reid-consulting-uk.ltd.uk
Thu Feb 26 08:19:55 EST 2004


> I have always wondered why the module system is not used at
> all in these conventions. I mean, the function names seem to
> come straight from the Haskell 1.2 days when there was no
> module system!

I used the module system in this way in the first version of the HGL 
(http://haskell.org/graphics/).  For example, fonts, colours, etc all 
provided three operations 'create', 'delete' and 'select' instead of 
'createFont', 'createColor', etc.  If (as was common), you imported several 
of these modules, you would use 'Font.create', 'Color.create', etc.  All 
seemed very clean.

I deliberately switched away from this in the second release because it wasn't 
working very well.  The problem is that most users don't want to have to 
write:

  import Font
  import Color
  import Window
  [about 10 such modules in total]

they just want to write:

  import Graphics

where the Graphics module imports Font, Color, Window, etc and re-exports 
them.

The problem is that you can't use any of the 'create' functions if you import 
Graphics since any reference to 'Graphics.create' would be ambiguous.

Haskell's module system provides a way for a module to merge multiple modules 
into one but provides no way to eliminate any ambiguities this may create.  
If we want to be able to use names like 'create' instead of 'createFont', we 
need to change the module system.  The obvious fix would have some of the 
flavour of the ML module system where a module can export a structured list 
of names instead of exporting a flat list of names.

--
Alastair Reid



More information about the Haskell mailing list