I have wasted several hours trying to fix simple Haskell program where I tried to ask the user to enter a string and then display it. The program looks like that:
main = do
putStrLn "Enter something "
entered <- getLine
putStrLn ("You have entered " ++ entered)
After hours of chasing my tail and reading lots of Monad tutorials I have discovered that my program works fine in cmd prompt. Can you imagine my frustration at this point?
This SO question gave me a clue to try it in cmd: https://stackoverflow.com/questions/8361508/execution-order-with-not-what-i-expected?rq=1
Is it possible to fix eshell? If not what is the best way to develop Haskell on Windows with Emacs?
After a bit of experimenting I decided to start cmd.exe with a customised script that sets my environment for Haskell development. The following script starts my cmd:
Using cmd sets my path correctly. I have tried a similar script that launches powershell, which gives me better autocompletion than cmd, but for some reason I can't make the PATH in powershell accept my script settings, other environment variables seem to be OK.
Following one commenter's question this is the version that works with eshell on Windows 10
import System.IO (hFlush, stdout)
main = do
putStrLn "Enter a string"
ln <- getLine
putStrLn ("Yo have entered " ++ ln)
Note the use of hFlush stdout after first printing that was causing problems.