From b2278c50bfce8d8c6f80d04822ecedf42081659d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Wed, 23 Aug 2023 21:05:25 +0200 Subject: Test: fully evaluate output line before taking the lock --- src/Test.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Test.hs b/src/Test.hs index 819c97d..a506345 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -4,6 +4,7 @@ module Test ( import Control.Arrow import Control.Concurrent +import Control.Exception import Control.Monad.Except import Control.Monad.Reader import Control.Monad.State @@ -107,9 +108,11 @@ getHead = do type Output = MVar () outLine :: Output -> String -> IO () -outLine mvar line = withMVar mvar $ \() -> do - putStrLn line - hFlush stdout +outLine mvar line = do + evaluate $ foldl' (flip seq) () line + withMVar mvar $ \() -> do + putStrLn line + hFlush stdout cmdOut :: String -> Command cmdOut line = do -- cgit v1.2.3