root

h(ell)NoFiles

This tool allows to embed resources in a Haskell program in a simple and portable way.

It creates a Haskell module from a directory containing resources (e.g., images, sounds, texts); each resource is then made available as a ByteString exported from said module. For example, if run on a directory containing files image1.png, image2.png and kaboom.snd, it will produce a module Resources of the form:

 module Resources

 where

 import Data.ByteString
 ...

 image1_png :: ByteString
 image1_png = ... -- contents of image1.png

 image2_png :: ByteString
 image2_png = ... -- contents of image2.png

 kaboom_snd :: ByteString
 kaboom_snd = ... -- contents of kaboom.snd

The contents of these files are not dumped into the Resources.hs file; instead a resources.s file is generated, which when assembled and linked to the final executable will include (via the .incbin directive) the actual files (the resources.s can be added in one of the c-sources directories of a cabal project and will be automatically assembled and linked).

Note that subdirectories are also handled: if in the above example, data contains a subdirectory small, the a module Resources.Small will be created as well (up to a maximum recursion depth set with the --recursion-limit flag).

Alternatives

file-embed and hsb2hs achieve the same effect but work rather differently.

Limitations

On systems with a very old version of the GNU Assembler (most notably OS X), the .incbin directive might not be available. In that case, the --no-incbin flag can be used to quote the content of the included resources in the .s file, which can be much slower and a ~6.5x blow-up in space with respect to the original resources.

Usage

Run with option --help to see all the available options.