on master help sign in
Add examples
commit17963a0a925538e4709e2d224abb0d423ce2f76b authorHarendra Kumar <harendra@composewell.com> dateTue 25 Feb 2020, 02:45 (7 years ago) parente799043
1 file changed+16
src/Streamly/Internal/Data/Unfold.hs+16
src/Streamly/Internal/Data/Unfold.hs+16
@@ -586,6 +586,18 @@ zipWithM f (Unfold step1 inject1) (Unfold step2 inject2) = Unfold step inject
586586 Skip s -> return $ Skip (s1, s, Just x)
587587 Stop -> return Stop
588588
589+-- | Divide the input into two unfolds and then zip the outputs to a single
590+-- stream.
591+--
592+-- @
593+-- S.mapM_ print
594+-- $ S.concatUnfold (UF.zipWith (,) UF.identity (UF.singleton sqrt))
595+-- $ S.map (\x -> (x,x))
596+-- $ S.fromList [1..10]
597+-- @
598+--
599+-- /Internal/
600+--
589601{-# INLINE zipWith #-}
590602zipWith :: Monad m
591603 => (a -> b -> c) -> Unfold m x a -> Unfold m y b -> Unfold m (x, y) c
@@ -594,6 +606,10 @@ zipWith f = zipWithM (\a b -> return (f a b))
594606-- | Distribute the input to two unfolds and then zip the outputs to a single
595607-- stream.
596608--
609+-- @
610+-- S.mapM_ print $ S.concatUnfold (UF.teeZipWith (,) UF.identity (UF.singleton sqrt)) $ S.fromList [1..10]
611+-- @
612+--
597613-- /Internal/
598614--
599615{-# INLINE_NORMAL teeZipWith #-}