Let's say I am defining the following parser:
let identifier = many1Satisfy isLetter //match an identifier
let parser = identifier //our parser is only to match identifiers
test parser " abc" //the text to parse contains a leading space which should yield us an error
When parsing, an error ocurrs, as one would expect:
Failure: Error in Ln: 1 Col: 1
abc
^
Unknown Error(s)
I am curious on why can't it decide the problem is that he's expecting a letter and can't find one. Am I expected to add that info somehow to the parser by myself?
as to why it can't tell you whats wrong: I guess this is due to the "many1Satisfy" - you see this combinator wraps another parser and I guess it just don't know in which state of "many1" an error occured and not what error - so it says "Unknown Error(s)"
this should work:
let ws = spaces
let identifier = ws >>. (many1Satisfy isLetter) //match an identifier, ignore whitespaces infront
let parser = identifier //our parser is only to match identifiers
test parser " abc"