on master help sign in
We'll do it ourselves
commitbf496c2f55f61f53fdc0ef7a03db7dc098ae766d authorJasper Van der Jeugt <m@jaspervdj.be> dateSat 30 Mar 2013, 11:31 (14 years ago) parent393a085
2 files changed+12−9
hakyll.cabal+2−2 src/Hakyll/Core/UnixFilter.hs+10−7
hakyll.cabal+2−2
@@ -139,7 +139,7 @@ Library
139139 binary >= 0.5 && < 0.8,
140140 blaze-html >= 0.5 && < 0.7,
141141 blaze-markup >= 0.5.1 && < 0.6,
142− bytestring >= 0.10 && < 0.11,
142+ bytestring >= 0.9 && < 0.11,
143143 citeproc-hs >= 0.3.2 && < 0.4,
144144 containers >= 0.3 && < 0.6,
145145 cryptohash >= 0.7 && < 0.9,
@@ -213,7 +213,7 @@ Test-suite hakyll-tests
213213 binary >= 0.5 && < 0.8,
214214 blaze-html >= 0.5 && < 0.7,
215215 blaze-markup >= 0.5.1 && < 0.6,
216− bytestring >= 0.10 && < 0.11,
216+ bytestring >= 0.9 && < 0.11,
217217 citeproc-hs >= 0.3.2 && < 0.4,
218218 containers >= 0.3 && < 0.6,
219219 cryptohash >= 0.7 && < 0.9,
src/Hakyll/Core/UnixFilter.hs+10−7
@@ -9,7 +9,7 @@ module Hakyll.Core.UnixFilter
99--------------------------------------------------------------------------------
1010import Control.Concurrent (forkIO)
1111import Control.Concurrent.MVar (newEmptyMVar, putMVar, takeMVar)
12−import Control.DeepSeq (NFData, deepseq)
12+import Control.DeepSeq (deepseq)
1313import Control.Monad (forM_)
1414import Data.ByteString.Lazy (ByteString)
1515import qualified Data.ByteString.Lazy as LB
@@ -57,7 +57,8 @@ unixFilter = unixFilterWith writer reader
5757 hPutStr handle input
5858 reader handle = do
5959 hSetEncoding handle localeEncoding
60− hGetContents handle
60+ out <- hGetContents handle
61+ deepseq out (return out)
6162
6263
6364--------------------------------------------------------------------------------
@@ -70,12 +71,14 @@ unixFilterLBS :: String -- ^ Program name
7071 -> [String] -- ^ Program args
7172 -> ByteString -- ^ Program input
7273 -> Compiler ByteString -- ^ Program output
73−unixFilterLBS = unixFilterWith LB.hPutStr LB.hGetContents
74+unixFilterLBS = unixFilterWith LB.hPutStr $ \handle -> do
75+ out <- LB.hGetContents handle
76+ LB.length out `seq` return out
7477
7578
7679--------------------------------------------------------------------------------
7780-- | Overloaded compiler
78−unixFilterWith :: (Monoid o, NFData o)
81+unixFilterWith :: Monoid o
7982 => (Handle -> i -> IO ()) -- ^ Writer
8083 -> (Handle -> IO o) -- ^ Reader
8184 -> String -- ^ Program name
@@ -96,7 +99,7 @@ unixFilterWith writer reader programName args input = do
9699
97100--------------------------------------------------------------------------------
98101-- | Internally used function
99−unixFilterIO :: (Monoid o, NFData o)
102+unixFilterIO :: Monoid o
100103 => (Handle -> i -> IO ())
101104 -> (Handle -> IO o)
102105 -> String
@@ -122,14 +125,14 @@ unixFilterIO writer reader programName args input = do
122125 -- Read from stdout
123126 _ <- forkIO $ do
124127 out <- reader outh
125− deepseq out (hClose outh)
128+ hClose outh
126129 writeIORef outRef out
127130 putMVar lock ()
128131
129132 -- Read from stderr
130133 _ <- forkIO $ do
131134 err <- hGetContents errh
132− deepseq err (hClose errh)
135+ hClose errh
133136 writeIORef errRef err
134137 putMVar lock ()
135138