on master help sign in
rename ZipStream and ZipParallel, add M suffix

The original names ZipStream and ZipParallel will be specialized to IO monad.

commitdcf4297e8e95d7413e1155c7811f2021af183798 authorHarendra Kumar <harendra.kumar@gmail.com> dateTue 24 Apr 2018, 21:17 (8 years ago) parenta526207
3 files changed+37−34
Changelog.md+4−1 src/Streamly.hs+7−7 src/Streamly/Streams.hs+26−26
Changelog.md+4−1
@@ -27,6 +27,9 @@
2727
2828 Stream types may have to be changed or type combinators may have to be added
2929 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`.
3033* Change the type of `foldrM` to make it consistent with `foldrM` in base.
3134* Remove the `MonadError` instance as it was not working correctly for
3235 parallel compositions. Use `MonadThrow` instead for error propagation.
@@ -38,7 +41,7 @@
3841 * `Streaming` to `IsStream`
3942 * `runStreaming` to `runStream`
4043 * `AsyncT` to `CoparallelT`
41− * `ZipAsync` to `ZipParallel`
44+ * `ZipAsync` to `ZipParallelM`
4245 * `interleaving` to `costreamly`
4346 * `asyncly` to `coparallely`
4447 * `zipping` to `zipStreamly`
src/Streamly.hs+7−7
@@ -30,8 +30,8 @@ module Streamly
3030
3131 -- * Zipping Streams
3232 -- $zipping
33− , ZipStream
34− , ZipParallel
33+ , ZipStreamM
34+ , ZipParallelM
3535
3636 -- * Stream Type Adapters
3737 -- $adapters
@@ -134,7 +134,7 @@ import Control.Monad.Trans.Class (MonadTrans (..))
134134-- $overview
135135--
136136-- 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
138138-- stream of elements. All these types have the same underlying representation
139139-- and can be adapted from one to another using type adaptor combinators
140140-- described later. Each of these types belongs to the 'IsStream' type class
@@ -151,10 +151,10 @@ import Control.Monad.Trans.Class (MonadTrans (..))
151151-- whereas 'CoparallelT' and 'ParallelT' are their concurrent counterparts. See the
152152-- documentation of the respective types for more details.
153153--
154−-- The types 'ZipStream' and 'ZipParallel' provide 'Applicative' instances to zip
154+-- The types 'ZipStreamM' and 'ZipParallelM' provide 'Applicative' instances to zip
155155-- 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
157−-- being zipped serially whereas 'ZipParallel' produces both the elements being
156+-- corresponding element in the other stream. 'ZipStreamM' generates the streams
157+-- being zipped serially whereas 'ZipParallelM' produces both the elements being
158158-- zipped concurrently.
159159--
160160-- 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 (..))
193193
194194-- $zipping
195195--
196−-- 'ZipStream' and 'ZipParallel', provide 'Applicative' instances for zipping the
196+-- 'ZipStreamM' and 'ZipParallelM', provide 'Applicative' instances for zipping the
197197-- corresponding elements of two streams together. Note that these types are
198198-- not monads.
199199
src/Streamly/Streams.hs+26−26
@@ -64,8 +64,8 @@ module Streamly.Streams
6464 , CoparallelT
6565 , AsyncT -- deprecated
6666 , ParallelT
67− , ZipStream
68− , ZipParallel
67+ , ZipStreamM
68+ , ZipParallelM
6969 , ZipAsync -- deprecated
7070
7171 -- * Type Adapters
@@ -701,7 +701,7 @@ zipWith f m1 m2 = fromStream $ go (toStream m1) (toStream m2)
701701 yield1 a ra = merge a ra
702702 (S.runStream mx) Nothing stp single1 yield1
703703
704−-- | The applicative instance of 'ZipStream' zips a number of streams serially
704+-- | The applicative instance of 'ZipStreamM' zips a number of streams serially
705705-- i.e. it produces one element from each stream serially and then zips all
706706-- those elements.
707707--
@@ -718,16 +718,16 @@ zipWith f m1 m2 = fromStream $ go (toStream m1) (toStream m2)
718718-- The 'Semigroup' instance of this type works the same way as that of
719719-- 'StreamT'.
720720--
721−newtype ZipStream m a = ZipStream {getZipStream :: Stream m a}
721+newtype ZipStreamM m a = ZipStreamM {getZipStreamM :: Stream m a}
722722 deriving (Functor, Semigroup, Monoid)
723723
724−instance Monad m => Applicative (ZipStream m) where
725− pure = ZipStream . S.repeat
724+instance Monad m => Applicative (ZipStreamM m) where
725+ pure = ZipStreamM . S.repeat
726726 (<*>) = zipWith id
727727
728−instance IsStream ZipStream where
729− toStream = getZipStream
730− fromStream = ZipStream
728+instance IsStream ZipStreamM where
729+ toStream = getZipStreamM
730+ fromStream = ZipStreamM
731731
732732------------------------------------------------------------------------------
733733-- Parallely Zipping Streams
@@ -747,7 +747,7 @@ zipAsyncWith :: (IsStream t, MonadParallel m)
747747 => (a -> b -> c) -> t m a -> t m b -> t m c
748748zipAsyncWith = zipParallelWith
749749
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
751751-- be zipped concurrently.
752752--
753753-- @
@@ -763,19 +763,19 @@ zipAsyncWith = zipParallelWith
763763-- The 'Semigroup' instance of this type works the same way as that of
764764-- 'StreamT'.
765765--
766−newtype ZipParallel m a = ZipParallel {getZipParallel :: Stream m a}
766+newtype ZipParallelM m a = ZipParallelM {getZipParallelM :: Stream m a}
767767 deriving (Functor, Semigroup, Monoid)
768768
769−{-# DEPRECATED ZipAsync "Please use ZipParallel instead." #-}
770−type ZipAsync = ZipParallel
769+{-# DEPRECATED ZipAsync "Please use ZipParallelM instead." #-}
770+type ZipAsync = ZipParallelM
771771
772−instance MonadParallel m => Applicative (ZipParallel m) where
773− pure = ZipParallel . S.repeat
772+instance MonadParallel m => Applicative (ZipParallelM m) where
773+ pure = ZipParallelM . S.repeat
774774 (<*>) = zipParallelWith id
775775
776−instance IsStream ZipParallel where
777− toStream = getZipParallel
778− fromStream = ZipParallel
776+instance IsStream ZipParallelM where
777+ toStream = getZipParallelM
778+ fromStream = ZipParallelM
779779
780780-------------------------------------------------------------------------------
781781-- Type adapting combinators
@@ -811,22 +811,22 @@ asyncly = coparallely
811811parallely :: IsStream t => ParallelT m a -> t m a
812812parallely = adapt
813813
814−-- | Fix the type of a polymorphic stream as 'ZipStream'.
815−zipStreamly :: IsStream t => ZipStream m a -> t m a
814+-- | Fix the type of a polymorphic stream as 'ZipStreamM'.
815+zipStreamly :: IsStream t => ZipStreamM m a -> t m a
816816zipStreamly = adapt
817817
818818-- | Same as 'zipStreamly'.
819819{-# 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
821821zipping = zipStreamly
822822
823−-- | Fix the type of a polymorphic stream as 'ZipParallel'.
824−zipParallely :: IsStream t => ZipParallel m a -> t m a
823+-- | Fix the type of a polymorphic stream as 'ZipParallelM'.
824+zipParallely :: IsStream t => ZipParallelM m a -> t m a
825825zipParallely = adapt
826826
827827-- | Same as 'zipParallely'.
828828{-# 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
830830zippingAsync = zipParallely
831831
832832-------------------------------------------------------------------------------
@@ -855,12 +855,12 @@ runParallelT = runStream . parallely
855855
856856-- | Same as @runStream . zipping@.
857857{-# DEPRECATED runZipStream "Please use 'runStream . zipStreamly instead." #-}
858−runZipStream :: Monad m => ZipStream m a -> m ()
858+runZipStream :: Monad m => ZipStreamM m a -> m ()
859859runZipStream = runStream . zipStreamly
860860
861861-- | Same as @runStream . zippingAsync@.
862862{-# DEPRECATED runZipAsync "Please use 'runStream . zipParallely instead." #-}
863−runZipAsync :: Monad m => ZipParallel m a -> m ()
863+runZipAsync :: Monad m => ZipParallelM m a -> m ()
864864runZipAsync = runStream . zipParallely
865865
866866------------------------------------------------------------------------------