diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-12-27 18:38:46 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-12-27 18:38:46 +0100 |
commit | a1043203bb4ef5bc1af4c9a8957af36d163f03fb (patch) | |
tree | c308082440d941b5bf2231564f2f6e1d8279013d /src/Hakyll | |
parent | e07014b5bd51fba81710d6b454df40ea62b6581a (diff) | |
download | hakyll-a1043203bb4ef5bc1af4c9a8957af36d163f03fb.tar.gz |
Add a snapshot state to target monad
Diffstat (limited to 'src/Hakyll')
-rw-r--r-- | src/Hakyll/Core/Target/Internal.hs | 18 |
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 + } |