on master help sign in
Make saveSnapshot chainable
commita20bc7bed9fd03e930297467f876c27f0072d1de authorJasper Van der Jeugt <m@jaspervdj.be> dateSun 30 Dec 2012, 09:50 (14 years ago) parent010b3bc
2 files changed+7−4
src/Hakyll/Core/Compiler.hs+4−1 tests/Hakyll/Core/Runtime/Tests.hs+3−3
src/Hakyll/Core/Compiler.hs+4−1
@@ -109,11 +109,14 @@ getResourceWith reader = do
109109
110110
111111--------------------------------------------------------------------------------
112+-- | Save a snapshot of the item. This function returns the same item, which
113+-- convenient for building '>>=' chains.
112114saveSnapshot :: (Binary a, Typeable a)
113− => Internal.Snapshot -> Item a -> Compiler ()
115+ => Internal.Snapshot -> Item a -> Compiler (Item a)
114116saveSnapshot snapshot item = do
115117 store <- compilerStore <$> compilerAsk
116118 compilerUnsafeIO $ Internal.saveSnapshot store snapshot item
119+ return item
117120
118121
119122--------------------------------------------------------------------------------
tests/Hakyll/Core/Runtime/Tests.hs+3−3
@@ -29,9 +29,9 @@ case01 = withTestConfiguration $ \config -> do
2929 match "*.md" $ do
3030 route $ setExtension "html"
3131 compile $ do
32− body <- getResourceBody
33− saveSnapshot "raw" body
34− return $ renderPandoc body
32+ getResourceBody
33+ >>= saveSnapshot "raw"
34+ >>= return . renderPandoc
3535
3636 match "bodies.txt" $ do
3737 route idRoute