summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gnoutcheff <gnoutchd@softwarefreedom.org>2021-09-14 16:21:23 -0400
committerDaniel Gnoutcheff <gnoutchd@softwarefreedom.org>2021-09-14 16:21:23 -0400
commitc9c39eec5fdb959b05404edc2675746f66fb36e1 (patch)
tree2f262bb50a789c8f699f919e8a42af650aad47ef
parent49203ec1cddf607f2f468ff4d1b230f9f236ccb5 (diff)
Flush stdout after each message, rather than after each line
-rw-r--r--app/Main.hs8
1 files 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 "<stdin>" <$> 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 [] = []