From c9c39eec5fdb959b05404edc2675746f66fb36e1 Mon Sep 17 00:00:00 2001 From: Daniel Gnoutcheff Date: Tue, 14 Sep 2021 16:21:23 -0400 Subject: Flush stdout after each message, rather than after each line --- app/Main.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 2205f77..4afb7fc 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -3,7 +3,7 @@ module Main (main) where import Text.Pandoc hiding (handleError) import XMLParse -- Our slightly modified copy of Text.XML.HaXml.Parse -import System.IO (hSetBuffering, stdout, BufferMode (LineBuffering)) +import System.IO (hFlush, stdout) import Text.XML.HaXml.Lex (xmlLex) import Text.XML.HaXml.Posn (Posn ()) import Text.ParserCombinators.Poly.State (stGet) @@ -32,12 +32,10 @@ rpcIn = map (either error id) . chop (xmlParseWith rpcMessage) . xmlLex "" <$> getContents rpcOut :: [Document ()] -> IO () -rpcOut = mapM_ $ BSL8.putStrLn . XPP.document . escapeDoc +rpcOut = mapM_ $ (<*) (hFlush stdout) . BSL8.putStr . XPP.document . escapeDoc main :: IO () -main = do - hSetBuffering stdout LineBuffering - rpcOut . plugin =<< rpcIn +main = rpcOut . plugin =<< rpcIn plugin :: [Document Posn] -> [Document ()] plugin [] = [] -- cgit v1.2.3