
28 Jul
2008
28 Jul
'08
8:14 p.m.
So at the moment you're using using Storable and a Haskell record, say:
data AIOCB = AIOCB { ... }
and we're suggesting instead:
newtype AIOCB = AIOCB (ForeignPtr AIOCB)
^^^ I am somewhat new to Haskell. Not a total newbie! But what exactly does the above mean? Are the three references of "AIOCB" in different namespaces? If it too much trouble to explain, can you point me at Haskell URL to read?
then to access a member use hsc2hs:
getBlah :: AIOCB -> IO Blah getBlah (AIOCB fptr) = withForeignPtr fptr $ \ptr -> {# peek aiocb,blah #} ptr
So you only access the parts you need and keep the aiocb C struct allocated on the heap (use mallocForeignPtr).
Duncan