Embed files and directories into Haskell code at compile time with Template Haskell
open sourceBSD-2-Clausefree
file-embed uses Template Haskell to read a file, or every file in a directory, at compile time and embed its contents in your Haskell code as a ByteString (or path and ByteString pairs), so data like JSON or text files ships inside the binary. Paths can be given relative to the package root.
Problems it solves
- ship a JSON file inside my Haskell executable instead of reading it at runtime
- bundle static assets into a single Haskell binary
- include a directory of templates in my compiled Haskell program
Features
- embed one file's contents as a ByteString at compile time
- embed every file in a directory as (path, ByteString) pairs
- paths relative to the package root with embedFileRelative
Limitations
- Embedding happens through Template Haskell, so the module needs the TemplateHaskell extension.1
