[Haskell-cafe] The 13-line example in Text.Megaparsec.Expr

Stephen Tetley stephen.tetley at gmail.com
Mon Feb 29 08:22:52 UTC 2016

Megaparsec does away with Parsec's LanguageDef machinery (which
provides reservedOp). This is a double edge sword - as Megaparsec's
author notes Parsec lexers (i.e LanguageDef based lexers) are
inflexible especially if you need whitespace sensitive parsing; but
they are very handy for the simple case of whitespace insensitive

For the expression parser, Megaparsec's documentation is wrong[*] and
probably it should use symbol rather than reservedOp. Note that symbol
is slightly different in Megaparsec as it's a plain combinator (rather
than one instantiated from a first class module as in Parsec) so it
takes two args rather than one.

[*] Well, likely wrong - I haven't got round to using Megaparsec yet.

On 27 February 2016 at 17:04, Özgür Akgün <ozgurakgun at gmail.com> wrote:
> Hi.
> On 27 February 2016 at 04:20, William Yager <will.yager at gmail.com> wrote:
>> https://hackage.haskell.org/package/parsec-3.1.9/docs/Text-Parsec-Token.html#v:reservedOp
>> ?
> If I understand it correctly, Jeffrey is asking about using Megaparsec, and
> this link is to the parsec combinator with the same name.
> I am very surprised to find out that Megaparsec does not provide[*] the same
> combinator. Especially since they keep the same example!
> [*] At least it is not listed here:
> http://hackage.haskell.org/package/megaparsec-4.4.0/docs/doc-index-All.html
> --
> Özgür Akgün
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list