git.iko.soy/typeable/file-embed
on master help sign in
Force signatures, automated test
commite0add1353887531a27d24992b871382a3fe1231a authorMichael Snoyman <michael@snoyman.com> dateSun 30 Dec 2012, 08:19 (14 years ago) parentc7753b6
3 files changed+11−3
Data/FileEmbed.hs+5−2 file-embed.cabal+1 test/main.hs+5−1
Data/FileEmbed.hs+5−2
@@ -14,7 +14,7 @@ module Data.FileEmbed
1414 ) where
1515
1616import Language.Haskell.TH.Syntax
17− ( Exp (AppE, ListE, LitE, TupE)
17+ ( Exp (AppE, ListE, LitE, TupE, SigE)
1818#if MIN_VERSION_template_haskell(2,5,0)
1919 , Lit (StringL, StringPrimL, IntegerL)
2020#else
@@ -57,7 +57,10 @@ embedFile fp =
5757-- > myDir :: [(FilePath, Data.ByteString.ByteString)]
5858-- > myDir = $(embedDir "dirName")
5959embedDir :: FilePath -> Q Exp
60−embedDir fp = ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))
60+embedDir fp = do
61+ typ <- [t| [(FilePath, B.ByteString)] |]
62+ e <- ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))
63+ return $ SigE e typ
6164
6265-- | Get a directory tree in the IO monad.
6366--
file-embed.cabal+1
@@ -29,6 +29,7 @@ test-suite test
2929 hs-source-dirs: test
3030 build-depends: base
3131 , file-embed
32+ , HUnit
3233
3334source-repository head
3435 type: git
test/main.hs+5−1
@@ -1,6 +1,10 @@
11{-# LANGUAGE TemplateHaskell #-}
2+{-# LANGUAGE OverloadedStrings #-}
23
34import Data.FileEmbed
5+import Test.HUnit ((@?=))
46
57main :: IO ()
6−main = print $(embedDir "test/sample")
8+main = do
9+ let received = $(embedDir "test/sample")
10+ received @?= [("foo", "foo\n")]