@@ -30,8 +30,6 @@ module Streamly.Internal.Data.Fold.Combinators
30 -- *** Reducers
30 -- *** Reducers
31 , drainMapM
31 , drainMapM
36 , rollingHash
34 , rollingHash
37 , defaultSalt
35 , defaultSalt
@@ -166,8 +164,6 @@ module Streamly.Internal.Data.Fold.Combinators
166 -- ** Trimming
164 -- ** Trimming
168 -- By elements
166 -- By elements
171 , takeEndBySeq
167 , takeEndBySeq
172 , takeEndBySeq_
168 , takeEndBySeq_
@@ -709,30 +705,6 @@ the = foldt' step initial id
709-- To Summary
705-- To Summary
710------------------------------------------------------------------------------
706------------------------------------------------------------------------------
712−-- | Like 'length', except with a more general 'Num' return value
716−-- >>> lengthGeneric = fmap getSum $ Fold.foldMap (Sum . const 1)
717−-- >>> lengthGeneric = Fold.foldl' (\n _ -> n + 1) 0
720−{-# INLINE lengthGeneric #-}
721−lengthGeneric :: (Monad m, Num b) => Fold m a b
722−lengthGeneric = foldl' (\n _ -> n + 1) 0
724−-- | Determine the length of the input stream.
728−-- >>> length = Fold.lengthGeneric
729−-- >>> length = fmap getSum $ Fold.foldMap (Sum . const 1)
731−{-# INLINE length #-}
732−length :: Monad m => Fold m a Int
733−length = lengthGeneric
736-- | Determine the sum of all elements of a stream of numbers. Returns additive
708-- | Determine the sum of all elements of a stream of numbers. Returns additive
737-- identity (@0@) when the stream is empty. Note that this is not numerically
709-- identity (@0@) when the stream is empty. Note that this is not numerically
738-- stable for floating point numbers.
710-- stable for floating point numbers.
@@ -1510,70 +1482,6 @@ droppingWhileM p = Fold step initial extract extract
1510droppingWhile :: Monad m => (a -> Bool) -> Fold m a (Maybe a)
1482droppingWhile :: Monad m => (a -> Bool) -> Fold m a (Maybe a)
1511droppingWhile p = droppingWhileM (return . p)
1483droppingWhile p = droppingWhileM (return . p)
1513−-- Note: Keep this consistent with S.splitOn. In fact we should eliminate
1514−-- S.splitOn in favor of the fold.
1516−-- XXX Use Fold.many instead once it is fixed.
1517−-- > Stream.splitOnSuffix p f = Stream.foldMany (Fold.takeEndBy_ p f)
1519−-- | Like 'takeEndBy' but drops the element on which the predicate succeeds.
1523−-- >>> input = Stream.fromList "hello\nthere\n"
1524−-- >>> line = Fold.takeEndBy_ (== '\n') Fold.toList
1525−-- >>> Stream.fold line input
1528−-- >>> Stream.fold Fold.toList $ Stream.foldMany line input
1529−-- ["hello","there"]
1531−{-# INLINE takeEndBy_ #-}
1532−takeEndBy_ :: Monad m => (a -> Bool) -> Fold m a b -> Fold m a b
1533−-- takeEndBy_ predicate = scanMaybe (takingEndBy_ predicate)
1534−takeEndBy_ predicate (Fold fstep finitial fextract ffinal) =
1535− Fold step finitial fextract ffinal
1540− if not (predicate a)
1542− else Done <$> ffinal s
1545−-- > Stream.splitWithSuffix p f = Stream.foldMany (Fold.takeEndBy p f)
1547−-- | Take the input, stop when the predicate succeeds taking the succeeding
1552−-- >>> input = Stream.fromList "hello\nthere\n"
1553−-- >>> line = Fold.takeEndBy (== '\n') Fold.toList
1554−-- >>> Stream.fold line input
1557−-- >>> Stream.fold Fold.toList $ Stream.foldMany line input
1558−-- ["hello\n","there\n"]
1560−{-# INLINE takeEndBy #-}
1561−takeEndBy :: Monad m => (a -> Bool) -> Fold m a b -> Fold m a b
1562−-- takeEndBy predicate = scanMaybe (takingEndBy predicate)
1563−takeEndBy predicate (Fold fstep finitial fextract ffinal) =
1564− Fold step finitial fextract ffinal
1570− if not (predicate a)
1574− Partial s1 -> Done <$> ffinal s1
1575− Done b -> return $ Done b
1577------------------------------------------------------------------------------
1485------------------------------------------------------------------------------
1578-- Binary splitting on a separator
1486-- Binary splitting on a separator
1579------------------------------------------------------------------------------
1487------------------------------------------------------------------------------