on master help sign in
Allow IO operations in compilers
commit2f951598efa4bc879bad22c3ae94991fff41694e authorJasper Van der Jeugt <jaspervdj@gmail.com> dateMon 17 Jan 2011, 22:43 (16 years ago) parentc576424
1 file changed+7
src/Hakyll/Core/Compiler.hs+7
src/Hakyll/Core/Compiler.hs+7
@@ -11,6 +11,7 @@ module Hakyll.Core.Compiler
1111 , require
1212 , requireAll
1313 , cached
14+ , unsafeCompiler
1415 ) where
1516
1617import Prelude hiding ((.), id)
@@ -142,3 +143,9 @@ cached name (Compiler d j) = Compiler d $ const $ CompilerM $ do
142143 Nothing -> error'
143144 where
144145 error' = error "Hakyll.Core.Compiler.cached: Cache corrupt!"
146+
147+-- | Create an unsafe compiler from a function in IO
148+--
149+unsafeCompiler :: (a -> IO b) -- ^ Function to lift
150+ -> Compiler a b -- ^ Resulting compiler
151+unsafeCompiler f = fromJob $ CompilerM . liftIO . f