From 50371ab5c198509c710a289430e1ad752eac786a Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Tue, 8 Jan 2013 12:47:55 +0100 Subject: Add preprocess rule --- src/Hakyll/Core/Rules.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/Hakyll/Core/Rules.hs') diff --git a/src/Hakyll/Core/Rules.hs b/src/Hakyll/Core/Rules.hs index 450df83..8037ffb 100644 --- a/src/Hakyll/Core/Rules.hs +++ b/src/Hakyll/Core/Rules.hs @@ -25,6 +25,8 @@ module Hakyll.Core.Rules , route -- * Advanced usage + , preprocess + , Dependency (..) , rulesExtraDependencies ) where @@ -33,6 +35,7 @@ module Hakyll.Core.Rules import Control.Applicative ((<$>)) import Control.Monad.Reader (ask, local) import Control.Monad.State (get, modify, put) +import Control.Monad.Trans (liftIO) import Control.Monad.Writer (censor, tell) import Data.Maybe (fromMaybe) import Data.Monoid (mempty) @@ -157,6 +160,13 @@ route :: Routes -> Rules () route route' = Rules $ modify $ \s -> s {rulesRoute = Just route'} +-------------------------------------------------------------------------------- +-- | Execute an 'IO' action immediately while the rules are being evaluated. +-- This should be avoided if possible, but occasionally comes in useful. +preprocess :: IO a -> Rules a +preprocess = Rules . liftIO + + -------------------------------------------------------------------------------- -- | Advanced usage: add extra dependencies to compilers. Basically this is -- needed when you're doing unsafe tricky stuff in the rules monad, but you -- cgit v1.2.3