[project @ 2002-04-24 16:31:37 by simonmar]
[ghc-base.git] / Data / IORef.hs
index dcc0eae..d165380 100644 (file)
@@ -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.2 2001/07/03 11:37:49 simonmar Exp $
+-- $Id: IORef.hs,v 1.5 2002/04/24 16:31:39 simonmar Exp $
 --
 -- Mutable references in the IO monad.
 --
@@ -29,7 +29,7 @@ module Data.IORef
 import Prelude
 
 #ifdef __GLASGOW_HASKELL__
-import GHC.Prim                ( mkWeak# )
+import GHC.Base                ( mkWeak# )
 import GHC.STRef
 import GHC.IOBase
 #if !defined(__PARALLEL_HASKELL__)
@@ -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