Wrong IO actions order using putStr and getLine

Posted by QWRp on Stack Overflow See other posts from Stack Overflow or by QWRp
Published on 2010-03-23T13:59:26Z Indexed on 2010/03/23 14:03 UTC
Read the original article Hit count: 411

Filed under:
|
|

I have a code :

main = do
    putStr "Test input : "
    content <- getLine
    putStrLn content

And when I run it (with runhaskell) or compile it (ghc 6.10.4) result is like this:

asd
Test input : asd

I'm new to haskell and in my opinion printing should be first. Am I right? In code sample on http://learnyouahaskell.com/ which used putStr then getLine presented output is different than mine (IMHO correct). When I use putStrLn program works as expected (print then prompt and print).

Is it a bug in ghc, or it is the way that it should work?

© Stack Overflow or respective owner

Related posts about ghc

Related posts about haskell