[Haskell-cafe] Simple network client

Bryan O'Sullivan bos at serpentine.com
Wed Jan 30 15:04:00 EST 2008


Adam Langley wrote:

> Also, if you want the above approach (read a bit, see if it's enough),
> see IncrementalGet in the binary-strict package which is a Get with a
> continuation monad that stops when it runs out of bytes and returns a
> continuation that you can give more data to in the future.

I've used this now, and it's really rather nice: exactly the sort of
thing one needs if multiplexing streams, or reading incomplete chunks,
and with a simple interface that doesn't force users to know or care
about Cont.  The one thing I found curious was the Result type: it's
oriented towards returning a list of results.

data Result a = Failed String
              | Finished B.ByteString [a]
              | Partial (B.ByteString -> Result a) [a]

I'd have expected it to look more like this:

data Result a = Failed String
              | Finished B.ByteString a
              | Partial (B.ByteString -> Result a)

(The change here is from a list to a singleton.)  I don't think I care
much for the extra boxing and reversing this involves.

	<b


More information about the Haskell-Cafe mailing list