从Text.Parsec.Token
:我不明白如何使用语义功能
lexeme p = do { x <- p; whiteSpace; return x }
看来,语义需要一个解析器P和提供具有相同行为为p解析器,但它也跳过所有尾随的空白。正确?
那为什么下面不工作:在下面的错误消息
constant :: Parser Int
constant = do
digits <- many1 digit
return (read digits)
lexConst :: Parser Int
lexConst = lexeme constant
最后一行的结果:
Couldn't match expected type `ParsecT
String() Data.Functor.Identity.Identity Int'
with actual type `ParsecT s0 u0 m0 a0 -> ParsecT s0 u0 m0 a0'
Expected type: Parser Int
Actual type: ParsecT s0 u0 m0 a0 -> ParsecT s0 u0 m0 a0
In the return type of a call of `lexeme'
In the expression: lexeme constant
我在做什么错?