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