Duh. Reinstate type variable for state token in Ref type.
Also rename to STRef since that's GHC's name for it.
, ThreadId, forkIO
,trace
- , Ref, newRef, readRef, writeRef
+ , STRef, newSTRef, readSTRef, writeSTRef
-- Arrrggghhh!!! Help! Help! Help!
-- What?! Prelude.hs doesn't even _define_ most of these things!
data PrimArray a -- immutable arrays with Int indices
data PrimByteArray
-data Ref a -- mutable variables
+data STRef s a -- mutable variables
data PrimMutableArray s a -- mutable arrays with Int indices
data PrimMutableByteArray s
-newRef :: a -> IO (Ref a)
-newRef = primNewRef
-readRef :: Ref a -> IO a
-readRef = primReadRef
-writeRef :: Ref a -> a -> IO ()
-writeRef = primWriteRef
+newSTRef :: a -> ST s (STRef s a)
+newSTRef = primNewRef
+readSTRef :: STRef s a -> ST s a
+readSTRef = primReadRef
+writeSTRef :: STRef s a -> a -> ST s ()
+writeSTRef = primWriteRef
+
+type IORef a = STRef RealWorld a
------------------------------------------------------------------------------
* included in the distribution.
*
* $RCSfile: link.c,v $
- * $Revision: 1.14 $
- * $Date: 1999/11/18 12:10:19 $
+ * $Revision: 1.15 $
+ * $Date: 1999/11/19 15:42:07 $
* ------------------------------------------------------------------------*/
#include "prelude.h"
typeAddr = linkTycon("Addr");
typePrimArray = linkTycon("PrimArray");
typePrimByteArray = linkTycon("PrimByteArray");
- typeRef = linkTycon("Ref");
+ typeRef = linkTycon("STRef");
typePrimMutableArray = linkTycon("PrimMutableArray");
typePrimMutableByteArray = linkTycon("PrimMutableByteArray");
typeFloat = linkTycon("Float");
#endif
nameMkPrimArray = addPrimCfunREP(findText("PrimArray#"),1,0,0);
nameMkPrimByteArray = addPrimCfunREP(findText("PrimByteArray#"),1,0,0);
- nameMkRef = addPrimCfunREP(findText("Ref#"),1,0,0);
+ nameMkRef = addPrimCfunREP(findText("STRef#"),1,0,0);
nameMkPrimMutableArray = addPrimCfunREP(findText("PrimMutableArray#"),1,0,0);
nameMkPrimMutableByteArray = addPrimCfunREP(findText("PrimMutableByteArray#"),1,0,0);
nameMkPrimMVar = addPrimCfunREP(findText("MVar#"),1,0,0);
* included in the distribution.
*
* $RCSfile: type.c,v $
- * $Revision: 1.14 $
- * $Date: 1999/11/19 13:54:49 $
+ * $Revision: 1.15 $
+ * $Date: 1999/11/19 15:42:08 $
* ------------------------------------------------------------------------*/
#include "prelude.h"
case BARR_REP:
return typePrimByteArray;
case REF_REP:
- return ap(typeRef,mkAlphaVar());
+ return ap2(typeRef,mkStateVar(),mkAlphaVar());
case MUTARR_REP:
return ap2(typePrimMutableArray,mkStateVar(),mkAlphaVar());
case MUTBARR_REP:
, ThreadId, forkIO
,trace
- , Ref, newRef, readRef, writeRef
+ , STRef, newSTRef, readSTRef, writeSTRef
-- Arrrggghhh!!! Help! Help! Help!
-- What?! Prelude.hs doesn't even _define_ most of these things!
data PrimArray a -- immutable arrays with Int indices
data PrimByteArray
-data Ref a -- mutable variables
+data STRef s a -- mutable variables
data PrimMutableArray s a -- mutable arrays with Int indices
data PrimMutableByteArray s
-newRef :: a -> IO (Ref a)
-newRef = primNewRef
-readRef :: Ref a -> IO a
-readRef = primReadRef
-writeRef :: Ref a -> a -> IO ()
-writeRef = primWriteRef
+newSTRef :: a -> ST s (STRef s a)
+newSTRef = primNewRef
+readSTRef :: STRef s a -> ST s a
+readSTRef = primReadRef
+writeSTRef :: STRef s a -> a -> ST s ()
+writeSTRef = primWriteRef
+
+type IORef a = STRef RealWorld a
------------------------------------------------------------------------------
* Copyright (c) 1994-1998.
*
* $RCSfile: Assembler.c,v $
- * $Revision: 1.17 $
- * $Date: 1999/11/19 13:54:53 $
+ * $Revision: 1.18 $
+ * $Date: 1999/11/19 15:42:12 $
*
* This module provides functions to construct BCOs and other closures
* required by the bytecode compiler.
, { "primIsIEEEDouble", "", "B", MONAD_Id, i_PRIMOP1, i_isIEEEDouble }
/* Ref operations */
- , { "primNewRef", "a", "R", MONAD_IO, i_PRIMOP2, i_newRef }
- , { "primWriteRef", "Ra", "", MONAD_IO, i_PRIMOP2, i_writeRef }
- , { "primReadRef", "R", "a", MONAD_IO, i_PRIMOP2, i_readRef }
+ , { "primNewRef", "a", "R", MONAD_ST, i_PRIMOP2, i_newRef }
+ , { "primWriteRef", "Ra", "", MONAD_ST, i_PRIMOP2, i_writeRef }
+ , { "primReadRef", "R", "a", MONAD_ST, i_PRIMOP2, i_readRef }
, { "primSameRef", "RR", "B", MONAD_Id, i_PRIMOP2, i_sameRef }
/* PrimArray operations */