hGet package:bytestring

Read a ByteString directly from the specified Handle. This is far more efficient than reading the characters into a String and then using pack. First argument is the Handle to read from, and the second is the number of bytes to read. It returns the bytes read, up to n, or empty if EOF has been reached. hGet is implemented in terms of hGetBuf. If the handle is a pipe or socket, and the writing end is closed, hGet will behave as if EOF was reached.
Read n bytes into a ByteString, directly from the specified Handle.
Read a handle's entire contents strictly into a ByteString. This function reads chunks at a time, increasing the chunk size on each read. The final string is then reallocated to the appropriate size. For files > half of available memory, this may lead to memory exhaustion. Consider using readFile in this case. The Handle is closed once the contents have been read, or if an exception is thrown.
Deprecated: Deprecated since bytestring-0.12. Use hGetLine instead. (Functions that rely on ASCII encodings belong in Data.ByteString.Char8)
hGetNonBlocking is similar to hGet, except that it will never block waiting for data to become available, instead it returns only whatever data is available. If there is no data available to be read, hGetNonBlocking returns empty. Note: on Windows and with Haskell implementation other than GHC, this function does not work correctly; it behaves identically to hGet.
Like hGet, except that a shorter ByteString may be returned if there are not enough bytes immediately available to satisfy the whole request. hGetSome only blocks if there is no data available, and EOF has not yet been reached.
Read a line from a handle
Read entire handle contents lazily into a ByteString. Chunks are read on demand, using the default chunk size. File handles are closed on EOF if all the file is read, or through garbage collection otherwise.