Re: Handle to haskell data
Manuel M T Chakravarty <[email protected]> Mon, 01 Dec 2003 14:37:04 +1100 (EST)
| Newsgroups | gmane.comp.lang.haskell.ffi |
|---|---|
| Message-ID | <[email protected]> |
Fergus Henderson <[email protected]> wrote, > On 30-Nov-2003, David Waern <[email protected]> wrote: > > > > Hi. I want to know if it is possible via FFI and GHC to allocate > > haskell data structures and return some kind of handle to their internal > > representation in the haskell runtime to another language that calls > > haskell code (c/c++). > > I haven't tried it myself, but I think the answer is yes: > use the StablePtr type, which in C is the HsStablePtr typedef in "HsFFI.h". Yes, that is exactly what StablePtrs are meant for. See also the description of the various pointer types at http://www.reid-consulting-uk.ltd.uk/docs/ffi-Common_Problems.html Manuel