e62467aa6d74b3a719f82f0bde2e4242d99a54bf
[packages/haskell2010.git] / Foreign / StablePtr.hs
1 #if __GLASGOW_HASKELL__ >= 701
2 {-# LANGUAGE Safe #-}
3 #endif
4
5 module Foreign.StablePtr
6 ( -- * Stable references to Haskell values
7 StablePtr -- abstract
8 , newStablePtr -- :: a -> IO (StablePtr a)
9 , deRefStablePtr -- :: StablePtr a -> IO a
10 , freeStablePtr -- :: StablePtr a -> IO ()
11 , castStablePtrToPtr -- :: StablePtr a -> Ptr ()
12 , castPtrToStablePtr -- :: Ptr () -> StablePtr a
13 , -- ** The C-side interface
14
15 -- $cinterface
16 ) where
17 import "base" Foreign.StablePtr as This___
18
19 -- $cinterface
20 --
21 -- The following definition is available to C programs inter-operating with
22 -- Haskell code when including the header @HsFFI.h@.
23 --
24 -- > typedef void *HsStablePtr; /* C representation of a StablePtr */
25 --
26 -- Note that no assumptions may be made about the values representing stable
27 -- pointers. In fact, they need not even be valid memory addresses. The only
28 -- guarantee provided is that if they are passed back to Haskell land, the
29 -- function 'deRefStablePtr' will be able to reconstruct the
30 -- Haskell value referred to by the stable pointer.