
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

On Sun, Mar 1, 2009 at 10:45 AM, Manlio Perillo
Hi. ... 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
You can hoist the common build-depends out of the executable stanzas. ie. from xmonad-utils.cabal: build-depends: base<4, X11>=1.3, ghc>=6.8, unix, random>=1.0 ... executable: hxsel main-is: Hxsel.hs hs-source-dirs: src ghc-options: -funbox-strict-fields -Wall ghc-prof-options: -prof -auto-all executable: hxput main-is: Hxput.hs hs-source-dirs: src ghc-options: -funbox-strict-fields -Wall ghc-prof-options: -prof -auto-all .... Notice that though hxput and hxsel need the packages in the top-level build-depends, they don't need to declare it. -- gwern

Gwern Branwen ha scritto:
[...]
You can hoist the common build-depends out of the executable stanzas. ie. from xmonad-utils.cabal:
build-depends: base<4, X11>=1.3, ghc>=6.8, unix, random>=1.0 ... executable: hxsel main-is: Hxsel.hs hs-source-dirs: src ghc-options: -funbox-strict-fields -Wall ghc-prof-options: -prof -auto-all
executable: hxput main-is: Hxput.hs hs-source-dirs: src ghc-options: -funbox-strict-fields -Wall ghc-prof-options: -prof -auto-all ....
Notice that though hxput and hxsel need the packages in the top-level build-depends, they don't need to declare it.
Thanks. From documentation it was not clear this feature. However, what happens if hxput add a build-depends field? Will this override the "global" field? Manlio Perillo

On Sun, Mar 1, 2009 at 12:10 PM, Manlio Perillo
Gwern Branwen ha scritto:
[...]
You can hoist the common build-depends out of the executable stanzas. ie. from xmonad-utils.cabal:
build-depends: base<4, X11>=1.3, ghc>=6.8, unix, random>=1.0 ... executable: hxsel main-is: Hxsel.hs hs-source-dirs: src ghc-options: -funbox-strict-fields -Wall ghc-prof-options: -prof -auto-all
executable: hxput main-is: Hxput.hs hs-source-dirs: src ghc-options: -funbox-strict-fields -Wall ghc-prof-options: -prof -auto-all ....
Notice that though hxput and hxsel need the packages in the top-level build-depends, they don't need to declare it.
Thanks. From documentation it was not clear this feature.
However, what happens if hxput add a build-depends field? Will this override the "global" field?
Manlio Perillo
It doesn't override, but adds to. If the toplevel declares 'base', and then hxput does 'build-depends: random', hxput will be built against 'base, random'. -- gwern

On Sun, 2009-03-01 at 18:10 +0100, Manlio Perillo wrote:
Gwern Branwen ha scritto:
[...]
You can hoist the common build-depends out of the executable stanzas. ie. from xmonad-utils.cabal:
build-depends: base<4, X11>=1.3, ghc>=6.8, unix, random>=1.0 ... executable: hxsel main-is: Hxsel.hs hs-source-dirs: src ghc-options: -funbox-strict-fields -Wall ghc-prof-options: -prof -auto-all
executable: hxput main-is: Hxput.hs hs-source-dirs: src ghc-options: -funbox-strict-fields -Wall ghc-prof-options: -prof -auto-all ....
Notice that though hxput and hxsel need the packages in the top-level build-depends, they don't need to declare it.
Thanks. From documentation it was not clear this feature.
That's because it's a bug, not a feature. :-) Be careful of using this "feature" as we might fix it. Duncan

Duncan Coutts ha scritto:
[...]
Notice that though hxput and hxsel need the packages in the top-level build-depends, they don't need to declare it.
Thanks. From documentation it was not clear this feature.
That's because it's a bug, not a feature. :-)
Be careful of using this "feature" as we might fix it.
Thanks, I was going to "fix" my Cabal configuration right now! Manlio Perillo

On Sun, Mar 1, 2009 at 11:56, Duncan Coutts
That's because it's a bug, not a feature. :-)
Be careful of using this "feature" as we might fix it.
I've wished for this feature, and have Cabal files right now that would be cleaner with it. Is there something technically wrong or undesirable about this feature that necessitates "fixing"? Denis

On Mon, 2009-03-02 at 07:15 -0700, Denis Bueno wrote:
On Sun, Mar 1, 2009 at 11:56, Duncan Coutts
wrote: That's because it's a bug, not a feature. :-)
Be careful of using this "feature" as we might fix it.
I've wished for this feature, and have Cabal files right now that would be cleaner with it. Is there something technically wrong or undesirable about this feature that necessitates "fixing"?
If it's supposed to work it should work consistently. It's a quirk that to support old-style .cabal files we allow build-depends but not other fields in the global section. If we do it properly we should either allow all fields there, or perhaps in an explicit "common" section or something. I hope we can address this and related limitations and quirks in the Cabal-1.8 development cycle. If you want to help out with that let me know and I can give you some pointers. Duncan
participants (4)
-
Denis Bueno
-
Duncan Coutts
-
Gwern Branwen
-
Manlio Perillo