
Simon Marlow
Olaf wrote,
How about this slightly more general interface, which works with the new FFI libraries, and is trivial to implement on top of the
Simon Marlow wrote, primitives in
GHC's IOExts:
hPut :: Storable a => Handle -> a -> IO () hGet :: Storable a => Handle -> IO a
What about endianess? In which format are Floats or even just Bools stored? For a file which probably shall be read from different machines this is not clear at all.
Like in any other language, too. If you are writing binary data, you get all the problems of writing binary data. I agree that on top of that it would be nice to have some really nice serilisation routines, but that should be a second step.
Overloading with Storable gives you more flexibility, since if you have a way to serialise an object in memory for passing to a foreign function, you also have a way to store it in binary format in a file (modulo problems with pointers, of course).
Yep, good idea. Cheers, Manuel