In my current working directory there is a file named test.txt
, which contains "Test\n"
.
With System.IO.readFile
, GHCI returns the content:
Prelude System.IO> readFile "test.txt"
"Test\n"
But not so with the following, which should be equal in my opinion:
Prelude System.IO> withFile "test.txt" ReadMode hGetContents
""
Why is it not the case? How to get the whole file contents within the withFile
IO
action?