on master help sign in
rename ZipStream to ZipSerial
7a9791bHarendra Kumar
src/Streamly.hs+4−2
@@ -27,7 +27,7 @@ module Streamly
27
27
28 -- * Zip Style Composition
28 -- * Zip Style Composition
29 -- $zipping
29 -- $zipping
30− , ZipStream
30+ , ZipSerial
31 , ZipAsync
31 , ZipAsync
32
32
33 -- * Sum Style Composition
33 -- * Sum Style Composition
@@ -54,7 +54,7 @@ module Streamly
54 , runInterleavedT
54 , runInterleavedT
55 , runAsyncT
55 , runAsyncT
56 , runParallelT
56 , runParallelT
57− , runZipStream
57+ , runZipSerial
58 , runZipAsync
58 , runZipAsync
59
59
60 -- * Fold Utilities
60 -- * Fold Utilities
@@ -73,7 +73,9 @@ module Streamly
73
73
74 -- * Deprecated
74 -- * Deprecated
75 , runStreamT
75 , runStreamT
76+ , runZipStream
76 , StreamT
77 , StreamT
78+ , ZipStream
77 )
79 )
78where
80where
79
81
src/Streamly/Streams.hs+34−23
@@ -50,7 +50,8 @@ module Streamly.Streams
50 , InterleavedT
50 , InterleavedT
51 , AsyncT
51 , AsyncT
52 , ParallelT
52 , ParallelT
53+ , ZipSerial
53− , ZipStream
54+ , ZipStream -- deprecated
54 , ZipAsync
55 , ZipAsync
55
56
56 -- * Type Adapters
57 -- * Type Adapters
@@ -68,7 +69,8 @@ module Streamly.Streams
68 , runInterleavedT
69 , runInterleavedT
69 , runAsyncT
70 , runAsyncT
70 , runParallelT
71 , runParallelT
72+ , runZipSerial
71− , runZipStream
73+ , runZipStream -- deprecated
72 , runZipAsync
74 , runZipAsync
73
75
74 -- * Zipping
76 -- * Zipping
@@ -728,10 +730,10 @@ zipWith f m1 m2 = fromStream $ go (toStream m1) (toStream m2)
728 yield1 a (Just ra) = merge a ra
730 yield1 a (Just ra) = merge a ra
729 (runStream mx) Nothing stp yield1
731 (runStream mx) Nothing stp yield1
730
732
731−-- | The applicative instance of 'ZipStream' zips a number of streams serially
733+-- | The applicative instance of 'ZipSerial' zips a number of streams serially
732-- i.e. it produces one element from each stream serially and then zips all
734-- i.e. it produces one element from each stream serially and then zips all
733-- those elements. Note, for convenience we have used the 'zipping' combinator
735-- those elements. Note, for convenience we have used the 'zipping' combinator
734−-- in the following example instead of using a 'ZipStream' type annotation.
736+-- in the following example instead of using a 'ZipSerial' type annotation.
735--
737--
736-- @
738-- @
737-- main = (toList . 'zipping' $ (,,) \<$\> s1 \<*\> s2 \<*\> s3) >>= print
739-- main = (toList . 'zipping' $ (,,) \<$\> s1 \<*\> s2 \<*\> s3) >>= print
@@ -745,27 +747,31 @@ zipWith f m1 m2 = fromStream $ go (toStream m1) (toStream m2)
745--
747--
746-- This applicative operation can be seen as the zipping equivalent of
748-- This applicative operation can be seen as the zipping equivalent of
747-- interleaving with '<=>'.
749-- interleaving with '<=>'.
748−newtype ZipStream m a = ZipStream {getZipStream :: Stream m a}
750+newtype ZipSerial m a = ZipSerial {getZipSerial :: Stream m a}
749 deriving (Semigroup, Monoid)
751 deriving (Semigroup, Monoid)
750
752
751−deriving instance MonadAsync m => Alternative (ZipStream m)
753+{-# Deprecated ZipStream "Please use ZipSerial instead." #-}
754+-- | Same as ZipSerial.
755+type ZipStream = ZipSerial
752
756
757+deriving instance MonadAsync m => Alternative (ZipSerial m)
758+
753−instance Monad m => Functor (ZipStream m) where
759+instance Monad m => Functor (ZipSerial m) where
754− fmap f (ZipStream (Stream m)) = ZipStream $ Stream $ \_ stp yld ->
760+ fmap f (ZipSerial (Stream m)) = ZipSerial $ Stream $ \_ stp yld ->
755 let yield a Nothing = yld (f a) Nothing
761 let yield a Nothing = yld (f a) Nothing
756 yield a (Just r) = yld (f a)
762 yield a (Just r) = yld (f a)
757− (Just (getZipStream (fmap f (ZipStream r))))
763+ (Just (getZipSerial (fmap f (ZipSerial r))))
758 in m Nothing stp yield
764 in m Nothing stp yield
759
765
760−instance Monad m => Applicative (ZipStream m) where
766+instance Monad m => Applicative (ZipSerial m) where
761− pure = ZipStream . srepeat
767+ pure = ZipSerial . srepeat
762 (<*>) = zipWith id
768 (<*>) = zipWith id
763
769
764−instance Streaming ZipStream where
770+instance Streaming ZipSerial where
765− toStream = getZipStream
771+ toStream = getZipSerial
766− fromStream = ZipStream
772+ fromStream = ZipSerial
767
773
768−instance (Monad m, Num a) => Num (ZipStream m a) where
774+instance (Monad m, Num a) => Num (ZipSerial m a) where
769 fromInteger n = pure (fromInteger n)
775 fromInteger n = pure (fromInteger n)
770
776
771 negate = fmap negate
777 negate = fmap negate
@@ -776,14 +782,14 @@ instance (Monad m, Num a) => Num (ZipStream m a) where
776 (*) = liftA2 (*)
782 (*) = liftA2 (*)
777 (-) = liftA2 (-)
783 (-) = liftA2 (-)
778
784
779−instance (Monad m, Fractional a) => Fractional (ZipStream m a) where
785+instance (Monad m, Fractional a) => Fractional (ZipSerial m a) where
780 fromRational n = pure (fromRational n)
786 fromRational n = pure (fromRational n)
781
787
782 recip = fmap recip
788 recip = fmap recip
783
789
784 (/) = liftA2 (/)
790 (/) = liftA2 (/)
785
791
786−instance (Monad m, Floating a) => Floating (ZipStream m a) where
792+instance (Monad m, Floating a) => Floating (ZipSerial m a) where
787 pi = pure pi
793 pi = pure pi
788
794
789 exp = fmap exp
795 exp = fmap exp
@@ -818,7 +824,7 @@ zipAsyncWith f m1 m2 = fromStream $ Stream $ \_ stp yld -> do
818 mb <- async m2
824 mb <- async m2
819 (runStream (toStream (zipWith f ma mb))) Nothing stp yld
825 (runStream (toStream (zipWith f ma mb))) Nothing stp yld
820
826
821−-- | Like 'ZipStream' but zips in parallel, it generates all the elements to
827+-- | Like 'ZipSerial' but zips in parallel, it generates all the elements to
822-- be zipped concurrently.
828-- be zipped concurrently.
823--
829--
824-- @
830-- @
@@ -917,8 +923,8 @@ asyncly x = x
917parallely :: ParallelT m a -> ParallelT m a
923parallely :: ParallelT m a -> ParallelT m a
918parallely x = x
924parallely x = x
919
925
920−-- | Interpret an ambiguously typed stream as 'ZipStream'.
926+-- | Interpret an ambiguously typed stream as 'ZipSerial'.
921−zipping :: ZipStream m a -> ZipStream m a
927+zipping :: ZipSerial m a -> ZipSerial m a
922zipping x = x
928zipping x = x
923
929
924-- | Interpret an ambiguously typed stream as 'ZipAsync'.
930-- | Interpret an ambiguously typed stream as 'ZipAsync'.
@@ -936,7 +942,7 @@ runSerialT = runStreaming
936-- | Same as @runSerialT@.
942-- | Same as @runSerialT@.
937{-# Deprecated runStreamT "Please use runSerialT instead." #-}
943{-# Deprecated runStreamT "Please use runSerialT instead." #-}
938runStreamT :: Monad m => SerialT m a -> m ()
944runStreamT :: Monad m => SerialT m a -> m ()
939−runStreamT = runStreaming
945+runStreamT = runSerialT
940
946
941-- | Same as @runStreaming . interleaving@.
947-- | Same as @runStreaming . interleaving@.
942runInterleavedT :: Monad m => InterleavedT m a -> m ()
948runInterleavedT :: Monad m => InterleavedT m a -> m ()
@@ -951,8 +957,13 @@ runParallelT :: Monad m => ParallelT m a -> m ()
951runParallelT = runStreaming
957runParallelT = runStreaming
952
958
953-- | Same as @runStreaming . zipping@.
959-- | Same as @runStreaming . zipping@.
954−runZipStream :: Monad m => ZipStream m a -> m ()
960+runZipSerial :: Monad m => ZipSerial m a -> m ()
955−runZipStream = runStreaming
961+runZipSerial = runStreaming
962+
963+{-# Deprecated runZipStream "Please use runZipSerial instead." #-}
964+-- | Same as ZipSerial.
965+runZipStream :: Monad m => ZipSerial m a -> m ()
966+runZipStream = runZipSerial
956
967
957-- | Same as @runStreaming . zippingAsync@.
968-- | Same as @runStreaming . zippingAsync@.
958runZipAsync :: Monad m => ZipAsync m a -> m ()
969runZipAsync :: Monad m => ZipAsync m a -> m ()
src/Streamly/Tutorial.hs+2−2
@@ -637,7 +637,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
637-- $applicative
637-- $applicative
638--
638--
639-- Applicative is precisely the same as the 'ap' operation of 'Monad'. For
639-- Applicative is precisely the same as the 'ap' operation of 'Monad'. For
640−-- zipping and parallel applicatives separate types 'ZipStream' and 'ZipAsync'
640+-- zipping and parallel applicatives separate types 'ZipSerial' and 'ZipAsync'
641-- are provided.
641-- are provided.
642--
642--
643-- The following example runs all iterations serially and takes a total 17
643-- The following example runs all iterations serially and takes a total 17
@@ -742,7 +742,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
742
742
743-- $serialzip
743-- $serialzip
744--
744--
745−-- 'ZipStream' zips streams serially:
745+-- 'ZipSerial' zips streams serially:
746--
746--
747-- @
747-- @
748-- import "Streamly"
748-- import "Streamly"