[Haskell-cafe] Packages and modules

David House dmhouse at gmail.com
Sun Jun 25 08:41:01 EDT 2006


Apologies to Brian for the multiple copies, this wasn't originally
sent to the list.

On 25/06/06, Brian Hulley <brianh at metamilk.com> wrote:
> I'm wondering: would it not be easier to just make it that the package name
> is prepended to the hierarchical module name, so the modules would instead
> be called by the names P.Data.Foo and Q.Data.Bar?

This has the disavantage that if you move a module from one package to
another, all existing code using that module breaks.

Perhaps we need something analoguous to qualified imports: as well as
specifying the modules hierarchical path, you could also specify its
package. E.g.,

import Network.HTTP from HTTP

Or, using your syntax:

import HTTP.Network.HTTP

I prefer mine because we could also allow not qualifying the package:

import Network.HTTP -- will search all known packages for a Network.HTTP package

This is likely to be less of a pain in the majority of cases when the
module names don't overlap. Also, ambiguity. Given 'import
HTTP.Network.HTTP', the compiler has to search for both packages named
HTTP and modules with a full hierarchical name of HTTP.Network.HTTP.
In the unlikely sitatution where a different package did indeed
provide a module called HTTP.Network.HTTP, there would be an overlap.

Finally the compiler could give better error messages if the module
doesn't exist. I.e. one of 'Package X not found' or 'Module Y not
found within package X' instead of 'Module Y not found'.

--
-David House, dmhouse at gmail.com


More information about the Haskell-Cafe mailing list