1

I am trying to write a simple parser with megaparsec and have the following issue:

type MyParser = Parsec Void String

xxx :: MyParser Int
xxx  = do
    satisfy (`notElem` "!>")
    return 1

gbgc :: MyParser [Int]
gbgc  = many (yyy <|> xxx)

I get the error on line: satisfy .... That says:

No instance for (ErrorComponent Void) arising from a do statement In a stmt of a 'do' block: satisfy (notElem "!>")

pulcher
  • 115
  • 5
  • 2
    `Parsec Void` is a parser that must never under any circumstances fail. It shouldn't be surprising that you can't just insert a _failing check_ like `satisfy`... – leftaroundabout Dec 13 '17 at 13:01
  • 3
    Your code compiles with the latest version of megaparsec (6.2.0). On older versions, you don't use `Void`; instead use `()` or [this](https://hackage.haskell.org/package/megaparsec-5.3.0/docs/Text-Megaparsec-Error.html#t:Dec) type. – user2407038 Dec 13 '17 at 18:16

0 Answers0