@@ -44,6 +44,7 @@ module Streamly.Internal.Data.Stream.StreamD.Type
4444 , fold
4545 , foldBreak
4646 , foldContinue
47+ , foldStream
4748
4849 -- * Right Folds
4950 , foldrT
@@ -305,6 +306,9 @@ foldBreak (Fold fstep begin done) (UnStream step state) = do
305306 b <- done fs
306307 return $! (b, Stream (\ _ _ -> return Stop) ())
307308
309+-- | If the fold finishes before the stream, we can detect that the fold is
310+-- done by checking if the initial action returns Done. But the remaining
311+-- stream is discarded.
308312{-# INLINE_NORMAL foldContinue #-}
309313foldContinue :: Monad m => Fold m a b -> Stream m a -> Fold m a b
310314foldContinue (Fold fstep finitial fextract) (Stream sstep state) =
@@ -330,6 +334,16 @@ foldContinue (Fold fstep finitial fextract) (Stream sstep state) =
330334 Skip s -> go SPEC fs s
331335 Stop -> return $ FL.Partial fs
332336
337+-- | Returns when either the fold or the stream finishes. If the Fold finishes
338+-- first we can check that using Fold.done. If the fold is not done then stream
339+-- would be nil.
340+--
341+-- /Unimplemented/
342+{-# INLINE_NORMAL foldStream #-}
343+foldStream :: -- Monad m =>
344+ Fold m a b -> Stream m a -> m (Fold m a b, Stream m a)
345+foldStream = undefined
346+
333347------------------------------------------------------------------------------
334348-- Right Folds
335349------------------------------------------------------------------------------