I am converting some valid Haskell code that uses Parsec, instead uses Attoparsec in the hope of getting better performance. I made changes and everything compiles, but my parser is not working correctly.
I am parsing a file consisting of different types of records, 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 expects more input.
These are the two main options I've tried. Both problems are the same.
items :: Parser [Item] items = sepBy (comment <|> recordType1 <|> recordType2) endOfLine
For this second, I changed the post / comment parser to use line breaks.
items :: Parser [Item] items = manyTill (comment <|> recordType1 <|> recordType2) endOfInput
Is there something wrong with my approach? Is there any other way to achieve what I'm trying to do?
haskell attoparsec
Dan dyer
source share