
13 Sep
2011
13 Sep
'11
10:03 p.m.
On Wed, 2011-09-14 at 13:56 +1200, Richard O'Keefe wrote:
I don't *expect* to implement anything just once. I am perfectly happy writing as many instance declarations as I have tuple sizes that I care about.
Ah, okay... then sure, you can do this: class Tuple a b c | a b -> c where tuple :: a -> b -> c instance Tuple (a -> b, a -> c) a (b,c) where tuple (f,g) x = (f x, g x) and so on... You'll need fundeps (or type families if you prefer to write it that way), and probably at least flexible and/or overlapping instances, too, but of course GHC will tell you about those. -- Chris Smith