@@ -23,6 +23,9 @@ import Language.Haskell.TH.Syntax
2323#endif
2424 , Q
2525 , runIO
26+#if MIN_VERSION_template_haskell(2,7,0)
27+ , Quasi(qAddDependentFile)
28+#endif
2629 )
2730import System.Directory (doesDirectoryExist, doesFileExist,
2831 getDirectoryContents)
@@ -42,7 +45,11 @@ import System.IO.Unsafe (unsafePerformIO)
4245-- > myFile :: Data.ByteString.ByteString
4346-- > myFile = $(embedFile "dirName/fileName")
4447embedFile :: FilePath -> Q Exp
45−embedFile fp = (runIO $ B.readFile fp) >>= bsToExp
48+embedFile fp =
49+#if MIN_VERSION_template_haskell(2,7,0)
50+ qAddDependentFile fp >>
51+#endif
52+ (runIO $ B.readFile fp) >>= bsToExp
4653
4754-- | Embed a directory recusrively in your source code.
4855--
@@ -61,6 +68,9 @@ getDir = fileList
6168
6269pairToExp :: (FilePath, B.ByteString) -> Q Exp
6370pairToExp (path, bs) = do
71+#if MIN_VERSION_template_haskell(2,7,0)
72+ qAddDependentFile path
73+#endif
6474 exp' <- bsToExp bs
6575 return $! TupE [LitE $ StringL path, exp']
6676