[Haskell-cafe] Re: [Haskell] Re: ANNOUNCE: enumerator, an alternative iteratee package

Simon Marlow marlowsd at gmail.com
Mon Aug 23 07:00:17 EDT 2010


On 21/08/2010 04:30, John Millikin wrote:

> This also changes the binary enumHandle to use non-blocking IO, as
> recommended by Magnus Therning. I'm embarrassed to admit I still don't
> understand the improvement, exactly, but three people so far have told
> me it's a good idea.

The issue is that hGet always waits for a complete buffer-full of data 
before returning.  The hWaitForInput/hGetNonBlocking combination fixes 
that problem, but you have to be careful to make sure that the Handle is 
in binary mode, otherwise hWaitForInput will not behave the way you 
expect (it will decode the input byte stream, and wait for a full 
character).  For more information, see

http://hackage.haskell.org/trac/ghc/ticket/3808

A better fix is to use hGetBufSome, but (a) it is only available in GHC 
6.14 which isn't released yet, and (b) there isn't a bytestring wrapper 
for it yet.

Cheers,
	Simon


More information about the Haskell-Cafe mailing list