2

我尝试为 Bryan O'Sullivan 的基于 Attoparsec 的 HTTP 解析器(http://www.serpentine.com/blog/2010/03/03/whats-in-a-parser-attoparsec-rewired-2/)运行测试,我得到了这个错误:

> runhaskell TestRFC2616.hs

TestRFC2616.hs:13:30:
    Not in scope: `many'
    Perhaps you meant one of these:
      `any' (imported from Prelude),
      `B.any' (imported from Data.ByteString.Char8),
      many' (imported from Data.Attoparsec)

很惊讶,我运行 ghci 得到了这个:

> ghci
GHCi, version 7.6.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :m +Data.Attoparsec
Prelude Data.Attoparsec> :t many

<interactive>:1:1:
    Not in scope: `many'
    Perhaps you meant one of these:
      `any' (imported from Prelude),
      many' (imported from Data.Attoparsec),
      `many1' (imported from Data.Attoparsec)
Prelude Data.Attoparsec>

谁能告诉我发生了什么事?

4

1 回答 1

1

这个例子是 4 岁。在 0.8.0 版本many中,Data.Attoparsec.Combinator模块中有一个实现,您可以在此处查看源代码。

该库的当前版本没有实现many函数,但它实现了一个many'函数(source here)。这就是为什么你ghci给你many'一个建议。

many实现Data.Attoparsec.Combinator的与所实现的相同Control.Applicative(请参见此处manyAlternative类型类中的实现)。你可能需要import. Control.Applicative如果可行,我建议您提出拉取请求以解决该问题(库存储库在此处

于 2013-09-26T16:36:05.733 回答