summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Hakyll/Core/DependencyAnalyzer.hs1
-rw-r--r--src/Hakyll/Core/Run.hs13
2 files changed, 12 insertions, 2 deletions
diff --git a/src/Hakyll/Core/DependencyAnalyzer.hs b/src/Hakyll/Core/DependencyAnalyzer.hs
index 2f13b37..c39b399 100644
--- a/src/Hakyll/Core/DependencyAnalyzer.hs
+++ b/src/Hakyll/Core/DependencyAnalyzer.hs
@@ -48,6 +48,7 @@ data DependencyAnalyzer a = DependencyAnalyzer
data Signal a = Build a
| Cycle [a]
| Done
+ deriving (Show)
instance (Ord a, Show a) => Monoid (DependencyAnalyzer a) where
mempty = DependencyAnalyzer mempty mempty mempty mempty
diff --git a/src/Hakyll/Core/Run.hs b/src/Hakyll/Core/Run.hs
index b076cb0..e2cab3c 100644
--- a/src/Hakyll/Core/Run.hs
+++ b/src/Hakyll/Core/Run.hs
@@ -6,7 +6,7 @@ module Hakyll.Core.Run
) where
import Prelude hiding (reverse)
-import Control.Monad (filterM)
+import Control.Monad (filterM, forM_)
import Control.Monad.Trans (liftIO)
import Control.Applicative (Applicative, (<$>))
import Control.Monad.Reader (ReaderT, runReaderT, ask)
@@ -147,9 +147,18 @@ stepAnalyzer = Runtime $ do
put $ state { hakyllAnalyzer = analyzer' }
case signal of Done -> return ()
- Cycle _ -> return ()
+ Cycle c -> unRuntime $ dumpCycle c
Build id' -> unRuntime $ build id'
+-- | Dump cyclic error and quit
+--
+dumpCycle :: [Identifier] -> Runtime ()
+dumpCycle cycle' = Runtime $ do
+ logger <- hakyllLogger <$> ask
+ section logger "Dependency cycle detected! Conflict:"
+ forM_ (zip cycle' $ drop 1 cycle') $ \(x, y) ->
+ report logger $ show x ++ " -> " ++ show y
+
build :: Identifier -> Runtime ()
build id' = Runtime $ do
logger <- hakyllLogger <$> ask