Search code examples
haskellghccabaltemplate-haskell

Including text files to embed with Cabal


I've got a library I'm building that includes a few very large strings using Template Haskell and file-embed.

I'm wondering, how do I ensure these files are included when I run Cabal dist?

The are all in a folder called core, but some are within subdirectories of core.


Solution

  • Cabal has an extra-source-files field precisely for these kinds of scenarios:

    Extra-source-files: relative/path/to/my/embedded-file.txt
    

    Quoting the Cabal User Guide:

    extra-source-files: filename list

    A list of additional files to be included in source distributions built with setup sdist.

    As withdata-filesit can use a limited form of wildcards in file names.