lineSplit turns a ByteStream into a connected stream of
ByteStreams at divide after a fixed number of newline characters.
Unlike most of the string splitting functions in this library, this
function preserves newlines characters.
Like
lines, this function properly handles both
\n and
\r\n endings regardless of the current platform. It does not
support
\r or
\n\r line endings.
>>> let planets = ["Mercury","Venus","Earth","Mars","Saturn","Jupiter","Neptune","Uranus"]
>>> S.mapsM_ (\x -> putStrLn "Chunk" >> Q.putStrLn x) $ Q.lineSplit 3 $ Q.string $ L.unlines planets
Chunk
Mercury
Venus
Earth
Chunk Mars Saturn Jupiter
Chunk Neptune Uranus
Since all characters originally present in the stream are preserved,
this function satisfies the following law:
Ɐ n bs. concat (lineSplit n bs) ≅ bs