Skip to content

Commit 776a990

Browse files
committed
Add missing module documentation files
1 parent 4b8afc8 commit 776a990

File tree

3 files changed

+174
-1
lines changed

3 files changed

+174
-1
lines changed

docs/Data.Array.ST.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
## Module Data.Array.ST
2+
3+
Helper functions for working with mutable arrays using the `ST` effect.
4+
5+
This module can be used when performance is important and mutation is a local effect.
6+
7+
#### `STArray`
8+
9+
``` purescript
10+
data STArray :: * -> * -> *
11+
```
12+
13+
A reference to a mutable array.
14+
15+
The first type parameter represents the memory region which the array belongs to.
16+
The second type parameter defines the type of elements of the mutable array.
17+
18+
The runtime representation of a value of type `STArray h a` is the same as that of `[a]`,
19+
except that mutation is allowed.
20+
21+
#### `Assoc`
22+
23+
``` purescript
24+
type Assoc a = { value :: a, index :: Int }
25+
```
26+
27+
An element and its index
28+
29+
#### `runSTArray`
30+
31+
``` purescript
32+
runSTArray :: forall a r. (forall h. Eff (st :: ST h | r) (STArray h a)) -> Eff r (Array a)
33+
```
34+
35+
Freeze a mutable array, creating an immutable array. Use this function as you would use
36+
`runST` to freeze a mutable reference.
37+
38+
The rank-2 type prevents the reference from escaping the scope of `runSTArray`.
39+
40+
#### `emptySTArray`
41+
42+
``` purescript
43+
emptySTArray :: forall a h r. Eff (st :: ST h | r) (STArray h a)
44+
```
45+
46+
Create an empty mutable array.
47+
48+
#### `thaw`
49+
50+
``` purescript
51+
thaw :: forall a h r. Array a -> Eff (st :: ST h | r) (STArray h a)
52+
```
53+
54+
Create a mutable copy of an immutable array.
55+
56+
#### `freeze`
57+
58+
``` purescript
59+
freeze :: forall a h r. STArray h a -> Eff (st :: ST h | r) (Array a)
60+
```
61+
62+
Create an immutable copy of a mutable array.
63+
64+
#### `peekSTArray`
65+
66+
``` purescript
67+
peekSTArray :: forall a h r. STArray h a -> Int -> Eff (st :: ST h | r) (Maybe a)
68+
```
69+
70+
Read the value at the specified index in a mutable array.
71+
72+
#### `pokeSTArray`
73+
74+
``` purescript
75+
pokeSTArray :: forall a h r. STArray h a -> Int -> a -> Eff (st :: ST h | r) Boolean
76+
```
77+
78+
Change the value at the specified index in a mutable array.
79+
80+
#### `pushSTArray`
81+
82+
``` purescript
83+
pushSTArray :: forall a h r. STArray h a -> a -> Eff (st :: ST h | r) Int
84+
```
85+
86+
Append an element to the end of a mutable array.
87+
88+
#### `pushAllSTArray`
89+
90+
``` purescript
91+
pushAllSTArray :: forall a h r. STArray h a -> Array a -> Eff (st :: ST h | r) Int
92+
```
93+
94+
Append the values in an immutable array to the end of a mutable array.
95+
96+
#### `spliceSTArray`
97+
98+
``` purescript
99+
spliceSTArray :: forall a h r. STArray h a -> Int -> Int -> Array a -> Eff (st :: ST h | r) (Array a)
100+
```
101+
102+
Remove and/or insert elements from/into a mutable array at the specified index.
103+
104+
#### `toAssocArray`
105+
106+
``` purescript
107+
toAssocArray :: forall a h r. STArray h a -> Eff (st :: ST h | r) (Array (Assoc a))
108+
```
109+
110+
Create an immutable copy of a mutable array, where each element
111+
is labelled with its index in the original array.
112+
113+

docs/Data.Array.Unsafe.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
## Module Data.Array.Unsafe
2+
3+
Unsafe helper functions for working with immutable arrays.
4+
5+
_Note_: these functions should be used with care, and may result in unspecified
6+
behavior, including runtime exceptions.
7+
8+
#### `unsafeIndex`
9+
10+
``` purescript
11+
unsafeIndex :: forall a. Array a -> Int -> a
12+
```
13+
14+
Find the element of an array at the specified index.
15+
16+
Note: this function can cause unpredictable failure at runtime if the index is out-of-bounds.
17+
18+
#### `head`
19+
20+
``` purescript
21+
head :: forall a. Array a -> a
22+
```
23+
24+
Get the first element of a non-empty array.
25+
26+
Running time: `O(1)`.
27+
28+
#### `tail`
29+
30+
``` purescript
31+
tail :: forall a. Array a -> Array a
32+
```
33+
34+
Get all but the first element of a non-empty array.
35+
36+
Running time: `O(n)`, where `n` is the length of the array.
37+
38+
#### `last`
39+
40+
``` purescript
41+
last :: forall a. Array a -> a
42+
```
43+
44+
Get the last element of a non-empty array.
45+
46+
Running time: `O(1)`.
47+
48+
#### `init`
49+
50+
``` purescript
51+
init :: forall a. Array a -> Array a
52+
```
53+
54+
Get all but the last element of a non-empty array.
55+
56+
Running time: `O(n)`, where `n` is the length of the array.
57+
58+

gulpfile.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ gulp.task("docs", ["clean-docs"], function () {
4747
.pipe(plumber())
4848
.pipe(purescript.pscDocs({
4949
docgen: {
50-
"Data.Array": "docs/Data.Array.md"
50+
"Data.Array": "docs/Data.Array.md",
51+
"Data.Array.ST": "docs/Data.Array.ST.md",
52+
"Data.Array.Unsafe": "docs/Data.Array.Unsafe.md"
5153
}
5254
}));
5355
});

0 commit comments

Comments
 (0)