[Haskell-cafe] Newbie question about tuples

Lukas Mai l.mai at web.de
Fri Jul 13 03:19:37 EDT 2007


Am Donnerstag, 12. Juli 2007 20:14 schrieb Andrew Coppin:

> The only thing the libraries provide, as far as I can tell, is the fact
> that tuples are all Functors. (In other words, you can apply some
> function to all the elements to get a new tuple.) I think that's about
> it. I doubt you can use that to define lifting functions...

Actually, they aren't (Functors). (,) takes two type arguments, (,,)
takes three, etc.  class Functor f requires f to take one type argument.
So something like

  instance Functor (,) where ...

won't compile. Besides, what should fmap (+1) (3, 4, "foo") do?

(Somewhere in the libraries there is an
instance Functor (,) a where fmap f (x, y) = (x, f y)
but that's probably not what you expected.)

HTH, Lukas


More information about the Haskell-Cafe mailing list