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

Jeffrey Brown jeffbrown.the at gmail.com
Sat Sep 24 19:57:47 UTC 2016


I found the answer to my most recent question while reading this
tutorial[1] on megaparsec. Thanks, and apologies for the noise.

[1]
https://mrkkrp.github.io/megaparsec/tutorials/parsing-simple-imperative-language.html

On Sat, Sep 24, 2016 at 12:45 AM, Jeffrey Brown <jeffbrown.the at gmail.com>
wrote:

> I'm trying this again! The comment for Megaparsec.makeExprParser refers to
> "parens". When I grep for "parens" in Megaparsec I get only two occurences,
> both of them in comments:
>
>     ./Lexer.hs:-- > parens    = between (symbol "(") (symbol ")")
>     ./Expr.hs:-- > term = parens expr <|> integer <?> "term"
>
> If I try defining parens as in the comment from Lexer.hs, I get these
> errors:
>
>     <interactive>:37:33:
>         Couldn't match type ‘Char’ with ‘()’
>         Expected type: [()]
>           Actual type: [Char]
>         In the first argument of ‘symbol’, namely ‘"("’
>         In the first argument of ‘between’, namely ‘(symbol "(")’
>         In the expression: between (symbol "(") (symbol ")")
>
>     <interactive>:37:46:
>         Couldn't match type ‘Char’ with ‘()’
>         Expected type: [()]
>           Actual type: [Char]
>         In the first argument of ‘symbol’, namely ‘")"’
>         In the second argument of ‘between’, namely ‘(symbol ")")’
>         In the expression: between (symbol "(") (symbol ")")
>
> [1] https://hackage.haskell.org/package/megaparsec-5.0.1/docs/
> Text-Megaparsec-Expr.html
>
> On Mon, Feb 29, 2016 at 2:05 AM, Özgür Akgün <ozgurakgun at gmail.com> wrote:
>
>>
>> On 29 February 2016 at 08:22, Stephen Tetley <stephen.tetley at gmail.com>
>> wrote:
>>
>>>
>>> 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.
>>>
>>
>>
>> You are right: https://github.com/mrkkrp/megaparsec/commit/750adb7c7
>> 0392c3195eda12d816f4a1a2305321e
>>
>>
>> --
>> Özgür Akgün
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>>
>>
>
>
> --
> Jeff Brown | Jeffrey Benjamin Brown
> Website <https://msu.edu/~brown202/>
> Facebook <https://www.facebook.com/mejeff.younotjeff>
> LinkedIn <https://www.linkedin.com/in/jeffreybenjaminbrown> (InMail is
> unreliable)
> Github <https://github.com/jeffreybenjaminbrown>
>



-- 
Jeff Brown | Jeffrey Benjamin Brown
Website <https://msu.edu/~brown202/>
Facebook <https://www.facebook.com/mejeff.younotjeff>
LinkedIn <https://www.linkedin.com/in/jeffreybenjaminbrown> (InMail is
unreliable)
Github <https://github.com/jeffreybenjaminbrown>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160924/226c67f7/attachment.html>


More information about the Haskell-Cafe mailing list