haskell-issues icon indicating copy to clipboard operation
haskell-issues copied to clipboard

Data.Distributive should implement zipWith

Open Gurkenglas opened this issue 7 years ago • 0 comments

Because as far as I can see it is safe but requires partial functions to implement:

type Pair a a = Pair a a deriving Functor

zipWith :: Distributive g => (a -> b -> c) -> g a -> g b -> g c
zipWith f x y = cotraverse hack $ Pair (fmap Left x) (fmap Right y) where
  hack (Pair (Left x) (Right y)) = f x y

Gurkenglas avatar Jun 03 '17 11:06 Gurkenglas