Handle to haskell data
Alastair Reid
alastair at reid-consulting-uk.ltd.uk
Mon Dec 1 05:07:44 EST 2003
On Sunday 30 November 2003 6:43 pm, David Waern 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++).
Use StablePtrs.
These are more or less a direct pointer to the Haskell data structure
with just enough magic to keep the garbage collector happy.
You can read more about StablePtrs in this paper:
http://www.reid-consulting-uk.ltd.uk/alastair/publications/gfpw94/index.html
Since that paper was written (1994), the names of the operations and their
types has changed quite a bit. See the current specification for details:
http://www.cse.unsw.edu.au/~chak/haskell/ffi/
--
Alastair Reid www.haskell-consulting.com
More information about the FFI
mailing list