on master help sign in
Add Prelude#and, Prelude#or
a39a35cVeladus
src/Streamly/Prelude.hs+13−1
@@ -99,6 +99,8 @@ module Streamly.Prelude
99 , length
99 , length
100 , all
100 , all
101 , any
101 , any
102+ , and
103+ , or
102 , maximum
104 , maximum
103 , minimum
105 , minimum
104 , sum
106 , sum
@@ -168,7 +170,7 @@ import Prelude
168 hiding (filter, drop, dropWhile, take, takeWhile, zipWith, foldr,
170 hiding (filter, drop, dropWhile, take, takeWhile, zipWith, foldr,
169 foldl, map, mapM, mapM_, sequence, all, any, sum, product, elem,
171 foldl, map, mapM, mapM_, sequence, all, any, sum, product, elem,
170 notElem, maximum, minimum, head, last, tail, length, null,
172 notElem, maximum, minimum, head, last, tail, length, null,
171− reverse, iterate, init)
173+ reverse, iterate, init, and, or)
172import qualified Prelude
174import qualified Prelude
173import qualified System.IO as IO
175import qualified System.IO as IO
174
176
@@ -572,6 +574,16 @@ all p m = S.all p (toStreamS m)
572any :: Monad m => (a -> Bool) -> SerialT m a -> m Bool
574any :: Monad m => (a -> Bool) -> SerialT m a -> m Bool
573any p m = S.any p (toStreamS m)
575any p m = S.any p (toStreamS m)
574
576
577+-- | Determines if all elements of a boolean stream are True.
578+{-# INLINE and #-}
579+and :: Monad m => SerialT m Bool -> m Bool
580+and = all (==True)
581+
582+-- | Determines wheter at least one element of a boolean stream is True.
583+{-# INLINE or #-}
584+or :: Monad m => SerialT m Bool -> m Bool
585+or = any (==True)
586+
575-- | Determine the sum of all elements of a stream of numbers
587-- | Determine the sum of all elements of a stream of numbers
576--
588--
577-- @since 0.1.0
589-- @since 0.1.0