[Haskell-cafe] Re: Difficulties implementing an incremental parser using Oleg-style left fold enumerator

Adam Langley agl at imperialviolet.org
Sat Mar 8 16:11:30 EST 2008


On Sat, Mar 8, 2008 at 12:56 AM, Johan Tibell <johan.tibell at gmail.com> wrote:
>  The problem -- maybe there are others too -- is that when a parser such as
>
>  many (byte 65)
>
>  is run it will always return a 'Partial' result waiting for more input
>  even though the enumerator is exhausted. In other words, there's no
>  way to detect end of input.

It appears that you need some way to distinguish the end of input
from, "that's all I have for now". You could use an empty Bytestring
in S if you were careful that you maintained that, in normal
processing, such a state doesn't arise. Otherwise, have a Maybe in
your state and set it to Nothing when the input is exhausted. Then
have combinators, like many, handle the EOF case sensibly.


AGL


-- 
Adam Langley agl at imperialviolet.org http://www.imperialviolet.org


More information about the Haskell-Cafe mailing list