From e2a0c8d336f2644218573bdec0f83cd675944c5f Mon Sep 17 00:00:00 2001 From: Chris Wells Date: Tue, 25 Mar 2025 07:17:53 -0500 Subject: More work on papers --- src/Hakyll/Util.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/Hakyll/Util.hs') 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 -- cgit v1.2.3