diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-03-04 00:02:37 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-03-04 00:02:37 +0100 |
commit | 76ebcf97b4e2c993297aa914ce576fc0abd68d06 (patch) | |
tree | e82dce223dc1cbbcd544449620270d2ae613133d /src/Text/Hakyll/RenderAction.hs | |
parent | e4f09b0a051092ff12726d491a464c4b9c67ddf5 (diff) | |
download | hakyll-76ebcf97b4e2c993297aa914ce576fc0abd68d06.tar.gz |
First careful transition from data to arrows. It compiles, but that's about it.
Diffstat (limited to 'src/Text/Hakyll/RenderAction.hs')
-rw-r--r-- | src/Text/Hakyll/RenderAction.hs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Text/Hakyll/RenderAction.hs b/src/Text/Hakyll/RenderAction.hs new file mode 100644 index 0000000..a84ce46 --- /dev/null +++ b/src/Text/Hakyll/RenderAction.hs @@ -0,0 +1,40 @@ +module Text.Hakyll.RenderAction + ( RenderAction (..) + , fromRenderable + ) where + +import Prelude hiding ((.), id) +import Control.Category +import Control.Monad ((<=<), mplus) + +import Text.Hakyll.Hakyll +import Text.Hakyll.Context +import Text.Hakyll.Renderable + +data RenderAction a b = RenderAction + { actionDependencies :: [FilePath] + , actionDestination :: Maybe (Hakyll FilePath) + , actionFunction :: a -> Hakyll b + } + +instance Category RenderAction where + id = RenderAction + { actionDependencies = [] + , actionDestination = Nothing + , actionFunction = return + } + + x . y = RenderAction + { actionDependencies = actionDependencies x ++ actionDependencies y + , actionDestination = actionDestination y `mplus` actionDestination x + , actionFunction = actionFunction x <=< actionFunction y + } + +fromRenderable :: (Renderable a) + => a + -> RenderAction () Context +fromRenderable renderable = RenderAction + { actionDependencies = getDependencies renderable + , actionDestination = Just $ getUrl renderable + , actionFunction = const $ toContext renderable + } |