on master help sign in
inline take and takeWhile
commit06749c41ff0070106182307213c460e17ae4a757 authorHarendra Kumar <harendra.kumar@gmail.com> dateFri 9 Mar 2018, 18:31 (9 years ago) parent3cca597
1 file changed+2
src/Streamly/Prelude.hs+2
src/Streamly/Prelude.hs+2
@@ -208,6 +208,7 @@ toList :: (Streaming t, Monad m) => t m a -> m [a]
208208toList = foldrM (\a xs -> fmap (a :) xs) (return [])
209209
210210-- | Take first 'n' elements from the stream and discard the rest.
211+{-# INLINE take #-}
211212take :: Streaming t => Int -> t m a -> t m a
212213take n m = fromStream $ go n (toStream m)
213214 where
@@ -229,6 +230,7 @@ filter p m = fromStream $ go (toStream m)
229230 in (runStream m1) ctx stp yield
230231
231232-- | End the stream as soon as the predicate fails on an element.
233+{-# INLINE takeWhile #-}
232234takeWhile :: Streaming t => (a -> Bool) -> t m a -> t m a
233235takeWhile p m = fromStream $ go (toStream m)
234236 where