on master help sign in
Move the zip functions from Streams.hs to Prelude.hs
a1f4c0eHarendra Kumar
src/Streamly/Prelude.hs+16
@@ -562,6 +562,10 @@ replicateM n m = fromStream $ go n
562-- Serially Zipping Streams
562-- Serially Zipping Streams
563------------------------------------------------------------------------------
563------------------------------------------------------------------------------
564
564
565+-- | Zip two streams serially using a pure zipping function.
566+zipWith :: IsStream t => (a -> b -> c) -> t m a -> t m b -> t m c
567+zipWith f m1 m2 = fromStream $ S.zipWith f (toStream m1) (toStream m2)
568+
565-- | Zip two streams serially using a monadic zipping function.
569-- | Zip two streams serially using a monadic zipping function.
566zipWithM :: IsStream t => (a -> b -> t m c) -> t m a -> t m b -> t m c
570zipWithM :: IsStream t => (a -> b -> t m c) -> t m a -> t m b -> t m c
567zipWithM f m1 m2 = fromStream $ go (toStream m1) (toStream m2)
571zipWithM f m1 m2 = fromStream $ go (toStream m1) (toStream m2)
@@ -580,6 +584,18 @@ zipWithM f m1 m2 = fromStream $ go (toStream m1) (toStream m2)
580-- Parallely Zipping Streams
584-- Parallely Zipping Streams
581------------------------------------------------------------------------------
585------------------------------------------------------------------------------
582
586
587+-- | Zip two streams concurrently (i.e. both the elements being zipped are
588+-- generated concurrently) using a pure zipping function.
589+zipParallelWith :: (IsStream t, MonadParallel m)
590+ => (a -> b -> c) -> t m a -> t m b -> t m c
591+zipParallelWith f m1 m2 =
592+ fromStream $ S.zipParallelWith f (toStream m1) (toStream m2)
593+
594+{-# DEPRECATED zipAsyncWith "Please use zipParallelWith instead." #-}
595+zipAsyncWith :: (IsStream t, MonadParallel m)
596+ => (a -> b -> c) -> t m a -> t m b -> t m c
597+zipAsyncWith = zipParallelWith
598+
583-- | Zip two streams asyncly (i.e. both the elements being zipped are generated
599-- | Zip two streams asyncly (i.e. both the elements being zipped are generated
584-- concurrently) using a monadic zipping function.
600-- concurrently) using a monadic zipping function.
585zipParallelWithM :: (IsStream t, MonadParallel m)
601zipParallelWithM :: (IsStream t, MonadParallel m)
src/Streamly/Streams.hs−22
@@ -100,11 +100,6 @@ module Streamly.Streams
100 , runZipStream -- deprecated
100 , runZipStream -- deprecated
101 , runZipAsync -- deprecated
101 , runZipAsync -- deprecated
102
102
103− -- * Zipping
104− , zipWith
105− , zipParallelWith
106− , zipAsyncWith -- deprecated
107−
108 -- * Fold Utilities
103 -- * Fold Utilities
109 , foldWith
104 , foldWith
110 , foldMapWith
105 , foldMapWith
@@ -121,7 +116,6 @@ import Control.Monad.Reader.Class (MonadReader(..))
121import Control.Monad.State.Class (MonadState(..))
116import Control.Monad.State.Class (MonadState(..))
122import Control.Monad.Trans.Class (MonadTrans (lift))
117import Control.Monad.Trans.Class (MonadTrans (lift))
123import Data.Semigroup (Semigroup(..))
118import Data.Semigroup (Semigroup(..))
124−import Prelude hiding (zipWith)
125import Streamly.Core ( MonadParallel
119import Streamly.Core ( MonadParallel
126 , SVar, SVarStyle(..)
120 , SVar, SVarStyle(..)
127 , SVarTag(..), SVarSched(..))
121 , SVarTag(..), SVarSched(..))
@@ -721,10 +715,6 @@ MONAD_COMMON_INSTANCES(ParallelT, MONADPARALLEL)
721-- Serially Zipping Streams
715-- Serially Zipping Streams
722------------------------------------------------------------------------------
716------------------------------------------------------------------------------
723
717
724−-- | Zip two streams serially using a pure zipping function.
725−zipWith :: IsStream t => (a -> b -> c) -> t m a -> t m b -> t m c
726−zipWith f m1 m2 = fromStream $ S.zipWith f (toStream m1) (toStream m2)
727−
728-- | The applicative instance of 'ZipStreamM' zips a number of streams serially
718-- | The applicative instance of 'ZipStreamM' zips a number of streams serially
729-- i.e. it produces one element from each stream serially and then zips all
719-- i.e. it produces one element from each stream serially and then zips all
730-- those elements.
720-- those elements.
@@ -757,18 +747,6 @@ instance Monad m => Applicative (ZipStreamM m) where
757-- Parallely Zipping Streams
747-- Parallely Zipping Streams
758------------------------------------------------------------------------------
748------------------------------------------------------------------------------
759
749
760−-- | Zip two streams concurrently (i.e. both the elements being zipped are
761−-- generated concurrently) using a pure zipping function.
762−zipParallelWith :: (IsStream t, MonadParallel m)
763− => (a -> b -> c) -> t m a -> t m b -> t m c
764−zipParallelWith f m1 m2 =
765− fromStream $ S.zipParallelWith f (toStream m1) (toStream m2)
766−
767−{-# DEPRECATED zipAsyncWith "Please use zipParallelWith instead." #-}
768−zipAsyncWith :: (IsStream t, MonadParallel m)
769− => (a -> b -> c) -> t m a -> t m b -> t m c
770−zipAsyncWith = zipParallelWith
771−
772-- | Like 'ZipStreamM' but zips in parallel, it generates all the elements to
750-- | Like 'ZipStreamM' but zips in parallel, it generates all the elements to
773-- be zipped concurrently.
751-- be zipped concurrently.
774--
752--