summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2013-02-16 13:01:57 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2013-02-16 13:01:57 +0100
commit4c40cea9e1ddef01e25f135656551ef8d494cffb (patch)
tree7c5f9d1983d9dfe0732c628a54d122f6b389679e /src
parent61dcb5f454fcbd912b09839021f4c79ca60973fe (diff)
parent1c2804287a099b4ac2f6c2d9b3db452f7ef7bee1 (diff)
downloadhakyll-4c40cea9e1ddef01e25f135656551ef8d494cffb.tar.gz
Merge branch 'master' into dev-metadata-route
Conflicts: tests/Hakyll/Core/Rules/Tests.hs
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