<div dir="ltr"><div>Attoparsec was created specifically for streaming, thus its parsing functions take into account that some portion of the pattern may yet to have arrived and its combinators avoid taking input greedily unintentionally.<br></div><div><br></div><div>It is not clear to me that megaparsec is capable of that. There is a package attoparsec-parsec package, which reimplements parsec's combinators in a way attoparsec can use, but I do not see a version of that for megaparsec. You would have to write every megaparsec combinator into an equivalent attoparsec to create such a package.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 28, 2021 at 11:37 AM Dmitriy Matrosov <<a href="mailto:sgf.dma@gmail.com">sgf.dma@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi.<br>
<br>
I've used attoparsec before and it can return 'Partial' result containing<br>
continuation, which is able to continue parsing if provided with more input.<br>
E.g.<br>
<br>
> let A.Partial c1 = A.parse (A.string "mac address") "mac "; in c1 "address"<br>
Done "" "mac address"<br>
<br>
Does the same thing possible with megaparsec?<br>
<br>
After looking through library API, i haven't find a way to do this.<br>
'runParser' (which seems the only way to run megaparsec parser) fails on<br>
incomplete (text) input.<br>
<br>
And if that's not possible, how should i deal with chunked input?<br>
E.g. i read from a socket with 'recv' and i don't want to read all<br>
data at once. How can i suspend parsing for a time, read next chunk and<br>
continue?<br>
<br>
Thanks.<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div>