[Haskell-beginners] Partial results with megaparsec

Dmitriy Matrosov sgf.dma at gmail.com
Mon Jun 28 15:37:07 UTC 2021


Hi.

I've used attoparsec before and it can return 'Partial' result containing
continuation, which is able to continue parsing if provided with more input.
E.g.

     > let A.Partial c1 = A.parse (A.string "mac address") "mac "; in c1 "address"
     Done "" "mac address"

Does the same thing possible with megaparsec?

After looking through library API, i haven't find a way to do this.
'runParser' (which seems the only way to run megaparsec parser) fails on
incomplete (text) input.

And if that's not possible, how should i deal with chunked input?
E.g. i read from a socket with 'recv' and i don't want to read all
data at once. How can i suspend parsing for a time, read next chunk and
continue?

Thanks.



More information about the Beginners mailing list