summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2013-02-16 12:59:38 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2013-02-16 12:59:38 +0100
commit1c2804287a099b4ac2f6c2d9b3db452f7ef7bee1 (patch)
treed5069a5124c734fb105f50821c357652e5e9dd61 /src
parent02a92d54cdee8299aac0f55cbe4a930ac5060d20 (diff)
downloadhakyll-1c2804287a099b4ac2f6c2d9b3db452f7ef7bee1.tar.gz
Add a test for compiler/route ordering
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll/Core/Rules/Internal.hs24
1 files changed, 8 insertions, 16 deletions
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