[Haskell-cafe] varargs zip

Janis Voigtlaender voigt at tcs.inf.tu-dresden.de
Sat Nov 22 09:20:17 EST 2008


Sean Leather wrote:
> EMGM [1] has a generic zipWith [2]:
> 
>>  zipWith :: FRep3 ZipWith f => (a -> b -> c) -> f a -> f b -> Maybe (f c)
> 
> This is generic according to the container type 'f'. A particular 
> specialization of this is zip:
> 
>>  zip :: FRep3 ZipWith f => f a -> f b -> Maybe (f (a, b))

Also, module Data.Zippable of package

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bff

has:

  tryZip :: Zippable f => f a -> f b -> Either String (f (a,b))

where "Either String" plays the role of "Maybe" above. And for the
underlying Zippable class, Joachim Breitner has implemented an automatic
TH deriver (makeZippable) using the derive-package. So no manual
boilerplate at all is necessary to use this version of generic zip.
(And there is also a tryZipWith.)

Ciao, Janis.

-- 
Dr. Janis Voigtlaender
http://wwwtcs.inf.tu-dresden.de/~voigt/
mailto:voigt at tcs.inf.tu-dresden.de


More information about the Haskell-Cafe mailing list