Is there any merit in the idea of allowing instances of Storable to be derived in a similar fashion to Show, providing that constituents are of class Storable. for instance (Int, Int) two Ints would be marshalled into consecutive memory locations in their order of declaration. (Int,String) an Int followed by a String dealing with constructors ========================== data X = X1 Int | X2 deriving Storable data Y = Y1 | Y2 deriving Storable three possible alternatives spring to mind A) Indexing Constructors by position X1 -> 0:Int X2 -> 1 where 0, 1 represent the constructor indexes ":" represents that the data items are physically contiguous "->" reads "marshalled as" This has the disadvantage of being sensitive to the constructor order B) using the constructor name as the index X1 -> X1:Int X2 -> X2 has the disadvantage of requiring a variable amount of memory for the tag. C) some other hash on the constructor name ? I would think that implementation would be fairly straight forward? The benefits would be significant - automatic marshalling of structures. uses: storing to disk, passing over network etc etc.. _________________________________________________________________ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus
"mike V" <mivori@hotmail.com> writes:
Is there any merit in the idea of allowing instances of Storable to be derived in a similar fashion to Show, providing that constituents are of class Storable.
The benefits would be significant - automatic marshalling of structures. uses: storing to disk, passing over network etc etc..
For storage and transmission needs, what you really want is binary serialisation. There are a couple of implementations of class Binary out there already - have a look at the libraries@haskell.org list for the most recent discussion. Regards, Malcolm
participants (2)
-
Malcolm Wallace -
mike V