module namespaces

Malcolm Wallace malcolm@abbess.demon.co.uk
Thu, 08 Mar 2001 20:21:57 +0000


Johannes Waldmann wrote:
> 
> I think the namespace proposal wants to be strictly upward compatible,
> therefore it's perhaps not the right time to discuss this ...
> but still I think the question "why should the source text of a module
> contain its name?" wants an answer.

Perhaps.  But it is required in Haskell'98, and I don't intend to
move away from the standard too far.

> Even if we stick to module headers, I don't really like the idea of
> `module Fully.Qualified.Name where ..'

Initally I thought this might be very verbose, and perhaps people
would be reluctant to use long names.  However, after playing with
adding full hierarchical names to several hundred modules, I
discovered I liked using the longer names.

They give extra clarity, and in practice you only have to write them
once or twice per module, so very little extra keyboard-pounding is
required.  I'm also a fan of import-renaming, and would highly
recommend that the style
    import qualified Very.Long.And.Tedious.Module.Name as X
be used more frequently, even for shorter names:
    import Pretty as PP

> Then I am not allowed
> to move (precompiled) modules around physically.

The question of where the interface/object files are stored
is really a matter for the compiler.  The location in the
namespace hierarchy is conceptually independent (although for
most systems I suppose it is likely to coincide).

> That's why I want some means of renaming them (during importing),
> and as I wrote earlier, not only for single modules (`import Foo as Bar')

Easily done using the current Haskell'98 mechanism.

> but also for complete hierarchies (`import Leipzig.Standard as Standard')

This is not part of my namespace proposal.  I don't really see
how one can easily distinguish a renaming of a hierarchy from a
renaming of a simple module.  Perhaps a syntactic method of
distinguishing them would be required.

> Anyway I think even the most restricitve form of hierarchical module names
> would be very helpful. I certainly would start using it.

My feeling is to go for the minimal extension to Haskell'98 first.
After some experience of using it, people will report what extra
facilities they find they would really like.

Regards,
    Malcolm