[Haskell-cafe] Re: ANN: A triple of new packages for talking tothe outside world

Adam Langley agl at imperialviolet.org
Thu Jan 17 15:36:46 EST 2008

On Jan 17, 2008 11:05 AM, Dominic Steinitz
<dominic.steinitz at blueyonder.co.uk> wrote:

> I'm not clear what happens if you
> are reading from a socket and not all the input has arrived but I'll think
> about that over the weekend.

At the moment, BitGet deals with strict ByteStrings only. One could use it
within a standard Get monad by getting a strict ByteString from the lazy input.
I believe that lazy ByteStrings got fixed a while back so that reading from a
socket doesn't block reading a whole block. (i.e. if you trickle data, byte by
byte, to a socket a lazy ByteString should return a spine of 1 byte strict

A fully lazy BitGet would also be possible, of course, I've just not written it
yet ;)

> Adam Langley <agl <at> imperialviolet.org> writes:
> Another thought: could e.g. getRightByteString be in the IO monad and then I
> don't have to run the Get(?) monad? Or is that a really stupid question?

If it were in the IO monad, I guess that you're suggesting that it read from a
handle? If that were the case, the remainder of the last byte would have to be
discarded because one can only read whole bytes from a Handle and there's no
mechanism for pushing back into it.

It's certainly possible to do, but I think a quick wrapper around a BitGet
would be the way to do it. If it's particually desirable I can add it, although
I'll admit that it seems a bit odd and I'm wondering what your use case is.



Adam Langley                                      agl at imperialviolet.org
http://www.imperialviolet.org                       650-283-9641

More information about the Haskell-Cafe mailing list