A fancier Get monad or two (a la binary and binary-strict)
johan.tibell at gmail.com
Wed Jul 30 11:16:59 EDT 2008
On Wed, Jul 30, 2008 at 9:26 AM, Duncan Coutts
<duncan.coutts at worc.ox.ac.uk> wrote:
> 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:
The use case is parsing HTTP without resorting to lazy I/O.
More information about the Libraries