diff options
Diffstat (limited to 'src/Text/Hakyll/ContextManipulations.hs')
-rw-r--r-- | src/Text/Hakyll/ContextManipulations.hs | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/Text/Hakyll/ContextManipulations.hs b/src/Text/Hakyll/ContextManipulations.hs index f73e88c..1c26f72 100644 --- a/src/Text/Hakyll/ContextManipulations.hs +++ b/src/Text/Hakyll/ContextManipulations.hs @@ -2,7 +2,6 @@ -- manipulate @Context@s. module Text.Hakyll.ContextManipulations ( renderValue - , renderMissingValue , changeValue , changeUrl , copyValue @@ -14,7 +13,7 @@ module Text.Hakyll.ContextManipulations ) where import Control.Monad (liftM) -import Control.Arrow (arr, (>>>)) +import Control.Arrow (arr) import System.Locale (TimeLocale, defaultTimeLocale) import System.FilePath (takeFileName, addExtension, dropExtension) import Data.Time.Format (parseTime, formatTime) @@ -33,21 +32,10 @@ renderValue :: String -- ^ Key of which the value should be copied. -> String -- ^ Key the value should be copied to. -> (String -> String) -- ^ Function to apply on the value. -> HakyllAction Context Context -renderValue source destination f = - arr (Context . M.delete destination . unContext) - >>> renderMissingValue source destination f - --- | Render a value, but do not overwrite the destination value if it already --- exists. --- -renderMissingValue :: String -- ^ Source key - -> String -- ^ Destination key - -> (String -> String) -- ^ Function to apply on the value - -> HakyllAction Context Context -renderMissingValue source destination f = arr $ \(Context context) -> Context $ +renderValue source destination f = arr $ \(Context context) -> Context $ case M.lookup source context of Nothing -> context - (Just value) -> M.insertWith (flip const) destination (f value) context + (Just value) -> M.insert destination (f value) context -- | Change a value in a @Context@. -- |