Skip to content

Commit 9d98a21

Browse files
committed
Updates for Int, etc
1 parent 7d21191 commit 9d98a21

File tree

5 files changed

+280
-277
lines changed

5 files changed

+280
-277
lines changed

README.md

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@ for many use cases due to their poor asymptotics.
1414
#### `(!!)`
1515

1616
``` purescript
17-
(!!) :: forall a. [a] -> Number -> Maybe a
17+
(!!) :: forall a. [a] -> Int -> Maybe a
1818
```
1919

20-
This operator provides a safe way to read a value at a particular index from an array.
21-
22-
This function returns `Nothing` if the index is out-of-bounds.
23-
24-
`Data.Array.Unsafe` provides the `unsafeIndex` function, which is an unsafe version of
25-
this function without bounds checking.
20+
This operator provides a safe way to read a value at a particular index
21+
from an array.
2622

2723
#### `snoc`
2824

@@ -91,62 +87,58 @@ Test whether an array is empty.
9187
#### `length`
9288

9389
``` purescript
94-
length :: forall a. [a] -> Number
90+
length :: forall a. [a] -> Int
9591
```
9692

97-
Get the number of elements in an array
93+
Get the number of elements in an array.
9894

9995
#### `findIndex`
10096

10197
``` purescript
102-
findIndex :: forall a. (a -> Boolean) -> [a] -> Number
98+
findIndex :: forall a. (a -> Boolean) -> [a] -> Maybe Int
10399
```
104100

105-
Find the first index for which a predicate holds,
106-
or `-1` if no such element exists
101+
Find the first index for which a predicate holds.
107102

108103
#### `findLastIndex`
109104

110105
``` purescript
111-
findLastIndex :: forall a. (a -> Boolean) -> [a] -> Number
106+
findLastIndex :: forall a. (a -> Boolean) -> [a] -> Maybe Int
112107
```
113108

114-
Find the last index for which a predicate holds,
115-
or `-1` if no such element exists
109+
Find the last index for which a predicate holds.
116110

117111
#### `elemIndex`
118112

119113
``` purescript
120-
elemIndex :: forall a. (Eq a) => a -> [a] -> Number
114+
elemIndex :: forall a. (Eq a) => a -> [a] -> Maybe Int
121115
```
122116

123-
Find the index of the first element equal to the specified element,
124-
or `-1` if no such element exists
117+
Find the index of the first element equal to the specified element.
125118

126119
#### `elemLastIndex`
127120

128121
``` purescript
129-
elemLastIndex :: forall a. (Eq a) => a -> [a] -> Number
122+
elemLastIndex :: forall a. (Eq a) => a -> [a] -> Maybe Int
130123
```
131124

132-
Find the index of the last element equal to the specified element,
133-
or `-1` if no such element exists
125+
Find the index of the last element equal to the specified element.
134126

135127
#### `append`
136128

137129
``` purescript
138130
append :: forall a. [a] -> [a] -> [a]
139131
```
140132

141-
Concatenate two arrays, creating a new array
133+
Concatenate two arrays, creating a new array.
142134

143135
#### `concat`
144136

145137
``` purescript
146138
concat :: forall a. [[a]] -> [a]
147139
```
148140

149-
Flatten an array of arrays, creating a new array
141+
Flatten an array of arrays, creating a new array.
150142

151143
#### `reverse`
152144

@@ -159,47 +151,47 @@ Reverse an array, creating a copy
159151
#### `drop`
160152

161153
``` purescript
162-
drop :: forall a. Number -> [a] -> [a]
154+
drop :: forall a. Int -> [a] -> [a]
163155
```
164156

165157
Drop a number of elements from the start of an array, creating a new array.
166158

167159
#### `take`
168160

169161
``` purescript
170-
take :: forall a. Number -> [a] -> [a]
162+
take :: forall a. Int -> [a] -> [a]
171163
```
172164

173165
Keep only a number of elements from the start of an array, creating a new array.
174166

175167
#### `insertAt`
176168

177169
``` purescript
178-
insertAt :: forall a. Number -> a -> [a] -> [a]
170+
insertAt :: forall a. Int -> a -> [a] -> [a]
179171
```
180172

181173
Insert an element at the specified index, creating a new array.
182174

183175
#### `deleteAt`
184176

185177
``` purescript
186-
deleteAt :: forall a. Number -> Number -> [a] -> [a]
178+
deleteAt :: forall a. Int -> Int -> [a] -> [a]
187179
```
188180

189181
Delete the element at the specified index, creating a new array.
190182

191183
#### `updateAt`
192184

193185
``` purescript
194-
updateAt :: forall a. Number -> a -> [a] -> [a]
186+
updateAt :: forall a. Int -> a -> [a] -> [a]
195187
```
196188

197189
Change the element at the specified index, creating a new array.
198190

199191
#### `modifyAt`
200192

201193
``` purescript
202-
modifyAt :: forall a. Number -> (a -> a) -> [a] -> [a]
194+
modifyAt :: forall a. Int -> (a -> a) -> [a] -> [a]
203195
```
204196

205197
Apply a function to the element at the specified index, creating a new array.
@@ -434,7 +426,7 @@ creating a new array.
434426
#### `replicate`
435427

436428
``` purescript
437-
replicate :: forall a. Number -> a -> [a]
429+
replicate :: forall a. Int -> a -> [a]
438430
```
439431

440432
Create an array with repeated instances of a value.
@@ -534,7 +526,7 @@ except that mutation is allowed.
534526
#### `Assoc`
535527

536528
``` purescript
537-
type Assoc a = { index :: Number, value :: a }
529+
type Assoc a = { index :: Int, value :: a }
538530
```
539531

540532
An element and its index
@@ -561,39 +553,39 @@ Create an empty mutable array.
561553
#### `peekSTArray`
562554

563555
``` purescript
564-
peekSTArray :: forall a h r. STArray h a -> Number -> Eff (st :: ST h | r) (Maybe a)
556+
peekSTArray :: forall a h r. STArray h a -> Int -> Eff (st :: ST h | r) (Maybe a)
565557
```
566558

567559
Read the value at the specified index in a mutable array.
568560

569561
#### `pokeSTArray`
570562

571563
``` purescript
572-
pokeSTArray :: forall a h r. STArray h a -> Number -> a -> Eff (st :: ST h | r) Boolean
564+
pokeSTArray :: forall a h r. STArray h a -> Int -> a -> Eff (st :: ST h | r) Boolean
573565
```
574566

575567
Change the value at the specified index in a mutable array.
576568

577569
#### `pushAllSTArray`
578570

579571
``` purescript
580-
pushAllSTArray :: forall a h r. STArray h a -> [a] -> Eff (st :: ST h | r) Number
572+
pushAllSTArray :: forall a h r. STArray h a -> [a] -> Eff (st :: ST h | r) Int
581573
```
582574

583575
Append the values in an immutable array to the end of a mutable array.
584576

585577
#### `pushSTArray`
586578

587579
``` purescript
588-
pushSTArray :: forall a h r. STArray h a -> a -> Eff (st :: ST h | r) Number
580+
pushSTArray :: forall a h r. STArray h a -> a -> Eff (st :: ST h | r) Int
589581
```
590582

591583
Append an element to the end of a mutable array.
592584

593585
#### `spliceSTArray`
594586

595587
``` purescript
596-
spliceSTArray :: forall a h r. STArray h a -> Number -> Number -> [a] -> Eff (st :: ST h | r) [a]
588+
spliceSTArray :: forall a h r. STArray h a -> Int -> Int -> [a] -> Eff (st :: ST h | r) [a]
597589
```
598590

599591
Remove and/or insert elements from/into a mutable array at the specified index.
@@ -670,7 +662,4 @@ init :: forall a. [a] -> [a]
670662

671663
Get all but the last element of a non-empty array.
672664

673-
Running time: `O(n)`, where `n` is the length of the array.
674-
675-
676-
665+
Running time: `O(n)`, where `n` is the length of the array.

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
],
2020
"dependencies": {
2121
"purescript-maybe": "~0.2.0",
22-
"purescript-control": "~0.2.0"
22+
"purescript-control": "~0.2.0",
23+
"purescript-integers": "~0.1.0"
2324
}
2425
}

0 commit comments

Comments
 (0)