Binary IO

Simon Marlow simonmar at microsoft.com
Fri Apr 22 07:13:18 EDT 2005


On 22 April 2005 12:05, Peter Simons wrote:

> Simon Marlow writes:
> 
>  > Does anyone have any *objections* to introducing
> 
>  >   System.IO.hGetWord8 :: Handle -> IO Word8
>  >   System.IO.hPutWord8 :: Word8 -> Handle -> IO Word8
> 
> I don't mind having these functions, but to be honest I
> doubt that they would be useful for real life applications.
> Reading a byte at a time is a performance nightmare,
> buffering or not. IMHO, the much better API is this one:
> 
>   hPutBufNonBlocking :: Handle -> Ptr a -> Int -> IO Int
>   hGetBufNonBlocking :: Handle -> Ptr a -> Int -> IO Int

You have these in GHC.IO at the moment.  I beieve they don't have proper
non-blocking behaviour on Windows, though.

These are also rather more difficult to implement than the single-byte
versions, so I can't see nhc98 or Hugs implementing them any time soon.

Cheers,
	Simon


More information about the Libraries mailing list