How to print output and ask input on the same line

This is my main function: main = do putStr "What's the value that each equation must satisfy? " c <- readLn putStr "How many unknowns are there? " n <- readLn sequence_ (result c n) Using runhugs / winhugs / ghci, I can see every output of putStr before it stops for readLn. But compiling it with ghc, it just stops for readLn and putStr output is printed together with sequence_' one. So, instead of: What's the value that each equation must satisfy? <stop for readLn> How many unknowns are there? <stop for readLn> <output of sequence_> I got: <stop for readLn> <stop for readLn> What's the value that each equation must satisfy? How many unknowns are there? <output of sequence_> Hope that's clear enough. -- View this message in context: http://www.nabble.com/How-to-print-output-and-ask-input-on-the-same-line-tp1... Sent from the Haskell - Glasgow-haskell-users mailing list archive at Nabble.com.

Austin Seipp wrote:
It's a buffering issue. You'll need to do:
hSetBuffering stdout NoBuffering
Before running putStr and doing readLn.
Just as I thought. Thanks, I'll try when I get home. -- View this message in context: http://www.nabble.com/How-to-print-output-and-ask-input-on-the-same-line-tp1... Sent from the Haskell - Glasgow-haskell-users mailing list archive at Nabble.com.
participants (2)
-
Austin Seipp
-
leledumbo