[Haskell-cafe] Newbie question about tuples
Andrew Coppin
andrewcoppin at btinternet.com
Fri Jul 13 15:03:06 EDT 2007
Lukas Mai wrote:
> 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).
Oh. Kay... well that makes me look *very* intelligent. :-}
> (,) takes two type arguments, (,,)
> takes three, etc. class Functor f requires f to take one type argument.
>
Ah. A kind error. Yes, you're right about that... oops.
> Besides, what should fmap (+1) (3, 4, "foo") do?
>
I was assuming it's only defined for (a,a), not for (a,b)...
> (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.)
>
Indeed.
Oh well...
More information about the Haskell-Cafe
mailing list