[Haskell-cafe] Re: Network parsing and parsec

Adam Turoff adam.turoff at gmail.com
Thu Sep 15 14:20:52 EDT 2005

On 9/15/05, John Goerzen <jgoerzen at complete.org> wrote:
> Not only that, but IMAP has a way where you can embed, say {305} instead
> of a string.  That means, "after you finish reading this line, read
> exactly 305 bytes, and consider that to be used here."  But if you see
> "{305}" (the double quotes indicating a string), this is just a string
> containing the text {305}.
> 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.

-- Adam

More information about the Haskell-Cafe mailing list