-1

I have the following definition in a parser using the Haskell ReadP library:

expr = chainl1 comp (string "===" >> return fun6) 

How can I skip spaces before the === operator? I don't know how to include it in this syntax.

Cactus
  • 27,075
  • 9
  • 69
  • 149
Ezis
  • 73
  • 8
  • I think the question is too broad, since it sounds like an answer would need to explain basic syntax, monads, and monadic parsing. There are lots of tutorials that deal with parser combinator libraries you can check out – jberryman Nov 01 '15 at 20:11
  • I know how to parse, i am just having some trouble with syntax in this one. Everything is working but when i try to parse strings with spaces before operators, they fail.... – Ezis Nov 01 '15 at 20:20
  • have you tried `spaces >> string "===" >> return fun6` – mb14 Nov 01 '15 at 21:14

1 Answers1

1

ReadP has skipSpaces for exactly that usecase; your parser then becomes

expr = chainl1 comp (skipSpaces >> string "===" >> return fun6) 
Cactus
  • 27,075
  • 9
  • 69
  • 149