diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Hakyll/Core/Metadata.hs | 9 | ||||
-rw-r--r-- | src/Hakyll/Core/Rules.hs | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/Hakyll/Core/Metadata.hs b/src/Hakyll/Core/Metadata.hs index 884acd3..9fc2d3e 100644 --- a/src/Hakyll/Core/Metadata.hs +++ b/src/Hakyll/Core/Metadata.hs @@ -2,6 +2,7 @@ module Hakyll.Core.Metadata ( Metadata , MonadMetadata (..) + , makePatternDependency ) where @@ -11,6 +12,7 @@ import Data.Map (Map) -------------------------------------------------------------------------------- +import Hakyll.Core.Dependencies import Hakyll.Core.Identifier import Hakyll.Core.Identifier.Pattern @@ -30,3 +32,10 @@ class Monad m => MonadMetadata m where forM matches' $ \id' -> do metadata <- getMetadata id' return (id', metadata) + + +-------------------------------------------------------------------------------- +makePatternDependency :: MonadMetadata m => Pattern -> m Dependency +makePatternDependency pattern = do + matches' <- getMatches pattern + return $ PatternDependency pattern matches' diff --git a/src/Hakyll/Core/Rules.hs b/src/Hakyll/Core/Rules.hs index 8037ffb..66210b6 100644 --- a/src/Hakyll/Core/Rules.hs +++ b/src/Hakyll/Core/Rules.hs @@ -171,6 +171,8 @@ 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 -- still want correct builds. +-- +-- A useful utility for this purpose is 'makePatternDependency'. rulesExtraDependencies :: [Dependency] -> Rules a -> Rules a rulesExtraDependencies deps = Rules . censor addDependencies . unRules where |