I wrote:
> [...]
> instance Marshalable a => Marshalable (Vec3 a) where
> sizeOf (Vec3 x _ _) = 3 * sizeOf x
> alignment (Vec3 x _ _) = alignment x
> [...]
After a segmentation fault in my OpenGL binding (thanks to Manuel for
pointing this out) I came to the conclusion that this should read:
instance Marshalable a => Marshalable (Vec3 a) where
sizeOf ~(Vec3 x _ _) = 3 * sizeOf x
alignment ~(Vec3 x _ _) = alignment x
Otherwise these methods are too strict and things like
...
buf <- malloc (sizeOf undefined)
...
fail. BTW, it is funny that one gets a segmentation fault when an
error condition like this happens in a Haskell callback. I guess it
happens whenever an exception is raised in a callback. It's quite
hard to debug one's code with this behaviour, the only way was
resorting good old printf debugging (aka "putStrLn debugging" :-).
Cheers,
Sven
--
Sven Panne Tel.: +49/89/2178-2235
LMU, Institut fuer Informatik FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen Oettingenstr. 67
mailto:[EMAIL PROTECTED] D-80538 Muenchen
http://www.informatik.uni-muenchen.de/~Sven.Panne