[Haskell-cafe] Code that writes code

John Millikin jmillikin at gmail.com
Thu Aug 19 17:10:28 EDT 2010

My preferred approach is to check the generation script into source
control, and add it to Cabal's extra-source-files section. If the
generated file is a standard .hs module, Cabal should add it to the
sdist automatically.

You might want to add a note to the README documenting how to
regenerate the module, so anybody branching your code knows which file
to modify.

There are ways to make Cabal automatically generate a file, but they
seem to assume an external preprocessor operating on a (single input
file -> single output file) model. More complicated systems, such as
running a separate script or (many files -> many files) don't work

On Thu, Aug 19, 2010 at 14:00, Andrew Coppin
<andrewcoppin at btinternet.com> wrote:
> I'm working on a small Haskell package. One module in particular contains so
> much boilerplate that rather than write the code myself, I wrote a small
> Haskell program that autogenerates it for me.
> What's the best way to package this for Cabal? Just stick the generated file
> in there? Or is there some (easy) way to tell Cabal how to recreate this
> file itself?

More information about the Haskell-Cafe mailing list