on master help sign in
rename ZipStream and ZipParallel, add M suffix
dcf4297Harendra Kumar
Changelog.md+4−1
@@ -27,6 +27,9 @@
27
27
28 Stream types may have to be changed or type combinators may have to be added
28 Stream types may have to be changed or type combinators may have to be added
29 or removed to adapt to this change.
29 or removed to adapt to this change.
30+* The type `ZipStream` has been redefined to be specialized to IO monad.
31+ `ZipStreamM` is now the same as the original `ZipStream` type. You will have
32+ to change all occurrences of `ZipStream` to `ZipStreamM`.
30* Change the type of `foldrM` to make it consistent with `foldrM` in base.
33* Change the type of `foldrM` to make it consistent with `foldrM` in base.
31* Remove the `MonadError` instance as it was not working correctly for
34* Remove the `MonadError` instance as it was not working correctly for
32 parallel compositions. Use `MonadThrow` instead for error propagation.
35 parallel compositions. Use `MonadThrow` instead for error propagation.
@@ -38,7 +41,7 @@
38 * `Streaming` to `IsStream`
41 * `Streaming` to `IsStream`
39 * `runStreaming` to `runStream`
42 * `runStreaming` to `runStream`
40 * `AsyncT` to `CoparallelT`
43 * `AsyncT` to `CoparallelT`
41− * `ZipAsync` to `ZipParallel`
44+ * `ZipAsync` to `ZipParallelM`
42 * `interleaving` to `costreamly`
45 * `interleaving` to `costreamly`
43 * `asyncly` to `coparallely`
46 * `asyncly` to `coparallely`
44 * `zipping` to `zipStreamly`
47 * `zipping` to `zipStreamly`
src/Streamly.hs+7−7
@@ -30,8 +30,8 @@ module Streamly
30
30
31 -- * Zipping Streams
31 -- * Zipping Streams
32 -- $zipping
32 -- $zipping
33− , ZipStream
33+ , ZipStreamM
34− , ZipParallel
34+ , ZipParallelM
35
35
36 -- * Stream Type Adapters
36 -- * Stream Type Adapters
37 -- $adapters
37 -- $adapters
@@ -134,7 +134,7 @@ import Control.Monad.Trans.Class (MonadTrans (..))
134-- $overview
134-- $overview
135--
135--
136-- Streamly provides six distinct stream types i.e. 'StreamT', 'CostreamT',
136-- Streamly provides six distinct stream types i.e. 'StreamT', 'CostreamT',
137−-- 'CoparallelT' and 'ParallelT', 'ZipStream' and 'ZipParallel', each representing a
137+-- 'CoparallelT' and 'ParallelT', 'ZipStreamM' and 'ZipParallelM', each representing a
138-- stream of elements. All these types have the same underlying representation
138-- stream of elements. All these types have the same underlying representation
139-- and can be adapted from one to another using type adaptor combinators
139-- and can be adapted from one to another using type adaptor combinators
140-- described later. Each of these types belongs to the 'IsStream' type class
140-- described later. Each of these types belongs to the 'IsStream' type class
@@ -151,10 +151,10 @@ import Control.Monad.Trans.Class (MonadTrans (..))
151-- whereas 'CoparallelT' and 'ParallelT' are their concurrent counterparts. See the
151-- whereas 'CoparallelT' and 'ParallelT' are their concurrent counterparts. See the
152-- documentation of the respective types for more details.
152-- documentation of the respective types for more details.
153--
153--
154−-- The types 'ZipStream' and 'ZipParallel' provide 'Applicative' instances to zip
154+-- The types 'ZipStreamM' and 'ZipParallelM' provide 'Applicative' instances to zip
155-- two streams together i.e. each element in one stream is combined with the
155-- two streams together i.e. each element in one stream is combined with the
156−-- corresponding element in the other stream. 'ZipStream' generates the streams
156+-- corresponding element in the other stream. 'ZipStreamM' generates the streams
157−-- being zipped serially whereas 'ZipParallel' produces both the elements being
157+-- being zipped serially whereas 'ZipParallelM' produces both the elements being
158-- zipped concurrently.
158-- zipped concurrently.
159--
159--
160-- Two streams of the same type can be merged using a sum style composition to
160-- Two streams of the same type can be merged using a sum style composition to
@@ -193,7 +193,7 @@ import Control.Monad.Trans.Class (MonadTrans (..))
193
193
194-- $zipping
194-- $zipping
195--
195--
196−-- 'ZipStream' and 'ZipParallel', provide 'Applicative' instances for zipping the
196+-- 'ZipStreamM' and 'ZipParallelM', provide 'Applicative' instances for zipping the
197-- corresponding elements of two streams together. Note that these types are
197-- corresponding elements of two streams together. Note that these types are
198-- not monads.
198-- not monads.
199
199
src/Streamly/Streams.hs+26−26
@@ -64,8 +64,8 @@ module Streamly.Streams
64 , CoparallelT
64 , CoparallelT
65 , AsyncT -- deprecated
65 , AsyncT -- deprecated
66 , ParallelT
66 , ParallelT
67− , ZipStream
67+ , ZipStreamM
68− , ZipParallel
68+ , ZipParallelM
69 , ZipAsync -- deprecated
69 , ZipAsync -- deprecated
70
70
71 -- * Type Adapters
71 -- * Type Adapters
@@ -701,7 +701,7 @@ zipWith f m1 m2 = fromStream $ go (toStream m1) (toStream m2)
701 yield1 a ra = merge a ra
701 yield1 a ra = merge a ra
702 (S.runStream mx) Nothing stp single1 yield1
702 (S.runStream mx) Nothing stp single1 yield1
703
703
704−-- | The applicative instance of 'ZipStream' zips a number of streams serially
704+-- | The applicative instance of 'ZipStreamM' zips a number of streams serially
705-- i.e. it produces one element from each stream serially and then zips all
705-- i.e. it produces one element from each stream serially and then zips all
706-- those elements.
706-- those elements.
707--
707--
@@ -718,16 +718,16 @@ zipWith f m1 m2 = fromStream $ go (toStream m1) (toStream m2)
718-- The 'Semigroup' instance of this type works the same way as that of
718-- The 'Semigroup' instance of this type works the same way as that of
719-- 'StreamT'.
719-- 'StreamT'.
720--
720--
721−newtype ZipStream m a = ZipStream {getZipStream :: Stream m a}
721+newtype ZipStreamM m a = ZipStreamM {getZipStreamM :: Stream m a}
722 deriving (Functor, Semigroup, Monoid)
722 deriving (Functor, Semigroup, Monoid)
723
723
724−instance Monad m => Applicative (ZipStream m) where
724+instance Monad m => Applicative (ZipStreamM m) where
725− pure = ZipStream . S.repeat
725+ pure = ZipStreamM . S.repeat
726 (<*>) = zipWith id
726 (<*>) = zipWith id
727
727
728−instance IsStream ZipStream where
728+instance IsStream ZipStreamM where
729− toStream = getZipStream
729+ toStream = getZipStreamM
730− fromStream = ZipStream
730+ fromStream = ZipStreamM
731
731
732------------------------------------------------------------------------------
732------------------------------------------------------------------------------
733-- Parallely Zipping Streams
733-- Parallely Zipping Streams
@@ -747,7 +747,7 @@ zipAsyncWith :: (IsStream t, MonadParallel m)
747 => (a -> b -> c) -> t m a -> t m b -> t m c
747 => (a -> b -> c) -> t m a -> t m b -> t m c
748zipAsyncWith = zipParallelWith
748zipAsyncWith = zipParallelWith
749
749
750−-- | Like 'ZipStream' but zips in parallel, it generates all the elements to
750+-- | Like 'ZipStreamM' but zips in parallel, it generates all the elements to
751-- be zipped concurrently.
751-- be zipped concurrently.
752--
752--
753-- @
753-- @
@@ -763,19 +763,19 @@ zipAsyncWith = zipParallelWith
763-- The 'Semigroup' instance of this type works the same way as that of
763-- The 'Semigroup' instance of this type works the same way as that of
764-- 'StreamT'.
764-- 'StreamT'.
765--
765--
766−newtype ZipParallel m a = ZipParallel {getZipParallel :: Stream m a}
766+newtype ZipParallelM m a = ZipParallelM {getZipParallelM :: Stream m a}
767 deriving (Functor, Semigroup, Monoid)
767 deriving (Functor, Semigroup, Monoid)
768
768
769−{-# DEPRECATED ZipAsync "Please use ZipParallel instead." #-}
769+{-# DEPRECATED ZipAsync "Please use ZipParallelM instead." #-}
770−type ZipAsync = ZipParallel
770+type ZipAsync = ZipParallelM
771
771
772−instance MonadParallel m => Applicative (ZipParallel m) where
772+instance MonadParallel m => Applicative (ZipParallelM m) where
773− pure = ZipParallel . S.repeat
773+ pure = ZipParallelM . S.repeat
774 (<*>) = zipParallelWith id
774 (<*>) = zipParallelWith id
775
775
776−instance IsStream ZipParallel where
776+instance IsStream ZipParallelM where
777− toStream = getZipParallel
777+ toStream = getZipParallelM
778− fromStream = ZipParallel
778+ fromStream = ZipParallelM
779
779
780-------------------------------------------------------------------------------
780-------------------------------------------------------------------------------
781-- Type adapting combinators
781-- Type adapting combinators
@@ -811,22 +811,22 @@ asyncly = coparallely
811parallely :: IsStream t => ParallelT m a -> t m a
811parallely :: IsStream t => ParallelT m a -> t m a
812parallely = adapt
812parallely = adapt
813
813
814−-- | Fix the type of a polymorphic stream as 'ZipStream'.
814+-- | Fix the type of a polymorphic stream as 'ZipStreamM'.
815−zipStreamly :: IsStream t => ZipStream m a -> t m a
815+zipStreamly :: IsStream t => ZipStreamM m a -> t m a
816zipStreamly = adapt
816zipStreamly = adapt
817
817
818-- | Same as 'zipStreamly'.
818-- | Same as 'zipStreamly'.
819{-# DEPRECATED zipping "Please use zipStreamly instead." #-}
819{-# DEPRECATED zipping "Please use zipStreamly instead." #-}
820−zipping :: IsStream t => ZipStream m a -> t m a
820+zipping :: IsStream t => ZipStreamM m a -> t m a
821zipping = zipStreamly
821zipping = zipStreamly
822
822
823−-- | Fix the type of a polymorphic stream as 'ZipParallel'.
823+-- | Fix the type of a polymorphic stream as 'ZipParallelM'.
824−zipParallely :: IsStream t => ZipParallel m a -> t m a
824+zipParallely :: IsStream t => ZipParallelM m a -> t m a
825zipParallely = adapt
825zipParallely = adapt
826
826
827-- | Same as 'zipParallely'.
827-- | Same as 'zipParallely'.
828{-# DEPRECATED zippingAsync "Please use zipParallely instead." #-}
828{-# DEPRECATED zippingAsync "Please use zipParallely instead." #-}
829−zippingAsync :: IsStream t => ZipParallel m a -> t m a
829+zippingAsync :: IsStream t => ZipParallelM m a -> t m a
830zippingAsync = zipParallely
830zippingAsync = zipParallely
831
831
832-------------------------------------------------------------------------------
832-------------------------------------------------------------------------------
@@ -855,12 +855,12 @@ runParallelT = runStream . parallely
855
855
856-- | Same as @runStream . zipping@.
856-- | Same as @runStream . zipping@.
857{-# DEPRECATED runZipStream "Please use 'runStream . zipStreamly instead." #-}
857{-# DEPRECATED runZipStream "Please use 'runStream . zipStreamly instead." #-}
858−runZipStream :: Monad m => ZipStream m a -> m ()
858+runZipStream :: Monad m => ZipStreamM m a -> m ()
859runZipStream = runStream . zipStreamly
859runZipStream = runStream . zipStreamly
860
860
861-- | Same as @runStream . zippingAsync@.
861-- | Same as @runStream . zippingAsync@.
862{-# DEPRECATED runZipAsync "Please use 'runStream . zipParallely instead." #-}
862{-# DEPRECATED runZipAsync "Please use 'runStream . zipParallely instead." #-}
863−runZipAsync :: Monad m => ZipParallel m a -> m ()
863+runZipAsync :: Monad m => ZipParallelM m a -> m ()
864runZipAsync = runStream . zipParallely
864runZipAsync = runStream . zipParallely
865
865
866------------------------------------------------------------------------------
866------------------------------------------------------------------------------