diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-01-25 11:14:22 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-01-25 11:14:22 +0100 |
commit | e536a5961c8ba795660c37349091c4a9427876fe (patch) | |
tree | 6a135b609f22d26f022551fe379e2e3f9ba2f15f /src/Hakyll/Core/Compiler | |
parent | 9b3e52412887da7d8864fcbde3af19edabfa9bd4 (diff) | |
download | hakyll-e536a5961c8ba795660c37349091c4a9427876fe.tar.gz |
Functor & Applicative instances for Compiler
Diffstat (limited to 'src/Hakyll/Core/Compiler')
-rw-r--r-- | src/Hakyll/Core/Compiler/Internal.hs | 10 |
1 files changed, 9 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) = |