Better way to check readiness
commitfd4f5a91bc955cb1ce47f28d0cfc472f30f68991
authoriko <ilyakooo0@gmail.com>
dateThu 24 Dec 2020, 19:59 (6 years ago)
parent4ab5a92
src/Main.hs+4−4
@@ -52,13 +52,13 @@ colors = cycle [green, blue, magenta, cyan]
5252
5353writeOutput :: [String] -> String -> Handle -> IO Bool
5454writeOutput color prog h = do
55− eof <- hIsEOF h
56− if eof
57− then return False
58− else do
55+ inputAvailable <- hReady h
56+ if inputAvailable
57+ then do
5958 l <- hGetLine h
6059 putStrLn $ formatWith color (prog <> " | ") <> l
6160 return True
61+ else return False
6262
6363prettifyProcesses :: [String] -> [String]
6464prettifyProcesses ps' =