[project @ 1999-03-27 16:16:19 by sof]
[ghc-hetmet.git] / ghc / docs / users_guide / MutableArray.sgml
index 4b08458..9abd850 100644 (file)
@@ -25,7 +25,8 @@ writeArray    :: Ix ix => MutableArray s ix elt -> ix -> elt -> ST s ()
 freezeArray   :: Ix ix => MutableArray s ix elt -> ST s (Array ix elt)
 thawArray     :: Ix ix => Array ix elt -> ST s (MutableArray s ix elt)
 
-unsafeFreezeArray :: Ix ix => MutableArray s ix elt -> ST s (Array ix elt)  
+unsafeFreezeArray   :: Ix ix => MutableArray s ix elt -> ST s (Array ix elt)  
+unsafeThawArray     :: Ix ix => Array ix elt -> ST s (MutableArray s ix elt)
 </code></tscreen>
 <nidx>newArray</nidx>
 <nidx>boundsOfArray</nidx>
@@ -34,6 +35,7 @@ unsafeFreezeArray :: Ix ix => MutableArray s ix elt -> ST s (Array ix elt)
 <nidx>freezeArray</nidx>
 <nidx>thawArray</nidx>
 <nidx>unsafeFreezeArray</nidx>
+<nidx>unsafeThawArray</nidx>
 
 <bf/Remarks:/
 
@@ -49,8 +51,9 @@ array in the process. Please don't :-)
 <item>
 The operation <tt/thawArray/ goes the other way, converting
 an immutable <tt/Array/ into a mutable one. This is done by
-copying. The operation <tt/unsafeThawArray/ is not provided
-(allthough it conceivably could be.)
+copying. The operation <tt/unsafeThawArray/ is also provided,
+which places the same kind of proof obligation on the programmer
+as <tt/unsafeFreezeArray/ does.
 </itemize>
 
 <sect3> <idx/Mutable byte arrays/
@@ -76,14 +79,14 @@ readAddrArray      :: Ix ix => MutableByteArray s ix -> ix -> ST s Addr
 readFloatArray     :: Ix ix => MutableByteArray s ix -> ix -> ST s Float
 readDoubleArray    :: Ix ix => MutableByteArray s ix -> ix -> ST s Double
 readStablePtrArray :: Ix ix => MutableByteArray s ix -> ix -> ST s (StablePtr a)
-readWord8Array    :: Ix ix => MutableByteArray s ix -> Int -> ST s Word8
-readWord16Array           :: Ix ix => MutableByteArray s ix -> Int -> ST s Word16
-readWord32Array           :: Ix ix => MutableByteArray s ix -> Int -> ST s Word32
-readWord64Array           :: Ix ix => MutableByteArray s ix -> Int -> ST s Word64
-readInt8Array     :: Ix ix => MutableByteArray s ix -> Int -> ST s Int8
-readInt16Array    :: Ix ix => MutableByteArray s ix -> Int -> ST s Int16
-readInt32Array    :: Ix ix => MutableByteArray s ix -> Int -> ST s Int32
-readInt64Array    :: Ix ix => MutableByteArray s ix -> Int -> ST s Int64
+readWord8Array    :: Ix ix => MutableByteArray s ix -> ix -> ST s Word8
+readWord16Array           :: Ix ix => MutableByteArray s ix -> ix -> ST s Word16
+readWord32Array           :: Ix ix => MutableByteArray s ix -> ix -> ST s Word32
+readWord64Array           :: Ix ix => MutableByteArray s ix -> ix -> ST s Word64
+readInt8Array     :: Ix ix => MutableByteArray s ix -> ix -> ST s Int8
+readInt16Array    :: Ix ix => MutableByteArray s ix -> ix -> ST s Int16
+readInt32Array    :: Ix ix => MutableByteArray s ix -> ix -> ST s Int32
+readInt64Array    :: Ix ix => MutableByteArray s ix -> ix -> ST s Int64
 
 writeCharArray        :: Ix ix => MutableByteArray s ix -> ix -> Char -> ST s () 
 writeIntArray         :: Ix ix => MutableByteArray s ix -> ix -> Int  -> ST s () 
@@ -91,14 +94,14 @@ writeAddrArray        :: Ix ix => MutableByteArray s ix -> ix -> Addr -> ST s ()
 writeFloatArray       :: Ix ix => MutableByteArray s ix -> ix -> Float -> ST s () 
 writeDoubleArray      :: Ix ix => MutableByteArray s ix -> ix -> Double -> ST s () 
 writeStablePtrArray   :: Ix ix => MutableByteArray s ix -> ix -> StablePtr a -> ST s () 
-writeWord8Array              :: Ix ix => MutableByteArray s ix -> Int -> Word8  -> ST s ()
-writeWord16Array      :: Ix ix => MutableByteArray s ix -> Int -> Word16 -> ST s ()
-writeWord32Array      :: Ix ix => MutableByteArray s ix -> Int -> Word32 -> ST s ()
-writeWord64Array      :: Ix ix => MutableByteArray s ix -> Int -> Word64 -> ST s ()
-writeInt8Array       :: Ix ix => MutableByteArray s ix -> Int -> Int8  -> ST s ()
-writeInt16Array       :: Ix ix => MutableByteArray s ix -> Int -> Int16 -> ST s ()
-writeInt32Array              :: Ix ix => MutableByteArray s ix -> Int -> Int32 -> ST s ()
-writeInt64Array              :: Ix ix => MutableByteArray s ix -> Int -> Int64 -> ST s ()
+writeWord8Array              :: Ix ix => MutableByteArray s ix -> ix -> Word8  -> ST s ()
+writeWord16Array      :: Ix ix => MutableByteArray s ix -> ix -> Word16 -> ST s ()
+writeWord32Array      :: Ix ix => MutableByteArray s ix -> ix -> Word32 -> ST s ()
+writeWord64Array      :: Ix ix => MutableByteArray s ix -> ix -> Word64 -> ST s ()
+writeInt8Array       :: Ix ix => MutableByteArray s ix -> ix -> Int8  -> ST s ()
+writeInt16Array       :: Ix ix => MutableByteArray s ix -> ix -> Int16 -> ST s ()
+writeInt32Array              :: Ix ix => MutableByteArray s ix -> ix -> Int32 -> ST s ()
+writeInt64Array              :: Ix ix => MutableByteArray s ix -> ix -> Int64 -> ST s ()
 
 freezeCharArray       :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix)
 freezeIntArray        :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix)
@@ -111,6 +114,9 @@ unsafeFreezeByteArray  :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix)
 
 sizeofMutableByteArray :: Ix ix => MutableByteArray s ix -> Int
 
+thawByteArray       :: Ix ix => ByteArray ixt -> ST s (MutableByteArray s ix)
+unsafeThawByteArray :: Ix ix => ByteArray ixt -> ST s (MutableByteArray s ix)
+
 </code></tscreen>
 <nidx>newCharArray</nidx>
 <nidx>newAddrArray</nidx>
@@ -150,6 +156,8 @@ sizeofMutableByteArray :: Ix ix => MutableByteArray s ix -> Int
 <nidx>freezeFloatArray</nidx>
 <nidx>freezeDoubleArray</nidx>
 <nidx>unsafeFreezeByteArray</nidx>
+<nidx>unsafeThawByteArray</nidx>
+<nidx>thawByteArray</nidx>
 
 <bf/Remarks:/
 <itemize>
@@ -192,7 +200,10 @@ into immutable byte arrays are also provided by the <tt/freeze*/
 class of actions. There's also the non-copying
 <tt/unsafeFreezeByteArray/. 
 <p>
-Thawing of byte arrays is currently not supported.
+<item>
+Operations for going the other way, where an immutable byte
+array is 'thawed' are also provided. <tt/thawByteArray/ does
+this by copying, whereas <tt/unsafeThawByteArray/ does not
 
 <item>
 The operation <tt/sizeofMutableByteArray/ returns the size of