@@ -1038,9 +1038,14 @@ parseMany (PRD.Parser pstep initial extract) (Stream step state) =
10381038 where
10391039
10401040 {-# INLINE_LATE stepOuter #-}
1041− -- Buffer is empty, go to stream processing loop
1042− stepOuter _ (ParseChunksInit [] st) = do
1043− initial >>= return . Skip . ParseChunksStream st []
1041+ -- Buffer is empty, get the first element from the stream, initialize the
1042+ -- fold and then go to stream processing loop.
1043+ stepOuter gst (ParseChunksInit [] st) = do
1044+ r <- step (adaptState gst) st
1045+ case r of
1046+ Yield x s -> initial >>= return . Skip . ParseChunksBuf [x] s []
1047+ Skip s -> return $ Skip $ ParseChunksInit [] s
1048+ Stop -> return Stop
10441049
10451050 -- Buffer is not empty, go to buffered processing loop
10461051 stepOuter _ (ParseChunksInit src st) = do
@@ -1049,7 +1054,7 @@ parseMany (PRD.Parser pstep initial extract) (Stream step state) =
10491054 -- XXX we just discard any leftover input at the end
10501055 stepOuter _ (ParseChunksInitLeftOver _) = return Stop
10511056
1052− -- Buffer is empty process elements from the stream
1057+ -- Buffer is empty, process elements from the stream
10531058 stepOuter gst (ParseChunksStream st buf pst) = do
10541059 r <- step (adaptState gst) st
10551060 case r of