[project @ 1999-02-02 14:14:11 by sof]
[ghc-hetmet.git] / ghc / docs / users_guide / ByteArray.sgml
1 <sect2>The <idx/ByteArray/ interface
2 <label id="sec:byte-array">
3 <p>
4 <nidx>ByteArray interface (GHC extensions)</nidx>
5
6 <tt/ByteArray/s are chunks of immutable Haskell heap:
7
8 <tscreen><code>
9 data ByteArray ix -- abstract
10                   -- instance of: Eq, CCallable.
11
12 newByteArray       :: Ix ix => (ix,ix) -> ST s (ByteArray ix)
13
14 indexCharArray     :: Ix ix => ByteArray ix -> ix -> Char 
15 indexIntArray      :: Ix ix => ByteArray ix -> ix -> Int
16 indexAddrArray     :: Ix ix => ByteArray ix -> ix -> Addr
17 indexFloatArray    :: Ix ix => ByteArray ix -> ix -> Float
18 indexDoubleArray   :: Ix ix => ByteArray ix -> ix -> Double
19
20 sizeofByteArray    :: Ix ix => ByteArray ix -> Int
21 </code></tscreen>
22 <nidx/newByteArray/
23 <nidx/indexCharArray/
24 <nidx/indexIntArray/
25 <nidx/indexAddrArray/
26 <nidx/indexFloatArray/
27 <nidx/indexDoubleArray/
28 <nidx/indexDoubleArray/
29 <nidx/sizeofByteArray/
30
31 <bf/Remarks:/
32
33 <itemize>
34 <item>
35 The operation <tt/newByteArray/ creates a byte array of length
36 equal to the range of its indices <em/in bytes/.
37 <item>
38 <tt/sizeofByteArray/ returns the size of the byte array, <em/in bytes/.
39
40 <item>
41 Equality on byte arrays is value equality, not pointer equality (as is
42 the case for its mutable variant.) Two byte arrays are equal if
43 they're of the same length and they're pairwise equal.
44
45 </itemize>