readFile package:base

The readFile function reads a file and returns the contents of the file as a string. The file is read lazily, on demand, as with getContents. This operation may fail with the same errors as hGetContents and openFile.

Examples

>>> readFile "~/hello_world"
"Greetings!"
>>> take 5 <$> readFile "/dev/zero"
"\NUL\NUL\NUL\NUL\NUL"
The readFile' function reads a file and returns the contents of the file as a string. This is identical to readFile, but the file is fully read before being returned, as with getContents'.