1 % -----------------------------------------------------------------------------
2 % $Id: PrelStable.lhs,v 1.8 2000/11/07 10:42:57 simonmar Exp $
4 % (c) The GHC Team, 1992-2000
7 \section{Module @PrelStable@}
10 {-# OPTIONS -fno-implicit-prelude #-}
14 , newStablePtr -- :: a -> IO (StablePtr a)
15 , deRefStablePtr -- :: StablePtr a -> a
16 , freeStablePtr -- :: StablePtr a -> IO ()
22 -----------------------------------------------------------------------------
25 data StablePtr a = StablePtr (StablePtr# a)
27 instance CCallable (StablePtr a)
28 instance CReturnable (StablePtr a)
30 newStablePtr :: a -> IO (StablePtr a)
31 deRefStablePtr :: StablePtr a -> IO a
32 foreign import unsafe freeStablePtr :: StablePtr a -> IO ()
34 newStablePtr a = IO $ \ s ->
35 case makeStablePtr# a s of (# s', sp #) -> (# s', StablePtr sp #)
37 deRefStablePtr (StablePtr sp) = IO $ \s -> deRefStablePtr# sp s
40 instance Eq (StablePtr a) where
41 (StablePtr sp1) == (StablePtr sp2) =
42 case eqStablePtr# sp1 sp2 of