git.iko.soy/typeable/file-embed
on master help sign in
Merge pull request #26 from srid/dirlisting
257de69Michael Snoyman
ChangeLog.md+4
@@ -1,3 +1,7 @@
1+## 0.0.11
2+
3+* embedDirListing [#26](https://github.com/snoyberg/file-embed/pull/26)
4+
1## 0.0.10.1
5## 0.0.10.1
2
6
3* Minor doc improvements
7* Minor doc improvements
Data/FileEmbed.hs+13
@@ -21,6 +21,7 @@ module Data.FileEmbed
21 embedFile
21 embedFile
22 , embedOneFileOf
22 , embedOneFileOf
23 , embedDir
23 , embedDir
24+ , embedDirListing
24 , getDir
25 , getDir
25 -- * Embed as a IsString
26 -- * Embed as a IsString
26 , embedStringFile
27 , embedStringFile
@@ -118,6 +119,18 @@ embedDir fp = do
118 e <- ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))
119 e <- ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))
119 return $ SigE e typ
120 return $ SigE e typ
120
121
122+-- | Embed a directory listing recursively in your source code.
123+--
124+-- > myFiles :: [FilePath]
125+-- > myFiles = $(embedDirListing "dirName")
126+--
127+-- @since 0.0.11
128+embedDirListing :: FilePath -> Q Exp
129+embedDirListing fp = do
130+ typ <- [t| [FilePath] |]
131+ e <- ListE <$> ((runIO $ fmap fst <$> fileList fp) >>= mapM strToExp)
132+ return $ SigE e typ
133+
121-- | Get a directory tree in the IO monad.
134-- | Get a directory tree in the IO monad.
122--
135--
123-- This is the workhorse of 'embedDir'
136-- This is the workhorse of 'embedDir'
file-embed.cabal+1−1
@@ -1,5 +1,5 @@
1name: file-embed
1name: file-embed
2−version: 0.0.10.1
2+version: 0.0.11
3license: BSD3
3license: BSD3
4license-file: LICENSE
4license-file: LICENSE
5author: Michael Snoyman <michael@snoyman.com>
5author: Michael Snoyman <michael@snoyman.com>