1-- | A Compiler manages targets and dependencies between targets.
3{-# LANGUAGE GeneralizedNewtypeDeriving #-}
4module Hakyll.Core.Compiler
12import Prelude hiding ((.), id)
13import Control.Arrow ((>>>))
14import Control.Applicative ((<$>))
15import Control.Monad.Reader (ask)
16import Control.Monad.Trans (liftIO)
17import Control.Category (Category, (.))
19import Data.Binary (Binary)
20import Data.Typeable (Typeable)
22import Hakyll.Core.Identifier
23import Hakyll.Core.Identifier.Pattern
24import Hakyll.Core.CompiledItem
25import Hakyll.Core.Writable
26import Hakyll.Core.ResourceProvider
27import Hakyll.Core.Compiler.Internal
29getIdentifier :: Compiler a Identifier
30getIdentifier = fromJob $ const $ CompilerM $
31 compilerIdentifier <$> ask
33getResourceString :: Compiler a String
34getResourceString = getIdentifier >>> getResourceString'
36 getResourceString' = fromJob $ \id' -> CompilerM $ do
37 provider <- compilerResourceProvider <$> ask
38 liftIO $ resourceString provider id'
40-- | Require another target. Using this function ensures automatic handling of
43require :: (Binary a, Typeable a, Writable a)
48 fromDependencies (const [identifier]) >>> fromJob require'
50 require' x = CompilerM $ do
51 lookup' <- compilerDependencyLookup <$> ask
52 return $ f x $ unCompiledItem $ lookup' identifier
54-- | Require a number of targets. Using this function ensures automatic handling
57requireAll :: (Binary a, Typeable a, Writable a)
62 fromDependencies getDeps >>> fromJob requireAll'
64 getDeps = matches pattern . resourceList
65 requireAll' x = CompilerM $ do
66 deps <- getDeps . compilerResourceProvider <$> ask
67 lookup' <- compilerDependencyLookup <$> ask
68 return $ f x $ map (unCompiledItem . lookup') deps
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list