@@ -1903,6 +1903,17 @@ foldMany (Fold fstep initial extract) (Stream step state) =
1903 step' _ (FoldManyYield b next) = return $ Yield b next
1903 step' _ (FoldManyYield b next) = return $ Yield b next
1904 step' _ FoldManyDone = return Stop
1904 step' _ FoldManyDone = return Stop
1906+-- | Group the input stream into groups of @n@ elements each and then fold each
1907+-- group using the provided fold function.
1909+-- @groupsOf n f = foldMany (FL.take n f)@
1911+-- >>> Stream.toList $ Stream.groupsOf 2 Fold.sum (Stream.enumerateFromTo 1 10)
1914+-- This can be considered as an n-fold version of 'take' where we apply
1915+-- 'take' repeatedly on the leftover stream until the stream exhausts.
1906{-# INLINE groupsOf #-}
1917{-# INLINE groupsOf #-}
1907groupsOf :: Monad m => Int -> Fold m a b -> Stream m a -> Stream m b
1918groupsOf :: Monad m => Int -> Fold m a b -> Stream m a -> Stream m b
1908groupsOf n f = foldMany (FL.take n f)
1919groupsOf n f = foldMany (FL.take n f)