diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-03-05 12:51:27 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-03-05 12:51:27 +0100 |
commit | 9bd35cd755a4e79804e1745cf116cadbb352690d (patch) | |
tree | 190d84e0df02f33257f11368198f55a181c7fcd4 /src | |
parent | 3b9b11c636787de9d5a0e5e49aff8e1495bd7c04 (diff) | |
download | hakyll-9bd35cd755a4e79804e1745cf116cadbb352690d.tar.gz |
Add makePatternDependency
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 |