@@ -44,6 +44,7 @@ module Streamly.Internal.Data.Stream.StreamD.Type
45 , foldBreak
45 , foldBreak
46 , foldContinue
46 , foldContinue
48 -- * Right Folds
49 -- * Right Folds
@@ -305,6 +306,9 @@ foldBreak (Fold fstep begin done) (UnStream step state) = do
305 b <- done fs
306 b <- done fs
306 return $! (b, Stream (\ _ _ -> return Stop) ())
307 return $! (b, Stream (\ _ _ -> return Stop) ())
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.
308{-# INLINE_NORMAL foldContinue #-}
312{-# INLINE_NORMAL foldContinue #-}
309foldContinue :: Monad m => Fold m a b -> Stream m a -> Fold m a b
313foldContinue :: Monad m => Fold m a b -> Stream m a -> Fold m a b
310foldContinue (Fold fstep finitial fextract) (Stream sstep state) =
314foldContinue (Fold fstep finitial fextract) (Stream sstep state) =
@@ -330,6 +334,16 @@ foldContinue (Fold fstep finitial fextract) (Stream sstep state) =
330 Skip s -> go SPEC fs s
334 Skip s -> go SPEC fs s
331 Stop -> return $ FL.Partial fs
335 Stop -> return $ FL.Partial fs
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
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
333------------------------------------------------------------------------------
347------------------------------------------------------------------------------
334-- Right Folds
348-- Right Folds
335------------------------------------------------------------------------------
349------------------------------------------------------------------------------