arc-lang 0.6.2 → 0.6.4
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.
- package/README.md +65 -130
- package/dist/ast.d.ts +30 -2
- package/dist/build.js +1 -1
- package/dist/formatter.js +15 -3
- package/dist/index.js +104 -0
- package/dist/interpreter.js +130 -17
- package/dist/lexer.d.ts +41 -37
- package/dist/lexer.js +47 -39
- package/dist/linter.js +18 -0
- package/dist/modules.js +5 -1
- package/dist/parser.d.ts +2 -0
- package/dist/parser.js +91 -11
- package/dist/repl.js +66 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -2
- package/stdlib/API_DESIGN.md +357 -0
- package/stdlib/ASYNC_DESIGN.md +815 -0
- package/stdlib/EXAMPLES.md +710 -0
- package/stdlib/MODULES.md +854 -0
- package/stdlib/README.md +64 -0
- package/stdlib/collections.arc +140 -0
- package/stdlib/crypto.arc +62 -0
- package/stdlib/csv.arc +40 -0
- package/stdlib/datetime.arc +75 -0
- package/stdlib/embed.arc +42 -0
- package/stdlib/env.arc +10 -0
- package/stdlib/error.arc +36 -0
- package/stdlib/html.arc +30 -0
- package/stdlib/http.arc +43 -0
- package/stdlib/io.arc +28 -0
- package/stdlib/json.arc +204 -0
- package/stdlib/llm.arc +193 -0
- package/stdlib/log.arc +20 -0
- package/stdlib/map.arc +72 -0
- package/stdlib/math.arc +133 -0
- package/stdlib/net.arc +17 -0
- package/stdlib/os.arc +81 -0
- package/stdlib/path.arc +11 -0
- package/stdlib/prompt.arc +49 -0
- package/stdlib/regex.arc +59 -0
- package/stdlib/result.arc +50 -0
- package/stdlib/store.arc +62 -0
- package/stdlib/strings.arc +44 -0
- package/stdlib/test.arc +61 -0
- package/stdlib/time.arc +19 -0
- package/stdlib/toml.arc +10 -0
- package/stdlib/yaml.arc +10 -0
|
@@ -0,0 +1,854 @@
|
|
|
1
|
+
# Arc Standard Library Modules
|
|
2
|
+
|
|
3
|
+
**Version:** 0.1
|
|
4
|
+
**Date:** 2026-02-16
|
|
5
|
+
**Status:** Phase 0 - Planning
|
|
6
|
+
|
|
7
|
+
This document lists all planned modules for the Arc standard library, organized by category.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Core Modules
|
|
12
|
+
|
|
13
|
+
### `core`
|
|
14
|
+
**Purpose:** Fundamental types and operations built into the language
|
|
15
|
+
|
|
16
|
+
**Exports:**
|
|
17
|
+
- Type constructors: `Int`, `Float`, `Bool`, `String`, `Nil`
|
|
18
|
+
- Result types: `Ok`, `Err`, `Result<T, E>`
|
|
19
|
+
- Option types: `Some`, `None`, `Option<T>`
|
|
20
|
+
- Control flow: `if`, `match`, `for`, `while`, `loop`
|
|
21
|
+
- Operators: `+`, `-`, `*`, `/`, `%`, `^`, `==`, `!=`, `<`, `>`, etc.
|
|
22
|
+
|
|
23
|
+
**Status:** Built-in (compiler)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
### `collections`
|
|
28
|
+
**Purpose:** Data structure operations
|
|
29
|
+
|
|
30
|
+
**Submodules:**
|
|
31
|
+
- `collections/list` - List/Array operations
|
|
32
|
+
- `collections/map` - Hash map/dictionary
|
|
33
|
+
- `collections/set` - Set operations
|
|
34
|
+
- `collections/queue` - FIFO queue
|
|
35
|
+
- `collections/stack` - LIFO stack
|
|
36
|
+
- `collections/heap` - Priority queue/heap
|
|
37
|
+
|
|
38
|
+
**Exports:**
|
|
39
|
+
```arc
|
|
40
|
+
// List
|
|
41
|
+
List, map, filter, reduce, take, drop, chunk, zip, flatten, uniq, sort
|
|
42
|
+
|
|
43
|
+
// Map
|
|
44
|
+
Map, get, set, keys, values, entries, merge, filter, map_values
|
|
45
|
+
|
|
46
|
+
// Set
|
|
47
|
+
Set, union (∪), intersect (∩), difference (-), subset (⊆), superset (⊇)
|
|
48
|
+
|
|
49
|
+
// Queue
|
|
50
|
+
Queue, enqueue, dequeue, peek, empty?
|
|
51
|
+
|
|
52
|
+
// Stack
|
|
53
|
+
Stack, push, pop, peek, empty?
|
|
54
|
+
|
|
55
|
+
// Heap
|
|
56
|
+
Heap, push, pop, peek, heapify
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Token Efficiency Target:** 40-50% reduction vs JS/Python
|
|
60
|
+
|
|
61
|
+
**Status:** Phase 3 - Implementation
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
### `string`
|
|
66
|
+
**Purpose:** String manipulation and text processing
|
|
67
|
+
|
|
68
|
+
**Exports:**
|
|
69
|
+
```arc
|
|
70
|
+
// Creation & Conversion
|
|
71
|
+
String, from, to_string, parse
|
|
72
|
+
|
|
73
|
+
// Queries
|
|
74
|
+
len (#), empty?, contains (∈), starts?, ends?, match?
|
|
75
|
+
|
|
76
|
+
// Transform
|
|
77
|
+
upper, lower, trim, trim_start, trim_end
|
|
78
|
+
replace, replace_all, split, join
|
|
79
|
+
pad_left, pad_right, center
|
|
80
|
+
repeat, reverse
|
|
81
|
+
|
|
82
|
+
// Pattern matching
|
|
83
|
+
match, match_all, replace_regex, split_regex
|
|
84
|
+
|
|
85
|
+
// Unicode
|
|
86
|
+
graphemes, codepoints, bytes, chars
|
|
87
|
+
normalize, is_ascii?, is_alpha?, is_digit?
|
|
88
|
+
|
|
89
|
+
// Formatting
|
|
90
|
+
fmt, template, interpolate
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Token Efficiency Target:** 35-45% reduction vs JS/Python
|
|
94
|
+
|
|
95
|
+
**Status:** Phase 3 - Implementation
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
### `math`
|
|
100
|
+
**Purpose:** Mathematical operations and functions
|
|
101
|
+
|
|
102
|
+
**Exports:**
|
|
103
|
+
```arc
|
|
104
|
+
// Constants
|
|
105
|
+
π (PI), e (E), τ (TAU), ∞ (INFINITY)
|
|
106
|
+
|
|
107
|
+
// Basic
|
|
108
|
+
abs (|x|), sign, min, max, clamp
|
|
109
|
+
round, floor, ceil, trunc
|
|
110
|
+
|
|
111
|
+
// Power & Roots
|
|
112
|
+
sqrt (√), cbrt (∛), pow (^), exp
|
|
113
|
+
log, log10, log2, ln
|
|
114
|
+
|
|
115
|
+
// Trigonometry
|
|
116
|
+
sin, cos, tan, asin, acos, atan, atan2
|
|
117
|
+
sinh, cosh, tanh, asinh, acosh, atanh
|
|
118
|
+
|
|
119
|
+
// Aggregates
|
|
120
|
+
sum (∑), product (∏), mean, median, mode
|
|
121
|
+
variance, stddev, min, max
|
|
122
|
+
|
|
123
|
+
// Random
|
|
124
|
+
random, random_int, random_range, shuffle, sample
|
|
125
|
+
|
|
126
|
+
// Ranges
|
|
127
|
+
range (..), step, take, infinite
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Token Efficiency Target:** 45-55% reduction vs JS/Python (thanks to symbols)
|
|
131
|
+
|
|
132
|
+
**Status:** Phase 3 - Implementation
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## I/O Modules
|
|
137
|
+
|
|
138
|
+
### `io`
|
|
139
|
+
**Purpose:** Input/output primitives
|
|
140
|
+
|
|
141
|
+
**Exports:**
|
|
142
|
+
```arc
|
|
143
|
+
// Console
|
|
144
|
+
print, println, eprint, eprintln, input, prompt
|
|
145
|
+
|
|
146
|
+
// Streams
|
|
147
|
+
Stream, read, write, close, flush
|
|
148
|
+
stdin, stdout, stderr
|
|
149
|
+
|
|
150
|
+
// Readers/Writers
|
|
151
|
+
Reader, Writer, read_all, read_line, read_bytes
|
|
152
|
+
write_all, write_line, write_bytes
|
|
153
|
+
|
|
154
|
+
// Buffering
|
|
155
|
+
BufferedReader, BufferedWriter, buffer_size
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**Token Efficiency Target:** 50-60% reduction vs JS/Python
|
|
159
|
+
|
|
160
|
+
**Status:** Phase 3 - Implementation
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
### `fs`
|
|
165
|
+
**Purpose:** File system operations
|
|
166
|
+
|
|
167
|
+
**Exports:**
|
|
168
|
+
```arc
|
|
169
|
+
// File operations
|
|
170
|
+
read, write, append, delete, copy, move
|
|
171
|
+
exists?, is_file?, is_dir?, is_symlink?
|
|
172
|
+
size, mtime, atime, ctime, permissions
|
|
173
|
+
|
|
174
|
+
// Directory operations
|
|
175
|
+
ls, mkdir, rmdir, chdir, pwd
|
|
176
|
+
walk, glob
|
|
177
|
+
|
|
178
|
+
// Path manipulation
|
|
179
|
+
abspath, relpath, basename, dirname, extname
|
|
180
|
+
joinpath, splitpath, normalize
|
|
181
|
+
|
|
182
|
+
// Temporary files
|
|
183
|
+
tmp, tmpdir, tmp_file
|
|
184
|
+
|
|
185
|
+
// Watching
|
|
186
|
+
watch, on_change, on_create, on_delete
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Token Efficiency Target:** 55-65% reduction vs JS/Python
|
|
190
|
+
|
|
191
|
+
**Status:** Phase 3 - Implementation
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
### `net`
|
|
196
|
+
**Purpose:** Network operations (low-level)
|
|
197
|
+
|
|
198
|
+
**Exports:**
|
|
199
|
+
```arc
|
|
200
|
+
// TCP
|
|
201
|
+
TcpListener, TcpStream
|
|
202
|
+
bind, connect, listen, accept
|
|
203
|
+
send, recv, close
|
|
204
|
+
|
|
205
|
+
// UDP
|
|
206
|
+
UdpSocket, send_to, recv_from
|
|
207
|
+
|
|
208
|
+
// DNS
|
|
209
|
+
resolve, lookup, reverse_lookup
|
|
210
|
+
|
|
211
|
+
// IP
|
|
212
|
+
IpAddr, Ipv4, Ipv6, parse, to_string
|
|
213
|
+
|
|
214
|
+
// URL
|
|
215
|
+
Url, parse, scheme, host, port, path, query, fragment
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Token Efficiency Target:** 40-50% reduction vs JS/Python
|
|
219
|
+
|
|
220
|
+
**Status:** Phase 3 - Implementation
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
### `http`
|
|
225
|
+
**Purpose:** HTTP client and server
|
|
226
|
+
|
|
227
|
+
**Exports:**
|
|
228
|
+
```arc
|
|
229
|
+
// Client
|
|
230
|
+
GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
|
|
231
|
+
request, fetch
|
|
232
|
+
|
|
233
|
+
// Client config
|
|
234
|
+
headers, timeout, retry, redirect
|
|
235
|
+
|
|
236
|
+
// Server
|
|
237
|
+
serve, route, handler
|
|
238
|
+
GET "/path" => handler
|
|
239
|
+
POST "/path" => handler
|
|
240
|
+
|
|
241
|
+
// Request/Response
|
|
242
|
+
Request, Response, status, body, headers, cookies
|
|
243
|
+
|
|
244
|
+
// WebSocket
|
|
245
|
+
WebSocket, connect, send, recv, on, close
|
|
246
|
+
|
|
247
|
+
// Middleware
|
|
248
|
+
cors, auth, logging, compression
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**Token Efficiency Target:** 50-60% reduction vs JS/Python
|
|
252
|
+
|
|
253
|
+
**Status:** Phase 3 - Implementation
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## Concurrency Modules
|
|
258
|
+
|
|
259
|
+
### `async`
|
|
260
|
+
**Purpose:** Async primitives and utilities
|
|
261
|
+
|
|
262
|
+
**Exports:**
|
|
263
|
+
```arc
|
|
264
|
+
// Execution
|
|
265
|
+
spawn, parallel, await, race, timeout
|
|
266
|
+
|
|
267
|
+
// Task management
|
|
268
|
+
Task, cancel, is_done?, is_cancelled?, result
|
|
269
|
+
|
|
270
|
+
// Sleep & Timing
|
|
271
|
+
sleep, delay, interval
|
|
272
|
+
|
|
273
|
+
// Utilities
|
|
274
|
+
join, join_all, select
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Token Efficiency Target:** 40-50% reduction vs JS/Python
|
|
278
|
+
|
|
279
|
+
**Status:** Phase 3 - Implementation
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
### `channel`
|
|
284
|
+
**Purpose:** Message passing between tasks
|
|
285
|
+
|
|
286
|
+
**Exports:**
|
|
287
|
+
```arc
|
|
288
|
+
// Channel creation
|
|
289
|
+
Channel, bounded, unbounded
|
|
290
|
+
|
|
291
|
+
// Operations
|
|
292
|
+
send (<-), recv (<-), try_send, try_recv
|
|
293
|
+
close, is_closed?
|
|
294
|
+
|
|
295
|
+
// Select
|
|
296
|
+
select, select_timeout
|
|
297
|
+
|
|
298
|
+
// Iteration
|
|
299
|
+
for msg in channel
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
**Token Efficiency Target:** 45-55% reduction vs Go
|
|
303
|
+
|
|
304
|
+
**Status:** Phase 3 - Implementation
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
### `sync`
|
|
309
|
+
**Purpose:** Synchronization primitives
|
|
310
|
+
|
|
311
|
+
**Exports:**
|
|
312
|
+
```arc
|
|
313
|
+
// Mutex
|
|
314
|
+
Mutex, lock, unlock, try_lock, is_locked?
|
|
315
|
+
with_lock (auto-unlock)
|
|
316
|
+
|
|
317
|
+
// RwLock (Read-write lock)
|
|
318
|
+
RwLock, read_lock, write_lock, unlock
|
|
319
|
+
|
|
320
|
+
// Atomic
|
|
321
|
+
Atomic, load, store, swap, compare_swap
|
|
322
|
+
inc, dec, add, sub
|
|
323
|
+
|
|
324
|
+
// WaitGroup
|
|
325
|
+
WaitGroup, add, done, wait
|
|
326
|
+
|
|
327
|
+
// Once
|
|
328
|
+
Once, do
|
|
329
|
+
|
|
330
|
+
// Semaphore
|
|
331
|
+
Semaphore, acquire, release, try_acquire
|
|
332
|
+
|
|
333
|
+
// Barrier
|
|
334
|
+
Barrier, wait
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Token Efficiency Target:** 35-45% reduction vs Go
|
|
338
|
+
|
|
339
|
+
**Status:** Phase 3 - Implementation
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## Data Modules
|
|
344
|
+
|
|
345
|
+
### `json`
|
|
346
|
+
**Purpose:** JSON serialization/deserialization
|
|
347
|
+
|
|
348
|
+
**Exports:**
|
|
349
|
+
```arc
|
|
350
|
+
// Parsing
|
|
351
|
+
parse, from_string, from_reader
|
|
352
|
+
|
|
353
|
+
// Serialization
|
|
354
|
+
stringify, to_string, to_writer
|
|
355
|
+
pretty, minify
|
|
356
|
+
|
|
357
|
+
// Validation
|
|
358
|
+
validate, schema
|
|
359
|
+
|
|
360
|
+
// Path queries (JSONPath)
|
|
361
|
+
query, select, filter
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
**Token Efficiency Target:** 50-60% reduction vs JS/Python
|
|
365
|
+
|
|
366
|
+
**Status:** Phase 3 - Implementation
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
### `csv`
|
|
371
|
+
**Purpose:** CSV/TSV handling
|
|
372
|
+
|
|
373
|
+
**Exports:**
|
|
374
|
+
```arc
|
|
375
|
+
// Reading
|
|
376
|
+
read, read_all, read_header
|
|
377
|
+
parse, from_string
|
|
378
|
+
|
|
379
|
+
// Writing
|
|
380
|
+
write, write_all, write_header
|
|
381
|
+
to_string
|
|
382
|
+
|
|
383
|
+
// Configuration
|
|
384
|
+
delimiter, quote, escape, header?
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
**Token Efficiency Target:** 45-55% reduction vs Python
|
|
388
|
+
|
|
389
|
+
**Status:** Phase 3 - Implementation
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
### `xml`
|
|
394
|
+
**Purpose:** XML parsing and generation
|
|
395
|
+
|
|
396
|
+
**Exports:**
|
|
397
|
+
```arc
|
|
398
|
+
// Parsing
|
|
399
|
+
parse, from_string, from_reader
|
|
400
|
+
|
|
401
|
+
// Generation
|
|
402
|
+
build, to_string, to_writer
|
|
403
|
+
|
|
404
|
+
// Queries (XPath)
|
|
405
|
+
query, select, filter
|
|
406
|
+
|
|
407
|
+
// Utilities
|
|
408
|
+
validate, schema
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
**Token Efficiency Target:** 40-50% reduction vs JS/Python
|
|
412
|
+
|
|
413
|
+
**Status:** Phase 4 - Lower priority
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
### `yaml`
|
|
418
|
+
**Purpose:** YAML serialization/deserialization
|
|
419
|
+
|
|
420
|
+
**Exports:**
|
|
421
|
+
```arc
|
|
422
|
+
// Parsing
|
|
423
|
+
parse, from_string, from_reader
|
|
424
|
+
|
|
425
|
+
// Serialization
|
|
426
|
+
stringify, to_string, to_writer
|
|
427
|
+
|
|
428
|
+
// Validation
|
|
429
|
+
validate, schema
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
**Token Efficiency Target:** 45-55% reduction vs Python
|
|
433
|
+
|
|
434
|
+
**Status:** Phase 4 - Lower priority
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
### `toml`
|
|
439
|
+
**Purpose:** TOML configuration files
|
|
440
|
+
|
|
441
|
+
**Exports:**
|
|
442
|
+
```arc
|
|
443
|
+
// Parsing
|
|
444
|
+
parse, from_string, from_reader
|
|
445
|
+
|
|
446
|
+
// Serialization
|
|
447
|
+
stringify, to_string, to_writer
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
**Token Efficiency Target:** 45-55% reduction vs Rust
|
|
451
|
+
|
|
452
|
+
**Status:** Phase 4 - Lower priority
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
## Utility Modules
|
|
457
|
+
|
|
458
|
+
### `test`
|
|
459
|
+
**Purpose:** Testing framework
|
|
460
|
+
|
|
461
|
+
**Exports:**
|
|
462
|
+
```arc
|
|
463
|
+
// Assertions
|
|
464
|
+
assert, assert_eq, assert_ne, assert_ok, assert_err
|
|
465
|
+
assert_true, assert_false, assert_nil, assert_some
|
|
466
|
+
assert_contains, assert_match, assert_throws
|
|
467
|
+
|
|
468
|
+
// Test definition
|
|
469
|
+
test "description" { ... }
|
|
470
|
+
suite "description" { ... }
|
|
471
|
+
|
|
472
|
+
// Setup/Teardown
|
|
473
|
+
before { ... }
|
|
474
|
+
after { ... }
|
|
475
|
+
before_each { ... }
|
|
476
|
+
after_each { ... }
|
|
477
|
+
|
|
478
|
+
// Mocking
|
|
479
|
+
mock, stub, spy
|
|
480
|
+
mock_fn, reset_mocks
|
|
481
|
+
|
|
482
|
+
// Running
|
|
483
|
+
run_tests, run_suite, filter
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
**Token Efficiency Target:** 40-50% reduction vs Jest/pytest
|
|
487
|
+
|
|
488
|
+
**Status:** Phase 4 - Implementation
|
|
489
|
+
|
|
490
|
+
---
|
|
491
|
+
|
|
492
|
+
### `bench`
|
|
493
|
+
**Purpose:** Benchmarking utilities
|
|
494
|
+
|
|
495
|
+
**Exports:**
|
|
496
|
+
```arc
|
|
497
|
+
// Benchmarking
|
|
498
|
+
bench "name" { ... }
|
|
499
|
+
benchmark, measure
|
|
500
|
+
|
|
501
|
+
// Statistics
|
|
502
|
+
mean, median, stddev, min, max, percentile
|
|
503
|
+
|
|
504
|
+
// Comparison
|
|
505
|
+
compare, baseline, regression?
|
|
506
|
+
|
|
507
|
+
// Reporting
|
|
508
|
+
report, summary, detailed
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
**Token Efficiency Target:** 45-55% reduction vs criterion
|
|
512
|
+
|
|
513
|
+
**Status:** Phase 4 - Implementation
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
### `log`
|
|
518
|
+
**Purpose:** Logging
|
|
519
|
+
|
|
520
|
+
**Exports:**
|
|
521
|
+
```arc
|
|
522
|
+
// Levels
|
|
523
|
+
trace, debug, info, warn, error, fatal
|
|
524
|
+
|
|
525
|
+
// Configuration
|
|
526
|
+
level, format, output
|
|
527
|
+
timestamp?, colors?
|
|
528
|
+
|
|
529
|
+
// Structured logging
|
|
530
|
+
log(level, message, context)
|
|
531
|
+
|
|
532
|
+
// Loggers
|
|
533
|
+
Logger, with_context, with_prefix
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
**Token Efficiency Target:** 40-50% reduction vs winston/logging
|
|
537
|
+
|
|
538
|
+
**Status:** Phase 4 - Implementation
|
|
539
|
+
|
|
540
|
+
---
|
|
541
|
+
|
|
542
|
+
### `error`
|
|
543
|
+
**Purpose:** Error handling utilities
|
|
544
|
+
|
|
545
|
+
**Exports:**
|
|
546
|
+
```arc
|
|
547
|
+
// Error types
|
|
548
|
+
Error, custom_error, error_chain
|
|
549
|
+
|
|
550
|
+
// Result helpers
|
|
551
|
+
ok, err, unwrap, unwrap_or, expect
|
|
552
|
+
map, map_err, and_then, or_else
|
|
553
|
+
|
|
554
|
+
// Option helpers
|
|
555
|
+
some, none, unwrap, unwrap_or, expect
|
|
556
|
+
map, and_then, or_else, filter
|
|
557
|
+
|
|
558
|
+
// Recovery
|
|
559
|
+
try, catch, finally, recover, panic
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
**Token Efficiency Target:** 35-45% reduction vs Rust
|
|
563
|
+
|
|
564
|
+
**Status:** Phase 3 - Implementation
|
|
565
|
+
|
|
566
|
+
---
|
|
567
|
+
|
|
568
|
+
### `time`
|
|
569
|
+
**Purpose:** Date and time operations
|
|
570
|
+
|
|
571
|
+
**Exports:**
|
|
572
|
+
```arc
|
|
573
|
+
// Current time
|
|
574
|
+
now, today, utc_now
|
|
575
|
+
|
|
576
|
+
// Creation
|
|
577
|
+
date, datetime, time, duration
|
|
578
|
+
parse, from_string, from_timestamp
|
|
579
|
+
|
|
580
|
+
// Formatting
|
|
581
|
+
format, to_string, iso8601, rfc3339
|
|
582
|
+
|
|
583
|
+
// Arithmetic
|
|
584
|
+
add, subtract, diff
|
|
585
|
+
add_days, add_hours, add_minutes
|
|
586
|
+
|
|
587
|
+
// Queries
|
|
588
|
+
year, month, day, hour, minute, second
|
|
589
|
+
weekday, is_weekend?, is_leap_year?
|
|
590
|
+
|
|
591
|
+
// Timezone
|
|
592
|
+
to_utc, to_local, to_timezone
|
|
593
|
+
timezone, offset
|
|
594
|
+
|
|
595
|
+
// Duration
|
|
596
|
+
seconds, minutes, hours, days, weeks
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
**Token Efficiency Target:** 45-55% reduction vs moment/datetime
|
|
600
|
+
|
|
601
|
+
**Status:** Phase 4 - Implementation
|
|
602
|
+
|
|
603
|
+
---
|
|
604
|
+
|
|
605
|
+
### `regex`
|
|
606
|
+
**Purpose:** Regular expressions
|
|
607
|
+
|
|
608
|
+
**Exports:**
|
|
609
|
+
```arc
|
|
610
|
+
// Creation
|
|
611
|
+
Regex, compile, new
|
|
612
|
+
|
|
613
|
+
// Matching
|
|
614
|
+
match?, match, match_all, captures
|
|
615
|
+
|
|
616
|
+
// Replacement
|
|
617
|
+
replace, replace_all
|
|
618
|
+
|
|
619
|
+
// Splitting
|
|
620
|
+
split, split_n
|
|
621
|
+
|
|
622
|
+
// Utilities
|
|
623
|
+
escape, is_valid?
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
**Token Efficiency Target:** 40-50% reduction vs JS/Python
|
|
627
|
+
|
|
628
|
+
**Status:** Phase 3 - Implementation
|
|
629
|
+
|
|
630
|
+
---
|
|
631
|
+
|
|
632
|
+
### `hash`
|
|
633
|
+
**Purpose:** Hashing and cryptography (basic)
|
|
634
|
+
|
|
635
|
+
**Exports:**
|
|
636
|
+
```arc
|
|
637
|
+
// Hash functions
|
|
638
|
+
md5, sha1, sha256, sha512
|
|
639
|
+
hash, checksum
|
|
640
|
+
|
|
641
|
+
// Encoding
|
|
642
|
+
base64, base64_url
|
|
643
|
+
hex_encode, hex_decode
|
|
644
|
+
|
|
645
|
+
// UUIDs
|
|
646
|
+
uuid, uuid_v4, parse_uuid
|
|
647
|
+
|
|
648
|
+
// Password
|
|
649
|
+
hash_password, verify_password
|
|
650
|
+
bcrypt, argon2
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
**Token Efficiency Target:** 40-50% reduction vs crypto libraries
|
|
654
|
+
|
|
655
|
+
**Status:** Phase 4 - Implementation
|
|
656
|
+
|
|
657
|
+
---
|
|
658
|
+
|
|
659
|
+
### `env`
|
|
660
|
+
**Purpose:** Environment and process utilities
|
|
661
|
+
|
|
662
|
+
**Exports:**
|
|
663
|
+
```arc
|
|
664
|
+
// Environment variables
|
|
665
|
+
get, set, delete, has?
|
|
666
|
+
all, vars
|
|
667
|
+
|
|
668
|
+
// Process
|
|
669
|
+
args, exit, abort
|
|
670
|
+
pid, ppid
|
|
671
|
+
|
|
672
|
+
// System info
|
|
673
|
+
os, arch, platform
|
|
674
|
+
home_dir, tmp_dir, cwd
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
**Token Efficiency Target:** 45-55% reduction vs process/os
|
|
678
|
+
|
|
679
|
+
**Status:** Phase 3 - Implementation
|
|
680
|
+
|
|
681
|
+
---
|
|
682
|
+
|
|
683
|
+
### `cmd`
|
|
684
|
+
**Purpose:** Command execution and shell interaction
|
|
685
|
+
|
|
686
|
+
**Exports:**
|
|
687
|
+
```arc
|
|
688
|
+
// Execution
|
|
689
|
+
exec, run, spawn, output
|
|
690
|
+
|
|
691
|
+
// Pipes
|
|
692
|
+
pipe, stdin, stdout, stderr
|
|
693
|
+
|
|
694
|
+
// Status
|
|
695
|
+
wait, exit_code, success?, failed?
|
|
696
|
+
|
|
697
|
+
// Shell
|
|
698
|
+
shell, cmd, bash, powershell
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
**Token Efficiency Target:** 50-60% reduction vs child_process/subprocess
|
|
702
|
+
|
|
703
|
+
**Status:** Phase 4 - Implementation
|
|
704
|
+
|
|
705
|
+
---
|
|
706
|
+
|
|
707
|
+
## Advanced Modules (Future)
|
|
708
|
+
|
|
709
|
+
### `db`
|
|
710
|
+
**Purpose:** Database abstraction
|
|
711
|
+
|
|
712
|
+
**Status:** Phase 5+ (design later)
|
|
713
|
+
|
|
714
|
+
**Planned exports:**
|
|
715
|
+
- SQL query builder
|
|
716
|
+
- Connection pooling
|
|
717
|
+
- Migrations
|
|
718
|
+
- ORM-lite
|
|
719
|
+
|
|
720
|
+
---
|
|
721
|
+
|
|
722
|
+
### `graphics`
|
|
723
|
+
**Purpose:** Image processing and manipulation
|
|
724
|
+
|
|
725
|
+
**Status:** Phase 5+ (design later)
|
|
726
|
+
|
|
727
|
+
**Planned exports:**
|
|
728
|
+
- Image loading/saving
|
|
729
|
+
- Resize, crop, rotate
|
|
730
|
+
- Filters and effects
|
|
731
|
+
- Drawing primitives
|
|
732
|
+
|
|
733
|
+
---
|
|
734
|
+
|
|
735
|
+
### `ml`
|
|
736
|
+
**Purpose:** Machine learning utilities (AI agent focus)
|
|
737
|
+
|
|
738
|
+
**Status:** Phase 5+ (design later)
|
|
739
|
+
|
|
740
|
+
**Planned exports:**
|
|
741
|
+
- Embeddings
|
|
742
|
+
- Similarity search
|
|
743
|
+
- Token counting
|
|
744
|
+
- Model inference helpers
|
|
745
|
+
|
|
746
|
+
---
|
|
747
|
+
|
|
748
|
+
## Module Organization
|
|
749
|
+
|
|
750
|
+
### Directory Structure
|
|
751
|
+
```
|
|
752
|
+
stdlib/
|
|
753
|
+
├── core/ # Core types (built-in)
|
|
754
|
+
├── collections/ # Data structures
|
|
755
|
+
│ ├── list.arc
|
|
756
|
+
│ ├── map.arc
|
|
757
|
+
│ ├── set.arc
|
|
758
|
+
│ └── ...
|
|
759
|
+
├── string/ # String operations
|
|
760
|
+
├── math/ # Mathematics
|
|
761
|
+
├── io/ # I/O primitives
|
|
762
|
+
├── fs/ # File system
|
|
763
|
+
├── net/ # Networking
|
|
764
|
+
├── http/ # HTTP client/server
|
|
765
|
+
├── async/ # Async primitives
|
|
766
|
+
├── channel/ # Message passing
|
|
767
|
+
├── sync/ # Synchronization
|
|
768
|
+
├── json/ # JSON
|
|
769
|
+
├── csv/ # CSV
|
|
770
|
+
├── xml/ # XML (future)
|
|
771
|
+
├── yaml/ # YAML (future)
|
|
772
|
+
├── toml/ # TOML (future)
|
|
773
|
+
├── test/ # Testing
|
|
774
|
+
├── bench/ # Benchmarking
|
|
775
|
+
├── log/ # Logging
|
|
776
|
+
├── error/ # Error utilities
|
|
777
|
+
├── time/ # Date/time
|
|
778
|
+
├── regex/ # Regular expressions
|
|
779
|
+
├── hash/ # Hashing/crypto
|
|
780
|
+
├── env/ # Environment
|
|
781
|
+
└── cmd/ # Command execution
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
### Import Syntax
|
|
785
|
+
|
|
786
|
+
```arc
|
|
787
|
+
// Import entire module
|
|
788
|
+
import collections
|
|
789
|
+
|
|
790
|
+
// Import specific exports
|
|
791
|
+
import {List, Map, Set} from collections
|
|
792
|
+
|
|
793
|
+
// Import with alias
|
|
794
|
+
import collections as col
|
|
795
|
+
import {List as L} from collections
|
|
796
|
+
|
|
797
|
+
// Import everything (discouraged)
|
|
798
|
+
import * from collections
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
---
|
|
802
|
+
|
|
803
|
+
## Implementation Priority
|
|
804
|
+
|
|
805
|
+
**Phase 3 (Core - Weeks 13-16):**
|
|
806
|
+
1. `collections` - Essential data structures
|
|
807
|
+
2. `string` - Text processing
|
|
808
|
+
3. `math` - Mathematical operations
|
|
809
|
+
4. `io` - I/O primitives
|
|
810
|
+
5. `fs` - File system
|
|
811
|
+
6. `http` - HTTP client/server
|
|
812
|
+
7. `async` - Async primitives
|
|
813
|
+
8. `channel` - Message passing
|
|
814
|
+
9. `sync` - Synchronization
|
|
815
|
+
10. `json` - JSON handling
|
|
816
|
+
11. `error` - Error utilities
|
|
817
|
+
12. `env` - Environment access
|
|
818
|
+
|
|
819
|
+
**Phase 4 (Extended - Weeks 17-20):**
|
|
820
|
+
1. `test` - Testing framework
|
|
821
|
+
2. `bench` - Benchmarking
|
|
822
|
+
3. `log` - Logging
|
|
823
|
+
4. `time` - Date/time
|
|
824
|
+
5. `regex` - Regular expressions
|
|
825
|
+
6. `csv` - CSV handling
|
|
826
|
+
7. `hash` - Hashing
|
|
827
|
+
8. `cmd` - Command execution
|
|
828
|
+
|
|
829
|
+
**Phase 5+ (Future):**
|
|
830
|
+
1. `xml` - XML parsing
|
|
831
|
+
2. `yaml` - YAML handling
|
|
832
|
+
3. `toml` - TOML parsing
|
|
833
|
+
4. `db` - Database abstraction
|
|
834
|
+
5. `graphics` - Image processing
|
|
835
|
+
6. `ml` - ML utilities
|
|
836
|
+
|
|
837
|
+
---
|
|
838
|
+
|
|
839
|
+
## Quality Standards
|
|
840
|
+
|
|
841
|
+
Every module must have:
|
|
842
|
+
1. ✅ Complete API documentation
|
|
843
|
+
2. ✅ Usage examples for every function
|
|
844
|
+
3. ✅ Token efficiency comparisons
|
|
845
|
+
4. ✅ 90%+ test coverage
|
|
846
|
+
5. ✅ Performance benchmarks
|
|
847
|
+
6. ✅ Error handling examples
|
|
848
|
+
7. ✅ Type signatures (gradual typing)
|
|
849
|
+
|
|
850
|
+
---
|
|
851
|
+
|
|
852
|
+
**Last Updated:** 2026-02-16
|
|
853
|
+
**Designed By:** Subagent 3 (Opus 4.6)
|
|
854
|
+
**Status:** Ready for Phase 3 implementation
|