From a21f18d8b34972cf6ad76e510d1aa507fd37125f Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Sat, 21 Jul 2018 13:20:09 -0400 Subject: [PATCH 1/2] Add `embedDirListing` Use case: need the file listing to be embedded, but without their contents (which can be huge). --- Data/FileEmbed.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Data/FileEmbed.hs b/Data/FileEmbed.hs index e55ff78..7311c8b 100644 --- a/Data/FileEmbed.hs +++ b/Data/FileEmbed.hs @@ -21,6 +21,7 @@ module Data.FileEmbed embedFile , embedOneFileOf , embedDir + , embedDirListing , getDir -- * Embed as a IsString , embedStringFile @@ -118,6 +119,16 @@ 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") +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' From 8ec3c5c85c229f2b86fc47f0f238b9d27d813541 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Fri, 27 Jul 2018 10:38:41 -0400 Subject: [PATCH 2/2] Add version 0.0.11 --- ChangeLog.md | 4 ++++ Data/FileEmbed.hs | 2 ++ file-embed.cabal | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index d496219..b38a3ea 100644 --- a/ChangeLog.md +++ b/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 diff --git a/Data/FileEmbed.hs b/Data/FileEmbed.hs index 7311c8b..bbd83ee 100644 --- a/Data/FileEmbed.hs +++ b/Data/FileEmbed.hs @@ -123,6 +123,8 @@ embedDir fp = do -- -- > myFiles :: [FilePath] -- > myFiles = $(embedDirListing "dirName") +-- +-- @since 0.0.11 embedDirListing :: FilePath -> Q Exp embedDirListing fp = do typ <- [t| [FilePath] |] diff --git a/file-embed.cabal b/file-embed.cabal index 90db951..0921df0 100644 --- a/file-embed.cabal +++ b/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