getText = do
c <- getChar
s <- getText
return (c : s)
main = do
s <- getText
putStr s
What I expect to see is that the input line being echoed each time after I press 'Enter'.
But nothing is echoed ... (I know that this is a infinite loop)
It seems that it won't "return
" until all the "IO" above it are performed. ...
However, the following code:
main = do
s <- getContents
putStr s
It display the line immediately after input.
Given the function getChar
, can I write a getText
that behaves like getContents
?