@@ -423,8 +423,6 @@ either (Unfold step1 inject1) = Unfold step inject
423 Skip s -> Skip (s, f)
423 Skip s -> Skip (s, f)
424 Stop -> Stop) <$> step1 st
424 Stop -> Stop) <$> step1 st
426−-- See StreamD.scanOnce for implementing this.
428-- | Scan the output of an 'Unfold' to change it in a stateful manner.
426-- | Scan the output of an 'Unfold' to change it in a stateful manner.
430-- /Pre-release/
428-- /Pre-release/
@@ -436,28 +434,26 @@ scan (Fold stepF initial extract) (Unfold stepU injectU) =
438 inject a = do
436 inject a = do
439− fs <- initial
437+ r <- initial
440− case fs of
438+ case r of
441− FL.Partial fs1 -> do
439+ FL.Partial fs -> Just . (fs,) <$> injectU a
443− return (fs1, Just us)
444− FL.Done _ -> return (undefined, Nothing)
440+ FL.Done _ -> return Nothing
446 {-# INLINE_LATE step #-}
442 {-# INLINE_LATE step #-}
447− step (fs, Just us) = do
443+ step (Just (fs, us)) = do
448 ru <- stepU us
444 ru <- stepU us
449 case ru of
445 case ru of
450 Yield x s -> do
446 Yield x s -> do
451 rf <- stepF fs x
447 rf <- stepF fs x
452 case rf of
448 case rf of
453− FL.Done v -> return $ Yield v (fs, Nothing)
449+ FL.Done v -> return $ Yield v Nothing
454 FL.Partial fs1 -> do
450 FL.Partial fs1 -> do
455 v <- extract fs1
451 v <- extract fs1
456− return $ Yield v (fs1, Just s)
452+ return $ Yield v (Just (fs1, s))
457− Skip s -> return $ Skip (fs, Just s)
453+ Skip s -> return $ Skip (Just (fs, s))
458 Stop -> return Stop
454 Stop -> return Stop
460− step (_, Nothing) = return Stop
456+ step Nothing = return Stop
462-- | Scan the output of an 'Unfold' to change it in a stateful manner.
458-- | Scan the output of an 'Unfold' to change it in a stateful manner.