----
-
--- This desperate scheme actually has some efficacy, if used before `utf8` in a zoom
--- but not much
-
-chunk :: Monad m => Int -> Lens' (Producer ByteString m r) (Producer ByteString m r)
-chunk n = lens (chunkyN n) (\_ b -> b) where
-
- chunkyN :: Monad m => Int -> Producer ByteString m r -> Producer ByteString m r
- chunkyN n = prod_loop where
-
- prod_loop p = do mbs <- lift $ next p
- case mbs of Left r -> return r
- Right (bs, p') -> do bs_loop bs
- prod_loop p'
- bs_loop bs = unless (S.null bs) $ do yield fore
- unless (S.null aft) (bs_loop aft)
- where (fore, aft) = S.splitAt n bs