[ANN] cartel - specify Cabal files using Haskell

The Cabal file format works very well for small projects. However, in big projects with a library, many executables, and test suites, some irritations emerge. You need to specify dependencies in multiple places, leading to redundancy. You also have to manually add in new modules, make sure you list all modules (a real pain with executables, as problems may arise only after you build a distribution tarball), and update your module lists when you refactor. Specifying your Cabal files in Haskell rather than in a plain-text file format helps deal with a lot of these problems. You have the full power of Haskell to make definitions in one place and then reuse them. You can also dynamically read a tree of modules and use the result, thus avoiding the need to manually update your module lists. A disadvantage to Cartel is that it can be a bit more verbose than a vanilla Cabal file. In addition, you also have to remember to generate the new Cabal file whenever you change the script that generates your Cabal file. Cabal already has an AST that it uses. Cartel could, perhaps, have re-used these structures. Cartel does not do this for three reasons. First, the Cabal API is a bit untidy, partially because it has to do things that Cartel doesn't have to worry about, but also because the comments in the Cabal modules themselves indicate that the whole thing could use a refactoring. Second, the Cabal developers make no commitment to keep that API stable. Third, the Cartel API tries only to replicate format of the plain-text Cabal file, which will be much more stable than the Cabal API. Hackage: http://hackage.haskell.org/package/cartel Github: https://github.com/massysett/cartel

Hi Omari, On Tue, May 27, 2014 at 09:55:59PM -0400, Omari Norman wrote:
The Cabal file format works very well for small projects. However, in big projects with a library, many executables, and test suites, some irritations emerge. You need to specify dependencies in multiple places, leading to redundancy.
That's not quite true, you can share the dependencies and specify the modules once, but you have to use a different sub directory for each section (library, executable, test-suite, benchmark) in the cabal file. See: https://github.com/dan-t/hsimport/blob/master/hsimport.cabal Greetings, Daniel

On Wed, May 28, 2014 at 2:20 AM, Daniel Trstenjak < daniel.trstenjak@gmail.com> wrote:
Hi Omari,
On Tue, May 27, 2014 at 09:55:59PM -0400, Omari Norman wrote:
The Cabal file format works very well for small projects. However, in big projects with a library, many executables, and test suites, some irritations emerge. You need to specify dependencies in multiple places, leading to redundancy.
That's not quite true, you can share the dependencies and specify the modules once, but you have to use a different sub directory for each section (library, executable, test-suite, benchmark) in the cabal file.
See: https://github.com/dan-t/hsimport/blob/master/hsimport.cabal
This is a solution only where you have shared code that can be pushed into the library. This may not be practical. Non-trivial tests, for instance, are going to have dependencies of their own. See http://hackage.haskell.org/package/penny-0.32.0.10/penny.cabal where three separate components must specify dependencies on text, time, and transformers. This was even after I moved a lot of code to the library for the sole reason of removing Cabal file redundancy. I could have the library re-export modules from those packages but that is a kludge.

On Wed, May 28, 2014 at 7:53 AM, Niklas Hambüchen
An example of how some project's cabal file looks in cartel would be nice.
Cartel's own cabal file is generated from Cartel. https://github.com/massysett/cartel/blob/master/genCabal.hs

you might also be interested in franchise, an attempt by david roundy
to create a decent haskell package manager before retiring from the
community
http://hackage.haskell.org/package/franchise
may have some ideas to reuse.
I use autoconf to generate cabal files when needed, working on a
better solution all around somwhat more similar to but distinct from
cartel and not haskell specific.
John
On Wed, May 28, 2014 at 6:35 AM, Omari Norman
On Wed, May 28, 2014 at 7:53 AM, Niklas Hambüchen
wrote: An example of how some project's cabal file looks in cartel would be nice.
Cartel's own cabal file is generated from Cartel.
https://github.com/massysett/cartel/blob/master/genCabal.hs
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- John Meacham - http://notanumber.net/
participants (4)
-
Daniel Trstenjak
-
John Meacham
-
Niklas Hambüchen
-
Omari Norman