
On Wed, Jul 30, 2008 at 9:26 AM, Duncan Coutts
On Wed, 2008-07-30 at 02:23 +0100, Chris Kuklewicz wrote:
Summary: I have two new Get-like monads for binary data (byte-aligned) that also (*) Suspend parsing and request more import when reading past the end of data. It is possible to respond with Nothing to indicate the hard end of data. (*) Return failures instead of calling error (*) Offer lookAhead,lookAheadM,lookAheadE like Data.Binary.Get (*) Are BinaryParser instances from Data.Binary.Strict.Class (*) Are Monad Transformers (and thus MonadIO) (*) Are MonadError,Plus,Reader,Writer,State and Applicative,Alternative (*) They differ because one is also MonadCont while the other is simpler (*) Simplified Non-transformer versions (applied to Identity) are defined
[..]
We'll have to look closely at the performance costs of the new features but my intuition is that a non-transformer but continuation based version that has error handling (and plus/alternative) and can request more input should have minimal cost.
I've written what I believe to be a similar, continuation-based parser. I haven't uploaded my latest patches (basically faster combinators) but the idea can be seen in the file here: http://www.johantibell.com/cgi-bin/gitweb.cgi?p=hyena.git;a=blob;f=Hyena/Par... The use case is parsing HTTP without resorting to lazy I/O. Cheers, Johan