@@ -215,10 +215,10 @@ import Data.Int (Int64)
215import Data.Map.Strict (Map)
215import Data.Map.Strict (Map)
217import Prelude
217import Prelude
218− hiding (filter, drop, dropWhile, take, takeWhile, zipWith, foldr,
218+ hiding (filter, drop, dropWhile, take, takeWhile, zipWith,
219 foldl, map, mapM_, sequence, all, any, sum, product, elem,
219 foldl, map, mapM_, sequence, all, any, sum, product, elem,
220 notElem, maximum, minimum, head, last, tail, length, null,
220 notElem, maximum, minimum, head, last, tail, length, null,
221− reverse, iterate, init, and, or, lookup, foldr1, (!!),
221+ reverse, iterate, init, and, or, lookup, (!!),
222 scanl, scanl1, replicate, concatMap, mconcat, foldMap, unzip,
222 scanl, scanl1, replicate, concatMap, mconcat, foldMap, unzip,
223 span, splitAt, break, mapM)
223 span, splitAt, break, mapM)
@@ -332,7 +332,7 @@ transform (Pipe pstep1 pstep2 pinitial) (Fold fstep finitial fextract) =
335− initial = Tuple' <$> return pinitial <*> finitial
335+ initial = Tuple' pinitial <$> finitial
336 step (Tuple' ps fs) x = do
336 step (Tuple' ps fs) x = do
337 r <- pstep1 ps x
337 r <- pstep1 ps x
@@ -929,7 +929,7 @@ splitAt
929splitAt n (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
929splitAt n (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
930 Fold step initial extract
930 Fold step initial extract
932− initial = Tuple3' <$> return n <*> initialL <*> initialR
932+ initial = Tuple3' n <$> initialL <*> initialR
934 step (Tuple3' i xL xR) input =
934 step (Tuple3' i xL xR) input =
@@ -1158,8 +1158,7 @@ foldCons (Fold stepL beginL doneL) (Fold stepR beginR doneR) =
1158-- @since 0.7.0
1158-- @since 0.7.0
1159{-# INLINE distribute #-}
1159{-# INLINE distribute #-}
1160distribute :: Monad m => [Fold m a b] -> Fold m a [b]
1160distribute :: Monad m => [Fold m a b] -> Fold m a [b]
1161−distribute [] = foldNil
1161+distribute = foldr foldCons foldNil
1162−distribute (x:xs) = foldCons x (distribute xs)
1164-- | Like 'distribute' but for folds that return (), this can be more efficient
1163-- | Like 'distribute' but for folds that return (), this can be more efficient
1165-- than 'distribute' as it does not need to maintain state.
1164-- than 'distribute' as it does not need to maintain state.
@@ -1173,9 +1172,8 @@ distribute_ fs = Fold step initial extract
1173 step ss a = do
1172 step ss a = do
1174 Prelude.mapM_ (\(Fold s i _) -> i >>= \r -> void (s r a)) ss
1173 Prelude.mapM_ (\(Fold s i _) -> i >>= \r -> void (s r a)) ss
1175 return ss
1174 return ss
1176− extract ss = do
1175+ extract ss =
1177 Prelude.mapM_ (\(Fold _ i e) -> i >>= \r -> e r) ss
1176 Prelude.mapM_ (\(Fold _ i e) -> i >>= \r -> e r) ss
1180------------------------------------------------------------------------------
1178------------------------------------------------------------------------------
1181-- Partitioning
1179-- Partitioning
@@ -1235,7 +1233,7 @@ partitionByM f (Fold stepL beginL doneL) (Fold stepR beginR doneR) =
1235 r <- f a
1233 r <- f a
1236 case r of
1234 case r of
1237 Left b -> Tuple' <$> stepL xL b <*> return xR
1235 Left b -> Tuple' <$> stepL xL b <*> return xR
1238− Right c -> Tuple' <$> return xL <*> stepR xR c
1236+ Right c -> Tuple' xL <$> stepR xR c
1239 done (Tuple' xL xR) = (,) <$> doneL xL <*> doneR xR
1237 done (Tuple' xL xR) = (,) <$> doneL xL <*> doneR xR
1241-- Note: we could use (a -> Bool) instead of (a -> Either b c), but the latter
1239-- Note: we could use (a -> Bool) instead of (a -> Either b c), but the latter
@@ -1369,8 +1367,8 @@ demuxWithDefault_ f kv (Fold dstep dinitial dextract) =
1369 initFold (Fold s i e) = i >>= \r -> return (Fold s (return r) e)
1367 initFold (Fold s i e) = i >>= \r -> return (Fold s (return r) e)
1370 initial = do
1368 initial = do
1371 mp <- Prelude.mapM initFold kv
1369 mp <- Prelude.mapM initFold kv
1373− return (Tuple' mp dacc)
1370+ Tuple' mp <$> dinitial
1374 step (Tuple' mp dacc) a
1372 step (Tuple' mp dacc) a
1375 | (k, a') <- f a
1373 | (k, a') <- f a
1376 = case Map.lookup k mp of
1374 = case Map.lookup k mp of