I'm trying my hand at writing a Producer "transformer" similar to `Pipes.ByteString.lines` which will split a ByteString stream into lines ending in the string `"xy"`.
My functions corresponding to `line`, `_lines` and `lines` are `splitXY`, `_splitXY`, and `splitXYs`.
It seems to work - try running `main1` and `main2`. The questions I have are:
1. Any issues with the code? (One problem I just spotted while writing this post is that if the input stream ends in `"xy"` an extra empty string is yielded at the end.)
2. Is there a library function which does the work of `loop1` -- i.e. traversing down a `Producer ... (Producer ...)` chain?
3. `splitXYs` was written to be analogous to `lines`, but GHC complains when I try type it the same way. ???
4. This was just an exercise in understanding how `lines` worked. What would be the recommended way to do this in the pipes ecosystem?
Thanks,
Erik