@@ -27,6 +27,7 @@ import Control.Monad.Reader (ask)
2727import Control.Arrow (second, (>>>), arr, (>>^))
2828import Control.Monad.State (get, put)
2929import Data.Monoid (mempty)
30+import qualified Data.Set as S
3031
3132import Data.Typeable (Typeable)
3233import Data.Binary (Binary)
@@ -44,18 +45,24 @@ import Hakyll.Core.Util.Arrow
4445-- | Add a route
4546--
4647tellRoute :: Routes -> Rules
47−tellRoute route' = RulesM $ tell $ RuleSet route' mempty
48+tellRoute route' = RulesM $ tell $ RuleSet route' mempty mempty
4849
4950-- | Add a number of compilers
5051--
5152tellCompilers :: (Binary a, Typeable a, Writable a)
5253 => [(Identifier, Compiler () a)]
5354 -> Rules
54−tellCompilers compilers = RulesM $ tell $ RuleSet mempty $
55− map (second boxCompiler) compilers
55+tellCompilers compilers = RulesM $ tell $ RuleSet mempty compilers' mempty
5656 where
57+ compilers' = map (second boxCompiler) compilers
5758 boxCompiler = (>>> arr compiledItem >>> arr CompileRule)
5859
60+-- | Add resources
61+--
62+tellResources :: [Resource]
63+ -> Rules
64+tellResources resources = RulesM $ tell $ RuleSet mempty mempty $ S.fromList resources
65+
5966-- | Add a compilation rule to the rules.
6067--
6168-- This instructs all resources matching the given pattern to be compiled using
@@ -66,8 +73,10 @@ compile :: (Binary a, Typeable a, Writable a)
6673 => Pattern -> Compiler Resource a -> Rules
6774compile pattern compiler = RulesM $ do
6875 identifiers <- matches pattern . map unResource . resourceList <$> ask
69− unRulesM $ tellCompilers $ flip map identifiers $ \identifier ->
70− (identifier, constA (Resource identifier) >>> compiler)
76+ unRulesM $ do
77+ tellCompilers $ flip map identifiers $ \identifier ->
78+ (identifier, constA (Resource identifier) >>> compiler)
79+ tellResources $ map Resource identifiers
7180
7281-- | Add a compilation rule
7382--
@@ -125,8 +134,9 @@ metaCompileWith :: (Binary a, Typeable a, Writable a)
125134 -- ^ Compiler generating the other compilers
126135 -> Rules
127136 -- ^ Resulting rules
128−metaCompileWith identifier compiler = RulesM $ tell $ RuleSet mempty
129− [(identifier, compiler >>> arr makeRule )]
137+metaCompileWith identifier compiler = RulesM $ tell $
138+ RuleSet mempty compilers mempty
130139 where
131140 makeRule = MetaCompileRule . map (second box)
141+ compilers = [(identifier, compiler >>> arr makeRule )]
132142 box = (>>> fromDependency identifier >>^ CompileRule . compiledItem)