diff options
Diffstat (limited to 'src/Hakyll/Util.hs')
| -rw-r--r-- | src/Hakyll/Util.hs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Hakyll/Util.hs b/src/Hakyll/Util.hs index edbdb16..35169fa 100644 --- a/src/Hakyll/Util.hs +++ b/src/Hakyll/Util.hs @@ -1,7 +1,12 @@ module Hakyll.Util - ( dropParentRoute + ( + -- * Route utils + dropParentRoute , modifyDirRoute , modifyDirRoute_ + -- * Context utils + , transformContext + , transformContext_ ) where import Prolog @@ -17,3 +22,11 @@ modifyDirRoute f = customRoute $ f . splitDirectories . toFilePath modifyDirRoute_ :: ([FilePath] -> [FilePath]) -> Routes modifyDirRoute_ f = modifyDirRoute $ joinPath . f + +-- | General contramap +transformContext :: (Item b -> Compiler (Item a)) -> Context a -> Context b +transformContext f (Context c) = Context $ \n args itm -> c n args =<< f itm + +-- | Slightly more general contramap +transformContext_ :: (b -> Compiler a) -> Context a -> Context b +transformContext_ = transformContext . traverse |
