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.hs18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/Hakyll/Core/Target/Internal.hs b/src/Hakyll/Core/Target/Internal.hs
index dce4bfe..e68de33 100644
--- a/src/Hakyll/Core/Target/Internal.hs
+++ b/src/Hakyll/Core/Target/Internal.hs
@@ -12,6 +12,7 @@ module Hakyll.Core.Target.Internal
import Control.Applicative (Applicative)
import Control.Monad.Trans (MonadIO)
import Control.Monad.Reader (ReaderT, runReaderT)
+import Control.Monad.State (StateT, evalStateT)
import Hakyll.Core.Identifier
import Hakyll.Core.ResourceProvider
@@ -30,11 +31,18 @@ data TargetEnvironment a = TargetEnvironment
, targetStore :: Store -- ^ Store for caching
}
+-- | State for the target monad
+--
+data TargetState = TargetState
+ { targetSnapshot :: Int -- ^ Snapshot ID
+ }
+
-- | 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, Applicative, MonadIO)
+newtype TargetM a b = TargetM
+ { unTargetM :: ReaderT (TargetEnvironment a) (StateT TargetState IO) b
+ } 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.
@@ -49,7 +57,8 @@ runTarget :: Target a
-> ResourceProvider
-> Store
-> IO a
-runTarget target id' lookup' provider store = runReaderT (unTargetM target) env
+runTarget target id' lookup' provider store =
+ evalStateT (runReaderT (unTargetM target) env) state
where
env = TargetEnvironment
{ targetIdentifier = id'
@@ -57,3 +66,6 @@ runTarget target id' lookup' provider store = runReaderT (unTargetM target) env
, targetResourceProvider = provider
, targetStore = store
}
+ state = TargetState
+ { targetSnapshot = 0
+ }