[Haskell-cafe] Re: totally confused about Haskell namespace issue conventions

Maurí­cio briqueabraque at yahoo.com
Sun Jun 7 11:06:31 EDT 2009


> as far as namespace is concerned what is division between a module's 
> name and it's associated .cabal with it's Hs-Source-Dirs directive? This 
> is kinda' absolute vs relative path I think.

Vasili,

First, let's talk about Haskell modules, without mentioning
cabal.

When Haskell 98 standard came, modules had just a name, like,
say, 'Complex'. You can still see those names in GHC library
for compatibility:

http://www.haskell.org/ghc/docs/latest/html/libraries

Another interesting think you can see in that link is the
separation of modules into 'packages'. Right to the name of
every module there's a package name, like 'haskell98', 'base',
'stm-2.1.1.2' etc.

GHC and others adopted the convention of using dot in module
names to have a standard way of showing hierarchy between
modules. There's also a convention used in GHC (and others?) of
allowing only one module per file and, when looking for such file
(as in --make) compose the search path with the module name,
replacing dots by the start of a sub-directory name. So: suppose
your search path (a colon separate list of directories) is
'.:/hs:sub' and GHC wants a file for module Data.Our.Test. Then
it looks for:

./Data.Our.Test
/hs/Data.OurTest
./sub/Data.OurTest

You can find details on that (like how to add to the search
path) here:

http://www.haskell.org/ghc/docs/latest/html/users_guide/separate-compilation.html

Now about .cabal file. When you use it, it helps you generate a
package. In 'hs-source-dirs' you say what is the search path. In
'exposed-modules' you say wich modules are going to be seen
by users of your package.  You can also use 'other-modules'
to name modules your package needs but are not going to be
visible to other packages.

Just say if anything is not clear. Best,
Maurício



More information about the Haskell-Cafe mailing list