From 1f169dd0a0132464e74400e3c5625e8a30658a4c Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Thu, 28 Oct 2010 01:29:13 +0200 Subject: Arrow version of addField --- src/Text/Hakyll/CreateContext.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Text/Hakyll/CreateContext.hs b/src/Text/Hakyll/CreateContext.hs index f894ff0..6a0e321 100644 --- a/src/Text/Hakyll/CreateContext.hs +++ b/src/Text/Hakyll/CreateContext.hs @@ -10,11 +10,14 @@ module Text.Hakyll.CreateContext , combineWithUrl ) where +import Prelude hiding (id) + import qualified Data.Map as M -import Control.Arrow (second, arr, (&&&)) +import Control.Arrow (second, arr, (&&&), (***)) import Control.Monad (liftM2) import Control.Applicative ((<$>)) import Control.Arrow ((>>>)) +import Control.Category (id) import Text.Hakyll.Context import Text.Hakyll.HakyllAction @@ -73,9 +76,10 @@ createListing url templates renderables additional = -- addField :: String -- ^ Key -> Either String (HakyllAction () String) -- ^ Value - -> HakyllAction a Context -- ^ Target - -> HakyllAction a Context -- ^ Result -addField key value target = value' &&& target >>> arr (uncurry insert) + -> HakyllAction Context Context -- ^ Result +addField key value = arr (const ()) &&& id + >>> value' *** id + >>> arr (uncurry insert) where value' = arr (const ()) >>> either (arr . const) id value insert v = Context . M.insert key v . unContext -- cgit v1.2.3