Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add embedDirListing #26

Merged
merged 2 commits into from Jul 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog.md
@@ -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
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")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Can you add a minor version bump in the cabal file, update the ChangeLog, and add a @since comment here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snoyberg Done.

--
-- @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
@@ -1,5 +1,5 @@
name: file-embed
version: 0.0.10.1
version: 0.0.11
license: BSD3
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>
Expand Down