@@ -879,40 +879,32 @@ teeWithMin f (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
879-- 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
882+-- If the result is extracted before any of the folds could finish then the
883+-- left one is taken.
882-- /Pre-release/
885-- /Pre-release/
884{-# INLINE shortest #-}
887{-# INLINE shortest #-}
885shortest :: Monad m => Fold m x a -> Fold m x b -> Fold m x (Either a b)
888shortest :: Monad m => Fold m x a -> Fold m x b -> Fold m x (Either a b)
886−shortest (Fold stepL beginL doneL) (Fold stepR beginR _) =
889+shortest (Fold stepL initialL extractL) (Fold stepR initialR _) =
887− Fold step begin done
890+ Fold step initial extract
891− begin = do
894+ {-# INLINE runBoth #-}
892− resL <- beginL
895+ runBoth actionL actionR = do
893− resR <- beginR
896+ resL <- actionL
895 case resL of
899 case resL of
896− Partial sL ->
900+ Partial sL -> bimap (Tuple' sL) Right resR
898− Partial sR -> Partial $ Tuple' sL sR
899− Done bR -> Done $ Right bR
900 Done bL -> Done $ Left bL
901 Done bL -> Done $ Left bL
903+ initial = runBoth initialL initialR
902− step (Tuple' sL sR) a = do
905+ step (Tuple' sL sR) a = runBoth (stepL sL a) (stepR sR a)
909− Partial sR1 -> Partial $ Tuple' sL1 sR1
910− Done bR -> Done $ Right bR
911− Done bL -> Done $ Left bL
913− done (Tuple' sL _) = do
907+ extract (Tuple' sL _) = Left <$> extractL sL
917{-# ANN type LongestRunner Fuse #-}
909{-# ANN type LongestRunner Fuse #-}
918data LongestRunner sL sR bL bR
910data LongestRunner sL sR bL bR