zipWith (,) xs ys == zip xs ys zipWith f [x1,x2,x3..] [y1,y2,y3..] == [f x1 y1, f x2 y2, f x3 y3..]zipWith is right-lazy:
>>> let f = undefined >>> zipWith f [] undefined []zipWith is capable of list fusion, but it is restricted to its first list argument and its resulting list.
>>> zipWith (+) [1, 2, 3] [4, 5, 6] [5,7,9]
>>> zipWith (++) ["hello ", "foo"] ["world!", "bar"] ["hello world!","foobar"]
zipWithExact f xs ys = | length xs == length ys = zipWith f xs ys | otherwise = error "some message"
zipWith (,) xs ys == zip xs ys zipWith f [x1,x2,x3..] [y1,y2,y3..] == [f x1 y1, f x2 y2, f x3 y3..]For example, zipWith (+) is applied to two lists to produce the list of corresponding sums:
>>> zipWith (+) [1, 2, 3] [4, 5, 6] [5,7,9]zipWith is right-lazy:
>>> let f = undefined >>> zipWith f [] undefined []zipWith is capable of list fusion, but it is restricted to its first list argument and its resulting list.
>>> zipWith (+) [1, 2, 3] [4, 5, 6] [5,7,9]zipWith is right-lazy:
zipWith f [] _|_ = []zipWith is capable of list fusion, but it is restricted to its first list argument and its resulting list.
>>> liftA2 (,) (Just 3) (Just 5) Just (3,5)
>>> liftA2 (+) [1, 2, 3] [4, 5, 6] [5,6,7,6,7,8,7,8,9]
>>> liftA2 (,) (Just 3) (Just 5) Just (3,5)
do a <- as b <- bs pure (f a b)
>>> liftM2 (+) [0,1] [0,2] [0,2,1,3]
>>> liftM2 (+) (Just 1) Nothing Nothing
>>> liftM2 (+) (+ 3) (* 2) 5 18
liftM2 (+) [0,1] [0,2] = [0,2,1,3] liftM2 (+) (Just 1) Nothing = Nothing