@@ -774,6 +774,7 @@ teeWith f (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
777+ {-# INLINE runBoth #-}
777 runBoth actionL actionR = do
778 runBoth actionL actionR = do
778 resL <- actionL
779 resL <- actionL
779 resR <- actionR
780 resR <- actionR
@@ -813,6 +814,7 @@ teeWithFst f (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
817+ {-# INLINE runBoth #-}
816 runBoth actionL actionR = do
818 runBoth actionL actionR = do
817 resL <- actionL
819 resL <- actionL
818 resR <- actionR
820 resR <- actionR
@@ -844,51 +846,34 @@ teeWithFst f (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
844-- /Pre-release/
846-- /Pre-release/
846{-# INLINE teeWithMin #-}
848{-# INLINE teeWithMin #-}
849+teeWithMin :: Monad m =>
847−teeWithMin :: Monad m => (b -> c -> d) -> Fold m a b -> Fold m a c -> Fold m a d
850+ (b -> c -> d) -> Fold m a b -> Fold m a c -> Fold m a d
848−teeWithMin f (Fold stepL beginL doneL) (Fold stepR beginR doneR) =
851+teeWithMin f (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
849− Fold step begin done
852+ Fold step initial extract
853− begin = do
856+ {-# INLINE runBoth #-}
854− resL <- beginL
857+ runBoth actionL actionR = do
855− resR <- beginR
858+ resL <- actionL
856 case resL of
860 case resL of
857− Partial sL1 -> do
861+ Partial sl -> do
858 case resR of
862 case resR of
859− Partial sR1 -> return $ Partial $ Tuple' sL1 sR1
863+ Partial sr -> return $ Partial $ Tuple' sl sr
860− Done br -> do
864+ Done br -> Done . (`f` br) <$> extractL sl
862− return $ Done $ f bl br
864 Done bl -> do
866 Done bl -> do
865− case resR of
868+ case resR of
866− Partial sr -> do
869+ Partial sr -> extractR sr
868− return $ Done $ f bl br
869− Done br -> return $ Done $ f bl br
870+ Done br -> return br
872+ initial = runBoth initialL initialR
871− step (Tuple' sL sR) a = do
874+ step (Tuple' sL sR) a = runBoth (stepL sL a) (stepR sR a)
872− resL <- stepL sL a
875+
873− resR <- stepR sR a
876+ extract (Tuple' sL sR) = f <$> extractL sL <*> extractR sR
877− Partial sR1 -> return $ Partial $ Tuple' sL1 sR1
880− return $ Done $ f bL bR
885− return $ Done $ f bL br
886− Done bR -> return $ Done $ f bL bR
888− done (Tuple' sL sR) = do
893-- | Shortest alternative. Apply both folds in parallel but choose the result
878-- | Shortest alternative. Apply both folds in parallel but choose the result
894-- from the one which consumed least input i.e. take the shortest succeeding
879-- from the one which consumed least input i.e. take the shortest succeeding