diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-03-30 11:31:14 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-03-30 11:31:14 +0100 |
commit | bf496c2f55f61f53fdc0ef7a03db7dc098ae766d (patch) | |
tree | 899e991405cc8e74a9c54d01364fa1e293bb38e9 /src | |
parent | 393a08594d3c98b9f47692890edbb31b1bf860c2 (diff) | |
download | hakyll-bf496c2f55f61f53fdc0ef7a03db7dc098ae766d.tar.gz |
We'll do it ourselves
Diffstat (limited to 'src')
-rw-r--r-- | src/Hakyll/Core/UnixFilter.hs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Hakyll/Core/UnixFilter.hs b/src/Hakyll/Core/UnixFilter.hs index 6824bd8..1544bf2 100644 --- a/src/Hakyll/Core/UnixFilter.hs +++ b/src/Hakyll/Core/UnixFilter.hs @@ -9,7 +9,7 @@ module Hakyll.Core.UnixFilter -------------------------------------------------------------------------------- import Control.Concurrent (forkIO) import Control.Concurrent.MVar (newEmptyMVar, putMVar, takeMVar) -import Control.DeepSeq (NFData, deepseq) +import Control.DeepSeq (deepseq) import Control.Monad (forM_) import Data.ByteString.Lazy (ByteString) import qualified Data.ByteString.Lazy as LB @@ -57,7 +57,8 @@ unixFilter = unixFilterWith writer reader hPutStr handle input reader handle = do hSetEncoding handle localeEncoding - hGetContents handle + out <- hGetContents handle + deepseq out (return out) -------------------------------------------------------------------------------- @@ -70,12 +71,14 @@ unixFilterLBS :: String -- ^ Program name -> [String] -- ^ Program args -> ByteString -- ^ Program input -> Compiler ByteString -- ^ Program output -unixFilterLBS = unixFilterWith LB.hPutStr LB.hGetContents +unixFilterLBS = unixFilterWith LB.hPutStr $ \handle -> do + out <- LB.hGetContents handle + LB.length out `seq` return out -------------------------------------------------------------------------------- -- | Overloaded compiler -unixFilterWith :: (Monoid o, NFData o) +unixFilterWith :: Monoid o => (Handle -> i -> IO ()) -- ^ Writer -> (Handle -> IO o) -- ^ Reader -> String -- ^ Program name @@ -96,7 +99,7 @@ unixFilterWith writer reader programName args input = do -------------------------------------------------------------------------------- -- | Internally used function -unixFilterIO :: (Monoid o, NFData o) +unixFilterIO :: Monoid o => (Handle -> i -> IO ()) -> (Handle -> IO o) -> String @@ -122,14 +125,14 @@ unixFilterIO writer reader programName args input = do -- Read from stdout _ <- forkIO $ do out <- reader outh - deepseq out (hClose outh) + hClose outh writeIORef outRef out putMVar lock () -- Read from stderr _ <- forkIO $ do err <- hGetContents errh - deepseq err (hClose errh) + hClose errh writeIORef errRef err putMVar lock () |