[Haskell] Proposal: Relative Module Imports
simonmar at microsoft.com
Fri May 6 09:07:33 EDT 2005
On 03 May 2005 22:13, S. Alexander Jacobson wrote:
> Problem: We need a way to simplify module imports.
> Problem details:
> * Hierarchical module names are getting really long (including a
> functional area, a package name, and a module name).
> * People typically import multiple modules from areas close to each
> other in the hierarchical module namespace (especially in the case of
> intra-package imports).
> * Long module names are required even for non-exposed modules because
> a program may contain only one module with a given name (regardless of
> its visibility).
> Idea: Allow module relative imports in a manner that does not break
> any existing code.
> * Use preceding dots to indicate that module name is relative
> * Use from keyword to specify a different relative base.
> Dot relative syntax Translation
> ------------------- -----------
> module Text.Space.Foo.M where module Text.Space.Foo.M where
> import .M2 import Text.Space.Foo.M2 as M2
> import ..Bar.Baz import Text.Space.Bar.Baz as Bar.Baz
> import Data.Set import Data.Set
> from ...HaXML.XML
> import .Types import Text.HaXML.XML.Types as Types
> import .Escape import Text.HaXML.XML.Escape as
> Escape import .Pretty import Text.HaXML.XML.Pretty
> as Pretty
> I believe that the proposed syntax is much more concise and readable
> than the current equivalent.
I was sure something like this had been suggested before, and in fact
several similar schemes have. Here's a couple of starters:
Why haven't we ever implemented anything like this? A good question,
with no really good answer. I think it's a combination of
(a) the current situation isn't *really* hurting that much
(b) the current situation is *really* easy to describe and implement
(c) none of the proposed solutions are obviously the right thing
(e.g. the '.' prefixes look a little obscure, IMO).
and from my perspective:
(d) I hoped that something like grafting would provide a more
Oh, and there was a recent proposal on the libraries list to allow
exporting of qualified names, which solves a similar/overlapping
FWIW, I think this proposal ended in a reasonable result. It just needs
someone to implement it...
More information about the Haskell