Description
Use Template Haskell to embed the result of an IO computation.
Description
Please see the README on GitHub at https://github.com/gtollini/io-embed#readme
README.md
io-embed
This library allows you to embed the result of an IO
computation at compile time - as long as said computation is internally typed as: Char
, String
, Integer
, Rational
, or ByteString
.
Installation
This package is available through both Cabal and Stackage.
Usage
Here's how you could embed the contents of a file using IOEmbed
:
{-# LANGUAGE TemplateHaskell #-}
fileContent = $(embedIO $ readFile "./README.md")
Alternativelly, you could use IOEmbedLit
by hand-crafting a Lit
. This is useful if you want to embed something other than the types listed above.
{-# LANGUAGE TemplateHaskell #-}
fileContentL = $(embedIOLit $ StringL <$> readFile "./README.md")