@@ -9,10 +9,12 @@ module Hakyll.Core.Target.Internal
9 , runTarget
9 , runTarget
12+import Control.Applicative (Applicative)
12import Control.Monad.Trans (MonadIO)
13import Control.Monad.Trans (MonadIO)
13import Control.Monad.Reader (ReaderT, runReaderT)
14import Control.Monad.Reader (ReaderT, runReaderT)
15import Hakyll.Core.Identifier
16import Hakyll.Core.Identifier
17+import Hakyll.Core.ResourceProvider
17-- | A lookup with which we can get dependencies
19-- | A lookup with which we can get dependencies
@@ -21,15 +23,16 @@ type DependencyLookup a = Identifier -> a
21-- | Environment for the target monad
23-- | Environment for the target monad
23data TargetEnvironment a = TargetEnvironment
25data TargetEnvironment a = TargetEnvironment
24− { targetIdentifier :: Identifier
26+ { targetIdentifier :: Identifier -- ^ Identifier
25 , targetDependencyLookup :: DependencyLookup a -- ^ Dependency lookup
27 , targetDependencyLookup :: DependencyLookup a -- ^ Dependency lookup
28+ , targetResourceProvider :: ResourceProvider -- ^ To get resources
28-- | Monad for targets. In this monad, the user can compose targets and describe
31-- | Monad for targets. In this monad, the user can compose targets and describe
29-- how they should be created.
32-- how they should be created.
31newtype TargetM a b = TargetM {unTargetM :: ReaderT (TargetEnvironment a) IO b}
34newtype TargetM a b = TargetM {unTargetM :: ReaderT (TargetEnvironment a) IO b}
32− deriving (Monad, Functor, MonadIO)
35+ deriving (Monad, Functor, Applicative, MonadIO)
34-- | Simplification of the 'TargetM' type for concrete cases: the type of the
37-- | Simplification of the 'TargetM' type for concrete cases: the type of the
35-- returned item should equal the type of the dependencies.
38-- returned item should equal the type of the dependencies.
@@ -38,10 +41,15 @@ type Target a = TargetM a a
39-- | Run a target, yielding an actual result.
42-- | Run a target, yielding an actual result.
41−runTarget :: Target a -> Identifier -> DependencyLookup a -> IO a
46+ -> DependencyLookup a
42−runTarget target id' lookup' = runReaderT (unTargetM target) env
49+runTarget target id' lookup' provider = runReaderT (unTargetM target) env
44 env = TargetEnvironment
51 env = TargetEnvironment
45 { targetIdentifier = id'
52 { targetIdentifier = id'
46 , targetDependencyLookup = lookup'
53 , targetDependencyLookup = lookup'
54+ , targetResourceProvider = provider