[Haskell-beginners] Talking betwean the parsers.

Felipe Lessa felipe.lessa at gmail.com
Fri Jul 17 19:47:31 EDT 2009


On Sat, Jul 18, 2009 at 12:40:15AM +0200, Maciej Piechotka wrote:
> I have a data structure of
> data Monad m => NntpConnection m = NntpConnection {
> 	input :: ByteString,
> 	output :: ByteString -> m ()
>     }
>
> I'd like to create echo structure such that the goes to output is going
> to (lazy) input. For sure it is possible to use network and IO monad -
> is is possible to do it purely?

In words, not code: you may create a Chan of strict ByteStrings.
On the output side you just append all the chunks of the lazy
ByteString to the Chan, or you may copy the lazy ByteString in
one chunk of strict ByteString.  On the input side you
"getContents" and "fromChunks".  Should work, I guess.

--
Felipe.


More information about the Beginners mailing list