29 Sep
2010
29 Sep
'10
11:50 a.m.
I have a question about Parsec. The following program
import Control.Applicative ((*>),(<*)) import Text.Parsec import Text.Parsec.Char block p = char '{' *> p <* char '}' parser = block (many digit) main = parseTest parser "{123a}"
gives the output parse error at (line 1, column 5): unexpected "a" expecting "}" Note the last line mentions only '}'. I would rather like to see expecting "}" or digit since the parser could very well accept another digit here. (1) What is the reason for this behaviour? (2) Is there another combinator that behaves as I would like? (3) Otherwise, how do I write one myself? BTW, I am using parsec-3.1.0 and ghc-6.12.3. Cheers Ben