Reputation: 3
I have the following code and am using an online IDE from School of Haskell:
import System.IO
main = do
h <- openFile "message.txt" WriteMode
hPutStrLn h "Greetings earthlings"
hClose h
But it doesn't seem to be working. Where is message.txt saved?
Upvotes: 0
Views: 56
Reputation: 10228
FP Complete's Haskell IDE doesn't let you browse the files you've created from code. But your program still worked!
import System.IO
main = do
h <- openFile "message.txt" WriteMode
hPutStrLn h "Greetings earthlings"
hClose h
r <- readFile "message.txt"
print r
You should see "Greetings earthlings\n"
in the console, as expected.
Upvotes: 1