Problem with hierarchical libraries.

Simon Marlow
Wed, 12 Mar 2003 11:59:49 -0000

> > IIRC, something very similar was suggested a while back on=20
> the libraries
> > list, except that the form beginning with a dot was the=20
> relative module
> > name (actually I think I prefer it that way).
> this seems exactly the opposite of what all file systems do.  i know=20
> lateral thinking is great, but why do we have to be backwards=20
> all the time?

Because it seems strange to have to add the prefix dot to all of our
existing imports ('import Prelude' becomes 'import .Prelude').  Besides,
I like the idea that the prefix dot is an indication that the current
module name has been omitted.

> > Personally, I've been using the hierarchical module names=20
> for a while
> > and I really don't mind writing out the whole name each=20
> time.  It means
> > you have less context to think about when reading the source.
> oh come on :-)   most of the time you don't get to see the=20
> module name=20
> at all -- you have to keep scrolling to the top of the file. =20
> virtually=20
> every editor can tell you what is the name of the file you are=20
> editing... (:f in vim).  and tools like haddoc can display=20
> the name of=20
> the module anyways.

I think you misunderstand me - my point was that currently, an import
declaration means the same regardless of what the current module name
is.  With relative imports, that's not true any more (but you're right
that the editor usually helps by showing the filename).  It's a minor
point I grant you, but simplicity at the expense of a bit of extra
typing is sometimes a good thing.

> > This arises because the meaning of a module is defined=20
> independently of
> > the mapping between modules and filenames.
> the meaning of modules can still be independent of the=20
> mapping between=20
> modules and filesnames.   all that has to be specified is how=20
> to compute this mapping.

And that's exactly what we don't want to do (IMO).  Filesystems are too
different - what about filesystems that don't have directories?  What if
I want to store my source code in a database or on the web?  What about
non-case-sensitive filesystems, or ones with restrictions on the length
of filenames?

> and one has to do that anyways, even if the haskell=20
> report pretends that this can be ommited.=20

Yes, but the point is that it is done by the compiler, not the language
specification, so compilers are free to implement different policies,
and the spec doesn't have to acquire any platform-specific warts.

The mapping between filenames and module names in GHC is rather
complicated, see recent discussions on  The mapping in Hugs is different -
more liberal in some ways, but less complicated because of the lack of
interface files.

> in fact if one decides to ignore this mapping,=20
> all that the "hirarchical modules" proposal does is allow one=20
> to write "." in a module name.

Bingo :-)