Add requireA/requireAllA functions

This commit is contained in:
Jasper Van der Jeugt 2011-01-18 23:58:29 +01:00
parent 374a9dde5a
commit 89cd33c723

View file

@ -9,7 +9,9 @@ module Hakyll.Core.Compiler
, getResourceString , getResourceString
, fromDependency , fromDependency
, require , require
, requireA
, requireAll , requireAll
, requireAllA
, cached , cached
, unsafeCompiler , unsafeCompiler
) where ) where
@ -108,6 +110,14 @@ require identifier f =
y <- getDependency identifier y <- getDependency identifier
return $ f x y return $ f x y
-- | Arrow-based variant of 'require'
--
requireA :: (Binary a, Typeable a, Writable a)
=> Identifier
-> Compiler (b, a) c
-> Compiler b c
requireA identifier = (require identifier (,) >>>)
-- | Require a number of targets. Using this function ensures automatic handling -- | Require a number of targets. Using this function ensures automatic handling
-- of dependencies -- of dependencies
-- --
@ -124,6 +134,14 @@ requireAll pattern f =
items <- mapM (unCompilerM . getDependency) deps items <- mapM (unCompilerM . getDependency) deps
return $ f x items return $ f x items
-- | Arrow-based variant of 'require'
--
requireAllA :: (Binary a, Typeable a, Writable a)
=> Pattern
-> Compiler (b, [a]) c
-> Compiler b c
requireAllA pattern = (requireAll pattern (,) >>>)
cached :: (Binary a, Typeable a, Writable a) cached :: (Binary a, Typeable a, Writable a)
=> String => String
-> Compiler () a -> Compiler () a