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
.
This package is available through both Cabal and Stackage.
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")