Read package:text

Common internal functions for reading textual data.
Functions used frequently when reading textual data.
Functions used frequently when reading textual data.
Read some text. If the read succeeds, return its value and the remaining text, otherwise an error message.
The readFile function reads a file and returns the contents of the file as a string. The entire file is read strictly, as with getContents. Beware that this function (similarly to readFile) is locale-dependent. Unexpected system locale may cause your application to read corrupted data or throw runtime exceptions about "invalid argument (invalid byte sequence)" or "invalid argument (invalid character)". This is also slow, because GHC first converts an entire input to UTF-32, which is afterwards converted to UTF-8. If your data is UTF-8, using decodeUtf8 . readFile is a much faster and safer alternative.
The readFile function reads a file and returns the contents of the file as a string. The entire file is read strictly, as with getContents.
Read a single chunk of strict text from a buffer. Used by both the strict and lazy implementations of hGetContents.
Read a file and return its contents as a string. The file is read lazily, as with getContents. Beware that this function (similarly to readFile) is locale-dependent. Unexpected system locale may cause your application to read corrupted data or throw runtime exceptions about "invalid argument (invalid byte sequence)" or "invalid argument (invalid character)". This is also slow, because GHC first converts an entire input to UTF-32, which is afterwards converted to UTF-8. If your data is UTF-8, using decodeUtf8 . readFile is a much faster and safer alternative.