[Haskell-beginners] hierarchy of modules

Stephen Tetley stephen.tetley at gmail.com
Sat Oct 31 15:33:53 EDT 2009

Hello Mike

An option I like is to put the main project files in a top level
directory called src, so your organization would look like this:


I usually have a running example which has imports for all the files
in the project inside a top level folder called demo...


For a GHCi session, I cd to $PROJECT/demo then

> ghci

Prelude> set -i../src

This is the useful bit of having all the project files under the src
hierarchy - the search path is very simple.

During development adding the files needed for cabal (Setup.hs,
project.cabal...) is still worthwhile - you can then generate
Haddock docs very easily. If you used Haddock in standalone mode you
would have to supply a few flags to tell which files to
document and where to put the output.

Each time you add or remove a module in the src tree, you should
re-run configure...

> runhaskell Setup.hs configure
> runhaskell Setup.hs haddock

but as your GHCi session is always using the interpreted project
source you don't need to run 'runhaskell Setup.hs build' and
'runhaskell Setup.hs install'.

Best wishes


More information about the Beginners mailing list