summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Hakyll/Core/Compiler/Internal.hs10
-rw-r--r--src/Hakyll/Core/Rules.hs2
2 files changed, 11 insertions, 1 deletions
diff --git a/src/Hakyll/Core/Compiler/Internal.hs b/src/Hakyll/Core/Compiler/Internal.hs
index 5ae2f5b..f1d591d 100644
--- a/src/Hakyll/Core/Compiler/Internal.hs
+++ b/src/Hakyll/Core/Compiler/Internal.hs
@@ -14,7 +14,7 @@ module Hakyll.Core.Compiler.Internal
) where
import Prelude hiding ((.), id)
-import Control.Applicative (Applicative, (<$>))
+import Control.Applicative (Applicative, pure, (<*>), (<$>))
import Control.Monad.Reader (ReaderT, Reader, ask, runReaderT, runReader)
import Control.Monad ((<=<), liftM2)
import Data.Set (Set)
@@ -58,6 +58,14 @@ data Compiler a b = Compiler
, compilerJob :: a -> CompilerM b
}
+instance Functor (Compiler a) where
+ fmap f (Compiler d j) = Compiler d $ fmap f . j
+
+instance Applicative (Compiler a) where
+ pure = Compiler (return S.empty) . const . return
+ (Compiler d1 f) <*> (Compiler d2 j) =
+ Compiler (liftM2 S.union d1 d2) $ \x -> f x <*> j x
+
instance Category Compiler where
id = Compiler (return S.empty) return
(Compiler d1 j1) . (Compiler d2 j2) =
diff --git a/src/Hakyll/Core/Rules.hs b/src/Hakyll/Core/Rules.hs
index dd0d9a6..1060af9 100644
--- a/src/Hakyll/Core/Rules.hs
+++ b/src/Hakyll/Core/Rules.hs
@@ -109,6 +109,8 @@ route pattern route' = tellRoute $ ifMatch pattern route'
-- | Add a compiler that produces other compilers over time
--
+-- TODO: Rename to metaCompile? Auto-generate identifier?
+--
addCompilers :: (Binary a, Typeable a, Writable a)
=> Identifier
-- ^ Identifier for this compiler