2013-09-25 26 views
2

我試圖運行布賴恩奧沙利文的基於Attoparsec-HTTP解析器(http://www.serpentine.com/blog/2010/03/03/whats-in-a-parser-attoparsec-rewired-2/)的測試,我得到這個錯誤:Attoparsec`many`方法

> 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> 

誰能告訴我發生了什麼事?

+5

'many'',而不是'many''。你可能想要'Control.Applicative'的'many'。 – 2013-09-25 23:21:37

回答

1

這個例子是4歲。在0.8.0版本中,在Data.Attoparsec.Combinator模塊中實現了many,您可以檢查源碼here

函數庫的當前版本沒有實現many函數,但它實現了一個函數(來源here)。這就是爲什麼你ghci給你many'作爲一個建議。這是在實施Data.Attoparsec.Combinator

many是在Control.Applicative實現相同的(見heremanyAlternative型類的實現)。您可能需要importControl.Applicative。如果這樣做,我會建議你提出一個拉請求來解決這個問題(庫存儲庫是here