totally confused about Haskell namespace issue conventions

Hello, Should namespace designation be specified in modules or in the .cabal file? Or to put it another way should a relative namespace be specified in a Haskell module and the remaining "top" part be specified in the associated .cabal file? Of course, yes/no answers are probably not sufficient ... i.e. please elaborate. Kind regards, Vasili

let put this subject in another way ... assuming there a coding convention,
vis-a-vis Haskell namespace, what is the division of responsibility between
a Haskell module and it's associated .cabal?
Regards,
Vasili
On Sun, Jun 7, 2009 at 2:26 AM, Vasili I. Galchin
Hello,
Should namespace designation be specified in modules or in the .cabal file? Or to put it another way should a relative namespace be specified in a Haskell module and the remaining "top" part be specified in the associated .cabal file? Of course, yes/no answers are probably not sufficient ... i.e. please elaborate.
Kind regards, Vasili

let me state another way ....
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.
Regards,
Vasili
On Sun, Jun 7, 2009 at 2:46 AM, Vasili I. Galchin
let put this subject in another way ... assuming there a coding convention, vis-a-vis Haskell namespace, what is the division of responsibility between a Haskell module and it's associated .cabal?
Regards,
Vasili
On Sun, Jun 7, 2009 at 2:26 AM, Vasili I. Galchin
wrote: Hello,
Should namespace designation be specified in modules or in the .cabal file? Or to put it another way should a relative namespace be specified in a Haskell module and the remaining "top" part be specified in the associated .cabal file? Of course, yes/no answers are probably not sufficient ... i.e. please elaborate.
Kind regards, Vasili

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... 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

Vasili I. Galchin wrote:
Hello,
Should namespace designation be specified in modules or in the .cabal file? Or to put it another way should a relative namespace be specified in a Haskell module and the remaining "top" part be specified in the associated .cabal file? Of course, yes/no answers are probably not sufficient ... i.e. please elaborate.
This is my, probably incomplete, understanding of how things work. The module statement at the top of a Haskell source file should contain the complete name, e.g. module Foo.Bar.Baz If you use GHC directly to build (e.g. using --make) then it will look for the module above at $x/Foo/Bar/Baz.hs, where $x is on of the paths where GHC has been told to look (e.g. using -i). In a Cabal file you mention the complete names of module you use/build (e.g. Foo.Bar.Baz above). Hs-Source-Dirs adds directories to the paths where GHC looks for modules ($x above). /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe
participants (3)
-
Magnus Therning
-
Maurício
-
Vasili I. Galchin