summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/Rules
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-04-04 20:49:22 +0200
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-04-04 20:49:22 +0200
commitf6c65aadd7e07bad9deda2d1d9ecc7ca5610e429 (patch)
tree396c97a2b3f5cb50d28ee2caa245a4e041fe89c0 /src/Hakyll/Core/Rules
parentc8588f13c8b5977723af3660ff87256b744f0643 (diff)
downloadhakyll-f6c65aadd7e07bad9deda2d1d9ecc7ca5610e429.tar.gz
Works-for-me implementation of nested rules
Diffstat (limited to 'src/Hakyll/Core/Rules')
-rw-r--r--src/Hakyll/Core/Rules/Internal.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Hakyll/Core/Rules/Internal.hs b/src/Hakyll/Core/Rules/Internal.hs
index 2895257..dc669c1 100644
--- a/src/Hakyll/Core/Rules/Internal.hs
+++ b/src/Hakyll/Core/Rules/Internal.hs
@@ -5,6 +5,7 @@ module Hakyll.Core.Rules.Internal
( CompileRule (..)
, RuleSet (..)
, RuleState (..)
+ , RuleEnvironment (..)
, RulesM (..)
, Rules
, runRules
@@ -55,10 +56,17 @@ data RuleState = RuleState
{ rulesMetaCompilerIndex :: Int
} deriving (Show)
+-- | Rule environment
+--
+data RuleEnvironment = RuleEnvironment
+ { rulesResourceProvider :: ResourceProvider
+ , rulesMatcher :: Identifier -> Bool
+ }
+
-- | The monad used to compose rules
--
newtype RulesM a = RulesM
- { unRulesM :: ReaderT ResourceProvider (WriterT RuleSet (State RuleState)) a
+ { unRulesM :: ReaderT RuleEnvironment (WriterT RuleSet (State RuleState)) a
} deriving (Monad, Functor, Applicative)
-- | Simplification of the RulesM type; usually, it will not return any
@@ -70,6 +78,9 @@ type Rules = RulesM ()
--
runRules :: Rules -> ResourceProvider -> RuleSet
runRules rules provider =
- evalState (execWriterT $ runReaderT (unRulesM rules) provider) state
+ evalState (execWriterT $ runReaderT (unRulesM rules) env) state
where
state = RuleState {rulesMetaCompilerIndex = 0}
+ env = RuleEnvironment { rulesResourceProvider = provider
+ , rulesMatcher = const True
+ }