parsec icon indicating copy to clipboard operation
parsec copied to clipboard

Parsec.Expr Example Broken?

Open Chobbes opened this issue 9 years ago • 3 comments

Hi!

I'm a wee baby Haskell programmer, but I noticed that the example at the bottom here:

https://hackage.haskell.org/package/parsec-3.1.9/docs/Text-Parsec-Expr.html

Doesn't seem to type check. I don't think the types of parens / reservedOp are agreeing here. Perhaps they changed?

https://hackage.haskell.org/package/parsec-3.1.9/docs/Text-Parsec-Token.html#v:reservedOp

Perhaps the example needs an update, or more clarification?

Thanks!

Chobbes avatar May 21 '15 04:05 Chobbes

It looks cool to me.

reservedOp :: String -> ParsecT s u m ()

and

prefix  name fun       = Prefix (do{ reservedOp name; return fun }) -- name :: String

are consistent with each other.

albertnetymk avatar Jul 02 '15 22:07 albertnetymk

reservedOp :: GenTokenParser s u m -> String -> ParsecT s u m ()

since it's actually in a record. I'm guessing that this example assumes you have gone through and done some...

import Text.Parsec.Token as T

reservedOp = T.reservedOp myTokenParser

which is fine, but it's a bit confusing in this example since if you are just looking at the libraries for the first time you would assume that reservedOp meant the function defined in the library in the first place.

Chobbes avatar Aug 21 '15 03:08 Chobbes

@Chobbes OK, I got your point. I guess this could be OP's doubt as well.

This repo is not so active, I think. Alternatively, if you are interested, https://github.com/mrkkrp/megaparsec

albertnetymk avatar Aug 21 '15 08:08 albertnetymk