[Haskell-cafe] Packages and modules

Brian Hulley brianh at metamilk.com
Mon Jun 26 13:51:06 EDT 2006

Brian Hulley wrote:
>   import Gtk/Widget.Button -- instead of grafting
> In all cases I think it would be an absolute disaster to allow
> modules to be imported without an explicit package id because this
> would defeat the whole purpose of having a simple per-package
> namespace for modules and wouldn't allow the reader of source to know
> which packages it's referring to.

I meant the above only in relaiton to modules in other packages. Modules in 
the current package would be identified as they are at the moment, without 
any package qualification (since only the compiler command line would know 
the name of the current package).

Here is an example of a module before and after applying my proposed syntax 
to the source of a module in some hypothetical package called duma:

   module Duma.Text.Line
                   ( T
                    , ...
                    ) where
   import Prelude hiding(length, take, drop)
   import qualified Prelude as P
   import Duma.Prime.Strict
   import qualified Data.ByteString.Char8 as B

and after:

   module Text.Line
                   ( T
                    , ...
                    ) where
   import Base/Prelude hiding(length, take, drop)
   import qualified Base/Prelude as P
   import Prime.Strict
   import qualified Fps/Data.ByteString.Char8 as B

So all that's needed is qualifying the Prelude and ByteString modules by 
Base/ and Fps/ respectively and we've gained the advantage of not having to 
decide on the name of the actual package (duma) in advance, and also not 
having to incorporate this name everywhere as part of the module name within 
the source of the duma package itself. Explicit package directives would 
only be needed if we wanted to refer to some specific version of a package 

    package fps-0.6 as Fps

but I'd imagine that usually we want to use the latest version.

With the above syntax I think the only thing that has to be unique are the 
package names ie fps-0.6 must always refer to the one and only fast packed 
string package otherwise we'd end up with a nightmare of incompatibility 
when trying to compile other people's code.

Regards, Brian.

Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.


More information about the Haskell-Cafe mailing list