X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FIORef.hs;h=d165380309d3733e5acaca322f68984924b91278;hb=9fa9bc17072a58c0bae2cce4764d38677e96ac29;hp=910ea86e141dbd5c800620355b98ab12eba61561;hpb=260e7f2ed9a43c6ecf5a556d77817f39ed2893ab;p=ghc-base.git diff --git a/Data/IORef.hs b/Data/IORef.hs index 910ea86..d165380 100644 --- a/Data/IORef.hs +++ b/Data/IORef.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- +-- | -- Module : Data.IORef -- Copyright : (c) The University of Glasgow 2001 -- License : BSD-style (see the file libraries/core/LICENSE) @@ -8,7 +8,7 @@ -- Stability : experimental -- Portability : portable -- --- $Id: IORef.hs,v 1.3 2001/12/21 15:07:21 simonmar Exp $ +-- $Id: IORef.hs,v 1.5 2002/04/24 16:31:39 simonmar Exp $ -- -- Mutable references in the IO monad. -- @@ -37,19 +37,26 @@ import GHC.Weak #endif #endif /* __GLASGOW_HASKELL__ */ -#ifdef __HUGS__ -import IOExts ( IORef, newIORef, writeIORef, readIORef ) -import ST ( stToIO, newSTRef, readSTRef, writeSTRef ) -#endif - import Data.Dynamic -#ifndef __PARALLEL_HASKELL__ +#if defined(__GLASGOW_HASKELL__) && !defined(__PARALLEL_HASKELL__) mkWeakIORef :: IORef a -> IO () -> IO (Weak (IORef a)) mkWeakIORef r@(IORef (STRef r#)) f = IO $ \s -> case mkWeak# r# r f s of (# s1, w #) -> (# s1, Weak w #) #endif +#if defined __HUGS__ +data IORef a -- mutable variables containing values of type a + +primitive newIORef "newRef" :: a -> IO (IORef a) +primitive readIORef "getRef" :: IORef a -> IO a +primitive writeIORef "setRef" :: IORef a -> a -> IO () +primitive eqIORef "eqRef" :: IORef a -> IORef a -> Bool + +instance Eq (IORef a) where + (==) = eqIORef +#endif /* __HUGS__ */ + modifyIORef :: IORef a -> (a -> a) -> IO () modifyIORef ref f = writeIORef ref . f =<< readIORef ref