on master help sign in
inline take and takeWhile
06749c4Harendra Kumar
src/Streamly/Prelude.hs+2
@@ -208,6 +208,7 @@ toList :: (Streaming t, Monad m) => t m a -> m [a]
208toList = foldrM (\a xs -> fmap (a :) xs) (return [])
208toList = foldrM (\a xs -> fmap (a :) xs) (return [])
209
209
210-- | Take first 'n' elements from the stream and discard the rest.
210-- | Take first 'n' elements from the stream and discard the rest.
211+{-# INLINE take #-}
211take :: Streaming t => Int -> t m a -> t m a
212take :: Streaming t => Int -> t m a -> t m a
212take n m = fromStream $ go n (toStream m)
213take n m = fromStream $ go n (toStream m)
213 where
214 where
@@ -229,6 +230,7 @@ filter p m = fromStream $ go (toStream m)
229 in (runStream m1) ctx stp yield
230 in (runStream m1) ctx stp yield
230
231
231-- | End the stream as soon as the predicate fails on an element.
232-- | End the stream as soon as the predicate fails on an element.
233+{-# INLINE takeWhile #-}
232takeWhile :: Streaming t => (a -> Bool) -> t m a -> t m a
234takeWhile :: Streaming t => (a -> Bool) -> t m a -> t m a
233takeWhile p m = fromStream $ go (toStream m)
235takeWhile p m = fromStream $ go (toStream m)
234 where
236 where