@@ -29,7 +29,6 @@ import Control.Monad.IO.Class (MonadIO(..))
2929import Control.Monad.State.Strict (StateT, get, put)
3030import Data.Functor.Identity (Identity, runIdentity)
3131import Data.IORef (newIORef, modifyIORef')
32−import Data.Maybe (fromJust)
3332import GHC.Generics (Generic)
3433import Prelude
3534 (Monad, Int, (+), ($), (.), return, fmap, even, (>), (<=), (==), (>=),
@@ -718,25 +717,32 @@ inspect $ 'zipM `hasNoType` ''D.Step
718717#endif
719718
720719{-# INLINE zipAsync #-}
720+zipAsync :: (S.IsStream t, S.MonadAsync m) => Int -> Int -> t m (Int, Int)
721+zipAsync count n = do
722+ S.zipAsyncWith (,)
723+ (sourceUnfoldrMN count n)
724+ (sourceUnfoldrMN count (n + 1))
725+
721726{-# INLINE zipAsyncM #-}
727+zipAsyncM :: (S.IsStream t, S.MonadAsync m) => Int -> Int -> t m (Int, Int)
728+zipAsyncM count n = do
729+ S.zipAsyncWithM (curry return)
730+ (sourceUnfoldrMN count n)
731+ (sourceUnfoldrMN count (n + 1))
732+
722733{-# INLINE zipAsyncAp #-}
723−zipAsync, zipAsyncAp, zipAsyncM :: S.MonadAsync m => Stream m Int -> m ()
724−
725−zipAsync src = do
726− r <- S.tail src
727− let src1 = fromJust r
728− transform (S.zipAsyncWith (,) src src1)
729−
730−zipAsyncM src = do
731− r <- S.tail src
732− let src1 = fromJust r
733− transform (S.zipAsyncWithM (curry return) src src1)
734−
735−zipAsyncAp src = do
736− r <- S.tail src
737− let src1 = fromJust r
738− transform (S.zipAsyncly $ (,) <$> S.serially src
739− <*> S.serially src1)
734+zipAsyncAp :: (S.IsStream t, S.MonadAsync m) => Int -> Int -> t m (Int, Int)
735+zipAsyncAp count n = do
736+ S.zipAsyncly $ (,)
737+ <$> (sourceUnfoldrMN count n)
738+ <*> (sourceUnfoldrMN count (n + 1))
739+
740+{-# INLINE mergeAsyncByM #-}
741+mergeAsyncByM :: (S.IsStream t, S.MonadAsync m) => Int -> Int -> t m Int
742+mergeAsyncByM count n = do
743+ S.mergeAsyncByM (\a b -> return (a `compare` b))
744+ (sourceUnfoldrMN count n)
745+ (sourceUnfoldrMN count (n + 1))
740746
741747-------------------------------------------------------------------------------
742748-- Multi-stream folds