packages feed

casa-reoc-0.1.0.0: src/ReOC/Render/Embed.hs

{-# OPTIONS_GHC -Wall #-}

-- | Files of the package, read when it is compiled.
module ReOC.Render.Embed (
  embedFileBytes,
) where

import qualified Data.ByteString as ByteString
import Language.Haskell.TH (Exp, Q, runIO)
import Language.Haskell.TH.Syntax (addDependentFile, lift)

{- | The contents of a file, relative to the package, as a @ByteString@
expression: the package recompiles when the file changes.
-}
embedFileBytes :: FilePath -> Q Exp
embedFileBytes path = do
  addDependentFile path
  runIO (ByteString.readFile path) >>= lift