on master help sign in
Add requireA/requireAllA functions
commit89cd33c7230bae30de5f74afab7fe50b2a6517db authorJasper Van der Jeugt <jaspervdj@gmail.com> dateTue 18 Jan 2011, 23:58 (16 years ago) parent374a9dd
1 file changed+18
src/Hakyll/Core/Compiler.hs+18
src/Hakyll/Core/Compiler.hs+18
@@ -9,7 +9,9 @@ module Hakyll.Core.Compiler
99 , getResourceString
1010 , fromDependency
1111 , require
12+ , requireA
1213 , requireAll
14+ , requireAllA
1315 , cached
1416 , unsafeCompiler
1517 ) where
@@ -108,6 +110,14 @@ require identifier f =
108110 y <- getDependency identifier
109111 return $ f x y
110112
113+-- | Arrow-based variant of 'require'
114+--
115+requireA :: (Binary a, Typeable a, Writable a)
116+ => Identifier
117+ -> Compiler (b, a) c
118+ -> Compiler b c
119+requireA identifier = (require identifier (,) >>>)
120+
111121-- | Require a number of targets. Using this function ensures automatic handling
112122-- of dependencies
113123--
@@ -124,6 +134,14 @@ requireAll pattern f =
124134 items <- mapM (unCompilerM . getDependency) deps
125135 return $ f x items
126136
137+-- | Arrow-based variant of 'require'
138+--
139+requireAllA :: (Binary a, Typeable a, Writable a)
140+ => Pattern
141+ -> Compiler (b, [a]) c
142+ -> Compiler b c
143+requireAllA pattern = (requireAll pattern (,) >>>)
144+
127145cached :: (Binary a, Typeable a, Writable a)
128146 => String
129147 -> Compiler () a