
7 Oct
2005
7 Oct
'05
2:39 p.m.
On Friday 07 October 2005 14:50, Benjamin Franksen wrote:
First a version that should work (at least it compiles) for poke:
\begin{code} instance (Storable a) => Storable (Endian a) where sizeOf (Endian a _) = sizeOf a alignment (Endian a _) = alignment a pokeByteOff p i (Endian a b) = if getHostByteOrder == b then pokeByteOff p i a else pokeByteOff p (sizeOf a - 1 - i) a \end{code}
Note that even this breaks down for more complex types (i.e. records). For instance, with the obvious Storable instance of (Int16,Int16), the elements will get swapped, too. I can't see how to solve this in a generic way. Ben