summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/Compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/Hakyll/Core/Compiler')
-rw-r--r--src/Hakyll/Core/Compiler/Internal.hs6
-rw-r--r--src/Hakyll/Core/Compiler/Require.hs8
2 files changed, 11 insertions, 3 deletions
diff --git a/src/Hakyll/Core/Compiler/Internal.hs b/src/Hakyll/Core/Compiler/Internal.hs
index 8eb950c..6e07602 100644
--- a/src/Hakyll/Core/Compiler/Internal.hs
+++ b/src/Hakyll/Core/Compiler/Internal.hs
@@ -29,6 +29,8 @@ import Control.Applicative (Alternative (..),
Applicative (..), (<$>))
import Control.Exception (SomeException, handle)
import Data.Monoid (Monoid (..))
+import Data.Set (Set)
+import qualified Data.Set as S
--------------------------------------------------------------------------------
@@ -50,7 +52,7 @@ data CompilerRead = CompilerRead
, -- | Resource provider
compilerProvider :: Provider
, -- | List of all known identifiers
- compilerUniverse :: [Identifier]
+ compilerUniverse :: Set Identifier
, -- | Site routes
compilerRoutes :: Routes
, -- | Compiler store
@@ -219,6 +221,6 @@ compilerGetMetadata identifier = do
compilerGetMatches :: Pattern -> Compiler [Identifier]
compilerGetMatches pattern = do
universe <- compilerUniverse <$> compilerAsk
- let matching = filterMatches pattern universe
+ let matching = filterMatches pattern $ S.toList universe
compilerTellDependencies [PatternDependency pattern matching]
return matching
diff --git a/src/Hakyll/Core/Compiler/Require.hs b/src/Hakyll/Core/Compiler/Require.hs
index f67bf2c..3571bf6 100644
--- a/src/Hakyll/Core/Compiler/Require.hs
+++ b/src/Hakyll/Core/Compiler/Require.hs
@@ -14,7 +14,9 @@ module Hakyll.Core.Compiler.Require
--------------------------------------------------------------------------------
import Control.Applicative ((<$>))
+import Control.Monad (when)
import Data.Binary (Binary)
+import qualified Data.Set as S
import Data.Typeable
@@ -61,7 +63,11 @@ require id' = requireSnapshot id' final
requireSnapshot :: (Binary a, Typeable a)
=> Identifier -> Snapshot -> Compiler (Item a)
requireSnapshot id' snapshot = do
- store <- compilerStore <$> compilerAsk
+ store <- compilerStore <$> compilerAsk
+ universe <- compilerUniverse <$> compilerAsk
+
+ -- Quick check for better error messages
+ when (id' `S.notMember` universe) $ compilerThrow notFound
compilerTellDependencies [IdentifierDependency id']
compilerResult $ CompilerRequire id' $ do