Variable-arity zipWith (re)invented.
2012-12-08 15:27:12 GMT
Continued discussion from https://groups.google.com/d/topic/haskell-cafe/-e-xaCEbd-w/discussion https://groups.google.com/d/topic/haskell-cafe/kM_-NvXAcx8/discussion Thank you for all the answeres and thinkings; Here's zipWithN for general Zip functors:  . This, together with  may constitute a small hackage. A modification from Wren's idea to  is the use of fmap instead of repeat. I'm wondering if there are any laws for Zip functors. I first thought that there are similarity between Zips and Applicatives, as  states > instance Applicative f => Zip f where > zip = liftA2 (,) However, my intuition is that zipping two arrays should result in an array of size of the same order as two, giving rise to a Zip functor law candidate: zipWith const xs $ zipWith const xs ys == zipWith const xs ys which is violated by the above statement "zip = liftA2 (,)" .  https://github.com/nushio3/practice/blob/master/variable-arity/ZipWithN-2.hs  https://github.com/nushio3/practice/blob/master/free-objects/zipf-12.hs  http://hackage.haskell.org/packages/archive/TypeCompose/0.9.7/doc/html/Data-Zip.html --(Continue reading)