Question

I tried running the tests for Bryan O'Sullivan's Attoparsec-based HTTP parser (http://www.serpentine.com/blog/2010/03/03/whats-in-a-parser-attoparsec-rewired-2/), and I got this error:

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

Surprised, I ran ghci and got this:

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

Can anyone tell me what's going on?

Était-ce utile?

La solution

This example is 4 years old. In version 0.8.0 there was a implementation of many in the Data.Attoparsec.Combinator module, you can check the source here.

The current version of the library doesn't implements a many function, but it implements a many' function (source here). That's why you ghci give you many' as a suggestion.

The many that was implemented in Data.Attoparsec.Combinator is the same that is implemented in Control.Applicative (see here the implementation of many in the Alternative type class). You probably need to import the Control.Applicative. If that works I would suggest that you make a pull request to solve that issue (the library repository is here)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top