diff options
-rw-r--r-- | src/Hakyll/Core/Rules/Internal.hs | 22 | ||||
-rw-r--r-- | src/Hakyll/Core/Runtime.hs | 3 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/Hakyll/Core/Rules/Internal.hs b/src/Hakyll/Core/Rules/Internal.hs index a7c2059..72166c8 100644 --- a/src/Hakyll/Core/Rules/Internal.hs +++ b/src/Hakyll/Core/Rules/Internal.hs @@ -16,6 +16,7 @@ import Control.Applicative (Applicative, (<$>)) import Control.Monad.Reader (ask) import Control.Monad.RWS (RWST, runRWST) import Control.Monad.Trans (liftIO) +import Data.Map (Map) import qualified Data.Map as M import Data.Monoid (Monoid, mappend, mempty) import Data.Set (Set) @@ -97,15 +98,26 @@ runRules rules provider = do (_, _, ruleSet) <- runRWST (unRules rules) env emptyRulesState -- Ensure compiler uniqueness - let ruleSet' = ruleSet - { rulesCompilers = M.toList $ - M.fromListWith (flip const) (rulesCompilers ruleSet) - } + uniqueCompilers <- case fromListUnique (rulesCompilers ruleSet) of + Right m -> return m + Left id' -> error $ + "Hakyll.Core.Rules.Internal.runRules: duplicate compiler for " ++ + show id' - return ruleSet' + return ruleSet {rulesCompilers = M.toList uniqueCompilers} where env = RulesRead { rulesProvider = provider , rulesMatches = [] , rulesVersion = Nothing } + + +-------------------------------------------------------------------------------- +fromListUnique :: Ord k => [(k, v)] -> Either k (Map k v) +fromListUnique = go M.empty + where + go m [] = Right m + go m ((k, v) : zs) = case M.lookup k m of + Nothing -> go (M.insert k v m) zs + Just _ -> Left k diff --git a/src/Hakyll/Core/Runtime.hs b/src/Hakyll/Core/Runtime.hs index 824d11b..208fcc3 100644 --- a/src/Hakyll/Core/Runtime.hs +++ b/src/Hakyll/Core/Runtime.hs @@ -53,7 +53,8 @@ run config verbosity rules = do provider <- newProvider store (shouldIgnoreFile config) $ providerDirectory config Logger.message logger "Running rules..." - ruleSet <- runRules rules provider + Logger.flush logger + ruleSet <- runRules rules provider -- Get old facts mOldFacts <- Store.get store factsKey |