1
我通过“runInteractiveCommand”在haskell中运行外部交互式程序,并且想要读取程序的输出,直到它显示程序提示符。到目前为止,我已经Haskell:runInteractiveCommand:如何忽略到目前为止给出的输出?
checkConsistency cal nets = do
(sparqIn, sparqOut, sparqErr, sparqId) <- runInteractiveCommand "sparq -i"
mapM_ (flip hSetBinaryMode False) [sparqIn, sparqOut]
hSetBuffering sparqIn LineBuffering
hSetBuffering sparqOut NoBuffering
hPutStrLn sparqIn ("load-calculus " ++ cal)
-- Here i need to wait for output and ignore it until the prompt is shown!
sparqAnswers <- mapM (checkConsistencyWithSparq sparqIn sparqOut) nets
return sparqAnswers
我觉得我应该在一个while循环使用“HREADY”和“hGetChar”但我不知道如何做到这一点没错。或者也许有更好的方法?
亲切的问候, Annaluise