git.iko.soy/typeable/file-embed
on master help sign in
Fix bug in qAddDependentFile (#2)
commit7a1f673b92a04e210214430cfb9c6a4821f53dbd authorMichael Snoyman <michael@snoyman.com> dateMon 7 May 2012, 19:22 (14 years ago) parent99d57c6
4 files changed+27−8
Data/FileEmbed.hs+4−4 file-embed.cabal+16−4 test/main.hs+6 test/sample/foo+1
Data/FileEmbed.hs+4−4
@@ -58,7 +58,7 @@ embedFile fp =
5858-- > myDir :: [(FilePath, Data.ByteString.ByteString)]
5959-- > myDir = $(embedDir "dirName")
6060embedDir :: FilePath -> Q Exp
61−embedDir fp = ListE <$> ((runIO $ fileList fp) >>= mapM pairToExp)
61+embedDir fp = ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))
6262
6363-- | Get a directory tree in the IO monad.
6464--
@@ -66,10 +66,10 @@ embedDir fp = ListE <$> ((runIO $ fileList fp) >>= mapM pairToExp)
6666getDir :: FilePath -> IO [(FilePath, B.ByteString)]
6767getDir = fileList
6868
69−pairToExp :: (FilePath, B.ByteString) -> Q Exp
70−pairToExp (path, bs) = do
69+pairToExp :: FilePath -> (FilePath, B.ByteString) -> Q Exp
70+pairToExp root (path, bs) = do
7171#if MIN_VERSION_template_haskell(2,7,0)
72− qAddDependentFile path
72+ qAddDependentFile $ root ++ '/' : path
7373#endif
7474 exp' <- bsToExp bs
7575 return $! TupE [LitE $ StringL path, exp']
file-embed.cabal+16−4
@@ -1,15 +1,16 @@
11name: file-embed
2−version: 0.0.4.2
2+version: 0.0.4.3
33license: BSD3
44license-file: LICENSE
55author: Michael Snoyman <michael@snoyman.com>
66maintainer: Michael Snoyman <michael@snoyman.com>
77synopsis: Use Template Haskell to embed file contents directly.
88category: Data
9−stability: unstable
10−cabal-version: >= 1.2
9+stability: Stable
10+cabal-version: >= 1.8
1111build-type: Simple
12−homepage: http://github.com/snoyberg/file-embed/tree/master
12+homepage: https://github.com/snoyberg/file-embed
13+extra-source-files: test/main.hs, test/sample/foo
1314
1415library
1516 build-depends: base >= 4 && < 5,
@@ -18,3 +19,14 @@ library
1819 template-haskell
1920 exposed-modules: Data.FileEmbed
2021 ghc-options: -Wall
22+
23+test-suite test
24+ type: exitcode-stdio-1.0
25+ main-is: main.hs
26+ hs-source-dirs: test
27+ build-depends: base
28+ , file-embed
29+
30+source-repository head
31+ type: git
32+ location: https://github.com/snoyberg/file-embed
test/main.hsnew file+6
@@ -0,0 +1,6 @@
1+{-# LANGUAGE TemplateHaskell #-}
2+
3+import Data.FileEmbed
4+
5+main :: IO ()
6+main = print $(embedDir "test/sample")
test/sample/foonew file+1
@@ -0,0 +1 @@
1+foo