Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Partial results with megaparsec (Dmitriy Matrosov) 2. Re: Partial results with megaparsec (David McBride) ---------------------------------------------------------------------- Message: 1 Date: Mon, 28 Jun 2021 18:37:07 +0300 From: Dmitriy Matrosov <sgf....@gmail.com> To: beginners@haskell.org Subject: [Haskell-beginners] Partial results with megaparsec Message-ID: <1570a77d-1f0f-86cf-25a6-cda296488...@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed 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. ------------------------------ Message: 2 Date: Mon, 28 Jun 2021 12:46:16 -0400 From: David McBride <toa...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Partial results with megaparsec Message-ID: <CAN+Tr43S22AT15cWOEHfKoN1RCH3+3O=1benswhjnq5giwp...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" 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. 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. On Mon, Jun 28, 2021 at 11:37 AM Dmitriy Matrosov <sgf....@gmail.com> wrote: > 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. > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210628/4ce787a2/attachment-0001.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 155, Issue 10 ******************************************