Interactive IO anomaly with GHC 5.04, OS X
Peter Pudney
Peter.Pudney at unisa.edu.au
Sun Aug 4 20:58:51 EDT 2002
If I start GHCi (OS X v10.1.5) and type in the following interactive function,
it works as expected:
Prelude> do {putStr "Prompt: "; l <- getLine; putStrLn l}
Prompt: OK
OK
But if I load a module, even the empty module
> module Empty where
the prompt is not written until after the getLine:
Prelude> :l Empty
Compiling Empty ( /Users/pjp/documents/Haskell/Empty.lhs, interpreted
)
Ok, modules loaded: Empty.
*Empty> do {putStr "Prompt: "; l <- getLine; putStrLn l}
wrong!
Prompt: wrong!
However, if I output a newline character at the end of the prompt, it works as
expected:
*Empty> do {putStrLn "Prompt: "; l <- getLine; putStrLn l}
Prompt:
OK
OK
*Empty> do {putStr "Prompt:\n..."; l <- getLine; putStrLn l}
Prompt:
wrong
...wrong
Unloading the module does not help -- I have to restart GHCi to get the
correct behaviour.
Compiled scripts exhibit the incorrect behaviour.
Peter
More information about the Glasgow-haskell-bugs
mailing list