1

如果我查看它的文档space建议使用void spaceChar.

但是,如果我真的尝试:

x :: Parser ()
x = void spaceChar

我明白了

* Couldn't match type `Token s0' with `Char'
    arising from a use of `spaceChar'
  The type variable `s0' is ambiguous
* In the first argument of `void', namely `spaceChar'
  In the expression: void spaceChar
  In an equation for `x': x = void spaceChar

我认为表达式是正确的,但我需要做一些事情来说服类型检查器。我怎样才能让它工作?

4

2 回答 2

1

ghci 建议类型(Token s ~ Char, MonadParsec e s f) => f ()。那一个应该工作。你从哪里得的名字Parser

于 2018-01-08T15:29:43.897 回答
0

我在尝试创建复制品时追踪了这个问题。问题有点深奥:我没有导入 Control.Monad。相反,看起来 void 正在其他地方(不确定在哪里)被拾取,并且这种 void 定义导致了该错误的发生。感谢所有试图提供帮助的人。

于 2018-01-08T16:01:19.790 回答