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 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe