diff options
| author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-04-05 22:02:40 +0200 |
|---|---|---|
| committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-04-05 22:02:40 +0200 |
| commit | 433f36e6f3efdf95276fe0a5f486db3be2824445 (patch) | |
| tree | 4eba909cfe316224f49e5bc87d340cc98d1f670c /src/Hakyll/Core/Rules | |
| parent | 041ec5c3096684d045637ddd72741192b9050e36 (diff) | |
| parent | 19dc9f5f9fb8bda417e5b5dcc47b9cf83c541366 (diff) | |
| download | hakyll-433f36e6f3efdf95276fe0a5f486db3be2824445.tar.gz | |
Merge branch 'nested-rules'
Diffstat (limited to 'src/Hakyll/Core/Rules')
| -rw-r--r-- | src/Hakyll/Core/Rules/Internal.hs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Hakyll/Core/Rules/Internal.hs b/src/Hakyll/Core/Rules/Internal.hs index 2895257..592194d 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 @@ -19,6 +20,7 @@ import Data.Set (Set) import Hakyll.Core.ResourceProvider import Hakyll.Core.Identifier +import Hakyll.Core.Identifier.Pattern import Hakyll.Core.Compiler.Internal import Hakyll.Core.Routes import Hakyll.Core.CompiledItem @@ -55,10 +57,17 @@ data RuleState = RuleState { rulesMetaCompilerIndex :: Int } deriving (Show) +-- | Rule environment +-- +data RuleEnvironment = RuleEnvironment + { rulesResourceProvider :: ResourceProvider + , rulesPattern :: Pattern + } + -- | 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 +79,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 + , rulesPattern = mempty + } |
