A fancier Get monad or two (a la binary and binary-strict)

Johan Tibell johan.tibell at gmail.com
Thu Jul 31 03:33:33 EDT 2008

Hi Chris,

Thanks for providing feedback. It's much appreciated.

On Wed, Jul 30, 2008 at 11:34 PM, Chris Kuklewicz
<haskell at list.mightyreason.com> wrote:
> The differences:
>  Your error handling is via Alternative, and if the first branch advances
> (consumes input) then the second branch is not attempted.  The state can
> only go forward (by 1 byte) or remain in place (there is no look-ahead).  If
> reading past the end, then either (*) the new first byte works (*) the new
> first fails and the Alternative is ready to try it.

This is by design. This is enough for parsing many network protocols
like HTTP and avoids having to deal with backtracking and the
potential space leaks and bookkeeping overhead that might come with

>  The management of saved state on the stack of pending operations is much
> simpler with your commit-if-advance semantics and much more complicated with
> my rollback semantics.  Oddly, it seems your committed operations do not
> immediately release the pending handlers so they can be garbage collected.
>  This same kind of issue motivated me to improve the implementation of
> binary-strict's incremental get.

I'm not sure what you mean by releasing pending handlers. It's
probably something I've not considered. Could you please elaborate?



More information about the Libraries mailing list