[Haskell-cafe] Building examples with Cabal

Heinrich Apfelmus apfelmus at quantentunnel.de
Thu Oct 17 08:27:25 UTC 2013

Sven Panne wrote:
> 2013/10/16 Heinrich Apfelmus <apfelmus at quantentunnel.de>:
>> I usually declare an "Executable" for each example and add a flag
>> "buildExamples" that controls whether the examples are built or not. Here an
>> example .cabal file.
>> http://hackage.haskell.org/package/threepenny-gui-
> I tried something similar in the past, but that didn't really work out:
>   * Things get *extremely* verbose and repetitive in the .cabal file.
> Currently there are roughly 90 GLUT examples, and I expect to have
> much more in the future. This would lead to more than 1000 lines of
> boilerplate .cabal stuff. OK, Emacs macros and copy-n-paste are your
> friends, but... :-P

Ah, I see. I'm lucky in that the number of examples I need to maintain 
is still in the one digit range.

>   * Can Cabal build the executables in parallel? Doing a parallel
> build of all examples via my make hack takes about 5 seconds, a
> non-parallel build takes 75 seconds, and I expect that gap to widen
> even more when I add more examples.
>   * How does one handle common parts in the examples? (e.g.
> https://github.com/haskell-opengl/GLUT/tree/master/examples/RedBook8/common,
> more to come there) Conditionally build helper libraries just for the
> examples?

Building a single helper library where you put all shared modules into 
seems like a reasonable idea to me.

> I can't believe that I'm the only package maintainer who has such a
> problem, so I really hope that there is some hidden solution out there
> I simply can't see...

It's not very pressing for me yet, but if you do find a solution, please 
let me know as well. :)

Best regards,
Heinrich Apfelmus


More information about the Haskell-Cafe mailing list