Skip to content

Commit

Permalink
Merge pull request snoyberg#26 from srid/dirlisting
Browse files Browse the repository at this point in the history
Add `embedDirListing`
  • Loading branch information
snoyberg authored Jul 29, 2018
2 parents 0c33a1d + 8ec3c5c commit 257de69
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.11

* embedDirListing [#26](https://github.com/snoyberg/file-embed/pull/26)

## 0.0.10.1

* Minor doc improvements
Expand Down
13 changes: 13 additions & 0 deletions Data/FileEmbed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Data.FileEmbed
embedFile
, embedOneFileOf
, embedDir
, embedDirListing
, getDir
-- * Embed as a IsString
, embedStringFile
Expand Down Expand Up @@ -118,6 +119,18 @@ embedDir fp = do
e <- ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))
return $ SigE e typ

-- | Embed a directory listing recursively in your source code.
--
-- > myFiles :: [FilePath]
-- > myFiles = $(embedDirListing "dirName")
--
-- @since 0.0.11
embedDirListing :: FilePath -> Q Exp
embedDirListing fp = do
typ <- [t| [FilePath] |]
e <- ListE <$> ((runIO $ fmap fst <$> fileList fp) >>= mapM strToExp)
return $ SigE e typ

-- | Get a directory tree in the IO monad.
--
-- This is the workhorse of 'embedDir'
Expand Down
2 changes: 1 addition & 1 deletion file-embed.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: file-embed
version: 0.0.10.1
version: 0.0.11
license: BSD3
license-file: LICENSE
author: Michael Snoyman <[email protected]>
Expand Down

0 comments on commit 257de69

Please sign in to comment.