@@ -497,31 +497,15 @@ foldlM' step begin m = S.foldlM' step begin $ toStreamS m
497-- Specialized folds
497-- Specialized folds
498------------------------------------------------------------------------------
498------------------------------------------------------------------------------
500−-- | Determine whether all elements of a stream satisfy a predicate.
500+-- | Determine whether the stream is empty.
503−all :: Monad m => (a -> Bool) -> SerialT m a -> m Bool
506−-- | Determine whether any of the elements of a stream satisfy a predicate.
509−any :: Monad m => (a -> Bool) -> SerialT m a -> m Bool
512−-- | Determine the sum of all elements of a stream of numbers
516−sum :: (Monad m, Num a) => SerialT m a -> m a
519−-- | Determine the product of all elements of a stream of numbers
521-- @since 0.1.1
502-- @since 0.1.1
522−{-# INLINE product #-}
523−product :: (Monad m, Num a) => SerialT m a -> m a
503+null :: Monad m => SerialT m a -> m Bool
524−product = foldl' (*) 1
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
526-- | Extract the first element of the stream, if any.
510-- | Extract the first element of the stream, if any.
@@ -550,39 +534,19 @@ tail m =
550last :: Monad m => SerialT m a -> m (Maybe a)
534last :: Monad m => SerialT m a -> m (Maybe a)
551last m = S.last $ toStreamS m
535last m = S.last $ toStreamS m
553−-- | Determine whether the stream is empty.
556−null :: Monad m => SerialT m a -> m Bool
558− let stop = return True
559− single _ = return False
560− yieldk _ _ = return False
561− in (K.unStream (toStream m)) Nothing stop single yieldk
563-- | Determine whether an element is present in the stream.
537-- | Determine whether an element is present in the stream.
565-- @since 0.1.0
539-- @since 0.1.0
566elem :: (Monad m, Eq a) => a -> SerialT m a -> m Bool
541elem :: (Monad m, Eq a) => a -> SerialT m a -> m Bool
567−elem e m = go (toStream m)
542+elem e m = S.elem e (toStreamS m)
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
575-- | Determine whether an element is not present in the stream.
544-- | Determine whether an element is not present in the stream.
577-- @since 0.1.0
546-- @since 0.1.0
547+{-# INLINE notElem #-}
578notElem :: (Monad m, Eq a) => a -> SerialT m a -> m Bool
548notElem :: (Monad m, Eq a) => a -> SerialT m a -> m Bool
579−notElem e m = go (toStream m)
549+notElem e m = S.notElem e (toStreamS m)
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
587-- | Determine the length of the stream.
551-- | Determine the length of the stream.
@@ -591,6 +555,34 @@ notElem e m = go (toStream m)
591length :: Monad m => SerialT m a -> m Int
555length :: Monad m => SerialT m a -> m Int
592length = foldl' (\n _ -> n + 1) 0
556length = foldl' (\n _ -> n + 1) 0
558+-- | Determine whether all elements of a stream satisfy a predicate.
562+all :: Monad m => (a -> Bool) -> SerialT m a -> m Bool
563+all p m = S.all p (toStreamS m)
565+-- | Determine whether any of the elements of a stream satisfy a predicate.
569+any :: Monad m => (a -> Bool) -> SerialT m a -> m Bool
570+any p m = S.any p (toStreamS m)
572+-- | Determine the sum of all elements of a stream of numbers
576+sum :: (Monad m, Num a) => SerialT m a -> m a
579+-- | Determine the product of all elements of a stream of numbers
582+{-# INLINE product #-}
583+product :: (Monad m, Num a) => SerialT m a -> m a
584+product = foldl' (*) 1
594-- | Determine the minimum element in a stream.
586-- | Determine the minimum element in a stream.
596-- @since 0.1.0
588-- @since 0.1.0