@@ -105,6 +105,8 @@ module Streamly.Prelude
105 , minimum
105 , minimum
107 , product
107 , product
109 -- *** Indices
111 -- *** Indices
110 , findIndices
112 , findIndices
@@ -170,7 +172,7 @@ import Prelude
170 hiding (filter, drop, dropWhile, take, takeWhile, zipWith, foldr,
172 hiding (filter, drop, dropWhile, take, takeWhile, zipWith, foldr,
171 foldl, map, mapM, mapM_, sequence, all, any, sum, product, elem,
173 foldl, map, mapM, mapM_, sequence, all, any, sum, product, elem,
172 notElem, maximum, minimum, head, last, tail, length, null,
174 notElem, maximum, minimum, head, last, tail, length, null,
173− reverse, iterate, init, and, or)
175+ reverse, iterate, init, and, or, lookup)
174import qualified Prelude
176import qualified Prelude
175import qualified System.IO as IO
177import qualified System.IO as IO
@@ -612,6 +614,17 @@ minimum m = S.minimum (toStreamS m)
612maximum :: (Monad m, Ord a) => SerialT m a -> m (Maybe a)
614maximum :: (Monad m, Ord a) => SerialT m a -> m (Maybe a)
613maximum m = S.maximum (toStreamS m)
615maximum m = S.maximum (toStreamS m)
617+-- | Looks the given key up, treating the given stream as an association list.
618+{-# INLINE lookup #-}
619+lookup :: (Monad m, Eq a) => a -> SerialT m (a, b) -> m (Maybe b)
622+-- | Returns the first element of the stream satisfying the given predicate,
625+find :: Monad m => (a -> Bool) -> SerialT m a -> m (Maybe a)
615-- | Finds all the indices of elements satisfying the given predicate.
628-- | Finds all the indices of elements satisfying the given predicate.
616{-# INLINE findIndices #-}
629{-# INLINE findIndices #-}
617findIndices :: IsStream t => (a -> Bool) -> t m a -> t m Int
630findIndices :: IsStream t => (a -> Bool) -> t m a -> t m Int