Hi,
I am newbie in Haskell and do not understand why the interpreted mode
differs from the compiled program.
I run this code
main =  do
          putStr "line1"
          x<-getLine
          putStr "line2"
          y<-getLine
          return (x++y)

either under runhugs or runghc or in a console under ghci and works
properly, that is, first displays "line1"  and then prompts for the
corresponding inputs through the keyboard, and so on. However, if I
compile the code with the command line
ghc --make Main.hs -o main
and launch the compiled program main, then at first prompts for the
input lines through the keyboard and then displays the strings "line1"
"line2".
I have read in the tutorials that the command "do" implies an ordered
execution and this only occurs in interpreted mode.
Using the monadic notation >> , >>= occurs the same unordered behavior.
¿How can I avoid the unordered execution of this code in a compiled
program?
Thanks in advance.
jepalomar







_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to