@@ -163,7 +163,7 @@ import Streamly.Internal.Data.Stream.IsStream.Common
163 ( fold, foldBreak, foldContinue, drop, findIndices, reverse, splitOnSeq
163 ( fold, foldBreak, foldContinue, drop, findIndices, reverse, splitOnSeq
164 , take , takeWhile, mkParallel)
164 , take , takeWhile, mkParallel)
165import Streamly.Internal.Data.Stream.IsStream.Type
165import Streamly.Internal.Data.Stream.IsStream.Type
166− (IsStream, toStreamS, fromStreamD, toStreamD)
166+ (IsStream, toStreamD, fromStreamD, toStreamD)
167import Streamly.Internal.Data.Stream.Serial (SerialT)
167import Streamly.Internal.Data.Stream.Serial (SerialT)
168import Streamly.Internal.Data.Unboxed (Unboxed)
168import Streamly.Internal.Data.Unboxed (Unboxed)
@@ -172,11 +172,6 @@ import qualified Streamly.Internal.Data.Fold as FL
172import qualified Streamly.Internal.Data.Stream.IsStream.Type as IsStream
172import qualified Streamly.Internal.Data.Stream.IsStream.Type as IsStream
173import qualified Streamly.Internal.Data.Stream.StreamD as D
173import qualified Streamly.Internal.Data.Stream.StreamD as D
174import qualified Streamly.Internal.Data.Stream.StreamK.Type as K
174import qualified Streamly.Internal.Data.Stream.StreamK.Type as K
175−#ifdef USE_STREAMK_ONLY
176−import qualified Streamly.Internal.Data.Stream.StreamK as S
178−import qualified Streamly.Internal.Data.Stream.StreamD as S
180import qualified Streamly.Internal.Data.Stream as Stream
175import qualified Streamly.Internal.Data.Stream as Stream
181import qualified System.IO as IO
176import qualified System.IO as IO
@@ -240,7 +235,7 @@ uncons = fmap (fmap (fmap IsStream.fromStream)) . K.uncons . Stream.toStreamK
240{-# INLINE foldr1 #-}
235{-# INLINE foldr1 #-}
241{-# DEPRECATED foldr1 "Use foldrM instead." #-}
236{-# DEPRECATED foldr1 "Use foldrM instead." #-}
242foldr1 :: Monad m => (a -> a -> a) -> SerialT m a -> m (Maybe a)
237foldr1 :: Monad m => (a -> a -> a) -> SerialT m a -> m (Maybe a)
243−foldr1 f m = S.foldr1 f (toStreamS m)
238+foldr1 f m = D.foldr1 f (toStreamD m)
245------------------------------------------------------------------------------
240------------------------------------------------------------------------------
246-- Left Folds
241-- Left Folds
@@ -260,12 +255,12 @@ foldlS f z =
261-- For example, to reverse a stream:
256-- For example, to reverse a stream:
263−-- > S.toList $ S.foldlT (flip S.cons) S.nil $ (S.fromList [1..5] :: SerialT IO Int)
258+-- > D.toList $ D.foldlT (flip D.cons) D.nil $ (D.fromList [1..5] :: SerialT IO Int)
265{-# INLINE foldlT #-}
260{-# INLINE foldlT #-}
266foldlT :: (Monad m, IsStream t, Monad (s m), MonadTrans s)
261foldlT :: (Monad m, IsStream t, Monad (s m), MonadTrans s)
267 => (s m b -> a -> s m b) -> s m b -> t m a -> s m b
262 => (s m b -> a -> s m b) -> s m b -> t m a -> s m b
268−foldlT f z s = S.foldlT f z (toStreamS s)
263+foldlT f z s = D.foldlT f z (toStreamD s)
270-- | Strict left fold with an extraction function. Like the standard strict
265-- | Strict left fold with an extraction function. Like the standard strict
271-- left fold, but applies a user supplied extraction function (the third
266-- left fold, but applies a user supplied extraction function (the third
@@ -320,7 +315,7 @@ foldxM = IsStream.foldlMx'
320-- /Since: 0.8.0 (signature change)/
315-- /Since: 0.8.0 (signature change)/
321{-# INLINE foldlM' #-}
316{-# INLINE foldlM' #-}
322foldlM' :: Monad m => (b -> a -> m b) -> m b -> SerialT m a -> m b
317foldlM' :: Monad m => (b -> a -> m b) -> m b -> SerialT m a -> m b
323−foldlM' step begin = S.foldlM' step begin . IsStream.toStreamS
318+foldlM' step begin = D.foldlM' step begin . IsStream.toStreamD
325------------------------------------------------------------------------------
320------------------------------------------------------------------------------
326-- Running a sink
321-- Running a sink
@@ -347,7 +342,7 @@ runSink = fold . toFold
347-- @since 0.1.0
342-- @since 0.1.0
348{-# INLINE mapM_ #-}
343{-# INLINE mapM_ #-}
349mapM_ :: Monad m => (a -> m b) -> SerialT m a -> m ()
344mapM_ :: Monad m => (a -> m b) -> SerialT m a -> m ()
350−mapM_ f = S.mapM_ f . IsStream.toStreamS
345+mapM_ f = D.mapM_ f . IsStream.toStreamD
353-- > drain = mapM_ (\_ -> return ())
348-- > drain = mapM_ (\_ -> return ())
@@ -422,7 +417,7 @@ runStream = drain
422-- @since 0.1.1
417-- @since 0.1.1
423{-# INLINE null #-}
418{-# INLINE null #-}
424null :: Monad m => SerialT m a -> m Bool
419null :: Monad m => SerialT m a -> m Bool
425−null = S.null . toStreamS
420+null = D.null . toStreamD
427-- | Extract the first element of the stream, if any.
422-- | Extract the first element of the stream, if any.
@@ -432,7 +427,7 @@ null = S.null . toStreamS
432-- @since 0.1.0
427-- @since 0.1.0
433{-# INLINE head #-}
428{-# INLINE head #-}
434head :: Monad m => SerialT m a -> m (Maybe a)
429head :: Monad m => SerialT m a -> m (Maybe a)
435−head = S.head . toStreamS
430+head = D.head . toStreamD
437-- | Extract the first element of the stream, if any, otherwise use the
432-- | Extract the first element of the stream, if any, otherwise use the
438-- supplied default value. It can help avoid one branch in high performance
433-- supplied default value. It can help avoid one branch in high performance
@@ -468,7 +463,7 @@ init m = fmap (fmap IsStream.fromStream) $ K.init $ Stream.toStreamK m
468-- @since 0.1.1
463-- @since 0.1.1
469{-# INLINE last #-}
464{-# INLINE last #-}
470last :: Monad m => SerialT m a -> m (Maybe a)
465last :: Monad m => SerialT m a -> m (Maybe a)
471−last m = S.last $ toStreamS m
466+last m = D.last $ toStreamD m
473-- | Determine whether an element is present in the stream.
468-- | Determine whether an element is present in the stream.
@@ -477,7 +472,7 @@ last m = S.last $ toStreamS m
477-- @since 0.1.0
472-- @since 0.1.0
478{-# INLINE elem #-}
473{-# INLINE elem #-}
479elem :: (Monad m, Eq a) => a -> SerialT m a -> m Bool
474elem :: (Monad m, Eq a) => a -> SerialT m a -> m Bool
480−elem e m = S.elem e (toStreamS m)
475+elem e m = D.elem e (toStreamD m)
482-- | Determine whether an element is not present in the stream.
477-- | Determine whether an element is not present in the stream.
@@ -486,7 +481,7 @@ elem e m = S.elem e (toStreamS m)
486-- @since 0.1.0
481-- @since 0.1.0
487{-# INLINE notElem #-}
482{-# INLINE notElem #-}
488notElem :: (Monad m, Eq a) => a -> SerialT m a -> m Bool
483notElem :: (Monad m, Eq a) => a -> SerialT m a -> m Bool
489−notElem e m = S.notElem e (toStreamS m)
484+notElem e m = D.notElem e (toStreamD m)
491-- | Determine the length of the stream.
486-- | Determine the length of the stream.
@@ -502,7 +497,7 @@ length = foldl' (\n _ -> n + 1) 0
502-- @since 0.1.0
497-- @since 0.1.0
503{-# INLINE all #-}
498{-# INLINE all #-}
504all :: Monad m => (a -> Bool) -> SerialT m a -> m Bool
499all :: Monad m => (a -> Bool) -> SerialT m a -> m Bool
505−all p m = S.all p (toStreamS m)
500+all p m = D.all p (toStreamD m)
507-- | Determine whether any of the elements of a stream satisfy a predicate.
502-- | Determine whether any of the elements of a stream satisfy a predicate.
@@ -511,7 +506,7 @@ all p m = S.all p (toStreamS m)
511-- @since 0.1.0
506-- @since 0.1.0
512{-# INLINE any #-}
507{-# INLINE any #-}
513any :: Monad m => (a -> Bool) -> SerialT m a -> m Bool
508any :: Monad m => (a -> Bool) -> SerialT m a -> m Bool
514−any p m = S.any p (toStreamS m)
509+any p m = D.any p (toStreamD m)
516-- | Determines if all elements of a boolean stream are True.
511-- | Determines if all elements of a boolean stream are True.
@@ -572,7 +567,7 @@ mconcat = Stream.foldr mappend mempty
572-- @since 0.1.0
567-- @since 0.1.0
573{-# INLINE minimum #-}
568{-# INLINE minimum #-}
574minimum :: (Monad m, Ord a) => SerialT m a -> m (Maybe a)
569minimum :: (Monad m, Ord a) => SerialT m a -> m (Maybe a)
575−minimum m = S.minimum (toStreamS m)
570+minimum m = D.minimum (toStreamD m)
577-- | Determine the minimum element in a stream using the supplied comparison
572-- | Determine the minimum element in a stream using the supplied comparison
578-- function.
573-- function.
@@ -582,7 +577,7 @@ minimum m = S.minimum (toStreamS m)
582-- @since 0.6.0
577-- @since 0.6.0
583{-# INLINE minimumBy #-}
578{-# INLINE minimumBy #-}
584minimumBy :: Monad m => (a -> a -> Ordering) -> SerialT m a -> m (Maybe a)
579minimumBy :: Monad m => (a -> a -> Ordering) -> SerialT m a -> m (Maybe a)
585−minimumBy cmp m = S.minimumBy cmp (toStreamS m)
580+minimumBy cmp m = D.minimumBy cmp (toStreamD m)
@@ -595,7 +590,7 @@ minimumBy cmp m = S.minimumBy cmp (toStreamS m)
595-- @since 0.1.0
590-- @since 0.1.0
596{-# INLINE maximum #-}
591{-# INLINE maximum #-}
597maximum :: (Monad m, Ord a) => SerialT m a -> m (Maybe a)
592maximum :: (Monad m, Ord a) => SerialT m a -> m (Maybe a)
598−maximum m = S.maximum (toStreamS m)
593+maximum m = D.maximum (toStreamD m)
600-- | Determine the maximum element in a stream using the supplied comparison
595-- | Determine the maximum element in a stream using the supplied comparison
601-- function.
596-- function.
@@ -605,7 +600,7 @@ maximum m = S.maximum (toStreamS m)
605-- @since 0.6.0
600-- @since 0.6.0
606{-# INLINE maximumBy #-}
601{-# INLINE maximumBy #-}
607maximumBy :: Monad m => (a -> a -> Ordering) -> SerialT m a -> m (Maybe a)
602maximumBy :: Monad m => (a -> a -> Ordering) -> SerialT m a -> m (Maybe a)
608−maximumBy cmp m = S.maximumBy cmp (toStreamS m)
603+maximumBy cmp m = D.maximumBy cmp (toStreamD m)
610-- | Ensures that all the elements of the stream are identical and then returns
605-- | Ensures that all the elements of the stream are identical and then returns
611-- that unique element.
606-- that unique element.
@@ -613,7 +608,7 @@ maximumBy cmp m = S.maximumBy cmp (toStreamS m)
613-- @since 0.6.0
608-- @since 0.6.0
614{-# INLINE the #-}
609{-# INLINE the #-}
615the :: (Eq a, Monad m) => SerialT m a -> m (Maybe a)
610the :: (Eq a, Monad m) => SerialT m a -> m (Maybe a)
616−the m = S.the (toStreamS m)
611+the m = D.the (toStreamD m)
618------------------------------------------------------------------------------
613------------------------------------------------------------------------------
619-- Searching
614-- Searching
@@ -624,7 +619,7 @@ the m = S.the (toStreamS m)
624-- @since 0.6.0
619-- @since 0.6.0
625{-# INLINE (!!) #-}
620{-# INLINE (!!) #-}
626(!!) :: Monad m => SerialT m a -> Int -> m (Maybe a)
621(!!) :: Monad m => SerialT m a -> Int -> m (Maybe a)
627−m !! i = toStreamS m S.!! i
622+m !! i = toStreamD m D.!! i
629-- | In a stream of (key-value) pairs @(a, b)@, return the value @b@ of the
624-- | In a stream of (key-value) pairs @(a, b)@, return the value @b@ of the
630-- first pair where the key equals the given value @a@.
625-- first pair where the key equals the given value @a@.
@@ -635,7 +630,7 @@ m !! i = toStreamS m S.!! i
635-- @since 0.5.0
630-- @since 0.5.0
636{-# INLINE lookup #-}
631{-# INLINE lookup #-}
637lookup :: (Monad m, Eq a) => a -> SerialT m (a, b) -> m (Maybe b)
632lookup :: (Monad m, Eq a) => a -> SerialT m (a, b) -> m (Maybe b)
638−lookup a m = S.lookup a (toStreamS m)
633+lookup a m = D.lookup a (toStreamD m)
640-- | Like 'findM' but with a non-monadic predicate.
635-- | Like 'findM' but with a non-monadic predicate.
@@ -645,7 +640,7 @@ lookup a m = S.lookup a (toStreamS m)
645-- @since 0.5.0
640-- @since 0.5.0
646{-# INLINE find #-}
641{-# INLINE find #-}
647find :: Monad m => (a -> Bool) -> SerialT m a -> m (Maybe a)
642find :: Monad m => (a -> Bool) -> SerialT m a -> m (Maybe a)
648−find p m = S.find p (toStreamS m)
643+find p m = D.find p (toStreamD m)
650-- | Returns the first element that satisfies the given predicate.
645-- | Returns the first element that satisfies the given predicate.
@@ -654,7 +649,7 @@ find p m = S.find p (toStreamS m)
654-- @since 0.6.0
649-- @since 0.6.0
655{-# INLINE findM #-}
650{-# INLINE findM #-}
656findM :: Monad m => (a -> m Bool) -> SerialT m a -> m (Maybe a)
651findM :: Monad m => (a -> m Bool) -> SerialT m a -> m (Maybe a)
657−findM p m = S.findM p (toStreamS m)
652+findM p m = D.findM p (toStreamD m)
659-- | Returns the first index that satisfies the given predicate.
654-- | Returns the first index that satisfies the given predicate.
@@ -712,7 +707,7 @@ toListRev = D.toListRev . toStreamD
715−-- toHandle h = S.mapM_ $ hPutStrLn h
710+-- toHandle h = D.mapM_ $ hPutStrLn h
718-- Write a stream of Strings to an IO Handle.
713-- Write a stream of Strings to an IO Handle.