buffering woes

Hal Daume III hdaume@ISI.EDU
Wed, 5 Feb 2003 09:56:00 -0800 (PST)


I expect the following to work, but it doesn't.  Can someone help:

9:53am moussor:JavaInterp/ cat > Test.hs
import System.IO

main = do
  hSetBuffering stdout NoBuffering
  hSetBuffering stdin  NoBuffering
  loop
    where loop = do
            putStr "> "
            s <- getLine
            putStrLn $ "You said: " ++ s
            loop     
9:54am moussor:JavaInterp/ ghc Test.hs -o test
9:54am moussor:JavaInterp/ ./test
> hello
foYou said: hello
> o^Ctest: interrupted
9:54am moussor:JavaInterp/ ./test
> hello
foYou said: hello
> o


You said: foo
> You said: 
> You said: 
> ^Ctest: interrupted
9:55am moussor:JavaInterp/ 


basically, i have to type 'fo' before it will give me my first reply.  I
thought the two calls to hSetBuffering would fix this.

--
Hal Daume III

 "Computer science is no more about computers    | hdaume@isi.edu
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume