on master help sign in
Save dependency graph after run
commit9d95ef483d5ae251a5fae3c693507746dc1a2d16 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSun 20 Mar 2011, 17:17 (16 years ago) parent92aa446
3 files changed+17−10
src/Hakyll/Core/DirectedGraph/Internal.hs+4−3 src/Hakyll/Core/Identifier.hs+5−3 src/Hakyll/Core/Run.hs+8−4
src/Hakyll/Core/DirectedGraph/Internal.hs+4−3
@@ -1,7 +1,7 @@
11-- | Internal structure of the DirectedGraph type. Not exported outside of the
22-- library.
33--
4−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
4+{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-}
55module Hakyll.Core.DirectedGraph.Internal
66 ( Node (..)
77 , DirectedGraph (..)
@@ -16,13 +16,14 @@ import qualified Data.Map as M
1616import qualified Data.Set as S
1717
1818import Data.Binary (Binary, put, get)
19+import Data.Typeable (Typeable)
1920
2021-- | A node in the directed graph
2122--
2223data Node a = Node
2324 { nodeTag :: a -- ^ Tag identifying the node
2425 , nodeNeighbours :: Set a -- ^ Edges starting at this node
25− } deriving (Show)
26+ } deriving (Show, Typeable)
2627
2728instance (Binary a, Ord a) => Binary (Node a) where
2829 put (Node t n) = put t >> put n
@@ -41,7 +42,7 @@ appendNodes (Node t1 n1) (Node t2 n2)
4142-- | Type used to represent a directed graph
4243--
4344newtype DirectedGraph a = DirectedGraph {unDirectedGraph :: Map a (Node a)}
44− deriving (Show, Binary)
45+ deriving (Show, Binary, Typeable)
4546
4647-- | Allow users to concatenate different graphs
4748--
src/Hakyll/Core/Identifier.hs+5−3
@@ -20,7 +20,7 @@
2020-- @posts/foo.html@. In this case, the identifier is the name of the source
2121-- file of the page.
2222--
23−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
23+{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-}
2424module Hakyll.Core.Identifier
2525 ( Identifier (..)
2626 , parseIdentifier
@@ -29,14 +29,16 @@ module Hakyll.Core.Identifier
2929
3030import Control.Arrow (second)
3131import Data.Monoid (Monoid)
32+import System.FilePath (joinPath)
3233
34+import Data.Binary (Binary)
3335import GHC.Exts (IsString, fromString)
34−import System.FilePath (joinPath)
36+import Data.Typeable (Typeable)
3537
3638-- | An identifier used to uniquely identify a value
3739--
3840newtype Identifier = Identifier {unIdentifier :: [String]}
39− deriving (Eq, Ord, Monoid)
41+ deriving (Eq, Ord, Monoid, Binary, Typeable)
4042
4143instance Show Identifier where
4244 show = toFilePath
src/Hakyll/Core/Run.hs+8−4
@@ -1,6 +1,6 @@
11-- | This is the module which binds it all together
22--
3−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3+{-# LANGUAGE GeneralizedNewtypeDeriving, OverloadedStrings #-}
44module Hakyll.Core.Run
55 ( run
66 ) where
@@ -10,7 +10,7 @@ import Control.Monad (filterM)
1010import Control.Monad.Trans (liftIO)
1111import Control.Applicative (Applicative, (<$>))
1212import Control.Monad.Reader (ReaderT, runReaderT, ask)
13−import Control.Monad.State.Strict (StateT, evalStateT, get, modify)
13+import Control.Monad.State.Strict (StateT, runStateT, get, modify)
1414import Control.Arrow ((&&&))
1515import qualified Data.Map as M
1616import Data.Monoid (mempty, mappend)
@@ -50,9 +50,13 @@ run configuration rules = do
5050
5151 -- Extract the reader/state
5252 reader = unRuntime $ addNewCompilers [] compilers
53− state' = runReaderT reader $ env logger ruleSet provider store
53+ stateT = runReaderT reader $ env logger ruleSet provider store
5454
55− evalStateT state' state
55+ -- Run the program and fetch the resulting state
56+ ((), state') <- runStateT stateT state
57+
58+ -- We want to save the final dependency graph for the next run
59+ storeSet store "Hakyll.Core.Run.run" "dependencies" $ hakyllGraph state'
5660
5761 -- Flush and return
5862 flushLogger logger