Binary IO

John Meacham john at
Fri Apr 22 07:41:44 EDT 2005

On Fri, Apr 22, 2005 at 01:26:14PM +0200, Peter Simons wrote:
> Simon Marlow writes:
>  >> hPutBufNonBlocking :: Handle -> Ptr a -> Int -> IO Int
>  >> hGetBufNonBlocking :: Handle -> Ptr a -> Int -> IO Int
>  > You have these in GHC.IO at the moment.
> I know. ;-)
>  > 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.
> What is difficult to implement about these functions? Aren't
> they just wrappers for read(2) and write(2)?

The handles have internal buffering that they might interact oddly with.
windows might do things differently... In any case, these seem much too
low level for the task at hand, which is to just make portable binary IO
_possible_. not necessarily efficient or elegant. And hGet/PutWord8 are
fast enough for most situations. We certainly don't want to have to
teach a new user about Foreign.C.Storable just because they want to do a
little simple binary IO.

A next generation IO system has been in the works for a while, which
will probably provide some portable low level primitives too. 

John Meacham - ⑆⑆john⑈ 

More information about the Libraries mailing list