@grain/stdlib 0.6.6 → 0.7.0

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 (137) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/LICENSE +1 -1
  3. package/README.md +2 -2
  4. package/array.gr +55 -7
  5. package/array.md +123 -77
  6. package/bigint.md +30 -30
  7. package/buffer.gr +20 -53
  8. package/buffer.md +47 -47
  9. package/bytes.gr +111 -35
  10. package/bytes.md +111 -32
  11. package/char.gr +201 -99
  12. package/char.md +361 -34
  13. package/exception.gr +11 -11
  14. package/exception.md +26 -1
  15. package/float32.gr +327 -3
  16. package/float32.md +606 -19
  17. package/float64.gr +320 -3
  18. package/float64.md +606 -19
  19. package/fs.gr +1082 -0
  20. package/fs.md +630 -0
  21. package/hash.gr +142 -88
  22. package/hash.md +102 -14
  23. package/int16.md +23 -23
  24. package/int32.gr +25 -4
  25. package/int32.md +65 -30
  26. package/int64.gr +26 -1
  27. package/int64.md +65 -30
  28. package/int8.md +23 -23
  29. package/json.gr +366 -51
  30. package/json.md +418 -2
  31. package/list.gr +328 -31
  32. package/list.md +492 -69
  33. package/map.gr +20 -12
  34. package/map.md +44 -38
  35. package/marshal.gr +41 -40
  36. package/marshal.md +2 -2
  37. package/number.gr +159 -30
  38. package/number.md +215 -38
  39. package/option.md +21 -21
  40. package/package.json +5 -3
  41. package/path.gr +48 -0
  42. package/path.md +103 -12
  43. package/pervasives.gr +2 -2
  44. package/pervasives.md +37 -37
  45. package/priorityqueue.gr +7 -7
  46. package/priorityqueue.md +19 -19
  47. package/queue.gr +183 -29
  48. package/queue.md +296 -40
  49. package/random.md +6 -6
  50. package/range.gr +4 -4
  51. package/range.md +6 -6
  52. package/rational.md +16 -16
  53. package/regex.gr +52 -51
  54. package/regex.md +11 -11
  55. package/result.md +16 -16
  56. package/runtime/atof/common.md +39 -39
  57. package/runtime/atof/decimal.gr +6 -6
  58. package/runtime/atof/decimal.md +8 -8
  59. package/runtime/atof/lemire.gr +5 -5
  60. package/runtime/atof/lemire.md +1 -1
  61. package/runtime/atof/parse.gr +16 -16
  62. package/runtime/atof/parse.md +2 -2
  63. package/runtime/atof/slow.md +1 -1
  64. package/runtime/atof/table.md +2 -2
  65. package/runtime/atoi/parse.gr +3 -3
  66. package/runtime/atoi/parse.md +1 -1
  67. package/runtime/bigint.gr +15 -47
  68. package/runtime/bigint.md +54 -60
  69. package/runtime/compare.gr +2 -2
  70. package/runtime/compare.md +1 -1
  71. package/runtime/dataStructures.md +33 -33
  72. package/runtime/debugPrint.gr +4 -1
  73. package/runtime/debugPrint.md +9 -9
  74. package/runtime/equal.gr +99 -77
  75. package/runtime/equal.md +1 -1
  76. package/runtime/exception.gr +62 -82
  77. package/runtime/exception.md +62 -11
  78. package/runtime/gc.gr +39 -45
  79. package/runtime/gc.md +4 -4
  80. package/runtime/malloc.gr +7 -7
  81. package/runtime/malloc.md +4 -4
  82. package/runtime/math/kernel/cos.gr +70 -0
  83. package/runtime/math/kernel/cos.md +14 -0
  84. package/runtime/math/kernel/sin.gr +65 -0
  85. package/runtime/math/kernel/sin.md +14 -0
  86. package/runtime/math/kernel/tan.gr +136 -0
  87. package/runtime/math/kernel/tan.md +14 -0
  88. package/runtime/math/rempio2.gr +244 -0
  89. package/runtime/math/rempio2.md +14 -0
  90. package/runtime/math/trig.gr +130 -0
  91. package/runtime/math/trig.md +28 -0
  92. package/runtime/math/umuldi.gr +26 -0
  93. package/runtime/math/umuldi.md +14 -0
  94. package/runtime/numberUtils.gr +29 -29
  95. package/runtime/numberUtils.md +12 -12
  96. package/runtime/numbers.gr +373 -381
  97. package/runtime/numbers.md +79 -73
  98. package/runtime/string.gr +37 -105
  99. package/runtime/string.md +3 -9
  100. package/runtime/unsafe/constants.md +24 -24
  101. package/runtime/unsafe/conv.md +13 -13
  102. package/runtime/unsafe/memory.gr +24 -20
  103. package/runtime/unsafe/memory.md +27 -7
  104. package/runtime/unsafe/offsets.gr +36 -0
  105. package/runtime/unsafe/offsets.md +88 -0
  106. package/runtime/unsafe/panic.gr +28 -0
  107. package/runtime/unsafe/panic.md +14 -0
  108. package/runtime/unsafe/tags.md +32 -32
  109. package/runtime/unsafe/wasmf32.md +28 -28
  110. package/runtime/unsafe/wasmf64.md +28 -28
  111. package/runtime/unsafe/wasmi32.md +47 -47
  112. package/runtime/unsafe/wasmi64.md +50 -50
  113. package/runtime/utf8.gr +189 -0
  114. package/runtime/utf8.md +117 -0
  115. package/runtime/wasi.gr +4 -2
  116. package/runtime/wasi.md +138 -138
  117. package/set.gr +18 -11
  118. package/set.md +42 -36
  119. package/stack.gr +171 -2
  120. package/stack.md +297 -15
  121. package/string.gr +352 -557
  122. package/string.md +77 -34
  123. package/uint16.md +22 -22
  124. package/uint32.gr +25 -4
  125. package/uint32.md +63 -28
  126. package/uint64.gr +25 -5
  127. package/uint64.md +63 -28
  128. package/uint8.md +22 -22
  129. package/uri.gr +57 -53
  130. package/uri.md +11 -12
  131. package/wasi/file.gr +67 -59
  132. package/wasi/file.md +39 -39
  133. package/wasi/process.md +5 -5
  134. package/wasi/random.md +3 -3
  135. package/wasi/time.md +4 -4
  136. package/runtime/utils/printing.gr +0 -60
  137. package/runtime/utils/printing.md +0 -26
package/fs.md ADDED
@@ -0,0 +1,630 @@
1
+ ---
2
+ title: Fs
3
+ ---
4
+
5
+ Utilities for high-level file system interactions. Utilizes WASI Preview 1 for underlying API
6
+
7
+ <details disabled>
8
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
9
+ No other changes yet.
10
+ </details>
11
+
12
+ ```grain
13
+ from "fs" include Fs
14
+ ```
15
+
16
+ ```grain
17
+ Fs.Utf8.readFile(Path.fromString("baz.txt"))
18
+ ```
19
+
20
+ ```grain
21
+ Fs.Utf8.writeFile(Path.fromString("baz.txt"), "Hello World\n")
22
+ ```
23
+
24
+ ```grain
25
+ Fs.copy(Path.fromString("foo.txt"), Path.fromString("foocopy.txt"))
26
+ ```
27
+
28
+ ## Types
29
+
30
+ Type declarations included in the Fs module.
31
+
32
+ ### Fs.**FileError**
33
+
34
+ ```grain
35
+ enum FileError {
36
+ NoPreopenedDirectories,
37
+ PermissionDenied,
38
+ AddressInUse,
39
+ AddressNotAvailable,
40
+ AddressFamilyNotSupported,
41
+ ResourceUnavailableOrOperationWouldBlock,
42
+ ConnectionAlreadyInProgress,
43
+ BadFileDescriptor,
44
+ BadMessage,
45
+ DeviceOrResourceBusy,
46
+ OperationCanceled,
47
+ NoChildProcesses,
48
+ ConnectionAborted,
49
+ ConnectionRefused,
50
+ ConnectionReset,
51
+ ResourceDeadlockWouldOccur,
52
+ DestinationAddressRequired,
53
+ MathematicsArgumentOutOfDomainOfFunction,
54
+ FileExists,
55
+ BadAddress,
56
+ FileTooLarge,
57
+ HostIsUnreachable,
58
+ IdentifierRemoved,
59
+ IllegalByteSequence,
60
+ OperationInProgress,
61
+ InterruptedFunction,
62
+ InvalidArgument,
63
+ IOError,
64
+ SocketIsConnected,
65
+ IsADirectory,
66
+ TooManyLevelsOfSymbolicLinks,
67
+ FileDescriptorValueTooLarge,
68
+ TooManyLinks,
69
+ MessageTooLarge,
70
+ FilenameTooLong,
71
+ NetworkIsDown,
72
+ ConnectionAbortedByNetwork,
73
+ NetworkUnreachable,
74
+ TooManyFilesOpenInSystem,
75
+ NoBufferSpaceAvailable,
76
+ NoSuchDevice,
77
+ NoSuchFileOrDirectory,
78
+ ExecutableFileFormatError,
79
+ NoLocksAvailable,
80
+ NotEnoughSpace,
81
+ NoMessageOfTheDesiredType,
82
+ ProtocolNotAvailable,
83
+ NoSpaceLeftOnDevice,
84
+ FunctionNotSupported,
85
+ TheSocketIsNotConnected,
86
+ NotADirectoryOrASymbolicLinkToADirectory,
87
+ DirectoryNotEmpty,
88
+ StateNotRecoverable,
89
+ NotASocket,
90
+ NotSupportedOrOperationNotSupportedOnSocket,
91
+ InappropriateIOControlOperation,
92
+ NoSuchDeviceOrAddress,
93
+ ValueTooLargeToBeStoredInDataType,
94
+ PreviousOwnerDied,
95
+ OperationNotPermitted,
96
+ BrokenPipe,
97
+ ProtocolError,
98
+ ProtocolNotSupported,
99
+ ProtocolWrongTypeForSocket,
100
+ ResultTooLarge,
101
+ ReadOnlyFileSystem,
102
+ InvalidSeek,
103
+ NoSuchProcess,
104
+ ConnectionTimedOut,
105
+ TextFileBusy,
106
+ CrossDeviceLink,
107
+ ExtensionCapabilitiesInsufficient,
108
+ UnknownFileError(Number),
109
+ }
110
+ ```
111
+
112
+ Potential errors that can be raised from system interactions.
113
+
114
+ ### Fs.**SpecialFileType**
115
+
116
+ ```grain
117
+ enum SpecialFileType {
118
+ Unknown,
119
+ BlockDevice,
120
+ CharacterDevice,
121
+ SocketDatagram,
122
+ SocketStream,
123
+ }
124
+ ```
125
+
126
+ Represents non-standard system file types.
127
+
128
+ ### Fs.**FileType**
129
+
130
+ ```grain
131
+ enum FileType {
132
+ File,
133
+ Directory,
134
+ SymbolicLink,
135
+ Special(SpecialFileType),
136
+ }
137
+ ```
138
+
139
+ Represents different system file types.
140
+
141
+ ### Fs.**Stats**
142
+
143
+ ```grain
144
+ record Stats {
145
+ fileType: FileType,
146
+ size: Number,
147
+ accessedTimestamp: Number,
148
+ modifiedTimestamp: Number,
149
+ changedTimestamp: Number,
150
+ }
151
+ ```
152
+
153
+ Represents metadata about a file.
154
+
155
+ Fields:
156
+
157
+ |name|type|description|
158
+ |----|----|-----------|
159
+ |`fileType`|`FileType`||
160
+ |`size`|`Number`|File size in bytes|
161
+ |`accessedTimestamp`|`Number`|Last accessed timestamp in nanoseconds|
162
+ |`modifiedTimestamp`|`Number`|Last modified timestamp in nanoseconds|
163
+ |`changedTimestamp`|`Number`|Last file status change timestamp in nanoseconds|
164
+
165
+ ### Fs.**DirectoryEntry**
166
+
167
+ ```grain
168
+ record DirectoryEntry {
169
+ name: String,
170
+ fileType: FileType,
171
+ }
172
+ ```
173
+
174
+ Represents information about an item in a directory.
175
+
176
+ ### Fs.**RemoveMode**
177
+
178
+ ```grain
179
+ enum RemoveMode {
180
+ RemoveFile,
181
+ RemoveEmptyDirectory,
182
+ RemoveRecursive,
183
+ }
184
+ ```
185
+
186
+ The type of removal operation to perform when calling `remove`.
187
+
188
+ ### Fs.**CopyMode**
189
+
190
+ ```grain
191
+ enum CopyMode {
192
+ CopyFile,
193
+ CopyRecursive,
194
+ }
195
+ ```
196
+
197
+ The type of copy operation to perform when calling `copy`.
198
+
199
+ ### Fs.**WriteMode**
200
+
201
+ ```grain
202
+ enum WriteMode {
203
+ Truncate,
204
+ Append,
205
+ }
206
+ ```
207
+
208
+ The type of write operation to perform when calling `writeFile`.
209
+
210
+ ## Values
211
+
212
+ Functions and constants included in the Fs module.
213
+
214
+ ### Fs.**remove**
215
+
216
+ <details disabled>
217
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
218
+ No other changes yet.
219
+ </details>
220
+
221
+ ```grain
222
+ remove:
223
+ (?removeMode: RemoveMode, ?baseDirPath: Option<Path.Path>, path: Path.Path) =>
224
+ Result<Void, FileError>
225
+ ```
226
+
227
+ Removes a file or directory.
228
+
229
+ Parameters:
230
+
231
+ |param|type|description|
232
+ |-----|----|-----------|
233
+ |`?removeMode`|`RemoveMode`|The type of removal to perform; `RemoveFile` by default|
234
+ |`?baseDirPath`|`Option<Path.Path>`|The path to the directory in which path resolution starts|
235
+ |`path`|`Path.Path`|The path of the file or directory to remove|
236
+
237
+ Returns:
238
+
239
+ |type|description|
240
+ |----|-----------|
241
+ |`Result<Void, FileError>`|`Ok(void)` if the operation succeeds, `Err(err)` if a file system error is encountered|
242
+
243
+ Examples:
244
+
245
+ ```grain
246
+ Fs.remove(Path.fromString("file.txt")) // removes a file
247
+ ```
248
+
249
+ ```grain
250
+ Fs.remove(removeMode=Fs.RemoveEmptyDirectory, Path.fromString("dir")) // removes an empty directory
251
+ ```
252
+
253
+ ```grain
254
+ Fs.remove(removeMode=Fs.RemoveRecursive, Path.fromString("dir")) // removes the directory and its contents
255
+ ```
256
+
257
+ ### Fs.**readDir**
258
+
259
+ <details disabled>
260
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
261
+ No other changes yet.
262
+ </details>
263
+
264
+ ```grain
265
+ readDir:
266
+ (?baseDirPath: Option<Path.Path>, path: Path.Path) =>
267
+ Result<List<DirectoryEntry>, FileError>
268
+ ```
269
+
270
+ Reads the contents of a directory.
271
+
272
+ Parameters:
273
+
274
+ |param|type|description|
275
+ |-----|----|-----------|
276
+ |`?baseDirPath`|`Option<Path.Path>`|The path to the directory in which resolution should begin|
277
+ |`path`|`Path.Path`|The path to the directory to read|
278
+
279
+ Returns:
280
+
281
+ |type|description|
282
+ |----|-----------|
283
+ |`Result<List<DirectoryEntry>, FileError>`|`Ok(contents)` containing the directory contents or `Err(err)` if a file system error is encountered|
284
+
285
+ ### Fs.**createDir**
286
+
287
+ <details disabled>
288
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
289
+ No other changes yet.
290
+ </details>
291
+
292
+ ```grain
293
+ createDir:
294
+ (?baseDirPath: Option<Path.Path>, path: Path.Path) =>
295
+ Result<Void, FileError>
296
+ ```
297
+
298
+ Creates a new empty directory at the given path.
299
+
300
+ Parameters:
301
+
302
+ |param|type|description|
303
+ |-----|----|-----------|
304
+ |`?baseDirPath`|`Option<Path.Path>`|The path to the directory in which resolution should begin|
305
+ |`path`|`Path.Path`|The path to create the new directory, relative to the base directory|
306
+
307
+ Returns:
308
+
309
+ |type|description|
310
+ |----|-----------|
311
+ |`Result<Void, FileError>`|`Ok(void)` if the operation succeeds, `Err(err)` if a file system error is encountered|
312
+
313
+ ### Fs.**createSymlink**
314
+
315
+ <details disabled>
316
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
317
+ No other changes yet.
318
+ </details>
319
+
320
+ ```grain
321
+ createSymlink:
322
+ (linkContents: Path.Path, ?targetBaseDirPath: Option<Path.Path>,
323
+ targetPath: Path.Path) => Result<Void, FileError>
324
+ ```
325
+
326
+ Creates a new symbolic link with the given contents.
327
+
328
+ Parameters:
329
+
330
+ |param|type|description|
331
+ |-----|----|-----------|
332
+ |`linkContents`|`Path.Path`|The path to store into the link|
333
+ |`?targetBaseDirPath`|`Option<Path.Path>`|The path to the directory in which the target path resolution starts|
334
+ |`targetPath`|`Path.Path`|The path to the target of the link|
335
+
336
+ Returns:
337
+
338
+ |type|description|
339
+ |----|-----------|
340
+ |`Result<Void, FileError>`|`Ok(void)` if the operation succeeds, `Err(err)` if a file system error or relativization error is encountered|
341
+
342
+ ### Fs.**stats**
343
+
344
+ <details disabled>
345
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
346
+ No other changes yet.
347
+ </details>
348
+
349
+ ```grain
350
+ stats:
351
+ (?followSymlink: Bool, ?baseDirPath: Option<Path.Path>, path: Path.Path) =>
352
+ Result<Stats, FileError>
353
+ ```
354
+
355
+ Queries information about a file.
356
+
357
+ Parameters:
358
+
359
+ |param|type|description|
360
+ |-----|----|-----------|
361
+ |`?followSymlink`|`Bool`|Whether to follow symlinks or not; if `true` then the stats of a valid symlink's underlying file will be returned. `true` by default|
362
+ |`?baseDirPath`|`Option<Path.Path>`|The path to the directory in which the path resolution starts|
363
+ |`path`|`Path.Path`|The path of the file to query|
364
+
365
+ Returns:
366
+
367
+ |type|description|
368
+ |----|-----------|
369
+ |`Result<Stats, FileError>`|`Ok(stats)` containing metadata or `Err(err)` if a file system error is encountered|
370
+
371
+ ### Fs.**exists**
372
+
373
+ <details disabled>
374
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
375
+ No other changes yet.
376
+ </details>
377
+
378
+ ```grain
379
+ exists: (?baseDirPath: Option<Path.Path>, path: Path.Path) => Bool
380
+ ```
381
+
382
+ Polls whether or not a file or directory exists at the given path.
383
+
384
+ Parameters:
385
+
386
+ |param|type|description|
387
+ |-----|----|-----------|
388
+ |`?baseDirPath`|`Option<Path.Path>`|The path to the directory in which the path resolution starts|
389
+ |`path`|`Path.Path`|The path of the file to query|
390
+
391
+ Returns:
392
+
393
+ |type|description|
394
+ |----|-----------|
395
+ |`Bool`|`true` if a file or directory exists at the path or `false` otherwise|
396
+
397
+ ### Fs.**readLink**
398
+
399
+ <details disabled>
400
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
401
+ No other changes yet.
402
+ </details>
403
+
404
+ ```grain
405
+ readLink:
406
+ (?baseDirPath: Option<Path.Path>, path: Path.Path) =>
407
+ Result<Path.Path, FileError>
408
+ ```
409
+
410
+ Reads the contents of a symbolic link.
411
+
412
+ Parameters:
413
+
414
+ |param|type|description|
415
+ |-----|----|-----------|
416
+ |`?baseDirPath`|`Option<Path.Path>`|The path to the directory to begin path resolution|
417
+ |`path`|`Path.Path`|The path to the link to read|
418
+
419
+ Returns:
420
+
421
+ |type|description|
422
+ |----|-----------|
423
+ |`Result<Path.Path, FileError>`|`Ok(path)` containing the link contents or `Err(err)` if a file system error is encountered|
424
+
425
+ ### Fs.**copy**
426
+
427
+ ```grain
428
+ copy:
429
+ (?copyMode: CopyMode, ?followSymlink: Bool,
430
+ ?sourceBaseDirPath: Option<Path.Path>, sourcePath: Path.Path,
431
+ ?targetBaseDirPath: Option<Path.Path>, targetPath: Path.Path) =>
432
+ Result<Void, FileError>
433
+ ```
434
+
435
+ Copies a file or directory.
436
+
437
+ Parameters:
438
+
439
+ |param|type|description|
440
+ |-----|----|-----------|
441
+ |`?copyMode`|`CopyMode`|The type of copy to perform; `CopyFile` by default|
442
+ |`?followSymlink`|`Bool`|Whether to follow symlinks or not; if `true` then the stats of a valid symlink's underlying file will be returned. `true` by default|
443
+ |`?sourceBaseDirPath`|`Option<Path.Path>`|The path to the directory in which the source path resolution starts|
444
+ |`sourcePath`|`Path.Path`|The path of the file or directory to copy|
445
+ |`?targetBaseDirPath`|`Option<Path.Path>`|The path to the directory in which the target path resolution starts|
446
+ |`targetPath`|`Path.Path`|The path to copy the file or directory to|
447
+
448
+ Returns:
449
+
450
+ |type|description|
451
+ |----|-----------|
452
+ |`Result<Void, FileError>`|`Ok(void)` if the operation succeeds, `Err(err)` if a file system error is encountered|
453
+
454
+ ### Fs.**rename**
455
+
456
+ <details disabled>
457
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
458
+ No other changes yet.
459
+ </details>
460
+
461
+ ```grain
462
+ rename:
463
+ (?sourceBaseDirPath: Option<Path.Path>, sourcePath: Path.Path,
464
+ ?targetBaseDirPath: Option<Path.Path>, targetPath: Path.Path) =>
465
+ Result<Void, FileError>
466
+ ```
467
+
468
+ Renames a file or directory.
469
+
470
+ Parameters:
471
+
472
+ |param|type|description|
473
+ |-----|----|-----------|
474
+ |`?sourceBaseDirPath`|`Option<Path.Path>`|The path to the directory in which the source path resolution starts|
475
+ |`sourcePath`|`Path.Path`|The path of the file to rename|
476
+ |`?targetBaseDirPath`|`Option<Path.Path>`|The path to the directory in which the target path resolution starts|
477
+ |`targetPath`|`Path.Path`|The new path of the file|
478
+
479
+ Returns:
480
+
481
+ |type|description|
482
+ |----|-----------|
483
+ |`Result<Void, FileError>`|`Ok(void)` if the operation succeeds, `Err(err)` if a file system error is encountered|
484
+
485
+ ## Fs.Binary
486
+
487
+ Functionality for reading and writing `Bytes` to files.
488
+
489
+ <details disabled>
490
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
491
+ No other changes yet.
492
+ </details>
493
+
494
+ ### Values
495
+
496
+ Functions and constants included in the Fs.Binary module.
497
+
498
+ #### Fs.Binary.**readFile**
499
+
500
+ <details disabled>
501
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
502
+ No other changes yet.
503
+ </details>
504
+
505
+ ```grain
506
+ readFile:
507
+ (?sync: Bool, ?baseDirPath: Option<Path.Path>, path: Path.Path) =>
508
+ Result<Bytes, FileError>
509
+ ```
510
+
511
+ Read the contents of a file as `Bytes`.
512
+
513
+ Parameters:
514
+
515
+ |param|type|description|
516
+ |-----|----|-----------|
517
+ |`?sync`|`Bool`|Whether to synchronously read; `true` by default|
518
+ |`?baseDirPath`|`Option<Path.Path>`|The path to the directory to begin path resolution|
519
+ |`path`|`Path.Path`|The file path to read from|
520
+
521
+ Returns:
522
+
523
+ |type|description|
524
+ |----|-----------|
525
+ |`Result<Bytes, FileError>`|`Ok(contents)` containing the bytes read if successful or `Err(err)` if a file system error is encountered|
526
+
527
+ #### Fs.Binary.**writeFile**
528
+
529
+ <details disabled>
530
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
531
+ No other changes yet.
532
+ </details>
533
+
534
+ ```grain
535
+ writeFile:
536
+ (?writeMode: WriteMode, ?sync: Bool, ?baseDirPath: Option<Path.Path>,
537
+ path: Path.Path, data: Bytes) => Result<Void, FileError>
538
+ ```
539
+
540
+ Write `Bytes` to a file.
541
+
542
+ Parameters:
543
+
544
+ |param|type|description|
545
+ |-----|----|-----------|
546
+ |`?writeMode`|`WriteMode`|The type of write operation to perform; `Truncate` by default|
547
+ |`?sync`|`Bool`|Whether to synchronously write; `true` by default|
548
+ |`?baseDirPath`|`Option<Path.Path>`|The path to the directory to begin path resolution|
549
+ |`path`|`Path.Path`|The file path to write to|
550
+ |`data`|`Bytes`|The bytes to write to the file|
551
+
552
+ Returns:
553
+
554
+ |type|description|
555
+ |----|-----------|
556
+ |`Result<Void, FileError>`|`Ok(void)` if the operation is successful or `Err(err)` if a file system error is encountered|
557
+
558
+ ## Fs.Utf8
559
+
560
+ Functionality for reading and writing `String`s to files.
561
+
562
+ <details disabled>
563
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
564
+ No other changes yet.
565
+ </details>
566
+
567
+ ### Values
568
+
569
+ Functions and constants included in the Fs.Utf8 module.
570
+
571
+ #### Fs.Utf8.**readFile**
572
+
573
+ <details disabled>
574
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
575
+ No other changes yet.
576
+ </details>
577
+
578
+ ```grain
579
+ readFile:
580
+ (?sync: Bool, ?baseDirPath: Option<Path.Path>, path: Path.Path) =>
581
+ Result<String, FileError>
582
+ ```
583
+
584
+ Read the contents of a file as a `String`.
585
+
586
+ Parameters:
587
+
588
+ |param|type|description|
589
+ |-----|----|-----------|
590
+ |`?sync`|`Bool`|Whether to synchronously read; `true` by default|
591
+ |`?baseDirPath`|`Option<Path.Path>`|The path to the directory to begin path resolution|
592
+ |`path`|`Path.Path`|The file path to read from|
593
+
594
+ Returns:
595
+
596
+ |type|description|
597
+ |----|-----------|
598
+ |`Result<String, FileError>`|`Ok(contents)` containing the string read if successful or `Err(err)` if a file system error is encountered|
599
+
600
+ #### Fs.Utf8.**writeFile**
601
+
602
+ <details disabled>
603
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
604
+ No other changes yet.
605
+ </details>
606
+
607
+ ```grain
608
+ writeFile:
609
+ (?writeMode: WriteMode, ?sync: Bool, ?baseDirPath: Option<Path.Path>,
610
+ path: Path.Path, data: String) => Result<Void, FileError>
611
+ ```
612
+
613
+ Write a `String` to a file.
614
+
615
+ Parameters:
616
+
617
+ |param|type|description|
618
+ |-----|----|-----------|
619
+ |`?writeMode`|`WriteMode`|The type of write operation to perform; `Truncate` by default|
620
+ |`?sync`|`Bool`|Whether to synchronously write; `true` by default|
621
+ |`?baseDirPath`|`Option<Path.Path>`|The path to the directory to begin path resolution|
622
+ |`path`|`Path.Path`|The file path to write to|
623
+ |`data`|`String`|The string to write to the file|
624
+
625
+ Returns:
626
+
627
+ |type|description|
628
+ |----|-----------|
629
+ |`Result<Void, FileError>`|`Ok(void)` if the operation is successful or `Err(err)` if a file system error is encountered|
630
+