Libraries and hierarchies
Alastair Reid
alastair@reid-consulting-uk.ltd.uk
Mon, 4 Aug 2003 16:50:30 +0100
> 3. As (2), but the full name of a module is not fixed in the source
> code,
> and can be mapped into the hierarchy at multiple places.
>
> [...]
>
> This suffers from
>(a) extra complication in the implementation and specification
> of the language,
I wonder if the extra complication is really that high.
Suppose that every module somehow has a unique name
(128 bit hash, global registry, whatever) and that we have
setup two mappings to the same thing:
Foo.Bar -> Reid.Consulting.Bar.version27
Baz.Bar -> Reid.Consulting.Bar.version27
to implement this in Hugs, it is _almost_ enough to simply
run all source code through a preprocessor which replaces
occurences of Foo.Bar and Baz.Bar with Reid.Consulting.Bar.version27.
Suppose a module imports both Foo.Bar and Baz.Bar.
The Haskell compiler will see this as two imports of
Reid.Consulting.Bar.version27 and will recognise that any types they define
are the same type.
This simple minded lexical substitution approach would fail in the usual
places that applying a preprocessor fails: inside strings, when a module name
is also used as a constructor name, etc. It would also interact with
qualified import. For this reason, the substitution needs to happen inside
the parser or early parts of the frontend. We'd also want to generate good
error messages so there would be a small change there as well. Overall, I
think it would be quite a small change.
>(b) needing unique package names,
The original proposal tied this feature strongly to packages. I wonder if
this is really necessary.
Putting that aside, it seems that unique package names are fairly easy to come
by. Some possibilities are:
1) Use the URI of the primary download site.
From choice, the URI would be for a tarfile or whatever
but all that really matters is that it is unique.
This will typically include a version number but, if not,
the user could add one if they care.
2) In the likely event that we have a few big repositories
and many small ones, simply prefix the name of the package
by the repository name or, if not available, name of author.
This is effectively the same as (1) but avoids using URIs.
3) Directory name on your system.
This would be a little like the current situation with Hugs where
you add -P options to the command line to add each package to
the searchpath.
>(c) referring unambiguously to a specific library must be done
> by GUID.
Rephrasing this as 'can be done by GUID', I would list this as a strength.
--
Alastair Reid