summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/Target/Internal.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Hakyll/Core/Target/Internal.hs')
-rw-r--r--src/Hakyll/Core/Target/Internal.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/Hakyll/Core/Target/Internal.hs b/src/Hakyll/Core/Target/Internal.hs
index 96e3087..f40c798 100644
--- a/src/Hakyll/Core/Target/Internal.hs
+++ b/src/Hakyll/Core/Target/Internal.hs
@@ -9,10 +9,12 @@ module Hakyll.Core.Target.Internal
, runTarget
) where
+import Control.Applicative (Applicative)
import Control.Monad.Trans (MonadIO)
import Control.Monad.Reader (ReaderT, runReaderT)
import Hakyll.Core.Identifier
+import Hakyll.Core.ResourceProvider
-- | A lookup with which we can get dependencies
--
@@ -21,15 +23,16 @@ type DependencyLookup a = Identifier -> a
-- | Environment for the target monad
--
data TargetEnvironment a = TargetEnvironment
- { targetIdentifier :: Identifier
+ { targetIdentifier :: Identifier -- ^ Identifier
, targetDependencyLookup :: DependencyLookup a -- ^ Dependency lookup
+ , targetResourceProvider :: ResourceProvider -- ^ To get resources
}
-- | Monad for targets. In this monad, the user can compose targets and describe
-- how they should be created.
--
newtype TargetM a b = TargetM {unTargetM :: ReaderT (TargetEnvironment a) IO b}
- deriving (Monad, Functor, MonadIO)
+ deriving (Monad, Functor, Applicative, MonadIO)
-- | Simplification of the 'TargetM' type for concrete cases: the type of the
-- returned item should equal the type of the dependencies.
@@ -38,10 +41,15 @@ type Target a = TargetM a a
-- | Run a target, yielding an actual result.
--
-runTarget :: Target a -> Identifier -> DependencyLookup a -> IO a
-runTarget target id' lookup' = runReaderT (unTargetM target) env
+runTarget :: Target a
+ -> Identifier
+ -> DependencyLookup a
+ -> ResourceProvider
+ -> IO a
+runTarget target id' lookup' provider = runReaderT (unTargetM target) env
where
env = TargetEnvironment
{ targetIdentifier = id'
, targetDependencyLookup = lookup'
+ , targetResourceProvider = provider
}