[Haskell-cafe] Re: Network parsing and parsec

John Goerzen jgoerzen at complete.org
Tue Sep 20 09:02:13 EDT 2005


On 2005-09-15, Adam Turoff <adam.turoff at gmail.com> wrote:
> On 9/15/05, John Goerzen <jgoerzen at complete.org> wrote:
>> So, to make that approach work, I would really need to do a lot of work
>> outside of Parsec -- the stuff that I really want to use Parsec for, I
>> think.
>
> Well, you do have a state monad to work with.  Why not just stuff
> the number 305 into your state, keep reading until you've read 305 bytes 
> (decrementing the count as you read), and return the 305-byte string 
> as your result for this parser?  When you resume,  you should 
> be ready to parse the next very token after the 305-byte string.

It's unclear to me exactly how to mix the IO monad with Parsec.  It
doesn't really seem to be doable.

Not to mention that if hGetContents is used, the Handle has to be put
into non-buffering mode, which means one syscall per character read.
Terribly slow.




More information about the Haskell-Cafe mailing list