git.iko.soy/typeable/file-embed
on master help sign in
Exposing getDir
5fa4f48Michael Snoyman
Data/FileEmbed.hs+7
@@ -2,6 +2,7 @@
2module Data.FileEmbed
2module Data.FileEmbed
3 ( embedFile
3 ( embedFile
4 , embedDir
4 , embedDir
5+ , getDir
5 ) where
6 ) where
6
7
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)
38
39
40+-- | Get a directory tree in the IO monad.
41+--
42+-- This is the workhorse of 'embedDir'
43+getDir :: FilePath -> IO [(FilePath, B.ByteString)]
44+getDir = fileList
45+
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
file-embed.cabal+3−3
@@ -1,5 +1,5 @@
1name: file-embed
1name: file-embed
2−version: 0.0.2
2+version: 0.0.3
3license: BSD3
3license: BSD3
4license-file: LICENSE
4license-file: LICENSE
5author: Michael Snoyman <michael@snoyman.com>
5author: Michael Snoyman <michael@snoyman.com>
@@ -13,8 +13,8 @@ homepage: http://github.com/snoyberg/file-embed/tree/master
13
13
14library
14library
15 build-depends: base >= 4 && < 5,
15 build-depends: base >= 4 && < 5,
16− bytestring >= 0.9.1.4 && < 1,
16+ bytestring >= 0.9.1.4 && < 0.10,
17− directory >= 1.0.0.3 && < 2,
17+ directory >= 1.0.0.3 && < 1.1,
18 template-haskell
18 template-haskell
19 exposed-modules: Data.FileEmbed
19 exposed-modules: Data.FileEmbed
20 ghc-options: -Wall
20 ghc-options: -Wall