[Haskell-cafe] mapTuple

minh thu noteed at gmail.com
Thu Jan 11 10:14:41 EST 2007

2007/1/11, Marco Túlio Gontijo e Silva <malebria at riseup.net>:
> Hello,
> is there a way to defined something as a map to use in tuples? I tried
> this:
> mapTuple f (a, b) = (f a, f b)
> But the type inferred to it is not as generic as I wanted:
> mapTuple :: (t -> t1) -> (t, t) -> (t1, t1)
> Then I tried a different, but not much, implementation:
> mapTuple' f g (a, b) = (f a, g b)
> mapTuple f = mapTuple' f f
> But the inferred type was the same.
> Is there a way to define a function in which I can be able to do
> something as this?
> mapTuple show ("string", True)


you might want invistigate "heterogeneous lists" : in your case, it's
"heterogeneous typle".
There's a page lying on the wiki I think... It involves typeclasses
and type quantifiers.

minh thu

More information about the Haskell-Cafe mailing list