代码的出现意味着我有一段时间第一次使用 megaparsec。自上次以来,情况发生了很大变化。假设
import qualified Text.Megaparsec as MP
import qualified Text.Megaparsec.Char as C
我试过
MP.parseTest (C.char '+') "+"
在 GHCI 中,它给出了以下相当无用的错误消息:
interactive>:121:1: error:
* Ambiguous type variable `e0' arising from a use of `MP.parseTest'
prevents the constraint `(MP.ShowErrorComponent
e0)' from being solved.
Probable fix: use a type annotation to specify what `e0' should be.
These potential instance exist:
one instance involving out-of-scope types
(use -fprint-potential-instances to see them all)
* In the expression: MP.parseTest (C.char '+') "+"
In an equation for `it': it = MP.parseTest (C.char '+') "+"
<interactive>:121:15: error:
* Ambiguous type variable `e0' arising from a use of `C.char'
prevents the constraint `(Ord e0)' from being solved.
Probable fix: use a type annotation to specify what `e0' should be.
These potential instances exist:
instance (Ord a, Ord b) => Ord (Either a b)
-- Defined in `Data.Either'
instance Ord Ordering -- Defined in `ghc-prim-0.5.3:GHC.Classes'
instance Ord Integer
-- Defined in `integer-gmp-1.0.2.0:GHC.Integer.Type'
...plus 25 others
...plus 131 instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
* In the first argument of `MP.parseTest', namely `(C.char '+')'
In the expression: MP.parseTest (C.char '+') "+"
In an equation for `it': it = MP.parseTest (C.char '+') "+"
我正确使用它吗?我需要做什么来解决这个问题?