From 1c2804287a099b4ac2f6c2d9b3db452f7ef7bee1 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sat, 16 Feb 2013 12:59:38 +0100 Subject: Add a test for compiler/route ordering --- src/Hakyll/Core/Rules/Internal.hs | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'src/Hakyll/Core') diff --git a/src/Hakyll/Core/Rules/Internal.hs b/src/Hakyll/Core/Rules/Internal.hs index 09d9b1e..6bb82df 100644 --- a/src/Hakyll/Core/Rules/Internal.hs +++ b/src/Hakyll/Core/Rules/Internal.hs @@ -16,9 +16,9 @@ import Control.Applicative (Applicative, (<$>)) import Control.Monad.Reader (ask) import Control.Monad.RWS (RWST, runRWST) import Control.Monad.Trans (liftIO) +import qualified Data.Map as M import Data.Monoid (Monoid, mappend, mempty) import Data.Set (Set) -import qualified Data.Set as S -------------------------------------------------------------------------------- @@ -92,25 +92,17 @@ instance MonadMetadata Rules where runRules :: Rules a -> Provider -> IO RuleSet runRules rules provider = do (_, _, ruleSet) <- runRWST (unRules rules) env emptyRulesState - case findDuplicate (map fst $ rulesCompilers ruleSet) of - Nothing -> return ruleSet - Just id' -> error $ - "Hakyll.Core.Rules.Internal: two different rules for " ++ - show id' ++ " exist, bailing out" + -- Ensure compiler uniqueness + let ruleSet' = ruleSet + { rulesCompilers = M.toList $ + M.fromListWith (flip const) (rulesCompilers ruleSet) + } + + return ruleSet' where env = RulesRead { rulesProvider = provider , rulesMatches = [] , rulesVersion = Nothing } - - --------------------------------------------------------------------------------- -findDuplicate :: Ord a => [a] -> Maybe a -findDuplicate = go S.empty - where - go _ [] = Nothing - go s (x : xs) - | x `S.member` s = Just x - | otherwise = go (S.insert x s) xs -- cgit v1.2.3