@grain/stdlib 0.4.2 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/LICENSE +1 -1
  3. package/array.gr +200 -89
  4. package/array.md +81 -5
  5. package/buffer.gr +93 -36
  6. package/bytes.gr +10 -10
  7. package/char.gr +112 -56
  8. package/char.md +200 -0
  9. package/float32.gr +120 -4
  10. package/float32.md +315 -0
  11. package/float64.gr +120 -4
  12. package/float64.md +315 -0
  13. package/hash.gr +42 -15
  14. package/hash.md +44 -0
  15. package/int32.gr +370 -75
  16. package/int32.md +833 -0
  17. package/int64.gr +370 -75
  18. package/int64.md +833 -0
  19. package/list.gr +121 -50
  20. package/map.gr +106 -110
  21. package/number.gr +37 -1
  22. package/number.md +66 -0
  23. package/option.gr +260 -53
  24. package/option.md +579 -0
  25. package/package.json +1 -1
  26. package/pervasives.gr +32 -20
  27. package/queue.gr +102 -30
  28. package/queue.md +191 -0
  29. package/range.gr +26 -26
  30. package/range.md +1 -1
  31. package/regex.md +9 -9
  32. package/result.gr +216 -70
  33. package/result.md +446 -0
  34. package/runtime/dataStructures.gr +28 -29
  35. package/runtime/debug.gr +0 -1
  36. package/runtime/equal.gr +37 -16
  37. package/runtime/exception.gr +28 -15
  38. package/runtime/gc.gr +33 -20
  39. package/runtime/malloc.gr +19 -11
  40. package/runtime/numberUtils.gr +208 -103
  41. package/runtime/numbers.gr +217 -118
  42. package/runtime/string.gr +98 -39
  43. package/runtime/stringUtils.gr +176 -0
  44. package/runtime/unsafe/conv.gr +10 -10
  45. package/runtime/unsafe/memory.gr +14 -3
  46. package/runtime/unsafe/printWasm.gr +4 -4
  47. package/runtime/unsafe/tags.gr +2 -2
  48. package/runtime/unsafe/wasmf32.gr +9 -2
  49. package/runtime/unsafe/wasmf64.gr +9 -2
  50. package/runtime/unsafe/wasmi32.gr +65 -47
  51. package/runtime/unsafe/wasmi64.gr +78 -50
  52. package/runtime/wasi.gr +199 -45
  53. package/set.gr +281 -119
  54. package/set.md +502 -0
  55. package/stack.gr +26 -26
  56. package/string.gr +657 -341
  57. package/string.md +815 -0
  58. package/sys/file.gr +356 -177
  59. package/sys/process.gr +10 -6
  60. package/sys/random.gr +3 -6
  61. package/sys/time.gr +3 -3
package/array.md CHANGED
@@ -263,6 +263,27 @@ Returns:
263
263
  |----|-----------|
264
264
  |`Array<a>`|The new array containing the elements from the input|
265
265
 
266
+ ### Array.**cycle**
267
+
268
+ <details disabled>
269
+ <summary tabindex="-1">Added in <code>next</code></summary>
270
+ No other changes yet.
271
+ </details>
272
+
273
+ ```grain
274
+ cycle : ((a -> Void), Number, Array<a>) -> Void
275
+ ```
276
+
277
+ Iterates an array a given number of times, calling an iterator function on each element.
278
+
279
+ Parameters:
280
+
281
+ |param|type|description|
282
+ |-----|----|-----------|
283
+ |`fn`|`a -> Void`|The iterator function to call with each element|
284
+ |`n`|`Number`|The number of times to iterate the given array|
285
+ |`array`|`Array<a>`|The array to iterate|
286
+
266
287
  ### Array.**forEach**
267
288
 
268
289
  <details>
@@ -350,7 +371,7 @@ Returns:
350
371
 
351
372
  |type|description|
352
373
  |----|-----------|
353
- |`Array<a>`|The new array with mapped values|
374
+ |`Array<b>`|The new array with mapped values|
354
375
 
355
376
  ### Array.**mapi**
356
377
 
@@ -377,7 +398,7 @@ Returns:
377
398
 
378
399
  |type|description|
379
400
  |----|-----------|
380
- |`Array<a>`|The new array with mapped values|
401
+ |`Array<b>`|The new array with mapped values|
381
402
 
382
403
  ### Array.**reduce**
383
404
 
@@ -404,7 +425,7 @@ Parameters:
404
425
  |-----|----|-----------|
405
426
  |`fn`|`(a, b) -> a`|The reducer function to call on each element, where the value returned will be the next accumulator value|
406
427
  |`initial`|`a`|The initial value to use for the accumulator on the first iteration|
407
- |`array`|`Array<a>`|The array to iterate|
428
+ |`array`|`Array<b>`|The array to iterate|
408
429
 
409
430
  Returns:
410
431
 
@@ -444,7 +465,7 @@ Parameters:
444
465
  |-----|----|-----------|
445
466
  |`fn`|`(a, b, Number) -> a`|The reducer function to call on each element, where the value returned will be the next accumulator value|
446
467
  |`initial`|`a`|The initial value to use for the accumulator on the first iteration|
447
- |`array`|`Array<a>`|The array to iterate|
468
+ |`array`|`Array<b>`|The array to iterate|
448
469
 
449
470
  Returns:
450
471
 
@@ -479,7 +500,7 @@ Returns:
479
500
 
480
501
  |type|description|
481
502
  |----|-----------|
482
- |`Array<a>`|The new array|
503
+ |`Array<b>`|The new array|
483
504
 
484
505
  ### Array.**every**
485
506
 
@@ -1006,3 +1027,58 @@ Returns:
1006
1027
  |----|-----------|
1007
1028
  |`Array<a>`|The subset of the array that was sliced|
1008
1029
 
1030
+ ### Array.**sort**
1031
+
1032
+ <details disabled>
1033
+ <summary tabindex="-1">Added in <code>next</code></summary>
1034
+ No other changes yet.
1035
+ </details>
1036
+
1037
+ ```grain
1038
+ sort : (((a, a) -> Number), Array<a>) -> Void
1039
+ ```
1040
+
1041
+ Sorts an array in-place.
1042
+
1043
+ Ordering is calculated using a comparator function which takes two array elements and must return 0 if both are equal, a positive number if the first is greater, and a negative number if the first is smaller.
1044
+
1045
+ Parameters:
1046
+
1047
+ |param|type|description|
1048
+ |-----|----|-----------|
1049
+ |`comp`|`(a, a) -> Number`|The comparator function used to indicate sort order|
1050
+ |`array`|`Array<a>`|The array to be sorted|
1051
+
1052
+ ### Array.**rotate**
1053
+
1054
+ <details disabled>
1055
+ <summary tabindex="-1">Added in <code>next</code></summary>
1056
+ No other changes yet.
1057
+ </details>
1058
+
1059
+ ```grain
1060
+ rotate : (Number, Array<a>) -> Void
1061
+ ```
1062
+
1063
+ Rotates an array by n elements to the right, in place.
1064
+
1065
+ If n is negative, the array will be rotated by n elements
1066
+ to the left. See examples.
1067
+
1068
+ Parameters:
1069
+
1070
+ |param|type|description|
1071
+ |-----|----|-----------|
1072
+ |`n`|`Number`|The number of elements to rotate by|
1073
+ |`arr`|`Array<a>`|The array to be rotated|
1074
+
1075
+ Examples:
1076
+
1077
+ ```grain
1078
+ let array = [> 1, 2, 3, 4, 5]; rotate(2, arr); arr == [> 4, 5, 1, 2, 3]
1079
+ ```
1080
+
1081
+ ```grain
1082
+ let array = [> 1, 2, 3, 4, 5]; rotate(-1, arr); arr == [> 2, 3, 4, 5, 1]
1083
+ ```
1084
+
package/buffer.gr CHANGED
@@ -23,17 +23,17 @@ record Buffer {
23
23
  }
24
24
 
25
25
  @disableGC
26
- let mut _SIZE_OFFSET = 1n;
26
+ let mut _SIZE_OFFSET = 1n
27
27
 
28
28
  @disableGC
29
- let mut _VALUE_OFFSET = 1n;
29
+ let mut _VALUE_OFFSET = 1n
30
30
 
31
31
  @disableGC
32
32
  let initOffsets = () => {
33
- _SIZE_OFFSET = 4n;
34
- _VALUE_OFFSET = 8n;
33
+ _SIZE_OFFSET = 4n
34
+ _VALUE_OFFSET = 8n
35
35
  }
36
- initOffsets();
36
+ initOffsets()
37
37
 
38
38
  let _8BIT_LEN = 1
39
39
 
@@ -45,27 +45,28 @@ let _64BIT_LEN = 8
45
45
 
46
46
  /* Gets the size of a Bytes via its ptr */
47
47
  @disableGC
48
- let getSize = (ptr) => WasmI32.load(ptr, _SIZE_OFFSET)
48
+ let getSize = ptr => WasmI32.load(ptr, _SIZE_OFFSET)
49
49
 
50
50
  /* Doubles the size of buffer's underlying byte sequence, if the given size is larger than the size of a buffer's underlying byte sequence */
51
51
  let autogrow = (len, buf) => {
52
52
  while (buf.len + len > Bytes.length(buf.data)) {
53
53
  let mut n = Bytes.length(buf.data)
54
- if (n == 0) n = 4 // Make sure bytes of 0 length grow too
54
+ if (n == 0) n = 4
55
+ // Make sure bytes of 0 length grow too
55
56
  buf.data = Bytes.resize(0, n, buf.data)
56
57
  }
57
58
  }
58
59
 
59
60
  /* Gets the pointer for a char's bytes following the char's tag */
60
61
  @disableGC
61
- let rec getCharAsWasmI32 = (char) => {
62
+ let rec getCharAsWasmI32 = char => {
62
63
  let c = WasmI32.fromGrain(char)
63
64
  WasmI32.load(c, 4n)
64
65
  }
65
66
 
66
67
  /* Gets the UTF-8 byte length of a char */
67
68
  @disableGC
68
- let rec getCharByteLength = (byte) => {
69
+ let rec getCharByteLength = byte => {
69
70
  let (+) = WasmI32.add
70
71
  let (&) = WasmI32.and
71
72
  let (==) = WasmI32.eq
@@ -132,13 +133,10 @@ let addInt32help = (value, buffer) => {
132
133
  *
133
134
  * @since v0.4.0
134
135
  */
135
- export let make = (initialSize) => {
136
- if (initialSize < 0) throw Exception.InvalidArgument("Buffers size must be >= 0")
137
- {
138
- len: 0,
139
- initialSize,
140
- data: Bytes.make(initialSize),
141
- }
136
+ export let make = initialSize => {
137
+ if (initialSize < 0)
138
+ throw Exception.InvalidArgument("Buffers size must be >= 0")
139
+ { len: 0, initialSize, data: Bytes.make(initialSize) }
142
140
  }
143
141
 
144
142
  /**
@@ -149,7 +147,7 @@ export let make = (initialSize) => {
149
147
  *
150
148
  * @since v0.4.0
151
149
  */
152
- export let length = (buffer) => buffer.len
150
+ export let length = buffer => buffer.len
153
151
 
154
152
  /**
155
153
  * Clears data in the buffer and sets its length to zero.
@@ -160,7 +158,7 @@ export let length = (buffer) => buffer.len
160
158
  *
161
159
  * @since v0.4.0
162
160
  */
163
- export let clear = (buffer) => {
161
+ export let clear = buffer => {
164
162
  Bytes.fill(0x0l, buffer.data)
165
163
  buffer.len = 0
166
164
  }
@@ -174,7 +172,7 @@ export let clear = (buffer) => {
174
172
  *
175
173
  * @since v0.4.0
176
174
  */
177
- export let reset = (buffer) => {
175
+ export let reset = buffer => {
178
176
  buffer.data = Bytes.make(buffer.initialSize)
179
177
  buffer.len = 0
180
178
  }
@@ -192,7 +190,6 @@ export let reset = (buffer) => {
192
190
  @disableGC
193
191
  export let rec truncate = (length, buffer) => {
194
192
  Memory.incRef(WasmI32.fromGrain((<)))
195
- Memory.incRef(WasmI32.fromGrain((||)))
196
193
  Memory.incRef(WasmI32.fromGrain((>)))
197
194
  if (length < 0 || length > buffer.len) throw Exception.IndexOutOfBounds
198
195
 
@@ -217,7 +214,7 @@ export let rec truncate = (length, buffer) => {
217
214
  *
218
215
  * @since v0.4.0
219
216
  */
220
- export let toBytes = (buffer) => {
217
+ export let toBytes = buffer => {
221
218
  let len = Bytes.length(buffer.data)
222
219
  if (buffer.len == len) {
223
220
  buffer.data
@@ -249,7 +246,7 @@ export let toBytesSlice = (start, length, buffer) => {
249
246
  *
250
247
  * @since v0.4.0
251
248
  */
252
- export let toString = (buffer) => {
249
+ export let toString = buffer => {
253
250
  Bytes.toString(toBytes(buffer))
254
251
  }
255
252
 
@@ -286,6 +283,8 @@ export let rec addChar = (char: Char, buffer: Buffer) => {
286
283
  Memory.incRef(WasmI32.fromGrain(c))
287
284
  Memory.incRef(WasmI32.fromGrain(buffer))
288
285
  addInt8help(c, buffer)
286
+ Memory.decRef(WasmI32.fromGrain(c))
287
+ void
289
288
  },
290
289
  2n => {
291
290
  let c = Conv.toInt32(n)
@@ -293,6 +292,8 @@ export let rec addChar = (char: Char, buffer: Buffer) => {
293
292
  Memory.incRef(WasmI32.fromGrain(c))
294
293
  Memory.incRef(WasmI32.fromGrain(buffer))
295
294
  addInt16help(c, buffer)
295
+ Memory.decRef(WasmI32.fromGrain(c))
296
+ void
296
297
  },
297
298
  3n => {
298
299
  let (<) = WasmI32.ltU
@@ -300,12 +301,14 @@ export let rec addChar = (char: Char, buffer: Buffer) => {
300
301
  let (*) = WasmI32.mul
301
302
  let (&) = WasmI32.and
302
303
  let (>>) = WasmI32.shrU
303
- for (let mut i = 0n; i < 3n; i = i + 1n) {
304
- let c = Conv.toInt32(n >> (i * 8n) & 0xffn)
304
+ for (let mut i = 0n; i < 3n; i += 1n) {
305
+ let c = Conv.toInt32(n >> i * 8n & 0xffn)
305
306
  Memory.incRef(WasmI32.fromGrain(addInt8help))
306
307
  Memory.incRef(WasmI32.fromGrain(c))
307
308
  Memory.incRef(WasmI32.fromGrain(buffer))
308
309
  addInt8help(c, buffer)
310
+ Memory.decRef(WasmI32.fromGrain(c))
311
+ void
309
312
  }
310
313
  },
311
314
  _ => {
@@ -314,6 +317,8 @@ export let rec addChar = (char: Char, buffer: Buffer) => {
314
317
  Memory.incRef(WasmI32.fromGrain(c))
315
318
  Memory.incRef(WasmI32.fromGrain(buffer))
316
319
  addInt32help(c, buffer)
320
+ Memory.decRef(WasmI32.fromGrain(c))
321
+ void
317
322
  },
318
323
  }
319
324
 
@@ -406,28 +411,58 @@ export let rec addString = (string, buffer) => {
406
411
  * @since v0.4.0
407
412
  */
408
413
  @disableGC
409
- export let rec addStringSlice = (start, length, string, buffer) => {
410
- Memory.incRef(WasmI32.fromGrain(String.byteLength))
411
- Memory.incRef(WasmI32.fromGrain(start))
412
- Memory.incRef(WasmI32.fromGrain(length))
414
+ export let rec addStringSlice = (start: Number, length, string, buffer) => {
415
+ // Handle negative start index (needed before #1071 is fixed)
416
+ let start = {
417
+ // this is a block to avoid making all of these operators
418
+ // overriden in the whole function
419
+ let (<<) = WasmI32.shl
420
+ let (>>) = WasmI32.shrS
421
+ let (+) = WasmI32.add
422
+ let (!=) = WasmI32.ne
423
+ let (&) = WasmI32.and
424
+ Memory.incRef(WasmI32.fromGrain(String.length))
425
+ Memory.incRef(WasmI32.fromGrain(string))
426
+ let strlen = WasmI32.fromGrain(String.length(string)) >> 1n
427
+ let mut startW = WasmI32.fromGrain(start)
428
+ if ((startW & 1n) != 1n) {
429
+ throw InvalidArgument("Invalid start index")
430
+ }
431
+ startW = startW >> 1n
432
+ if (WasmI32.ltS(startW, 0n)) {
433
+ WasmI32.toGrain(WasmI32.shl(startW + strlen, 1n) + 1n)
434
+ } else {
435
+ start
436
+ }
437
+ }
438
+ let end = start + length
439
+ Memory.incRef(WasmI32.fromGrain(String.slice))
440
+ // no incref for start since we know it's a simple num. Add back for good measure after #1071 is fixed!
441
+ Memory.incRef(WasmI32.fromGrain(end))
413
442
  Memory.incRef(WasmI32.fromGrain(string))
414
- let bytelen = String.byteLength(String.slice(start, length, string))
443
+ let slice = String.slice(start, end, string)
444
+
445
+ Memory.incRef(WasmI32.fromGrain(String.byteLength))
446
+ Memory.incRef(WasmI32.fromGrain(slice))
447
+ let bytelen = String.byteLength(slice)
415
448
 
416
449
  Memory.incRef(WasmI32.fromGrain(autogrow))
417
450
  Memory.incRef(WasmI32.fromGrain(bytelen))
418
451
  Memory.incRef(WasmI32.fromGrain(buffer))
419
452
  autogrow(bytelen, buffer)
420
453
 
421
- let srcOff = coerceNumberToWasmI32(start)
454
+ let srcOff = 0n
422
455
  let dstOff = coerceNumberToWasmI32(buffer.len)
423
- let src = WasmI32.fromGrain(string)
456
+ let src = WasmI32.fromGrain(slice)
424
457
  let dst = WasmI32.fromGrain(buffer.data)
425
458
  appendBytes(srcOff, dstOff, coerceNumberToWasmI32(bytelen), src, dst)
459
+ Memory.decRef(WasmI32.fromGrain(slice))
426
460
 
427
461
  Memory.incRef(WasmI32.fromGrain((+)))
428
462
  Memory.incRef(WasmI32.fromGrain(buffer.len))
429
463
  Memory.incRef(WasmI32.fromGrain(bytelen))
430
464
  buffer.len = buffer.len + bytelen
465
+ Memory.decRef(WasmI32.fromGrain(bytelen))
431
466
 
432
467
  Memory.decRef(WasmI32.fromGrain(start))
433
468
  Memory.decRef(WasmI32.fromGrain(length))
@@ -448,17 +483,40 @@ export let rec addStringSlice = (start, length, string, buffer) => {
448
483
  * @since v0.4.0
449
484
  */
450
485
  @disableGC
451
- export let rec addBytesSlice = (start: Number, length: Number, bytes: Bytes, buffer: Buffer) => {
486
+ export let rec addBytesSlice =
487
+ (
488
+ start: Number,
489
+ length: Number,
490
+ bytes: Bytes,
491
+ buffer: Buffer,
492
+ ) => {
493
+ let (-) = WasmI32.sub
494
+ let (<) = WasmI32.ltS
495
+ let (>) = WasmI32.gtS
496
+ let (>=) = WasmI32.geS
497
+
498
+ // bounds check start
499
+ let bytelen = WasmI32.load(WasmI32.fromGrain(bytes), 4n)
500
+ let srcOff = coerceNumberToWasmI32(start)
501
+ if (srcOff < 0n || srcOff >= bytelen) {
502
+ throw Exception.IndexOutOfBounds
503
+ }
504
+
505
+ // bounds check length
506
+ let len = coerceNumberToWasmI32(length)
507
+ if (len < 0n || len > bytelen - srcOff) {
508
+ throw Exception.IndexOutOfBounds
509
+ }
510
+
452
511
  Memory.incRef(WasmI32.fromGrain(autogrow))
453
512
  Memory.incRef(WasmI32.fromGrain(length))
454
513
  Memory.incRef(WasmI32.fromGrain(buffer))
455
514
  autogrow(length, buffer)
456
515
 
457
- let srcOff = coerceNumberToWasmI32(start)
458
516
  let dstOff = coerceNumberToWasmI32(buffer.len)
459
517
  let src = WasmI32.fromGrain(bytes)
460
518
  let dst = WasmI32.fromGrain(buffer.data)
461
- appendBytes(srcOff, dstOff, coerceNumberToWasmI32(length), src, dst)
519
+ appendBytes(srcOff, dstOff, len, src, dst)
462
520
 
463
521
  Memory.incRef(WasmI32.fromGrain((+)))
464
522
  Memory.incRef(WasmI32.fromGrain(buffer.len))
@@ -507,7 +565,6 @@ export let addBufferSlice = (start, length, srcBuffer, dstBuffer) => {
507
565
  * @section Binary operations on integers: Functions for encoding and decoding integers stored in a buffer.
508
566
  */
509
567
 
510
-
511
568
  /**
512
569
  * Gets a signed 8-bit integer starting at the given byte index.
513
570
  *
@@ -783,4 +840,4 @@ export let addFloat64 = (value, buffer) => {
783
840
  let index = buffer.len
784
841
  buffer.len = buffer.len + _64BIT_LEN
785
842
  setFloat64(index, value, buffer)
786
- }
843
+ }
package/bytes.gr CHANGED
@@ -15,7 +15,7 @@ import Conv from "runtime/unsafe/conv"
15
15
  import {
16
16
  tagSimpleNumber,
17
17
  allocateBytes,
18
- allocateString
18
+ allocateString,
19
19
  } from "runtime/dataStructures"
20
20
  import Exception from "runtime/exception"
21
21
  import Int32 from "int32"
@@ -85,7 +85,7 @@ let getSize = ptr => WasmI32.load(ptr, _SIZE_OFFSET)
85
85
  @disableGC
86
86
  export let rec make = (size: Number) => {
87
87
  let bytes = allocateBytes(coerceNumberToWasmI32(size))
88
- let ret = WasmI32.toGrain(bytes): (Bytes)
88
+ let ret = WasmI32.toGrain(bytes): Bytes
89
89
  Memory.decRef(WasmI32.fromGrain(size))
90
90
  Memory.decRef(WasmI32.fromGrain(make))
91
91
  ret
@@ -113,7 +113,7 @@ export let rec fromString = (string: String) => {
113
113
  let size = getSize(src)
114
114
  let dst = allocateBytes(size)
115
115
  Memory.copy(dst + _VALUE_OFFSET, src + _VALUE_OFFSET, size)
116
- let ret = WasmI32.toGrain(dst): (Bytes)
116
+ let ret = WasmI32.toGrain(dst): Bytes
117
117
  Memory.decRef(WasmI32.fromGrain(string))
118
118
  Memory.decRef(WasmI32.fromGrain(fromString))
119
119
  ret
@@ -134,7 +134,7 @@ export let rec toString = (bytes: Bytes) => {
134
134
  let size = getSize(src)
135
135
  let dst = allocateString(size)
136
136
  Memory.copy(dst + _VALUE_OFFSET, src + _VALUE_OFFSET, size)
137
- let ret = WasmI32.toGrain(dst): (String)
137
+ let ret = WasmI32.toGrain(dst): String
138
138
  Memory.decRef(WasmI32.fromGrain(bytes))
139
139
  Memory.decRef(WasmI32.fromGrain(toString))
140
140
  ret
@@ -172,7 +172,7 @@ export let rec copy = (b: Bytes) => {
172
172
  let size = getSize(src)
173
173
  let dst = allocateBytes(size)
174
174
  Memory.copy(dst + _VALUE_OFFSET, src + _VALUE_OFFSET, size)
175
- let ret = WasmI32.toGrain(dst): (Bytes)
175
+ let ret = WasmI32.toGrain(dst): Bytes
176
176
  Memory.decRef(WasmI32.fromGrain(b))
177
177
  Memory.decRef(WasmI32.fromGrain(copy))
178
178
  ret
@@ -200,13 +200,13 @@ export let rec slice = (start: Number, length: Number, bytes: Bytes) => {
200
200
  let length = coerceNumberToWasmI32(length)
201
201
  if (start + length > size) {
202
202
  throw Exception.InvalidArgument(
203
- "The given index and length do not specify a valid range of bytes",
203
+ "The given index and length do not specify a valid range of bytes"
204
204
  )
205
205
  }
206
206
  let dst = allocateBytes(length)
207
207
  let offset = start
208
208
  Memory.copy(dst + _VALUE_OFFSET, src + _VALUE_OFFSET + start, length)
209
- let ret = WasmI32.toGrain(dst): (Bytes)
209
+ let ret = WasmI32.toGrain(dst): Bytes
210
210
  Memory.decRef(WasmI32.fromGrain(iOrig))
211
211
  Memory.decRef(WasmI32.fromGrain(lenOrig))
212
212
  Memory.decRef(WasmI32.fromGrain(bytes))
@@ -263,10 +263,10 @@ export let rec resize = (left: Number, right: Number, bytes: Bytes) => {
263
263
  Memory.copy(
264
264
  dst + _VALUE_OFFSET + dstOffset,
265
265
  src + _VALUE_OFFSET + srcOffset,
266
- len,
266
+ len
267
267
  )
268
268
  }
269
- let ret = WasmI32.toGrain(dst): (Bytes)
269
+ let ret = WasmI32.toGrain(dst): Bytes
270
270
  Memory.decRef(WasmI32.fromGrain(leftOrig))
271
271
  Memory.decRef(WasmI32.fromGrain(rightOrig))
272
272
  Memory.decRef(WasmI32.fromGrain(bytes))
@@ -317,7 +317,7 @@ export let rec move =
317
317
  let ret = Memory.copy(
318
318
  dst + _VALUE_OFFSET + dstIndex,
319
319
  src + _VALUE_OFFSET + srcIndex,
320
- length,
320
+ length
321
321
  )
322
322
 
323
323
  Memory.decRef(WasmI32.fromGrain(srcIndexOrig))