@@ -23,6 +23,9 @@ import Language.Haskell.TH.Syntax
26+#if MIN_VERSION_template_haskell(2,7,0)
27+ , Quasi(qAddDependentFile)
27import System.Directory (doesDirectoryExist, doesFileExist,
30import System.Directory (doesDirectoryExist, doesFileExist,
28 getDirectoryContents)
31 getDirectoryContents)
@@ -42,7 +45,11 @@ import System.IO.Unsafe (unsafePerformIO)
42-- > myFile :: Data.ByteString.ByteString
45-- > myFile :: Data.ByteString.ByteString
43-- > myFile = $(embedFile "dirName/fileName")
46-- > myFile = $(embedFile "dirName/fileName")
44embedFile :: FilePath -> Q Exp
47embedFile :: FilePath -> Q Exp
49+#if MIN_VERSION_template_haskell(2,7,0)
50+ qAddDependentFile fp >>
45−embedFile fp = (runIO $ B.readFile fp) >>= bsToExp
52+ (runIO $ B.readFile fp) >>= bsToExp
47-- | Embed a directory recusrively in your source code.
54-- | Embed a directory recusrively in your source code.
@@ -61,6 +68,9 @@ getDir = fileList
62pairToExp :: (FilePath, B.ByteString) -> Q Exp
69pairToExp :: (FilePath, B.ByteString) -> Q Exp
63pairToExp (path, bs) = do
70pairToExp (path, bs) = do
71+#if MIN_VERSION_template_haskell(2,7,0)
72+ qAddDependentFile path
64 exp' <- bsToExp bs
74 exp' <- bsToExp bs
65 return $! TupE [LitE $ StringL path, exp']
75 return $! TupE [LitE $ StringL path, exp']