Jeff Shaw | 25 Sep 16:58 2012
Picon

in the vector library, why define unbox tuples > 2?

I'm looking at storing a data type with 7 fields in an unboxed vector, 
which means that I'll have to use GenUnboxTuple to create an instance 
for Unbox (a,b,c,d,e,f,g), but I was thinking that another solution is 
to use "instance (Unbox a, Unbox b) => Unbox (a,b)" recursively to 
create "instance Unbox (a,(b,(c,(d,(e,(f,g))))))". Is there any reason I 
shouldn't say something like,

import qualified Data.Vector.Unboxed as Vector

data X = X Int Int Int Int Int Int Int

toTuple (X a b c d e f g) = (a,(b,(c,(d,(e,(f,g))))))

toVector = Vector.fromList . map toTuple

I guess I'm wondering if there is a technical reason why I should use an 
explicit Unbox instance for 7-tuples, or if it's just a convenience to 
have Unbox defined for tuples > 2?

Thanks,
Jeff

Gmane