What is the most efficient way to parse a large text content (300K+) for all matches of already created Attoparsec parser?
I have written a slow performant code like that:
import Data.Either (rights)
findAll :: Parser a -> String -> [a]
findAll parser = rights . map (parseOnly parser . pack) . oneLess where
oneLess [] = []
oneLess (whole@(_:xs)) = whole : oneLess xs
It is for String, but I think the best will be with ByteStrings.
Parsing "abba" in "abbabba" should return only one match ["abba"], i.e. after it match then to continue after it.