On Wed, Aug 8, 2012 at 8:26 PM, silly8888 <silly8...@gmail.com> wrote:
> Inserting a character into the stream can be expensive if for example
> the stream is a ByteString.
> I tried the following crazy solution and it seems that it works:
>
> succeed :: Parser ()
> succeed = mkPT $ \st ->
>     return $ Consumed $ return $ Ok () st $ unknownError st
>
> succeed is a parser that always succeeds without really consuming any
> input but it also resets the error state.
>

Because you're using the 'Consumed' constructor, you're also telling
parsec not the back-track if there any errors following this parsers.

This means that 'succeed >> failingParser' won't backtrack, even if
'failingParser' doesn't consume input.

Are you using your original parser within a larger parser? Are the
error messages also not great?

Antoine

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to