on master help sign in
Allow IO operations in compilers
2f95159Jasper Van der Jeugt
src/Hakyll/Core/Compiler.hs+7
@@ -11,6 +11,7 @@ module Hakyll.Core.Compiler
11 , require
11 , require
12 , requireAll
12 , requireAll
13 , cached
13 , cached
14+ , unsafeCompiler
14 ) where
15 ) where
15
16
16import Prelude hiding ((.), id)
17import Prelude hiding ((.), id)
@@ -142,3 +143,9 @@ cached name (Compiler d j) = Compiler d $ const $ CompilerM $ do
142 Nothing -> error'
143 Nothing -> error'
143 where
144 where
144 error' = error "Hakyll.Core.Compiler.cached: Cache corrupt!"
145 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