Currently I'm trying to learn Haskell IO, and am using System.IO writeFile to edit a text file with this code:
main = do
putStr "Enter Some Text: "
text <- getLine
writeFile "text.txt" text
putStrLn "Updated!"
In ghci this works fine, but when I try to repeat it using runhaskell, it appears to run the 'text <- getLine' function first, and has the following output (first two lines were inputted):
runhaskell EditFile.hs
hello
Enter Some Text: Updated!
Why does runhaskell not run the function in order, and is there a way around this? (i.e. can I make it print "Enter Some Text: " before getting the user input?)