[Haskell-cafe] ANN: conduit-network-stream, A base layer for network protocols with Conduits

Nils mail at nils.cc
Mon Feb 25 14:09:14 CET 2013


Of course you don't have to use my library if your library already 
solves the same problem.

Am 25.02.2013 13:10, schrieb Alexander V Vershilov:
> data Result = Error Text ByteString | NeedMore (ByteString -> Result a)
> | HaveResult a

I still see an issue with this if you're receiving multiple messages in 
one `ByteString` chunk. A type like `HaveResult a ByteString` which also 
returns the leftover `ByteString` after the first result has been found 
could solve this, but you'd still have to re-yield this bytestring by 
hand and you'll possible end up with more calls to "decode" than necessary.

Of course, with json you could avoid this problem by wrapping all 
messages into a json-list and sending this list as one big message. But 
that way you lose almost all advantages of a conduit - you cannot map 
over those list iems, you cannot process each item one by one, you 
cannot fold or filter them. When using this approach I don't really see 
the advantage over using the plain old "connectTo/hGetContents" method?

Anyway, my library is independent of the "bytestring encoding" you want 
to use with it. I think it's the most general solution and avoids having 
to re-implement the same solution for each and every "protocol design" 
over and over again.



More information about the Haskell-Cafe mailing list