Storable tuples and what is 'alignment'?

Hal Daume III hdaume@ISI.EDU
Mon, 5 Aug 2002 17:39:19 -0700 (PDT)


Two things:

1) Why aren't there built in Storable instances for tuples?  Writing my
own is a pain and in keeping with the 'up to 7tuple' limit, I think built
in instances would be nice

2) Could someone tell me what 'alignment' is and if this is the correct
definition of a storable tuple:

instance (Storable a, Storable b) => Storable (a,b) where
    sizeOf (a,b) = sizeOf a + sizeOf b
    alignment (a,b) = alignment a + alignment b
    peek ptr = do a <- peek (castPtr ptr)
		  b <- peek (castPtr ptr `plusPtr` sizeOf a)
		  return (a,b)
    poke ptr (a,b) = do poke (castPtr ptr) a
			poke (castPtr ptr `plusPtr` sizeOf a) b

--
Hal Daume III

 "Computer science is no more about computers    | hdaume@isi.edu
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume