@@ -2,6 +2,7 @@
2module Data.FileEmbed
2module Data.FileEmbed
3 ( embedFile
3 ( embedFile
7import Language.Haskell.TH (runQ,
8import Language.Haskell.TH (runQ,
@@ -36,6 +37,12 @@ embedFile fp = (runIO $ B.readFile fp) >>= bsToExp
36embedDir :: FilePath -> Q Exp
37embedDir :: FilePath -> Q Exp
37embedDir fp = ListE <$> ((runIO $ fileList fp) >>= mapM pairToExp)
38embedDir fp = ListE <$> ((runIO $ fileList fp) >>= mapM pairToExp)
40+-- | Get a directory tree in the IO monad.
42+-- This is the workhorse of 'embedDir'
43+getDir :: FilePath -> IO [(FilePath, B.ByteString)]
39pairToExp :: (FilePath, B.ByteString) -> Q Exp
46pairToExp :: (FilePath, B.ByteString) -> Q Exp
40pairToExp (path, bs) = do
47pairToExp (path, bs) = do
41 exp' <- bsToExp bs
48 exp' <- bsToExp bs