>>> runEffect $ rest >-> P.drop 1 >-> P.print
"goodbye"
>>> (rec1,rest) <- P.toListM' $ accumLines txt ^. PP.span (/= mempty)
>>> rec1
["hello","world"]
Like I said, this may all be wrong-headed and uncomprehending, I'm partly just testing
ideas to see what you are intending.
>>> let cmp a b = a /= mempty && b /= mempty
>>> let kludge p = PG.folds (\a b -> a <> "\n" <> b) mempty id (accumLines p ^. PG.groupsBy cmp)
>>> runEffect $ kludge txt >-> P.filter (/= "\n") >-> P.print
"\nhello\nworld"
"\ngoodbye"
I made some progress http://sprunge.us/iPPE Defining `splitOn` in terms of `breakOn` is
pretty simple. Ideally one would like to use `T.splitOn`, since it is so fast and would speed
up operations when we are taking in large text chunks; that would be a totally different structure.
The two formulations of `breakOn` follow your method and
just pass along what could be an initial segment of a match: the first just keeps the last bit
that is one Char shorter than the needle (irrespective of content); the other inspects this chunk.
The second is nicer but I was worried the apparatus of inspection was going to slow things
more than it was worth. It doesn't seem worse from some initial tests. Do they seem wrong, or clunky?
Michael