
Was there any kind of consensus emerging on this? Leaving aside what might be done with the Char-based functions (and people seem to think they're fine as is) I'd like to suggest the following:
* System.IO: addition of new Word8-based functions
hGetOctet :: Handle -> IO Word8 hLookAheadOctet :: Handle -> IO Word8 hPutOctet :: Handle -> Word8 -> IO ()
I'd go for hGetWord8, hLookAheadWord8 and so on, but it's not a big deal.
hPutArray :: Handle -> [Word8] -> IO ()
There are currently these two functions in Data.Array.IO: hGetArray :: Handle -> IOUArray Int Word8 -> Int -> IO Int hPutArray :: Handle -> IOUArray Int Word8 -> Int -> IO () turning an IOUArray Int Word8 into [Word8] is accomplished by Data.Array.IArray.elems.
hLazyGetArray :: Handle -> IO [Word8]
Other suggestions: hGetContentsRaw, hGetWord8Contents
...as per hGetChar, hLookAhead, hPutChar, hPutStr and hGetContents.
hGetArrayBlock :: Handle -> Int -> IO [Word8] hGetArrayReady :: Handle -> Int -> IO [Word8]
hGetArrayBlock would read so many octets from the handle, up to the EOF. hGetArrayReady would read so many octets from the handle, up to the EOF or octets not ready. The semantics would be something like this:
We used to have hGetBuf and hGetBufFull in IOExts, which are analogous to your hGetArrayReady and hGetArrayBlock respectively. I forget why exactly, but we removed hGetBufFull and made hGetBuf behave as the blocking version. Hmm, I'm not sure about these functions returns lists. Arrays seem more natural to me, also given that we have nice overloaded support for arrays which makes conversion to/from lists painless.
...but I expect they should be implemented natively.
hSetFileSize :: Handle -> Integer -> IO ()
There's currently no way to set the size of a file. hSetFileSize would truncate the file or pad with zero octets.
Yes, we should have this too.
* Network.Socket
The send & receive functions don't do any kind of character interpretation do they? I suggest these functions be given new types (and probably new names, as I suppose we'll need the old ones for compatibility):
sendTo :: Socket -> [Word8] -> SockAddr -> IO Int recvFrom :: Socket -> Int -> IO ([Word8], Int, SockAddr) send :: Socket -> [Word8] -> IO Int recv :: Socket -> Int -> IO [Word8]
Yes, sounds fine. Cheers, Simon