[project @ 2002-10-09 17:08:18 by malcolm]
[haskell-directory.git] / Data / IORef.hs
index 2580df2..284c2bf 100644 (file)
@@ -28,6 +28,10 @@ module Data.IORef
 
 import Prelude
 
+#ifdef __HUGS__
+import Hugs.IORef
+#endif
+
 #ifdef __GLASGOW_HASKELL__
 import GHC.Base                ( mkWeak# )
 import GHC.STRef
@@ -37,7 +41,18 @@ import GHC.Weak
 #endif
 #endif /* __GLASGOW_HASKELL__ */
 
+#ifdef __NHC__
+import NHC.IOExtras
+    ( IORef
+    , newIORef
+    , readIORef
+    , writeIORef
+    )
+#endif
+
+#ifndef __NHC__
 import Data.Dynamic
+#endif
 
 #if defined(__GLASGOW_HASKELL__) && !defined(__PARALLEL_HASKELL__)
 -- |Make a 'Weak' pointer to an 'IORef'
@@ -46,21 +61,11 @@ 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__ */
-
 -- |Mutate the contents of an 'IORef'
 modifyIORef :: IORef a -> (a -> a) -> IO ()
 modifyIORef ref f = writeIORef ref . f =<< readIORef ref
 
+#ifndef __NHC__
 #include "Dynamic.h"
 INSTANCE_TYPEABLE1(IORef,ioRefTc,"IORef")
+#endif