@@ -3,10 +3,10 @@
3{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3{-# LANGUAGE GeneralizedNewtypeDeriving #-}
4module Hakyll.Core.Compiler
4module Hakyll.Core.Compiler
6 , getIdentifier
7 , getIdentifier
8 , getResourceString
9 , getResourceString
11 , requireAll
11 , requireAll
@@ -31,6 +31,23 @@ import Hakyll.Core.ResourceProvider
31import Hakyll.Core.Compiler.Internal
31import Hakyll.Core.Compiler.Internal
32import Hakyll.Core.Store
32import Hakyll.Core.Store
34+-- | Run a compiler, yielding the resulting target and it's dependencies. This
35+-- version of 'runCompilerJob' also stores the result
37+runCompiler :: Compiler () CompiledItem -- ^ Compiler to run
38+ -> Identifier -- ^ Target identifier
39+ -> ResourceProvider -- ^ Resource provider
40+ -> DependencyLookup -- ^ Dependency lookup table
41+ -> Maybe FilePath -- ^ Route
43+ -> Bool -- ^ Was the resource modified?
44+ -> IO CompiledItem -- ^ Resulting item
45+runCompiler compiler identifier provider lookup' route store modified = do
46+ CompiledItem result <- runCompilerJob
47+ compiler identifier provider lookup' route store modified
48+ storeSet store "Hakyll.Core.Compiler.runCompiler" identifier result
49+ return $ CompiledItem result
34-- | Get the identifier of the item that is currently being compiled
51-- | Get the identifier of the item that is currently being compiled
36getIdentifier :: Compiler a Identifier
53getIdentifier :: Compiler a Identifier
@@ -50,12 +67,6 @@ getResourceString = getIdentifier >>> getResourceString'
50 provider <- compilerResourceProvider <$> ask
67 provider <- compilerResourceProvider <$> ask
51 liftIO $ resourceString provider id'
68 liftIO $ resourceString provider id'
53−-- | Store a finished item in the cache
55−storeResult :: Store -> Identifier -> CompiledItem -> IO ()
56−storeResult store identifier (CompiledItem x) =
57− storeSet store "Hakyll.Core.Compiler.storeResult" identifier x
59-- | Auxiliary: get a dependency
70-- | Auxiliary: get a dependency
61getDependencyOrResult :: (Binary a, Writable a, Typeable a)
72getDependencyOrResult :: (Binary a, Writable a, Typeable a)
@@ -68,7 +79,7 @@ getDependencyOrResult identifier = CompilerM $ do
68 Just r -> return $ unCompiledItem r
79 Just r -> return $ unCompiledItem r
69 -- Not found here, try the main cache
80 -- Not found here, try the main cache
70 Nothing -> fmap (fromMaybe error') $ liftIO $
81 Nothing -> fmap (fromMaybe error') $ liftIO $
71− storeGet store "Hakyll.Core.Compiler.storeResult" identifier
82+ storeGet store "Hakyll.Core.Compiler.runCompiler" identifier
73 error' = error "Hakyll.Core.Compiler.getDependency: Not found"
84 error' = error "Hakyll.Core.Compiler.getDependency: Not found"