An even fancier Get monad, last in a series?
haskell at list.mightyreason.com
Tue Aug 5 13:48:31 EDT 2008
And now MyGetW.hs  is even more capable:
During the parsing one can use a "yieldItem y" command to queue y for delivery
to the code running the Get monad.
The length of this queue can be examined with "pendingItems" which returns an
Int, which will be non-negative.
To immediately pause parsing and return a Data.Sequence of yielded items to the
user one calls "flushItems" which returns the sequence and a lazy value which is
the future of the paused parsing.
The pending queue of items is also returned every time the parser needs more
input, sees an error, or completes.
Thus the parser can be a lazy participant in a chain of processing.
The queued items are undisturbed by fail/throwError/mzero all lookAhead*
functions and any use of callCC and the continuations it returns. Thus
"yieldItem" is for life and cannot be undone.
The continuation returned by "callCC" was improved internally to not hold onto
the old input state of the BinaryParser or the old user state. It does not use
these things and should not keep them alive.
Frankly, I cannot think of any more features to add. Once Haddock can be used
with a released Cabal I may make a more proper release of these files.
 MyGetW.hs and MyGet.hs and MyGetSimplified.hs are still at
More information about the Libraries