Data.IOEmbed
embedIO :: forall a. Typeable a => IO a -> Q Exp Source #
Embeds an IO a value - as long as a is Char, String, Integer, Rational, or ByteString.
IO
a
Char
String
Integer
Rational
ByteString
{-# LANGUAGE TemplateHaskell #-} fileContent = $(embedIO $ readFile "./README.md")
embedIOLit :: IO Lit -> Q Exp Source #
If you want to embed something else, you can manually generate an IO Lit and use this function.
Lit
{-# LANGUAGE TemplateHaskell #-} fileContentL = $(embedIOLit $ StringL <$> readFile "./README.md")
toLitE :: forall a. Typeable a => a -> Exp Source #
Converts Char, String, Integer, Rational, or ByteString to a literal expression.