I am converting some functioning Haskell code that uses Parsec to instead use Attoparsec in the hope of getting better performance. I have made the changes and everything compiles but my parser does not work correctly.
I am parsing a file that consists of various record types, one per line. Each of my individual functions for parsing a record or comment works correctly but when I try to write a function to compile a sequence of records the parser always returns a partial result because it is expecting more input.
These are the two main variations that I've tried. Both have the same problem.
items :: Parser [Item]
items = sepBy (comment <|> recordType1 <|> recordType2) endOfLine
For this second one I changed the record/comment parsers to consume the end-of-line characters.
items :: Parser [Item]
items = manyTill (comment <|> recordType1 <|> recordType2) endOfInput
Is there anything wrong with my approach? Is there some other way to achieve what I am attempting?
feed
is actually the correct way to deal with this situation? It might be a good idea to make this a little clearer in the documentation—I know it confused me when I first came across it. – Commonly