[project @ 2000-01-05 11:06:23 by rrt]
[ghc-hetmet.git] / ghc / docs / users_guide / ByteArray.sgml
1 <Sect2 id="sec-byte-array">
2 <Title>The ByteArray
3 <IndexTerm><Primary>ByteArray</Primary></IndexTerm>
4 interface
5 </Title>
6
7 <Para>
8 <IndexTerm><Primary>ByteArray interface (GHC extensions)</Primary></IndexTerm>
9 </Para>
10
11 <Para>
12 <Literal>ByteArray</Literal>s are chunks of immutable Haskell heap:
13 </Para>
14
15 <Para>
16
17 <ProgramListing>
18 data ByteArray ix -- abstract
19                   -- instance of: Eq, CCallable.
20
21 newByteArray       :: Ix ix =&#62; (ix,ix) -&#62; ST s (ByteArray ix)
22
23 indexCharArray     :: Ix ix =&#62; ByteArray ix -&#62; ix -&#62; Char
24 indexIntArray      :: Ix ix =&#62; ByteArray ix -&#62; ix -&#62; Int
25 indexAddrArray     :: Ix ix =&#62; ByteArray ix -&#62; ix -&#62; Addr
26 indexFloatArray    :: Ix ix =&#62; ByteArray ix -&#62; ix -&#62; Float
27 indexDoubleArray   :: Ix ix =&#62; ByteArray ix -&#62; ix -&#62; Double
28
29 sizeofByteArray    :: Ix ix =&#62; ByteArray ix -&#62; Int
30 </ProgramListing>
31
32 <IndexTerm><Primary>newByteArray</Primary></IndexTerm>
33 <IndexTerm><Primary>indexCharArray</Primary></IndexTerm>
34 <IndexTerm><Primary>indexIntArray</Primary></IndexTerm>
35 <IndexTerm><Primary>indexAddrArray</Primary></IndexTerm>
36 <IndexTerm><Primary>indexFloatArray</Primary></IndexTerm>
37 <IndexTerm><Primary>indexDoubleArray</Primary></IndexTerm>
38 <IndexTerm><Primary>indexDoubleArray</Primary></IndexTerm>
39 <IndexTerm><Primary>sizeofByteArray</Primary></IndexTerm>
40 </Para>
41
42 <Para>
43 <Emphasis>Remarks:</Emphasis>
44 </Para>
45
46 <Para>
47
48 <ItemizedList>
49 <ListItem>
50
51 <Para>
52 The operation <Literal>newByteArray</Literal> creates a byte array of length
53 equal to the range of its indices <Emphasis>in bytes</Emphasis>.
54 </Para>
55 </ListItem>
56 <ListItem>
57
58 <Para>
59 <Literal>sizeofByteArray</Literal> returns the size of the byte array, <Emphasis>in bytes</Emphasis>.
60
61 </Para>
62 </ListItem>
63 <ListItem>
64
65 <Para>
66 Equality on byte arrays is value equality, not pointer equality (as is
67 the case for its mutable variant.) Two byte arrays are equal if
68 they're of the same length and they're pairwise equal.
69
70 </Para>
71 </ListItem>
72
73 </ItemizedList>
74
75 </Para>
76
77 </Sect2>