The documentation for Text.Megaparsec.Char.Lexer.charLiteral
suggests using char '"' *> manyTill charLiteral (char '"')
for parsing string literals (where manyTill
is defined in the module Control.Applicative.Combinators
in the parser-combinators
library).
However, Control.Applicative.Combinators
also defines between
, which -- as far as I can see -- should do the same as the above suggestion when used like so: between (char '"') (char '"') (many charLiteral)
.
However, using the between
parser above does not work for parsing string literals -- failing with "unexpected end of input.
expecting '"' or literal character" (indicating that the ending quote is never detected). Why not?
Also, more generally, why isn't between pBegin pEnd (many p)
equivalent to pBegin *> manyTill p pEnd
?