@@ -163,7 +163,7 @@ import Streamly.Internal.Data.Stream.IsStream.Common
163163 ( fold, foldBreak, foldContinue, drop, findIndices, reverse, splitOnSeq
164164 , take , takeWhile, mkParallel)
165165import Streamly.Internal.Data.Stream.IsStream.Type
166− (IsStream, toStreamS, fromStreamD, toStreamD)
166+ (IsStream, toStreamD, fromStreamD, toStreamD)
167167import Streamly.Internal.Data.Stream.Serial (SerialT)
168168import Streamly.Internal.Data.Unboxed (Unboxed)
169169
@@ -172,11 +172,6 @@ import qualified Streamly.Internal.Data.Fold as FL
172172import qualified Streamly.Internal.Data.Stream.IsStream.Type as IsStream
173173import qualified Streamly.Internal.Data.Stream.StreamD as D
174174import qualified Streamly.Internal.Data.Stream.StreamK.Type as K
175−#ifdef USE_STREAMK_ONLY
176−import qualified Streamly.Internal.Data.Stream.StreamK as S
177−#else
178−import qualified Streamly.Internal.Data.Stream.StreamD as S
179−#endif
180175import qualified Streamly.Internal.Data.Stream as Stream
181176import qualified System.IO as IO
182177
@@ -240,7 +235,7 @@ uncons = fmap (fmap (fmap IsStream.fromStream)) . K.uncons . Stream.toStreamK
240235{-# INLINE foldr1 #-}
241236{-# DEPRECATED foldr1 "Use foldrM instead." #-}
242237foldr1 :: 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)
244239
245240------------------------------------------------------------------------------
246241-- Left Folds
@@ -260,12 +255,12 @@ foldlS f z =
260255--
261256-- For example, to reverse a stream:
262257--
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)
264259--
265260{-# INLINE foldlT #-}
266261foldlT :: (Monad m, IsStream t, Monad (s m), MonadTrans s)
267262 => (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)
269264
270265-- | Strict left fold with an extraction function. Like the standard strict
271266-- left fold, but applies a user supplied extraction function (the third
@@ -320,7 +315,7 @@ foldxM = IsStream.foldlMx'
320315-- /Since: 0.8.0 (signature change)/
321316{-# INLINE foldlM' #-}
322317foldlM' :: 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
324319
325320------------------------------------------------------------------------------
326321-- Running a sink
@@ -347,7 +342,7 @@ runSink = fold . toFold
347342-- @since 0.1.0
348343{-# INLINE mapM_ #-}
349344mapM_ :: 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
351346
352347-- |
353348-- > drain = mapM_ (\_ -> return ())
@@ -422,7 +417,7 @@ runStream = drain
422417-- @since 0.1.1
423418{-# INLINE null #-}
424419null :: Monad m => SerialT m a -> m Bool
425−null = S.null . toStreamS
420+null = D.null . toStreamD
426421
427422-- | Extract the first element of the stream, if any.
428423--
@@ -432,7 +427,7 @@ null = S.null . toStreamS
432427-- @since 0.1.0
433428{-# INLINE head #-}
434429head :: Monad m => SerialT m a -> m (Maybe a)
435−head = S.head . toStreamS
430+head = D.head . toStreamD
436431
437432-- | Extract the first element of the stream, if any, otherwise use the
438433-- 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
468463-- @since 0.1.1
469464{-# INLINE last #-}
470465last :: Monad m => SerialT m a -> m (Maybe a)
471−last m = S.last $ toStreamS m
466+last m = D.last $ toStreamD m
472467
473468-- | Determine whether an element is present in the stream.
474469--
@@ -477,7 +472,7 @@ last m = S.last $ toStreamS m
477472-- @since 0.1.0
478473{-# INLINE elem #-}
479474elem :: (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)
481476
482477-- | Determine whether an element is not present in the stream.
483478--
@@ -486,7 +481,7 @@ elem e m = S.elem e (toStreamS m)
486481-- @since 0.1.0
487482{-# INLINE notElem #-}
488483notElem :: (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)
490485
491486-- | Determine the length of the stream.
492487--
@@ -502,7 +497,7 @@ length = foldl' (\n _ -> n + 1) 0
502497-- @since 0.1.0
503498{-# INLINE all #-}
504499all :: 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)
506501
507502-- | Determine whether any of the elements of a stream satisfy a predicate.
508503--
@@ -511,7 +506,7 @@ all p m = S.all p (toStreamS m)
511506-- @since 0.1.0
512507{-# INLINE any #-}
513508any :: 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)
515510
516511-- | Determines if all elements of a boolean stream are True.
517512--
@@ -572,7 +567,7 @@ mconcat = Stream.foldr mappend mempty
572567-- @since 0.1.0
573568{-# INLINE minimum #-}
574569minimum :: (Monad m, Ord a) => SerialT m a -> m (Maybe a)
575−minimum m = S.minimum (toStreamS m)
570+minimum m = D.minimum (toStreamD m)
576571
577572-- | Determine the minimum element in a stream using the supplied comparison
578573-- function.
@@ -582,7 +577,7 @@ minimum m = S.minimum (toStreamS m)
582577-- @since 0.6.0
583578{-# INLINE minimumBy #-}
584579minimumBy :: 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)
586581
587582-- |
588583-- @
@@ -595,7 +590,7 @@ minimumBy cmp m = S.minimumBy cmp (toStreamS m)
595590-- @since 0.1.0
596591{-# INLINE maximum #-}
597592maximum :: (Monad m, Ord a) => SerialT m a -> m (Maybe a)
598−maximum m = S.maximum (toStreamS m)
593+maximum m = D.maximum (toStreamD m)
599594
600595-- | Determine the maximum element in a stream using the supplied comparison
601596-- function.
@@ -605,7 +600,7 @@ maximum m = S.maximum (toStreamS m)
605600-- @since 0.6.0
606601{-# INLINE maximumBy #-}
607602maximumBy :: 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)
609604
610605-- | Ensures that all the elements of the stream are identical and then returns
611606-- that unique element.
@@ -613,7 +608,7 @@ maximumBy cmp m = S.maximumBy cmp (toStreamS m)
613608-- @since 0.6.0
614609{-# INLINE the #-}
615610the :: (Eq a, Monad m) => SerialT m a -> m (Maybe a)
616−the m = S.the (toStreamS m)
611+the m = D.the (toStreamD m)
617612
618613------------------------------------------------------------------------------
619614-- Searching
@@ -624,7 +619,7 @@ the m = S.the (toStreamS m)
624619-- @since 0.6.0
625620{-# INLINE (!!) #-}
626621(!!) :: Monad m => SerialT m a -> Int -> m (Maybe a)
627−m !! i = toStreamS m S.!! i
622+m !! i = toStreamD m D.!! i
628623
629624-- | In a stream of (key-value) pairs @(a, b)@, return the value @b@ of the
630625-- first pair where the key equals the given value @a@.
@@ -635,7 +630,7 @@ m !! i = toStreamS m S.!! i
635630-- @since 0.5.0
636631{-# INLINE lookup #-}
637632lookup :: (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)
639634
640635-- | Like 'findM' but with a non-monadic predicate.
641636--
@@ -645,7 +640,7 @@ lookup a m = S.lookup a (toStreamS m)
645640-- @since 0.5.0
646641{-# INLINE find #-}
647642find :: 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)
649644
650645-- | Returns the first element that satisfies the given predicate.
651646--
@@ -654,7 +649,7 @@ find p m = S.find p (toStreamS m)
654649-- @since 0.6.0
655650{-# INLINE findM #-}
656651findM :: 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)
658653
659654-- | Returns the first index that satisfies the given predicate.
660655--
@@ -712,7 +707,7 @@ toListRev = D.toListRev . toStreamD
712707
713708-- |
714709-- @
715−-- toHandle h = S.mapM_ $ hPutStrLn h
710+-- toHandle h = D.mapM_ $ hPutStrLn h
716711-- @
717712--
718713-- Write a stream of Strings to an IO Handle.