parsec
parsec copied to clipboard
Parsec.Expr Example Broken?
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!
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.
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 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