putStr doesn't have the same behavior in GHCi and after compilation with GHC
Hi,
main :: IO ()
main = do {
putStr "hello";
x <- getChar; -- or x <- getLine;
putStr "x = ";
print x;
}
the program works in GHCi and after compilation with GHC. in GHCi it works fine but after compilation it does not work fine. in GHCi the first line of code is evaluated the first while after compilation is the second line which is evaluated first. so in GHCi we have as a result:
hellom
x = 'm'
and after compilation we have as a result:
m
hellox = 'm'
After compilation, putStr is not evaluated the first. It is getChar or getLine. In GHCi the behavior is correct. But after compilation the behavior is strange.
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | Unknown/Multiple |
Architecture |