[Haskell-cafe] Cabal and `main-is` field

Manlio Perillo manlio_perillo at libero.it
Sun Mar 1 10:45:59 EST 2009


Hi.

I have started to use Cabal for a small project where I have to build 
several executables.

The project layout is something like this:

/
   bin/
     a.hs
     b.hs
   src/
     X.hs
     Y.hs


The Cabal configuration file is something like:

executable a
     build-depends: haskell98, base, ...

     main-is:           a.hs
     hs-source-dirs:    src bin
     other-modules: X

This is perfectly reasonable, but it is odd, IMHO.

I don't understand why `main-is` is relative to `hs-source-dirs`.
What is the rationale?
After all, there is only one executable that can be specified in the 
`executable` block.

The configuration file should be, instead (IMHO, of course):

executable a
     build-depends: haskell98, base, ...

     main-is:           bin/a.hs
     hs-source-dirs:    src
     other-modules: X


Another "problem" I have noted, is that if I specify `main-is` field two 
times, no error is reported.
Simply, Cabal uses the last directive.



One last thing: is it possible to define "macros" in Cabal?
In my package, I have n executables, that have many dependencies in common.
I would like to avoid having to repeat the same dependencies for each 
executable block.



Thanks   Manlio Perillo


More information about the Haskell-Cafe mailing list