@@ -380,15 +380,50 @@ transform (Pipe pstep1 pstep2 pinitial) (Fold fstep finitial fextract) =
381 extract (Tuple' _ fs) = fextract fs
381 extract (Tuple' _ fs) = fextract fs
383−-- See StreamD/Transform.scanOnce for implementing this.
385-- | Scan the input of a 'Fold' to change it in a stateful manner using another
383-- | Scan the input of a 'Fold' to change it in a stateful manner using another
386-- 'Fold'.
384-- 'Fold'.
387−--
385+-- XXX if any Fold is done assuming finish the resulting Fold?
388−-- /Unimplemented/
386+-- /Pre-release/
389{-# INLINE scan #-}
387{-# INLINE scan #-}
390−scan :: Fold m a b -> Fold m b c -> Fold m a c
388+scan :: Monad m => Fold m a b -> Fold m b c -> Fold m a c
391−scan = undefined
389+scan (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
390+ Fold step initial extract
398+ Done b1 -> return $ case r2 of
400+ Partial fs2 -> Partial (Nothing, Just fs2, b1)
401+ Partial fs -> return $ case r2 of
403+ Partial fs2 -> Partial (Just fs, Just fs2, undefined)
405+ step (Just s1, s2, _) x = do
409+ r2 <- stepR (fromJust s2) b
411+ Partial fs2 -> Done <$> extractR fs2
412+ Done b2 -> return $ Done b2
415+ r2 <- stepR (fromJust s2) b
417+ Partial fs2 -> Partial (Just fs, Just fs2, undefined)
420+ step (Nothing, s2, b1) _ = do
421+ r2 <- stepR (fromJust s2) b1
423+ Partial fs2 -> Done <$> extractR fs2
424+ Done b2 -> return $ Done b2
426+ extract (_, s2, _) = extractR (fromJust s2)
393------------------------------------------------------------------------------
428------------------------------------------------------------------------------
394-- Left folds
429-- Left folds