summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-01-17 22:43:44 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-01-17 22:43:44 +0100
commit2f951598efa4bc879bad22c3ae94991fff41694e (patch)
tree68fd8723f631539d721f4b5de60c6bab8958bb7a
parentc5764243257c685a680f51df25d33aa1339449ba (diff)
downloadhakyll-2f951598efa4bc879bad22c3ae94991fff41694e.tar.gz
Allow IO operations in compilers
-rw-r--r--src/Hakyll/Core/Compiler.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Hakyll/Core/Compiler.hs b/src/Hakyll/Core/Compiler.hs
index 8d7b13c..a2853a4 100644
--- a/src/Hakyll/Core/Compiler.hs
+++ b/src/Hakyll/Core/Compiler.hs
@@ -11,6 +11,7 @@ module Hakyll.Core.Compiler
, require
, requireAll
, cached
+ , unsafeCompiler
) where
import Prelude hiding ((.), id)
@@ -142,3 +143,9 @@ cached name (Compiler d j) = Compiler d $ const $ CompilerM $ do
Nothing -> error'
where
error' = error "Hakyll.Core.Compiler.cached: Cache corrupt!"
+
+-- | Create an unsafe compiler from a function in IO
+--
+unsafeCompiler :: (a -> IO b) -- ^ Function to lift
+ -> Compiler a b -- ^ Resulting compiler
+unsafeCompiler f = fromJob $ CompilerM . liftIO . f