@@ -497,31 +497,15 @@ foldlM' step begin m = S.foldlM' step begin $ toStreamS m
497497-- Specialized folds
498498------------------------------------------------------------------------------
499499
500−-- | Determine whether all elements of a stream satisfy a predicate.
501−--
502−-- @since 0.1.0
503−all :: Monad m => (a -> Bool) -> SerialT m a -> m Bool
504−all = K.all
505−
506−-- | Determine whether any of the elements of a stream satisfy a predicate.
507−--
508−-- @since 0.1.0
509−any :: Monad m => (a -> Bool) -> SerialT m a -> m Bool
510−any = K.any
511−
512−-- | Determine the sum of all elements of a stream of numbers
513−--
514−-- @since 0.1.0
515−{-# INLINE sum #-}
516−sum :: (Monad m, Num a) => SerialT m a -> m a
517−sum = foldl' (+) 0
518−
519−-- | Determine the product of all elements of a stream of numbers
500+-- | Determine whether the stream is empty.
520501--
521502-- @since 0.1.1
522−{-# INLINE product #-}
523−product :: (Monad m, Num a) => SerialT m a -> m a
524−product = foldl' (*) 1
503+null :: Monad m => SerialT m a -> m Bool
504+null m =
505+ let stop = return True
506+ single _ = return False
507+ yieldk _ _ = return False
508+ in (K.unStream (toStream m)) Nothing stop single yieldk
525509
526510-- | Extract the first element of the stream, if any.
527511--
@@ -550,39 +534,19 @@ tail m =
550534last :: Monad m => SerialT m a -> m (Maybe a)
551535last m = S.last $ toStreamS m
552536
553−-- | Determine whether the stream is empty.
554−--
555−-- @since 0.1.1
556−null :: Monad m => SerialT m a -> m Bool
557−null m =
558− let stop = return True
559− single _ = return False
560− yieldk _ _ = return False
561− in (K.unStream (toStream m)) Nothing stop single yieldk
562−
563537-- | Determine whether an element is present in the stream.
564538--
565539-- @since 0.1.0
540+{-# INLINE elem #-}
566541elem :: (Monad m, Eq a) => a -> SerialT m a -> m Bool
567−elem e m = go (toStream m)
568− where
569− go m1 =
570− let stop = return False
571− single a = return (a == e)
572− yieldk a r = if a == e then return True else go r
573− in (K.unStream m1) Nothing stop single yieldk
542+elem e m = S.elem e (toStreamS m)
574543
575544-- | Determine whether an element is not present in the stream.
576545--
577546-- @since 0.1.0
547+{-# INLINE notElem #-}
578548notElem :: (Monad m, Eq a) => a -> SerialT m a -> m Bool
579−notElem e m = go (toStream m)
580− where
581− go m1 =
582− let stop = return True
583− single a = return (a /= e)
584− yieldk a r = if a == e then return False else go r
585− in (K.unStream m1) Nothing stop single yieldk
549+notElem e m = S.notElem e (toStreamS m)
586550
587551-- | Determine the length of the stream.
588552--
@@ -591,6 +555,34 @@ notElem e m = go (toStream m)
591555length :: Monad m => SerialT m a -> m Int
592556length = foldl' (\n _ -> n + 1) 0
593557
558+-- | Determine whether all elements of a stream satisfy a predicate.
559+--
560+-- @since 0.1.0
561+{-# INLINE all #-}
562+all :: Monad m => (a -> Bool) -> SerialT m a -> m Bool
563+all p m = S.all p (toStreamS m)
564+
565+-- | Determine whether any of the elements of a stream satisfy a predicate.
566+--
567+-- @since 0.1.0
568+{-# INLINE any #-}
569+any :: Monad m => (a -> Bool) -> SerialT m a -> m Bool
570+any p m = S.any p (toStreamS m)
571+
572+-- | Determine the sum of all elements of a stream of numbers
573+--
574+-- @since 0.1.0
575+{-# INLINE sum #-}
576+sum :: (Monad m, Num a) => SerialT m a -> m a
577+sum = foldl' (+) 0
578+
579+-- | Determine the product of all elements of a stream of numbers
580+--
581+-- @since 0.1.1
582+{-# INLINE product #-}
583+product :: (Monad m, Num a) => SerialT m a -> m a
584+product = foldl' (*) 1
585+
594586-- | Determine the minimum element in a stream.
595587--
596588-- @since 0.1.0