summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/Compiler
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-04-12 10:09:03 +0200
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-04-12 10:09:03 +0200
commitb37da38d3911bbc8381a39fe526e69599d9ddcf1 (patch)
treed27f2dbf8860ddbdf0d791aff77dd8504ba6da92 /src/Hakyll/Core/Compiler
parent0a3cd37cc9635d2d1e6696bff91dcd37e81bd202 (diff)
downloadhakyll-b37da38d3911bbc8381a39fe526e69599d9ddcf1.tar.gz
Major refactoring of identifiers/resources/groups
Diffstat (limited to 'src/Hakyll/Core/Compiler')
-rw-r--r--src/Hakyll/Core/Compiler/Internal.hs28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/Hakyll/Core/Compiler/Internal.hs b/src/Hakyll/Core/Compiler/Internal.hs
index 1a3c4c3..594c23e 100644
--- a/src/Hakyll/Core/Compiler/Internal.hs
+++ b/src/Hakyll/Core/Compiler/Internal.hs
@@ -39,9 +39,9 @@ type Dependencies = Set Identifier
--
data DependencyEnvironment = DependencyEnvironment
{ -- | Target identifier
- dependencyIdentifier :: Identifier
- , -- | Resource provider
- dependencyResourceProvider :: ResourceProvider
+ dependencyIdentifier :: Identifier
+ , -- | List of available identifiers we can depend upon
+ dependencyUniverse :: [Identifier]
}
-- | Environment in which a compiler runs
@@ -51,6 +51,8 @@ data CompilerEnvironment = CompilerEnvironment
compilerIdentifier :: Identifier
, -- | Resource provider
compilerResourceProvider :: ResourceProvider
+ , -- | List of all known identifiers
+ compilerUniverse :: [Identifier]
, -- | Site routes
compilerRoutes :: Routes
, -- | Compiler store
@@ -107,17 +109,19 @@ instance ArrowChoice Compiler where
runCompilerJob :: Compiler () a -- ^ Compiler to run
-> Identifier -- ^ Target identifier
-> ResourceProvider -- ^ Resource provider
+ -> [Identifier] -- ^ Universe
-> Routes -- ^ Route
-> Store -- ^ Store
-> Bool -- ^ Was the resource modified?
-> Logger -- ^ Logger
-> IO (Throwing a) -- ^ Result
-runCompilerJob compiler identifier provider route store modified logger =
+runCompilerJob compiler id' provider universe route store modified logger =
runReaderT (runErrorT $ unCompilerM $ compilerJob compiler ()) env
where
env = CompilerEnvironment
- { compilerIdentifier = identifier
+ { compilerIdentifier = id'
, compilerResourceProvider = provider
+ , compilerUniverse = universe
, compilerRoutes = route
, compilerStore = store
, compilerResourceModified = modified
@@ -126,25 +130,25 @@ runCompilerJob compiler identifier provider route store modified logger =
runCompilerDependencies :: Compiler () a
-> Identifier
- -> ResourceProvider
+ -> [Identifier]
-> Dependencies
-runCompilerDependencies compiler identifier provider =
+runCompilerDependencies compiler identifier universe =
runReader (compilerDependencies compiler) env
where
env = DependencyEnvironment
- { dependencyIdentifier = identifier
- , dependencyResourceProvider = provider
+ { dependencyIdentifier = identifier
+ , dependencyUniverse = universe
}
fromJob :: (a -> CompilerM b)
-> Compiler a b
fromJob = Compiler (return S.empty)
-fromDependencies :: (Identifier -> ResourceProvider -> [Identifier])
+fromDependencies :: (Identifier -> [Identifier] -> [Identifier])
-> Compiler b b
fromDependencies collectDeps = flip Compiler return $ do
- DependencyEnvironment identifier provider <- ask
- return $ S.fromList $ collectDeps identifier provider
+ DependencyEnvironment identifier universe <- ask
+ return $ S.fromList $ collectDeps identifier universe
-- | Wait until another compiler has finished before running this compiler
--