2 % (c) The AQUA Project, Glasgow University, 1994-1996
5 \section[IOExts]{Module @IOExts@}
8 {-# OPTIONS -fno-implicit-prelude #-}
16 -- instance Eq (IORef a)
22 -- instance Eq (IOArray ix a)
43 reallyUnsafePtrEq a b =
44 case reallyUnsafePtrEquality# a b of
49 newtype IORef a = IORef (MutableVar RealWorld a)
52 newIORef :: a -> IO (IORef a)
53 newIORef v = stToIO (newVar v) >>= \ var -> return (IORef var)
55 readIORef :: IORef a -> IO a
56 readIORef (IORef var) = stToIO (readVar var)
58 writeIORef :: IORef a -> a -> IO ()
59 writeIORef (IORef var) v = stToIO (writeVar var v)
63 newtype IOArray ix elt = IOArray (MutableArray RealWorld ix elt)
66 newIOArray :: Ix ix => (ix,ix) -> elt -> IO (IOArray ix elt)
67 boundsIOArray :: Ix ix => IOArray ix elt -> (ix, ix)
68 readIOArray :: Ix ix => IOArray ix elt -> ix -> IO elt
69 writeIOArray :: Ix ix => IOArray ix elt -> ix -> elt -> IO ()
70 freezeIOArray :: Ix ix => IOArray ix elt -> IO (Array ix elt)
73 stToIO (newArray ixs elt) >>= \arr ->
76 boundsIOArray (IOArray arr) = boundsOfArray
78 readIOArray (IOArray arr) ix = stToIO (readArray arr ix)
80 writeIOArray (IOArray arr) ix elt = stToIO (writeArray arr ix elt)
82 freezeIOArray (IOArray arr) = stToIO (freezeArray arr)