@@ -1,13 +1,13 @@
1−-- | This is the module which exports @RenderAction@.
2−module Text.Hakyll.RenderAction
3− ( RenderAction (..)
4− , createRenderAction
5− , createSimpleRenderAction
6− , createFileRenderAction
1+-- | This is the module which exports @HakyllAction@.
2+module Text.Hakyll.HakyllAction
3+ ( HakyllAction (..)
4+ , createHakyllAction
5+ , createSimpleHakyllAction
6+ , createFileHakyllAction
77 , createManipulationAction
88 , chain
9− , runRenderAction
10− , runRenderActionIfNeeded
9+ , runHakyllAction
10+ , runHakyllActionIfNeeded
1111 , Renderable
1212 ) where
1313
@@ -23,85 +23,85 @@ import Text.Hakyll.File (toDestination, isFileMoreRecent)
2323import Text.Hakyll.Hakyll
2424
2525-- | Type used for rendering computations that carry along dependencies.
26−data RenderAction a b = RenderAction
27− { -- | Dependencies of the @RenderAction@.
26+data HakyllAction a b = HakyllAction
27+ { -- | Dependencies of the @HakyllAction@.
2828 actionDependencies :: [FilePath]
29− , -- | URL pointing to the result of this @RenderAction@.
29+ , -- | URL pointing to the result of this @HakyllAction@.
3030 actionUrl :: Maybe (Hakyll FilePath)
3131 , -- | The actual render function.
3232 actionFunction :: a -> Hakyll b
3333 }
3434
35−-- | Create a @RenderAction@ from a function.
36−createRenderAction :: (a -> Hakyll b) -- ^ Function to execute.
37− -> RenderAction a b
38−createRenderAction f = id { actionFunction = f }
35+-- | Create a @HakyllAction@ from a function.
36+createHakyllAction :: (a -> Hakyll b) -- ^ Function to execute.
37+ -> HakyllAction a b
38+createHakyllAction f = id { actionFunction = f }
3939
40−-- | Create a @RenderAction@ from a simple @Hakyll@ value.
41−createSimpleRenderAction :: Hakyll b -- ^ Hakyll value to pass on.
42− -> RenderAction () b
43−createSimpleRenderAction = createRenderAction . const
40+-- | Create a @HakyllAction@ from a simple @Hakyll@ value.
41+createSimpleHakyllAction :: Hakyll b -- ^ Hakyll value to pass on.
42+ -> HakyllAction () b
43+createSimpleHakyllAction = createHakyllAction . const
4444
45−-- | Create a @RenderAction@ that operates on one file.
46−createFileRenderAction :: FilePath -- ^ File to operate on.
45+-- | Create a @HakyllAction@ that operates on one file.
46+createFileHakyllAction :: FilePath -- ^ File to operate on.
4747 -> Hakyll b -- ^ Value to pass on.
48− -> RenderAction () b -- ^ The resulting action.
49−createFileRenderAction path action = RenderAction
48+ -> HakyllAction () b -- ^ The resulting action.
49+createFileHakyllAction path action = HakyllAction
5050 { actionDependencies = [path]
5151 , actionUrl = Just $ return path
5252 , actionFunction = const action
5353 }
5454
55−-- | Create a @RenderAction@ from a @ContextManipulation@.
55+-- | Create a @HakyllAction@ from a @ContextManipulation@.
5656createManipulationAction :: ContextManipulation -- ^ Manipulation to apply.
57− -> RenderAction Context Context
58−createManipulationAction = createRenderAction . (return .)
57+ -> HakyllAction Context Context
58+createManipulationAction = createHakyllAction . (return .)
5959
60−-- | Run a @RenderAction@ now.
61−runRenderAction :: RenderAction () a -- ^ Render action to run.
60+-- | Run a @HakyllAction@ now.
61+runHakyllAction :: HakyllAction () a -- ^ Render action to run.
6262 -> Hakyll a -- ^ Result of the action.
63−runRenderAction action = actionFunction action ()
63+runHakyllAction action = actionFunction action ()
6464
65−-- | Run a @RenderAction@, but only when it is out-of-date. At this point, the
65+-- | Run a @HakyllAction@, but only when it is out-of-date. At this point, the
6666-- @actionUrl@ field must be set.
67−runRenderActionIfNeeded :: RenderAction () () -- ^ Action to run.
67+runHakyllActionIfNeeded :: HakyllAction () () -- ^ Action to run.
6868 -> Hakyll () -- ^ Empty result.
69−runRenderActionIfNeeded action = do
69+runHakyllActionIfNeeded action = do
7070 url <- case actionUrl action of
7171 (Just u) -> u
7272 Nothing -> error "No url when checking dependencies."
7373 destination <- toDestination url
7474 valid <- isFileMoreRecent destination $ actionDependencies action
7575 unless valid $ do liftIO $ hPutStrLn stderr $ "Rendering " ++ destination
76− runRenderAction action
76+ runHakyllAction action
7777
78−-- | Chain a number of @RenderAction@ computations.
79−chain :: [RenderAction a a] -- ^ Actions to chain.
80− -> RenderAction a a -- ^ Resulting action.
78+-- | Chain a number of @HakyllAction@ computations.
79+chain :: [HakyllAction a a] -- ^ Actions to chain.
80+ -> HakyllAction a a -- ^ Resulting action.
8181chain [] = id
8282chain list@(_:_) = foldl1 (>>>) list
8383
84−-- | This is a specialized version of @RenderAction@, a @Context@ that can be
84+-- | This is a specialized version of @HakyllAction@, a @Context@ that can be
8585-- rendered.
86−type Renderable = RenderAction () Context
86+type Renderable = HakyllAction () Context
8787
88−instance Category RenderAction where
89− id = RenderAction
88+instance Category HakyllAction where
89+ id = HakyllAction
9090 { actionDependencies = []
9191 , actionUrl = Nothing
9292 , actionFunction = return
9393 }
9494
95− x . y = RenderAction
95+ x . y = HakyllAction
9696 { actionDependencies = actionDependencies x ++ actionDependencies y
9797 , actionUrl = actionUrl y `mplus` actionUrl x
9898 , actionFunction = actionFunction x <=< actionFunction y
9999 }
100100
101−instance Arrow RenderAction where
101+instance Arrow HakyllAction where
102102 arr f = id { actionFunction = return . f }
103103
104− first x = RenderAction
104+ first x = HakyllAction
105105 { actionDependencies = actionDependencies x
106106 , actionUrl = actionUrl x
107107 , actionFunction = \(y, z) -> do y' <- actionFunction x y