Consider this parsec parser (put in a file parsec-eof-test.hs):
import Text.Parsec
import Text.Parsec.String
main = do
x <- parse (manyTill anyChar eof >> fail "forced fail") "" <$> readFile "parsec-eof-test.hs"
print (x :: Either ParseError String)
If you run it, you get:
Left (line 7, column 1):
unexpected end of input
expecting end of input
forced fail
unexpected end of input - expecting end of input - that doesn't make any sense, it's a contradiction.
What's going on here?
Is it a bad default in parsec, or is what I'm looking at actually some stack of potential errors that parsec came by while parsing?
Since my parser manyTill anyChar eof consumes input, I'd expect the only error message to be emitted to be forced fail. What am I missing?