[clean up Data.IORef
John Meacham <john@repetae.net>**20061109055533] hunk ./E/PrimOpt.hs 144
-        primopt (PrimPrim "newRef__") [x,y] rt  = return $ EAp (EAp (ELam x' $ ELam y' $ eCaseTup' (EPrim (primPrim "newRef_") [EVar x',EVar y'] (ltTuple' [a,b])) [a',b'] (eTuple [EVar a',EVar b']) ) x) y where
-            [x',y',a',b'] = vars [getType x,getType y,a,b]
-            ELit LitCons { litArgs = [a,b], litType = ESort EStar } = rt
-        primopt (PrimPrim "readRef__") [x,y] rt  = return $ EAp (EAp (ELam x' $ ELam y' $ eCaseTup' (EPrim (primPrim "readRef_") [EVar x',EVar y'] (ltTuple' [a,b])) [a',b'] (eTuple [EVar a',EVar b']) ) x) y where
-            [x',y',a',b'] = vars [getType x,getType y,a,b]
-            ELit LitCons { litArgs = [a,b], litType = ESort EStar } = rt
+--        primopt (PrimPrim "newRef__") [x,y] rt  = return $ EAp (EAp (ELam x' $ ELam y' $ eCaseTup' (EPrim (primPrim "newRef_") [EVar x',EVar y'] (ltTuple' [a,b])) [a',b'] (eTuple [EVar a',EVar b']) ) x) y where
+--            [x',y',a',b'] = vars [getType x,getType y,a,b]
+--            ELit LitCons { litArgs = [a,b], litType = ESort EStar } = rt
+--        primopt (PrimPrim "readRef__") [x,y] rt  = return $ EAp (EAp (ELam x' $ ELam y' $ eCaseTup' (EPrim (primPrim "readRef_") [EVar x',EVar y'] (ltTuple' [a,b])) [a',b'] (eTuple [EVar a',EVar b']) ) x) y where
+--            [x',y',a',b'] = vars [getType x,getType y,a,b]
+--            ELit LitCons { litArgs = [a,b], litType = ESort EStar } = rt
hunk ./lib/base/Data/IORef.hs 1
+{-# OPTIONS_JHC -N #-}
hunk ./lib/base/Data/IORef.hs 11
+import Jhc.Basics
+import Jhc.Order
hunk ./lib/base/Data/IORef.hs 14
+import Jhc.Addr
hunk ./lib/base/Data/IORef.hs 16
-data IORef a = IORef a
+newtype IORef a = IORef Addr
+
+
+foreign import primitive newRef__   :: a -> World__ -> (# World__, IORef a #)
+foreign import primitive readRef__  :: IORef a -> World__ -> (# World__, a #)
+foreign import primitive writeRef__ :: IORef a -> a -> World__ -> World__
hunk ./lib/base/Data/IORef.hs 23
-{-# NOINLINE newIORef #-}
hunk ./lib/base/Data/IORef.hs 24
-newIORef v = do
-    v' <- strictReturn v
-    return (IORef v')
+newIORef v = IO $ \_ w -> newRef__ v w
+
hunk ./lib/base/Data/IORef.hs 27
-{-# NOINLINE readIORef #-}
hunk ./lib/base/Data/IORef.hs 28
-readIORef r = do
-    --v <- strictReturn r
-    case r of
-        IORef r -> strictReturn r
+readIORef r = IO $ \_ w -> readRef__ r w
hunk ./lib/base/Data/IORef.hs 30
+writeIORef :: IORef a -> a -> IO ()
+writeIORef r v = IO $ \_ w -> case writeRef__ r v w of w' -> (# w', () #)
hunk ./lib/base/Data/IORef.hs 33
---foreign import primitive newRef__ :: forall s . a -> s -> (s,Ref s a)
---foreign import primitive readRef__ :: forall s . Ref s a -> s -> (s,a)
-foreign import primitive writeRef__ ::  IORef a -> a -> World__ -> World__
+foreign import primitive eqRef__ :: IORef a -> IORef a -> Bool
hunk ./lib/base/Data/IORef.hs 35
-{-# NOINLINE writeIORef #-}
-writeIORef :: IORef a -> a -> IO ()
-writeIORef r v = do
-    IO $ \_ world -> case writeRef__ r v world of
-        world' -> JustIO world' ()
+instance Eq (IORef a) where
+    x == y = eqRef__ x y
+    x /= y = not (eqRef__ x y)
hunk ./lib/base/Data/IORef.hs 39
---foreign import primitive eqRef__ :: forall s . Ref s a -> Ref s a -> Bool
hunk ./lib/base/Data/IORef.hs 40
+modifyIORef :: IORef a -> (a -> a) -> IO ()
+modifyIORef ref f = IO $ \_ w -> case readRef__ ref w of
+    (# w', a #) -> case writeRef__ ref (f a) w' of
+        w'' -> (# w'', () #)
+
+atomicModifyIORef :: IORef a -> (a -> (a,b)) -> IO b
+atomicModifyIORef r f = IO $ \_ w -> case readRef__ r w of
+    (# w', a #) -> case f a of
+        (a',b) -> case writeRef__ r a' w' of
+            w'' -> (# w'', b #)
+{-
hunk ./lib/base/Data/IORef.hs 57
+{-# NOINLINE newIORef #-}
+newIORef :: a -> IO (IORef a)
+newIORef v = do
+    v' <- strictReturn v
+    return (IORef v')
hunk ./lib/base/Data/IORef.hs 63
---instance Eq (IORef a) where
---    x == y = eqRef__ x y
---    x /= y = not (eqRef__ x y)
-
-modifyIORef :: IORef a -> (a -> a) -> IO ()
-modifyIORef ref f = writeIORef ref . f =<< readIORef ref
+{-# NOINLINE readIORef #-}
+readIORef :: IORef a -> IO a
+readIORef r = do
+    --v <- strictReturn r
+    case r of
+        IORef r -> strictReturn r
+-}
hunk ./lib/base/Data/IORef.hs 71
-atomicModifyIORef r f = do
-    a <- readIORef r
-    case f a of
-        (a',b) -> writeIORef r a' >> return b
+--foreign import primitive newRef__ :: forall s . a -> s -> (s,Ref s a)
+--foreign import primitive readRef__ :: forall s . Ref s a -> s -> (s,a)