on master help sign in
Implement zipWith in terms of zipWithM in StreamK
commit27c3fd76ae3b0c7f24bfabee1eec7ebd4d9e9ce4 authorAdithya Kumar <adithya@composewell.com> dateFri 4 Feb 2022, 06:33 (5 years ago) parent52f5379
1 file changed+2−13
src/Streamly/Internal/Data/Stream/StreamK.hs+2−13
src/Streamly/Internal/Data/Stream/StreamK.hs+2−13
@@ -751,19 +751,8 @@ mapMaybe f = go
751751--
752752-- @since 0.1.0
753753{-# INLINE zipWith #-}
754−zipWith :: (a -> b -> c) -> Stream m a -> Stream m b -> Stream m c
755−zipWith f = go
756−
757− where
758−
759− go mx my = mkStream $ \st yld sng stp -> do
760− let merge a ra =
761− let single2 b = sng (f a b)
762− yield2 b rb = yld (f a b) (go ra rb)
763− in foldStream (adaptState st) yield2 single2 stp my
764− let single1 a = merge a nil
765− yield1 = merge
766− foldStream (adaptState st) yield1 single1 stp mx
754+zipWith :: Monad m => (a -> b -> c) -> Stream m a -> Stream m b -> Stream m c
755+zipWith f = zipWithM (\a b -> return (f a b))
767756
768757-- | Zip two streams serially using a monadic zipping function.
769758--