Re: [Haskell-cafe] parsec: parserFail multiple error messages

2012-08-09 Thread Christian Maeder
The error message can be improved in your examples by using count 5 instead of many1. C. Am 08.08.2012 21:24, schrieb silly: I am trying to create a parsec parser that parses an integer and then checks if that integer has the right size. If not, it generates an error. I tried the

Re: [Haskell-cafe] parsec: parserFail multiple error messages

2012-08-09 Thread silly8888
On Thu, Aug 9, 2012 at 3:59 AM, Christian Maeder christian.mae...@dfki.de wrote: The error message can be improved in your examples by using count 5 instead of many1. Yes, I know. That's what I ended up doing. But this is an ad hoc solution. I think parsec should offer a more general solution.

Re: [Haskell-cafe] parsec: parserFail multiple error messages

2012-08-09 Thread Albert Y. C. Lai
On 12-08-08 03:24 PM, silly wrote: The problem is that when I try this parse integer 7 I get the following error: Left (line 1, column 6): unexpected end of input expecting digit integer overflow ie there are three error messages but I only want the last one. Is there something I

[Haskell-cafe] parsec: parserFail multiple error messages

2012-08-08 Thread silly8888
I am trying to create a parsec parser that parses an integer and then checks if that integer has the right size. If not, it generates an error. I tried the following: 8--- import Text.Parsec import Text.Parsec.String integer :: Parser

Re: [Haskell-cafe] parsec: parserFail multiple error messages

2012-08-08 Thread Nick Vanderweit
I found a similar question asked in June 2009 on the haskell-beginners archives, titled Clearing Parsec error messages. A hack that was proposed (http://www.haskell.org/pipermail/beginners/2009-June/001809.html) was to insert a dummy character into the stream, consume it, and then fail. Still,

Re: [Haskell-cafe] parsec: parserFail multiple error messages

2012-08-08 Thread silly8888
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

Re: [Haskell-cafe] parsec: parserFail multiple error messages

2012-08-08 Thread Antoine Latter
On Wed, Aug 8, 2012 at 8:26 PM, silly 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 $