@@ -93,7 +93,6 @@ module Hakyll.Core.Compiler
93 ( Compiler
93 ( Compiler
94 , runCompiler
94 , runCompiler
95 , getIdentifier
95 , getIdentifier
97 , getRoute
96 , getRoute
98 , getRouteFor
97 , getRouteFor
99 , getResourceString
98 , getResourceString
@@ -135,8 +134,7 @@ import Hakyll.Core.Identifier
135import Hakyll.Core.Identifier.Pattern
134import Hakyll.Core.Identifier.Pattern
136import Hakyll.Core.CompiledItem
135import Hakyll.Core.CompiledItem
137import Hakyll.Core.Writable
136import Hakyll.Core.Writable
138−import Hakyll.Core.Resource
137+import Hakyll.Core.ResourceProvider
139−import Hakyll.Core.Resource.Provider
140import Hakyll.Core.Compiler.Internal
138import Hakyll.Core.Compiler.Internal
141import Hakyll.Core.Store (Store)
139import Hakyll.Core.Store (Store)
142import Hakyll.Core.Rules.Internal
140import Hakyll.Core.Rules.Internal
@@ -181,11 +179,6 @@ getIdentifier :: Compiler a (Identifier b)
181getIdentifier = fromJob $ const $ CompilerM $
179getIdentifier = fromJob $ const $ CompilerM $
182 castIdentifier . compilerIdentifier <$> ask
180 castIdentifier . compilerIdentifier <$> ask
184−-- | Get the resource that is currently being compiled
186−getResource :: Compiler a Resource
187−getResource = getIdentifier >>> arr fromIdentifier
189-- | Get the route we are using for this item
182-- | Get the route we are using for this item
191getRoute :: Compiler a (Maybe FilePath)
184getRoute :: Compiler a (Maybe FilePath)
@@ -200,22 +193,23 @@ getRouteFor = fromJob $ \identifier -> CompilerM $ do
201-- | Get the resource we are compiling as a string
194-- | Get the resource we are compiling as a string
203−getResourceString :: Compiler Resource String
196+getResourceString :: Compiler a String
204getResourceString = getResourceWith resourceString
197getResourceString = getResourceWith resourceString
206-- | Get the resource we are compiling as a lazy bytestring
199-- | Get the resource we are compiling as a lazy bytestring
208−getResourceLBS :: Compiler Resource ByteString
201+getResourceLBS :: Compiler a ByteString
209getResourceLBS = getResourceWith resourceLBS
202getResourceLBS = getResourceWith resourceLBS
211-- | Overloadable function for 'getResourceString' and 'getResourceLBS'
204-- | Overloadable function for 'getResourceString' and 'getResourceLBS'
213−getResourceWith :: (Resource -> IO a) -> Compiler Resource a
206+getResourceWith :: (Identifier a -> IO b) -> Compiler c b
214−getResourceWith reader = fromJob $ \r -> CompilerM $ do
207+getResourceWith reader = fromJob $ \_ -> CompilerM $ do
215− let filePath = unResource r
216 provider <- compilerResourceProvider <$> ask
208 provider <- compilerResourceProvider <$> ask
209+ r <- compilerIdentifier <$> ask
210+ let filePath = toFilePath r
217 if resourceExists provider r
211 if resourceExists provider r
218− then liftIO $ reader r
212+ then liftIO $ reader $ castIdentifier r
219 else throwError $ error' filePath
213 else throwError $ error' filePath
221 error' id' = "Hakyll.Core.Compiler.getResourceWith: resource "
215 error' id' = "Hakyll.Core.Compiler.getResourceWith: resource "
@@ -299,17 +293,17 @@ requireAllA pattern = (id &&& requireAll_ pattern >>>)
300cached :: (Binary a, Typeable a, Writable a)
294cached :: (Binary a, Typeable a, Writable a)
301 => String
295 => String
302− -> Compiler Resource a
296+ -> Compiler () a
303− -> Compiler Resource a
297+ -> Compiler () a
304cached name (Compiler d j) = Compiler d $ const $ CompilerM $ do
298cached name (Compiler d j) = Compiler d $ const $ CompilerM $ do
305− logger <- compilerLogger <$> ask
299+ logger <- compilerLogger <$> ask
306 identifier <- castIdentifier . compilerIdentifier <$> ask
300 identifier <- castIdentifier . compilerIdentifier <$> ask
307− store <- compilerStore <$> ask
301+ store <- compilerStore <$> ask
308− modified <- compilerResourceModified <$> ask
302+ modified <- compilerResourceModified <$> ask
309− progName <- liftIO getProgName
303+ progName <- liftIO getProgName
310 report logger $ "Checking cache: " ++ if modified then "modified" else "OK"
304 report logger $ "Checking cache: " ++ if modified then "modified" else "OK"
311 if modified
305 if modified
312− then do v <- unCompilerM $ j $ fromIdentifier identifier
306+ then do v <- unCompilerM $ j ()
313 liftIO $ Store.set store [name, show identifier] v
307 liftIO $ Store.set store [name, show identifier] v
315 else do v <- liftIO $ Store.get store [name, show identifier]
309 else do v <- liftIO $ Store.get store [name, show identifier]