I know that Megaparsec doesn't backtrack automatically and that you have to use "try" for that, but this behavior of "many" was unexpected. Why oh why doesn't it parse the final space? https://stackoverflow.com/a/78355045/1364288
Maybe I didn't read the documentation thoroughly, but I don't think it's actually spelled out in the Haddocks?
So, if I'm getting this right, parsing failures that consume input are treated differently from parsing failures that don't consume input, and only the latter interact in the expected way with combinators like "many" and "optional"?
Ok, the heart of the matter is the Alternative instance on which the "many" and "optional" combinators depend.
As the docs say, "empty is a parser that fails without consuming input". So a parser that fails while consuming input can't be equated to "empty". I guess the moral of the story is that one should almost always use "try" with Alternative-y combinators.