Add makePatternDependency
This commit is contained in:
parent
3b9b11c636
commit
9bd35cd755
2 changed files with 11 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
module Hakyll.Core.Metadata
|
module Hakyll.Core.Metadata
|
||||||
( Metadata
|
( Metadata
|
||||||
, MonadMetadata (..)
|
, MonadMetadata (..)
|
||||||
|
, makePatternDependency
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +12,7 @@ import Data.Map (Map)
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
import Hakyll.Core.Dependencies
|
||||||
import Hakyll.Core.Identifier
|
import Hakyll.Core.Identifier
|
||||||
import Hakyll.Core.Identifier.Pattern
|
import Hakyll.Core.Identifier.Pattern
|
||||||
|
|
||||||
|
@ -30,3 +32,10 @@ class Monad m => MonadMetadata m where
|
||||||
forM matches' $ \id' -> do
|
forM matches' $ \id' -> do
|
||||||
metadata <- getMetadata id'
|
metadata <- getMetadata id'
|
||||||
return (id', metadata)
|
return (id', metadata)
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
makePatternDependency :: MonadMetadata m => Pattern -> m Dependency
|
||||||
|
makePatternDependency pattern = do
|
||||||
|
matches' <- getMatches pattern
|
||||||
|
return $ PatternDependency pattern matches'
|
||||||
|
|
|
@ -171,6 +171,8 @@ preprocess = Rules . liftIO
|
||||||
-- | Advanced usage: add extra dependencies to compilers. Basically this is
|
-- | Advanced usage: add extra dependencies to compilers. Basically this is
|
||||||
-- needed when you're doing unsafe tricky stuff in the rules monad, but you
|
-- needed when you're doing unsafe tricky stuff in the rules monad, but you
|
||||||
-- still want correct builds.
|
-- still want correct builds.
|
||||||
|
--
|
||||||
|
-- A useful utility for this purpose is 'makePatternDependency'.
|
||||||
rulesExtraDependencies :: [Dependency] -> Rules a -> Rules a
|
rulesExtraDependencies :: [Dependency] -> Rules a -> Rules a
|
||||||
rulesExtraDependencies deps = Rules . censor addDependencies . unRules
|
rulesExtraDependencies deps = Rules . censor addDependencies . unRules
|
||||||
where
|
where
|
||||||
|
|
Loading…
Reference in a new issue