on master help sign in
Add teeZipWith
e799043Harendra Kumar
src/Streamly/Internal/Data/Unfold.hs+11
@@ -109,6 +109,7 @@ module Streamly.Internal.Data.Unfold
109 -- * Zipping
109 -- * Zipping
110 , zipWithM
110 , zipWithM
111 , zipWith
111 , zipWith
112+ , teeZipWith
112
113
113 -- * Nesting
114 -- * Nesting
114 , concat
115 , concat
@@ -590,6 +591,16 @@ zipWith :: Monad m
590 => (a -> b -> c) -> Unfold m x a -> Unfold m y b -> Unfold m (x, y) c
591 => (a -> b -> c) -> Unfold m x a -> Unfold m y b -> Unfold m (x, y) c
591zipWith f = zipWithM (\a b -> return (f a b))
592zipWith f = zipWithM (\a b -> return (f a b))
592
593
594+-- | Distribute the input to two unfolds and then zip the outputs to a single
595+-- stream.
596+--
597+-- /Internal/
598+--
599+{-# INLINE_NORMAL teeZipWith #-}
600+teeZipWith :: Monad m
601+ => (a -> b -> c) -> Unfold m x a -> Unfold m x b -> Unfold m x c
602+teeZipWith f unf1 unf2 = lmap (\x -> (x,x)) $ zipWith f unf1 unf2
603+
593-------------------------------------------------------------------------------
604-------------------------------------------------------------------------------
594-- Nested
605-- Nested
595-------------------------------------------------------------------------------
606-------------------------------------------------------------------------------