eliscript 0.0.1
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/LICENSE +674 -0
- package/README.md +135 -0
- package/bin/eliscript +16 -0
- package/bin/eliscript-bootstrap +15 -0
- package/bin/eliscript-build +15 -0
- package/bin/eliscript-check +15 -0
- package/bin/eliscript-eval +15 -0
- package/bin/eliscript-format +15 -0
- package/bin/eliscript-org +10 -0
- package/bin/eliscript-portable +17 -0
- package/bin/eliscript-seed +10 -0
- package/bin/eliscript-seed-build +10 -0
- package/bin/eliscript-watch +15 -0
- package/bootstrap/README.md +100 -0
- package/bootstrap/compiler/analyzer.eli +1426 -0
- package/bootstrap/compiler/compiler.eli +472 -0
- package/bootstrap/compiler/emitter.eli +1745 -0
- package/bootstrap/compiler/expander.eli +2522 -0
- package/bootstrap/compiler/formatter.eli +359 -0
- package/bootstrap/compiler/ir.eli +297 -0
- package/bootstrap/compiler/lower.eli +661 -0
- package/bootstrap/compiler/project.eli +1120 -0
- package/bootstrap/compiler/reader.eli +321 -0
- package/bootstrap/compiler/source-map.eli +165 -0
- package/bootstrap/compiler/symbol.eli +92 -0
- package/bootstrap/compiler/syntax.eli +54 -0
- package/bootstrap/compiler/transient-analysis.eli +825 -0
- package/bootstrap/host/build.mjs +28 -0
- package/bootstrap/host/bun.mjs +282 -0
- package/bootstrap/host/check-cli.mjs +163 -0
- package/bootstrap/host/eliscript-cli.mjs +36 -0
- package/bootstrap/host/evaluation-cli.mjs +401 -0
- package/bootstrap/host/evaluation.mjs +560 -0
- package/bootstrap/host/format-cli.mjs +139 -0
- package/bootstrap/host/project-cli.mjs +295 -0
- package/bootstrap/host/project.mjs +1080 -0
- package/bootstrap/host/watch-cli.mjs +129 -0
- package/bootstrap/host/watch.mjs +267 -0
- package/browser/host.mjs +357 -0
- package/browser/worker.mjs +60 -0
- package/compiler/README.md +118 -0
- package/compiler/eliscript-analyzer.el +716 -0
- package/compiler/eliscript-cli.el +108 -0
- package/compiler/eliscript-diagnostic.el +158 -0
- package/compiler/eliscript-emitter.el +1351 -0
- package/compiler/eliscript-evaluation.el +259 -0
- package/compiler/eliscript-expander.el +1630 -0
- package/compiler/eliscript-form.el +79 -0
- package/compiler/eliscript-ir-emitter.el +1460 -0
- package/compiler/eliscript-ir.el +356 -0
- package/compiler/eliscript-lower.el +463 -0
- package/compiler/eliscript-macro-eval.el +811 -0
- package/compiler/eliscript-parameters.el +324 -0
- package/compiler/eliscript-portable.el +492 -0
- package/compiler/eliscript-project-cli.el +156 -0
- package/compiler/eliscript-project.el +1676 -0
- package/compiler/eliscript-reader.el +421 -0
- package/compiler/eliscript-source-map.el +192 -0
- package/compiler/eliscript-symbol.el +101 -0
- package/compiler/eliscript-transient-analysis.el +817 -0
- package/compiler/eliscript.el +239 -0
- package/dist/bootstrap/analyzer.mjs +968 -0
- package/dist/bootstrap/analyzer.mjs.map +1 -0
- package/dist/bootstrap/compiler.mjs +228 -0
- package/dist/bootstrap/compiler.mjs.map +1 -0
- package/dist/bootstrap/emitter.mjs +1173 -0
- package/dist/bootstrap/emitter.mjs.map +1 -0
- package/dist/bootstrap/expander.mjs +1469 -0
- package/dist/bootstrap/expander.mjs.map +1 -0
- package/dist/bootstrap/formatter.mjs +304 -0
- package/dist/bootstrap/formatter.mjs.map +1 -0
- package/dist/bootstrap/ir.mjs +193 -0
- package/dist/bootstrap/ir.mjs.map +1 -0
- package/dist/bootstrap/lower.mjs +344 -0
- package/dist/bootstrap/lower.mjs.map +1 -0
- package/dist/bootstrap/project.mjs +585 -0
- package/dist/bootstrap/project.mjs.map +1 -0
- package/dist/bootstrap/reader.mjs +259 -0
- package/dist/bootstrap/reader.mjs.map +1 -0
- package/dist/bootstrap/source-map.mjs +154 -0
- package/dist/bootstrap/source-map.mjs.map +1 -0
- package/dist/bootstrap/symbol.mjs +74 -0
- package/dist/bootstrap/symbol.mjs.map +1 -0
- package/dist/bootstrap/syntax.mjs +38 -0
- package/dist/bootstrap/syntax.mjs.map +1 -0
- package/dist/bootstrap/transient-analysis.mjs +660 -0
- package/dist/bootstrap/transient-analysis.mjs.map +1 -0
- package/dist/browser/compiler.js +6491 -0
- package/editor/README.md +83 -0
- package/editor/eliscript-mode.el +878 -0
- package/editor/eliscript-repl.el +501 -0
- package/package.json +163 -0
- package/platform/README.md +48 -0
- package/platform/browser.mjs +204 -0
- package/platform/worker.mjs +166 -0
- package/runtime/README.md +296 -0
- package/runtime/core/collection-internals.mjs +512 -0
- package/runtime/core/collection.mjs +645 -0
- package/runtime/core/data-text.mjs +532 -0
- package/runtime/core/data.mjs +268 -0
- package/runtime/core/identifier.mjs +314 -0
- package/runtime/core/lazy-sequence.mjs +244 -0
- package/runtime/core/list-internals.mjs +18 -0
- package/runtime/core/list.mjs +273 -0
- package/runtime/core/map-internals.mjs +793 -0
- package/runtime/core/map.mjs +394 -0
- package/runtime/core/metadata-internals.mjs +14 -0
- package/runtime/core/metadata.mjs +44 -0
- package/runtime/core/object-impl.mjs +65 -0
- package/runtime/core/object-impl.mjs.map +1 -0
- package/runtime/core/object.mjs +13 -0
- package/runtime/core/order.mjs +234 -0
- package/runtime/core/persistent-kind.mjs +43 -0
- package/runtime/core/protocol-error.mjs +36 -0
- package/runtime/core/protocol-impl.mjs +326 -0
- package/runtime/core/protocol-impl.mjs.map +1 -0
- package/runtime/core/protocol.mjs +14 -0
- package/runtime/core/queue-internals.mjs +27 -0
- package/runtime/core/queue.mjs +238 -0
- package/runtime/core/record.mjs +346 -0
- package/runtime/core/regex.mjs +184 -0
- package/runtime/core/sequence.mjs +632 -0
- package/runtime/core/set-algebra.mjs +287 -0
- package/runtime/core/set-internals.mjs +33 -0
- package/runtime/core/set.mjs +378 -0
- package/runtime/core/sorted-internals.mjs +215 -0
- package/runtime/core/sorted.mjs +598 -0
- package/runtime/core/text-impl.mjs +95 -0
- package/runtime/core/text-impl.mjs.map +1 -0
- package/runtime/core/text.mjs +15 -0
- package/runtime/core/transducer.mjs +668 -0
- package/runtime/core/transient-internals.mjs +38 -0
- package/runtime/core/transient.mjs +53 -0
- package/runtime/core/truth.mjs +3 -0
- package/runtime/core/type.mjs +262 -0
- package/runtime/core/value-internals.mjs +188 -0
- package/runtime/core/value.mjs +93 -0
- package/runtime/core/vector-internals.mjs +102 -0
- package/runtime/core/vector.mjs +951 -0
- package/runtime/literals.mjs +34 -0
- package/runtime/source-mapping.mjs +220 -0
- package/runtime/testing/list.mjs +52 -0
- package/runtime/testing/map.mjs +145 -0
- package/runtime/testing/queue.mjs +49 -0
- package/runtime/testing/set.mjs +61 -0
- package/runtime/testing/sorted.mjs +105 -0
- package/runtime/testing/value.mjs +17 -0
- package/runtime/testing/vector.mjs +102 -0
- package/runtime/worker-value-codec.mjs +565 -0
- package/runtime/worker-value-stream.mjs +786 -0
- package/runtime/worker.mjs +975 -0
- package/stdlib/README.md +774 -0
- package/stdlib/bit.eli +36 -0
- package/stdlib/core/collection.eli +134 -0
- package/stdlib/core/data-text.eli +16 -0
- package/stdlib/core/data.eli +306 -0
- package/stdlib/core/identifier.eli +32 -0
- package/stdlib/core/lazy-sequence.eli +63 -0
- package/stdlib/core/metadata.eli +20 -0
- package/stdlib/core/object.eli +89 -0
- package/stdlib/core/order.eli +133 -0
- package/stdlib/core/protocol.eli +387 -0
- package/stdlib/core/record.eli +16 -0
- package/stdlib/core/regex.eli +17 -0
- package/stdlib/core/seq.eli +701 -0
- package/stdlib/core/set.eli +312 -0
- package/stdlib/core/sorted.eli +53 -0
- package/stdlib/core/text.eli +103 -0
- package/stdlib/core/transducer.eli +59 -0
- package/stdlib/core/transient.eli +24 -0
- package/stdlib/core/type.eli +19 -0
- package/stdlib/core/walk.eli +195 -0
- package/stdlib/core/zipper.eli +508 -0
- package/stdlib/data-text.eli +1092 -0
- package/stdlib/data.eli +42 -0
- package/stdlib/deferred.eli +70 -0
- package/stdlib/function.eli +120 -0
- package/stdlib/hierarchy.eli +245 -0
- package/stdlib/identifier.eli +147 -0
- package/stdlib/interop/js.eli +616 -0
- package/stdlib/json.eli +870 -0
- package/stdlib/metadata.eli +56 -0
- package/stdlib/multimethod.eli +464 -0
- package/stdlib/numeric.eli +193 -0
- package/stdlib/object.eli +96 -0
- package/stdlib/persistent-list.eli +145 -0
- package/stdlib/persistent-map.eli +724 -0
- package/stdlib/persistent-queue.eli +32 -0
- package/stdlib/persistent-set.eli +236 -0
- package/stdlib/persistent-vector.eli +342 -0
- package/stdlib/result.eli +141 -0
- package/stdlib/sequence.eli +106 -0
- package/stdlib/state/atom.eli +265 -0
- package/stdlib/text.eli +88 -0
- package/stdlib/value.eli +325 -0
package/stdlib/README.md
ADDED
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
# Standard Library
|
|
2
|
+
|
|
3
|
+
[Project README](../README.md) | [Runtime](../runtime/README.md) |
|
|
4
|
+
[Specifications](../specs/README.md) | [Generated API Index](../docs/pages/api.html)
|
|
5
|
+
|
|
6
|
+
This directory contains portable Eliscript functions and macros plus focused
|
|
7
|
+
runtime-backed `core/` modules for semantics that need optimized host support.
|
|
8
|
+
UI-library and publishing support should be focused application packages, not
|
|
9
|
+
special cases embedded throughout the compiler or core standard library.
|
|
10
|
+
|
|
11
|
+
Framework integration uses ordinary ESM imports and calls. The standard
|
|
12
|
+
library contains no framework lowering or framework-specific helpers;
|
|
13
|
+
application ergonomics belong in replaceable application packages.
|
|
14
|
+
|
|
15
|
+
The generated API index is the exact current module/export inventory. Its
|
|
16
|
+
stability labels come from each module's owning specification and remain
|
|
17
|
+
provisional wherever the label is `accepted`.
|
|
18
|
+
|
|
19
|
+
## Core Collections
|
|
20
|
+
|
|
21
|
+
`core/collection.eli` exposes open collection capabilities alongside exact
|
|
22
|
+
persistent value categories. Capability predicates such as `counted?` and
|
|
23
|
+
`seqable?` can recognize supported host values, while `collection?`, `list?`,
|
|
24
|
+
`vector?`, `map?`, `set?`, `sequential?`, and `sequence?` describe Eliscript's
|
|
25
|
+
own persistent values and logical sequence views:
|
|
26
|
+
|
|
27
|
+
```elisp
|
|
28
|
+
(import "../../stdlib/core/collection.eli"
|
|
29
|
+
bounded-count collection? distinct? sequence? subvec vector?)
|
|
30
|
+
|
|
31
|
+
[(collection? [1 2 3])
|
|
32
|
+
(vector? [1 2 3])
|
|
33
|
+
(sequence? [1 2 3])
|
|
34
|
+
(bounded-count 2 [1 2 3])
|
|
35
|
+
(subvec [10 20 30 40] 1 3)
|
|
36
|
+
(distinct? [1 2] [1 2])]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`bounded-count` consumes at most its non-negative safe-integer limit, including
|
|
40
|
+
for unbounded views. `distinct?` compares persistent values structurally and
|
|
41
|
+
host objects by identity. Exact classification and traversal semantics are in
|
|
42
|
+
[0164](../specs/0164-persistent-collection-classification.md).
|
|
43
|
+
`subvec` adds O(1) persistent Vector range views with complete protocol,
|
|
44
|
+
structural-sharing, metadata, and value behavior; see
|
|
45
|
+
[0165](../specs/0165-persistent-subvector-views.md).
|
|
46
|
+
|
|
47
|
+
`persistent-queue.eli` exposes an immutable FIFO collection backed by shared
|
|
48
|
+
Vector views. Its append and removal operations compose with the
|
|
49
|
+
same collection, value, and metadata protocols; see
|
|
50
|
+
[0166](../specs/0166-persistent-queue.md).
|
|
51
|
+
|
|
52
|
+
`core/record.eli` supports declarative immutable domain types. A declaration
|
|
53
|
+
such as `(defrecord Person [name age])` creates the exact type `Person`, the
|
|
54
|
+
constructors `->Person` and `map->Person`, and the predicate `Person?`.
|
|
55
|
+
Records compose with persistent Map operations, value equality and hashing,
|
|
56
|
+
metadata, and `extend-type`; see [0168](../specs/0168-immutable-record-types.md).
|
|
57
|
+
|
|
58
|
+
`core/type.eli` is the lower-level protocol implementation layer. `deftype`
|
|
59
|
+
creates frozen positional identity values with direct protocol methods, while
|
|
60
|
+
`reify` creates a frozen anonymous implementation whose methods capture lexical
|
|
61
|
+
bindings. Both require complete protocol implementations; see
|
|
62
|
+
[0169](../specs/0169-protocol-implementation-values.md).
|
|
63
|
+
|
|
64
|
+
## Core Ordering
|
|
65
|
+
|
|
66
|
+
`core/order.eli` provides the maintained language-level comparison and sorting
|
|
67
|
+
algorithms over the runtime's open `IComparable` protocol:
|
|
68
|
+
|
|
69
|
+
```elisp
|
|
70
|
+
(import "../../stdlib/core/order.eli"
|
|
71
|
+
compare-values reverse-comparator sort sort-by)
|
|
72
|
+
|
|
73
|
+
[(sort [3 1 2 1])
|
|
74
|
+
(sort (reverse-comparator) [3 1 2 1])
|
|
75
|
+
(sort-by (lambda (entry) (get entry :priority)) entries)]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Natural comparison covers nullish values, booleans, numbers, big integers,
|
|
79
|
+
strings, Keywords, Symbols, persistent Lists, and persistent Vectors. Custom
|
|
80
|
+
types participate through ordinary protocol extension. Sorting is stable,
|
|
81
|
+
accepts any reducible source, caches each key exactly once, returns a persistent
|
|
82
|
+
Vector, and never mutates its source. `min-key` and `max-key` choose the last
|
|
83
|
+
value on an equal key, matching the stable tie contract.
|
|
84
|
+
|
|
85
|
+
## Functional Combinators
|
|
86
|
+
|
|
87
|
+
`function.eli` supplies ten higher-order building blocks in portable
|
|
88
|
+
Eliscript, without compiler intrinsics or host-framework helpers:
|
|
89
|
+
|
|
90
|
+
```elisp
|
|
91
|
+
(import "../../stdlib/function.eli"
|
|
92
|
+
comp every-pred fnil juxt partial trampoline)
|
|
93
|
+
|
|
94
|
+
[(funcall (comp (lambda (value) (* value 2)) +) 3 4)
|
|
95
|
+
(funcall (juxt 1+ 1-) 5)
|
|
96
|
+
(funcall (fnil + 0 0) nil 8)]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Composition runs right to left, partial application preserves every forwarded
|
|
100
|
+
value including JavaScript `undefined`, and `juxt` returns a persistent Vector.
|
|
101
|
+
`every-pred` and `some-fn` preserve Lisp truth and short-circuit in documented
|
|
102
|
+
predicate-major order. `trampoline` evaluates arbitrarily long thunk chains
|
|
103
|
+
with constant stack usage. The complete identity, argument, nullish, ordering,
|
|
104
|
+
and portability contracts are specified in
|
|
105
|
+
[0149](../specs/0149-portable-functional-combinators.md).
|
|
106
|
+
|
|
107
|
+
## Deferred Computation
|
|
108
|
+
|
|
109
|
+
`deferred.eli` provides synchronous delayed values and value-semantic function
|
|
110
|
+
memoization without compiler syntax or framework policy:
|
|
111
|
+
|
|
112
|
+
```elisp
|
|
113
|
+
(import "../../stdlib/deferred.eli" delay force memoize realized?)
|
|
114
|
+
|
|
115
|
+
(let* ((answer (delay (lambda () (expensive-computation))))
|
|
116
|
+
(cached-score (memoize score)))
|
|
117
|
+
[(realized? answer)
|
|
118
|
+
(force answer)
|
|
119
|
+
(funcall cached-score document options)])
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
A Delay producer runs only on its first successful `force`; errors restore the
|
|
123
|
+
pending state, recursive forcing is rejected, and all successful values
|
|
124
|
+
including `nil`, `undefined`, and `false` are retained exactly. Memoization keys
|
|
125
|
+
complete argument vectors with persistent value equality, so structurally equal
|
|
126
|
+
persistent inputs share cache entries. Exact identity, retry, error, and host
|
|
127
|
+
parity semantics are specified in
|
|
128
|
+
[0161](../specs/0161-deferred-and-memoized-computation.md).
|
|
129
|
+
|
|
130
|
+
## Bit
|
|
131
|
+
|
|
132
|
+
`bit.eli` builds population count and 32-bit rotations entirely from portable
|
|
133
|
+
Eliscript intrinsics:
|
|
134
|
+
|
|
135
|
+
```elisp
|
|
136
|
+
(import "../../stdlib/bit.eli" bit-count rotate-left rotate-right)
|
|
137
|
+
|
|
138
|
+
(bit-count -1)
|
|
139
|
+
(rotate-left 305419896 8)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
`bit-count` uses parallel masked reduction rather than a per-bit loop.
|
|
143
|
+
Rotations normalize their distance to five bits and return unsigned words.
|
|
144
|
+
The module is the reference algorithm layer for future trie and hash sources;
|
|
145
|
+
exact normalization and shift semantics are specified in
|
|
146
|
+
[specs/0052-portable-32-bit-operations.md](../specs/0052-portable-32-bit-operations.md).
|
|
147
|
+
|
|
148
|
+
## Persistent List
|
|
149
|
+
|
|
150
|
+
`persistent-list.eli` implements an immutable singly linked List in portable
|
|
151
|
+
Eliscript. `cons` and `conj` allocate one front node; `first`, `rest`, `peek`,
|
|
152
|
+
and `pop` are constant-time operations, and the new value shares its complete
|
|
153
|
+
old suffix by identity:
|
|
154
|
+
|
|
155
|
+
```elisp
|
|
156
|
+
(import "../../stdlib/persistent-list.eli"
|
|
157
|
+
empty-persistent-list persistent-list-cons persistent-list-first)
|
|
158
|
+
|
|
159
|
+
(persistent-list-first
|
|
160
|
+
(persistent-list-cons (empty-persistent-list) "value")
|
|
161
|
+
nil)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Reduction and reversal are iterative and remain stack safe at one million
|
|
165
|
+
nodes. The representation and provisional failure semantics are specified in
|
|
166
|
+
[specs/0054-eliscript-persistent-list.md](../specs/0054-eliscript-persistent-list.md).
|
|
167
|
+
|
|
168
|
+
## Persistent Vector
|
|
169
|
+
|
|
170
|
+
`persistent-vector.eli` is the first complete persistent collection algorithm
|
|
171
|
+
written in portable Eliscript. It implements a 32-way trie, a bounded short
|
|
172
|
+
tail, path-copying `conj`, `assoc`, and `pop`, chunked reduction, and explicit
|
|
173
|
+
native-array conversion:
|
|
174
|
+
|
|
175
|
+
```elisp
|
|
176
|
+
(import "../../stdlib/persistent-vector.eli"
|
|
177
|
+
empty-persistent-vector persistent-vector-conj persistent-vector-nth)
|
|
178
|
+
|
|
179
|
+
(persistent-vector-nth
|
|
180
|
+
(persistent-vector-conj (empty-persistent-vector) "value")
|
|
181
|
+
0
|
|
182
|
+
nil)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
The source does not import the JavaScript collection runtime and does not use
|
|
186
|
+
host mutation. It is the readable correctness reference for later collection
|
|
187
|
+
protocol, transient, and literal work. Exact provisional semantics and
|
|
188
|
+
structural evidence are specified in
|
|
189
|
+
[specs/0053-eliscript-persistent-vector.md](../specs/0053-eliscript-persistent-vector.md).
|
|
190
|
+
|
|
191
|
+
## Persistent Map
|
|
192
|
+
|
|
193
|
+
`persistent-map.eli` implements the complete associative HAMT in portable
|
|
194
|
+
Eliscript. Sparse bitmap nodes, dense 32-slot nodes, full-hash collision nodes,
|
|
195
|
+
and entries are immutable; association and removal copy only the selected
|
|
196
|
+
path. Its low-level constructors accept explicit hash, key-equality, and
|
|
197
|
+
value-equality functions for specialized domains:
|
|
198
|
+
|
|
199
|
+
```elisp
|
|
200
|
+
(import "../../stdlib/persistent-map.eli"
|
|
201
|
+
empty-persistent-map persistent-map-assoc persistent-map-get)
|
|
202
|
+
|
|
203
|
+
(let* ((hash (lambda (key) key))
|
|
204
|
+
(equal (lambda (left right) (= left right)))
|
|
205
|
+
(map (persistent-map-assoc
|
|
206
|
+
(empty-persistent-map hash equal equal)
|
|
207
|
+
7
|
|
208
|
+
"value")))
|
|
209
|
+
(persistent-map-get map 7 nil))
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Seed and self-hosted outputs are byte-identical. Bun and Node agree on a
|
|
213
|
+
100,000-key fixture, while generated model histories, complete-hash
|
|
214
|
+
collisions, measured 32/24 node transitions, and a million-key update prove
|
|
215
|
+
correctness and structural sharing. Exact provisional semantics are specified
|
|
216
|
+
in [specs/0055-eliscript-persistent-map.md](../specs/0055-eliscript-persistent-map.md).
|
|
217
|
+
|
|
218
|
+
## Persistent Set
|
|
219
|
+
|
|
220
|
+
`persistent-set.eli` is a thin immutable membership and collection-algebra
|
|
221
|
+
layer over `persistent-map.eli`. It imports the Map through a verified portable
|
|
222
|
+
source edge and duplicates no HAMT node or routing algorithm:
|
|
223
|
+
|
|
224
|
+
```elisp
|
|
225
|
+
(import "../../stdlib/persistent-set.eli"
|
|
226
|
+
empty-persistent-set persistent-set-conj persistent-set-has?)
|
|
227
|
+
|
|
228
|
+
(let* ((hash (lambda (value) value))
|
|
229
|
+
(equal (lambda (left right) (= left right)))
|
|
230
|
+
(set (persistent-set-conj
|
|
231
|
+
(empty-persistent-set hash equal)
|
|
232
|
+
7)))
|
|
233
|
+
(persistent-set-has? set 7))
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
The provisional API includes union, intersection, difference, subset,
|
|
237
|
+
superset, disjointness, equality, reduction, and explicit array conversion.
|
|
238
|
+
Two Sets must share the exact hash and key-equality function identities before
|
|
239
|
+
binary algebra is accepted. Dual-compiler/dual-host reports, generated model
|
|
240
|
+
histories, collision and 32/24 transition cases, and a million-member sharing
|
|
241
|
+
test are specified in
|
|
242
|
+
[specs/0056-eliscript-persistent-set.md](../specs/0056-eliscript-persistent-set.md).
|
|
243
|
+
|
|
244
|
+
## Value Semantics
|
|
245
|
+
|
|
246
|
+
`value.eli` is the ordinary policy layer over all four persistent collection
|
|
247
|
+
modules. It recursively compares and hashes scalars, Lists, Vectors, Maps, and
|
|
248
|
+
Sets, and supplies Map/Set constructors that share the exact same policy
|
|
249
|
+
functions:
|
|
250
|
+
|
|
251
|
+
```elisp
|
|
252
|
+
(import "../../stdlib/value.eli"
|
|
253
|
+
value-equal? value-hash
|
|
254
|
+
empty-value-map value-map-from-entries
|
|
255
|
+
empty-value-set value-set-from-array)
|
|
256
|
+
|
|
257
|
+
(value-equal?
|
|
258
|
+
(value-set-from-array [1 2 3])
|
|
259
|
+
(value-set-from-array [3 2 1]))
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Map and Set equality and hashes are independent of insertion order; List and
|
|
263
|
+
Vector remain distinct ordered value families. Nested `undefined` is preserved
|
|
264
|
+
instead of collapsing to `nil`. Opaque JavaScript objects, functions, and
|
|
265
|
+
native Symbols use process-local identity hashes backed by weak object/function
|
|
266
|
+
storage, so ordinary identity-keyed Maps and Sets retain expected HAMT depth.
|
|
267
|
+
Exact provisional semantics and evidence are in
|
|
268
|
+
[0057](../specs/0057-portable-value-semantics.md) and
|
|
269
|
+
[0074](../specs/0074-process-local-host-identity-hashing.md).
|
|
270
|
+
|
|
271
|
+
## Numeric Foundation
|
|
272
|
+
|
|
273
|
+
`numeric.eli` exposes the binary64 Number model and exact safe-integer
|
|
274
|
+
operations without a JavaScript Math dependency:
|
|
275
|
+
|
|
276
|
+
```elisp
|
|
277
|
+
(import "../../stdlib/numeric.eli"
|
|
278
|
+
checked-multiply gcd modulo quot rem safe-integer?)
|
|
279
|
+
|
|
280
|
+
[(safe-integer? 9007199254740991)
|
|
281
|
+
(quot -5 3)
|
|
282
|
+
(rem -5 3)
|
|
283
|
+
(modulo -5 3)
|
|
284
|
+
(gcd 54 24)
|
|
285
|
+
(checked-multiply 9007199254740991 2)]
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Classification covers finite values, NaN, infinities, integers, safe
|
|
289
|
+
integers, sign, zero, and parity. Checked arithmetic returns nil instead of a
|
|
290
|
+
rounded unsafe result. `quot` truncates toward zero, `rem` follows the dividend
|
|
291
|
+
sign, and `modulo` follows the divisor sign. GCD and overflow-checked LCM are
|
|
292
|
+
iterative. See [0077](../specs/0077-portable-numeric-foundation.md) for the
|
|
293
|
+
complete 25-operation provisional contract.
|
|
294
|
+
|
|
295
|
+
## Result Values
|
|
296
|
+
|
|
297
|
+
`result.eli` exports portable, value-semantic Ok and Err records plus branch
|
|
298
|
+
and persistent-Vector combinators:
|
|
299
|
+
|
|
300
|
+
```elisp
|
|
301
|
+
(import "../../stdlib/result.eli"
|
|
302
|
+
and-then err map-ok ok result-payload traverse-results)
|
|
303
|
+
|
|
304
|
+
(and-then
|
|
305
|
+
(lambda (value) (if (> value 0) (ok (* value 2)) (err "not positive")))
|
|
306
|
+
(map-ok 1+ (ok 20)))
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Results are exact three-field persistent Maps, not JavaScript classes. Equal
|
|
310
|
+
payloads produce equal Results and hashes, reconstructed Results work as Map
|
|
311
|
+
keys, and false, nil, and undefined remain valid payloads. Inactive branch
|
|
312
|
+
combinators preserve the exact input identity. `collect-results` and
|
|
313
|
+
`traverse-results` return persistent Vectors, preserve order, and stop at the
|
|
314
|
+
first non-Ok item without recursive stack growth. See
|
|
315
|
+
[0075](../specs/0075-portable-result-values.md) for the complete 15-operation
|
|
316
|
+
surface and portability contract.
|
|
317
|
+
|
|
318
|
+
## JSON Values
|
|
319
|
+
|
|
320
|
+
`json.eli` implements strict JSON parsing and deterministic encoding entirely
|
|
321
|
+
as portable Eliscript. Parsed arrays become persistent Vectors and objects
|
|
322
|
+
become value-semantic persistent Maps:
|
|
323
|
+
|
|
324
|
+
```elisp
|
|
325
|
+
(import "../../stdlib/json.eli" parse-json stringify-json)
|
|
326
|
+
(import "../../stdlib/result.eli" and-then ok result-payload)
|
|
327
|
+
|
|
328
|
+
(and-then stringify-json
|
|
329
|
+
(parse-json "{\"items\":[1,2,3],\"ready\":true}"))
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Both operations return Result values. The encoder accepts only nil, booleans,
|
|
333
|
+
finite numbers, strings, persistent Vectors, and string-keyed persistent Maps;
|
|
334
|
+
native containers and other Eliscript value families require an explicit
|
|
335
|
+
boundary conversion. Object keys are sorted, duplicate input keys are
|
|
336
|
+
rejected, UTF-16 strings are escaped deterministically, and length, depth, and
|
|
337
|
+
value-count limits are configurable. See
|
|
338
|
+
[0076](../specs/0076-portable-json-values.md) for the seven-operation surface,
|
|
339
|
+
error codes, limits, and portability contract.
|
|
340
|
+
|
|
341
|
+
## Identifier Values
|
|
342
|
+
|
|
343
|
+
`core/identifier.eli` exposes optimized immutable, qualified Keyword and
|
|
344
|
+
Symbol values. `identifier.eli` provides matching constructors implemented
|
|
345
|
+
entirely with `defportable`:
|
|
346
|
+
|
|
347
|
+
```elisp
|
|
348
|
+
(import "../../stdlib/core/identifier.eli"
|
|
349
|
+
identifier-name keyword keyword? qualified-name symbol symbol?)
|
|
350
|
+
|
|
351
|
+
(let ((key (keyword "article/title"))
|
|
352
|
+
(name (symbol "article" "title")))
|
|
353
|
+
[(keyword? key)
|
|
354
|
+
(symbol? name)
|
|
355
|
+
(identifier-name key)
|
|
356
|
+
(qualified-name name)])
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
Keywords are interned; Symbols are non-interned values with namespace/name
|
|
360
|
+
equality. Both use deterministic hashes and work as runtime and portable value
|
|
361
|
+
Map keys or Set members. JSON serialization is deliberately rejected until a
|
|
362
|
+
versioned value codec exists. Source literals remain unchanged in this slice.
|
|
363
|
+
Portable Keywords are not interned, but equal portable/runtime identifiers
|
|
364
|
+
share hashes and cross-representation Map/Set behavior. Exact semantics are
|
|
365
|
+
specified in [0067](../specs/0067-first-class-keyword-symbol-values.md) and
|
|
366
|
+
[0070](../specs/0070-portable-identifier-values.md).
|
|
367
|
+
|
|
368
|
+
## Metadata
|
|
369
|
+
|
|
370
|
+
`metadata.eli` implements portable metadata dispatch for persistent Lists,
|
|
371
|
+
Vectors, Maps, and Sets. `core/metadata.eli` exposes the optimized runtime
|
|
372
|
+
protocols to ordinary Eliscript source:
|
|
373
|
+
|
|
374
|
+
```elisp
|
|
375
|
+
(import "../../stdlib/core/metadata.eli"
|
|
376
|
+
meta supports-metadata? vary-meta with-meta)
|
|
377
|
+
(import "../../runtime/core/map.mjs" persistentHashMap)
|
|
378
|
+
(import "../../runtime/core/vector.mjs" persistentVector)
|
|
379
|
+
|
|
380
|
+
(let ((value (with-meta
|
|
381
|
+
(persistentVector 1 2 3)
|
|
382
|
+
(persistentHashMap ["source" "example"]))))
|
|
383
|
+
[(supports-metadata? value)
|
|
384
|
+
(meta value)
|
|
385
|
+
(vary-meta value
|
|
386
|
+
(lambda (current) current))])
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Metadata is `nil` or a persistent Map. It changes only the root wrapper,
|
|
390
|
+
survives persistent and transient updates, and does not affect equality or
|
|
391
|
+
hashing. The portable collection modules also export representation-level
|
|
392
|
+
`*-meta` and `*-with-meta` functions for portable dispatch. Exact semantics
|
|
393
|
+
are specified in
|
|
394
|
+
[specs/0068-immutable-metadata-semantics.md](../specs/0068-immutable-metadata-semantics.md).
|
|
395
|
+
|
|
396
|
+
## Canonical Runtime Data Text
|
|
397
|
+
|
|
398
|
+
`core/data-text.eli` exposes the optimized runtime printer and reader through
|
|
399
|
+
Lisp-named functions:
|
|
400
|
+
|
|
401
|
+
```elisp
|
|
402
|
+
(import "../../stdlib/core/data-text.eli"
|
|
403
|
+
print-value read-value read-values)
|
|
404
|
+
|
|
405
|
+
(read-value
|
|
406
|
+
(print-value
|
|
407
|
+
(read-value "^{:source \"example\"} {:values [1 2 3]}")))
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
The format covers scalar edges, Keyword/Symbol values, persistent Vector, Map,
|
|
411
|
+
Set, and metadata values. Map and Set output is deterministic, malformed and
|
|
412
|
+
duplicate data is rejected with source positions, and explicit limits bound
|
|
413
|
+
depth, text length, and value count. Portable List and portable collection
|
|
414
|
+
representations remain outside this optimized module and are implemented
|
|
415
|
+
separately in `data-text.eli`. See
|
|
416
|
+
[specs/0069-canonical-runtime-data-text.md](../specs/0069-canonical-runtime-data-text.md).
|
|
417
|
+
|
|
418
|
+
## Canonical Portable Data Text
|
|
419
|
+
|
|
420
|
+
`data-text.eli` prints and reads scalar, identifier, persistent List, Vector,
|
|
421
|
+
Map, Set, and metadata values without importing the JavaScript collection
|
|
422
|
+
runtime:
|
|
423
|
+
|
|
424
|
+
```elisp
|
|
425
|
+
(import "../../stdlib/data-text.eli"
|
|
426
|
+
data-text-result-value print-value read-value)
|
|
427
|
+
|
|
428
|
+
(data-text-result-value
|
|
429
|
+
(read-value
|
|
430
|
+
(data-text-result-value
|
|
431
|
+
(print-value value))))
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
Portable operations return explicit success/failure objects because portable
|
|
435
|
+
closures do not use exception control flow. Successful values live in a
|
|
436
|
+
one-element payload so `undefined` remains distinguishable from failure.
|
|
437
|
+
Lists use `(...)`; Map and Set output uses a stable Eliscript-authored merge
|
|
438
|
+
sort. Located errors and default depth, length, and value-count limits match
|
|
439
|
+
the runtime format. See
|
|
440
|
+
[specs/0071-canonical-portable-data-text.md](../specs/0071-canonical-portable-data-text.md).
|
|
441
|
+
|
|
442
|
+
## Atom State
|
|
443
|
+
|
|
444
|
+
`state/atom.eli` separates changing identity from immutable persistent values:
|
|
445
|
+
|
|
446
|
+
```elisp
|
|
447
|
+
(import "../../stdlib/state/atom.eli"
|
|
448
|
+
add-watch atom compare-and-set! deref reset-vals! swap-vals!)
|
|
449
|
+
|
|
450
|
+
(let ((counter (atom 0)))
|
|
451
|
+
(add-watch counter "log"
|
|
452
|
+
(lambda (_key _reference old-value new-value)
|
|
453
|
+
(print old-value new-value)))
|
|
454
|
+
(swap-vals! counter (lambda (value amount) (+ value amount)) 2)
|
|
455
|
+
(compare-and-set! counter 2 8)
|
|
456
|
+
(reset-vals! counter 10)
|
|
457
|
+
(deref counter))
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
Validators run before installation. Watches receive committed old/new pairs
|
|
461
|
+
after installation, and nested watch updates are queued so one transition's
|
|
462
|
+
complete watch snapshot runs before the next transition. Validator and swap
|
|
463
|
+
callbacks cannot recursively change the same Atom, preventing stale outer
|
|
464
|
+
writes. Compare-and-set uses canonical value equality and does no work on a
|
|
465
|
+
mismatch. The `-vals!` operations return persistent old/new pairs. Atom
|
|
466
|
+
failures use structured codes; user callback exceptions retain
|
|
467
|
+
their original identity. Atoms are host identities and are deliberately not
|
|
468
|
+
part of canonical data text or portable worker values. Exact semantics and
|
|
469
|
+
cross-compiler/cross-host evidence are specified in
|
|
470
|
+
[0072](../specs/0072-atomic-state-references.md).
|
|
471
|
+
|
|
472
|
+
## Value-dispatched Multimethods
|
|
473
|
+
|
|
474
|
+
`multimethod.eli` creates callable functions whose implementation is selected
|
|
475
|
+
from the value returned by a dispatch function:
|
|
476
|
+
|
|
477
|
+
```elisp
|
|
478
|
+
(import "../../stdlib/multimethod.eli"
|
|
479
|
+
add-method! multi-fn methods remove-method!)
|
|
480
|
+
|
|
481
|
+
(let ((render (multi-fn "render" (lambda (kind value) kind))))
|
|
482
|
+
(add-method! render "text"
|
|
483
|
+
(lambda (_kind value) (str "text:" value)))
|
|
484
|
+
(add-method! render "default"
|
|
485
|
+
(lambda (kind value) (str kind ":" value)))
|
|
486
|
+
(render "text" "hello"))
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
Dispatch keys use Eliscript value equality, so independently constructed equal
|
|
490
|
+
persistent values select the same method. Method additions, replacements, and
|
|
491
|
+
removals install new Persistent Map roots; a previous `methods` result remains
|
|
492
|
+
an immutable snapshot. The callable identity is authenticated by a private
|
|
493
|
+
weak registry, while dispatch and method exceptions keep their original
|
|
494
|
+
identity. Exact behavior is specified in
|
|
495
|
+
[0156](../specs/0156-value-dispatched-multimethods.md).
|
|
496
|
+
|
|
497
|
+
`hierarchy.eli` adds immutable derivation snapshots, and multimethods can use
|
|
498
|
+
those snapshots for ancestor dispatch with explicit preferences:
|
|
499
|
+
|
|
500
|
+
```elisp
|
|
501
|
+
(import "../../stdlib/multimethod.eli"
|
|
502
|
+
add-method! derive! multi-fn prefer-method!)
|
|
503
|
+
|
|
504
|
+
(let ((render (multi-fn "render" (lambda (kind) kind))))
|
|
505
|
+
(derive! render "photo" "media")
|
|
506
|
+
(derive! render "photo" "visual")
|
|
507
|
+
(add-method! render "media" (lambda (_kind) "media"))
|
|
508
|
+
(add-method! render "visual" (lambda (_kind) "visual"))
|
|
509
|
+
(prefer-method! render "visual" "media")
|
|
510
|
+
(render "photo"))
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
Unordered matching ancestors raise an ambiguity error. Exact methods remain
|
|
514
|
+
the fast path, and every method, hierarchy, or preference mutation invalidates
|
|
515
|
+
derived cache entries. Full behavior is specified in
|
|
516
|
+
[0157](../specs/0157-persistent-dispatch-hierarchies.md).
|
|
517
|
+
|
|
518
|
+
## JavaScript Container Interop
|
|
519
|
+
|
|
520
|
+
`interop/js.eli` defines the explicit boundary between immutable persistent
|
|
521
|
+
values and native mutable JavaScript containers:
|
|
522
|
+
|
|
523
|
+
```elisp
|
|
524
|
+
(import "../../stdlib/interop/js.eli"
|
|
525
|
+
from-js js-array js-object to-js to-js-object)
|
|
526
|
+
|
|
527
|
+
(let* ((source (js-object "items" (js-array "left" "right")))
|
|
528
|
+
(state (from-js source (js* "({deep: true})")))
|
|
529
|
+
(props (to-js-object state (js* "({deep: true})"))))
|
|
530
|
+
props)
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
`to-js` and `from-js` are shallow by default. Deep conversion is explicit and
|
|
534
|
+
supports mixed portable/runtime List, Vector, Map, Set, native Array, Map,
|
|
535
|
+
Set, and plain-object graphs. It preserves repeated source identity, rejects
|
|
536
|
+
cycles with exact paths, rejects accessors without executing them, and refuses
|
|
537
|
+
Map/Set conversions that would silently collapse value-equal keys or members.
|
|
538
|
+
`to-js-object` is the focused UI props and JavaScript options adapter. A
|
|
539
|
+
particular framework may consume it, but no framework defines its semantics.
|
|
540
|
+
Exact semantics and cross-compiler/cross-host evidence are specified in
|
|
541
|
+
[0073](../specs/0073-native-javascript-container-interop.md).
|
|
542
|
+
|
|
543
|
+
## Protocol-driven Core
|
|
544
|
+
|
|
545
|
+
`core/seq.eli`, `core/data.eli`, and `core/set.eli` expose the current
|
|
546
|
+
protocol-driven runtime algorithms through Lisp-named Eliscript modules:
|
|
547
|
+
|
|
548
|
+
```elisp
|
|
549
|
+
(import "../../stdlib/core/seq.eli"
|
|
550
|
+
cycle distinct flatten generate interleave iterate map mapcat
|
|
551
|
+
partition partition-all range reductions repeat repeatedly tree-seq
|
|
552
|
+
first sequence-nth take-last drop-last split-at split-with)
|
|
553
|
+
(import "../../stdlib/core/data.eli"
|
|
554
|
+
assoc-in get-in group-by frequencies keys vals
|
|
555
|
+
update-keys update-vals merge-with select-keys zipmap)
|
|
556
|
+
(import "../../stdlib/core/set.eli"
|
|
557
|
+
difference disjoint? index intersection join map-invert project
|
|
558
|
+
rename rename-keys select set subset? superset? union)
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
Sequence transforms accept any `IReduce` source and return persistent Vectors.
|
|
562
|
+
The maintained vocabulary includes indexed mapping/keeping, prefix and sampled
|
|
563
|
+
selection, interposition, adjacent and global deduplication, mapcat,
|
|
564
|
+
round-robin interleaving, stepped and padded partitioning, stack-safe tree
|
|
565
|
+
traversal, sequential flattening, and intermediate reduction history.
|
|
566
|
+
Boundary selection preserves present `undefined` values separately from
|
|
567
|
+
absence. Tail selection uses bounded ring storage, while positional and
|
|
568
|
+
predicate splitting traverse once and return persistent Vector pairs.
|
|
569
|
+
Keyed-data transforms return value-semantic persistent Maps, with persistent
|
|
570
|
+
Vector group values. Nested associative reads and updates preserve existing
|
|
571
|
+
container shapes and create persistent Maps for missing levels. Selection,
|
|
572
|
+
plain merge, and zipping use owner-token builders; combining merge retains
|
|
573
|
+
value-semantic prior-value lookup. Searches and bounded transforms use reduced
|
|
574
|
+
values for early termination.
|
|
575
|
+
|
|
576
|
+
`keys` and `vals` project any keyed protocol source into persistent Vectors.
|
|
577
|
+
`update-keys` and `update-vals` transform keyed entries into a new persistent
|
|
578
|
+
Map; source values remain unchanged and a transformed-key collision keeps the
|
|
579
|
+
last traversed value.
|
|
580
|
+
|
|
581
|
+
Set conversion and algebra accept arbitrary protocol collections and return
|
|
582
|
+
value-semantic persistent Sets. Intersection and difference retain left-hand
|
|
583
|
+
metadata; subset, superset, and disjoint checks stop as soon as the answer is
|
|
584
|
+
known.
|
|
585
|
+
Relations are persistent Sets of keyed rows. `select` and `project` filter and
|
|
586
|
+
shape rows, `rename-keys` and `rename` transform schemas, `index` groups rows by
|
|
587
|
+
projected persistent Map keys, and `join` performs natural or explicit
|
|
588
|
+
key-mapped joins using the smaller relation as its index.
|
|
589
|
+
|
|
590
|
+
`reduce-kv` passes indexes or stored keys directly through `IKVReduce`.
|
|
591
|
+
Persistent Vector and HAMT Map values avoid public entry allocation, external
|
|
592
|
+
keyed types can implement the capability independently, and merge operations
|
|
593
|
+
prefer the keyed path without changing Vector/Array entry-source semantics.
|
|
594
|
+
|
|
595
|
+
`dissoc` and `disj` remove one or more mappings or members through `IMap` and
|
|
596
|
+
`ISet`. `peek` and `pop` provide `IStack` access using the List head or
|
|
597
|
+
Vector/Array tail. Persistent values preserve structural sharing and their
|
|
598
|
+
existing root/navigation metadata rules; native values are copied before removal.
|
|
599
|
+
|
|
600
|
+
`counted?`, `indexed?`, `seqable?`, `reducible?`, `reversible?`, and
|
|
601
|
+
`associative?` inspect complete protocol capabilities without invoking an
|
|
602
|
+
operation. `empty?` uses `ISeqable` instead of assuming count support, while
|
|
603
|
+
`not-empty` returns nil or the original non-empty value by identity. Exact
|
|
604
|
+
capability and empty-value semantics are specified in
|
|
605
|
+
[0162](../specs/0162-collection-capability-predicates.md).
|
|
606
|
+
|
|
607
|
+
`range`, `repeat`, `repeatedly`, `iterate`, `cycle`, and `generate` create
|
|
608
|
+
replayable sequence views. Finite sources publish exact counts; open sources
|
|
609
|
+
are explicitly unbounded, so `collection-count` rejects them without starting
|
|
610
|
+
a traversal. Producer callbacks execute only for consumed values, and `cycle`
|
|
611
|
+
captures its finite `IReduce` input once as a persistent snapshot.
|
|
612
|
+
|
|
613
|
+
`rest`, `next`, `prepend`, `second`, `ffirst`, `nfirst`, `fnext`, `nnext`,
|
|
614
|
+
`nth-rest`, and `nth-next` compose replayable sequence views without realizing
|
|
615
|
+
their tails. `rest` and `nth-rest` return possibly-empty sequence values;
|
|
616
|
+
`next` and `nth-next` return nil when no value remains. Bounded, unknown, and
|
|
617
|
+
unbounded cardinality remain explicit across slicing and prepending. Exact
|
|
618
|
+
semantics are specified in
|
|
619
|
+
[0163](../specs/0163-replayable-sequence-head-tail-views.md).
|
|
620
|
+
|
|
621
|
+
`eduction` composes transducers into a replayable `IReduce`-only pipeline, so a
|
|
622
|
+
bounded consumer can transform an unbounded source without realizing an
|
|
623
|
+
intermediate Vector or tail. Reduction state is fresh for every run, while
|
|
624
|
+
`run!` provides explicit ordered side-effect consumption and returns nil.
|
|
625
|
+
|
|
626
|
+
`core/lazy-sequence.eli` adds `lazy-seq`, `lazy-cons`, `lazy-seq?`, `realized?`,
|
|
627
|
+
`realized-count`, and `realize`. Producers and recursive tails start only when
|
|
628
|
+
their next value is requested; every traversal shares one cached prefix and
|
|
629
|
+
stable failure position. Transducer `sequence` exposes mapping, filtering,
|
|
630
|
+
bounded termination, and completion output as the same memoized pull sequence,
|
|
631
|
+
so bounded consumers can process infinite inputs without an intermediate
|
|
632
|
+
collection. Recursive `lazy-cons` chains are flattened iteratively. Exact
|
|
633
|
+
semantics are specified in
|
|
634
|
+
[0176](../specs/0176-memoized-lazy-sequences.md).
|
|
635
|
+
|
|
636
|
+
The same module exposes direct `lazy-map`, `lazy-filter`, `lazy-keep`,
|
|
637
|
+
`lazy-take`, `lazy-drop`, indexed, predicate, sampling, interposition,
|
|
638
|
+
deduplication, mapcat, and partitioning variants. Each operation returns a
|
|
639
|
+
memoized pull sequence, so ordinary function composition works on unbounded
|
|
640
|
+
inputs without forcing an intermediate collection. Exact semantics are
|
|
641
|
+
specified in [0177](../specs/0177-lazy-sequence-combinators.md).
|
|
642
|
+
|
|
643
|
+
`core/regex.eli` exposes frozen authenticated patterns through `regex`,
|
|
644
|
+
`regex?`, source and flag inspection, complete matching, offset search,
|
|
645
|
+
memoized lazy scanning, and global replacement. Native matcher state is private;
|
|
646
|
+
capture groups become persistent Vectors, absent groups become nil, string
|
|
647
|
+
replacement is literal, and zero-width Unicode scans advance without looping.
|
|
648
|
+
Exact semantics are specified in
|
|
649
|
+
[0178](../specs/0178-immutable-regex-text-processing.md).
|
|
650
|
+
|
|
651
|
+
These modules intentionally import `runtime/core/*.mjs` and are not yet
|
|
652
|
+
eligible for portable closure extraction. They are the language-level entry
|
|
653
|
+
points for the current protocol core. Exact semantics and allocation evidence
|
|
654
|
+
are specified in
|
|
655
|
+
[specs/0063-protocol-driven-core-algorithms.md](../specs/0063-protocol-driven-core-algorithms.md).
|
|
656
|
+
Finite selection and splitting are specified in
|
|
657
|
+
[0150](../specs/0150-protocol-driven-finite-sequence-selection.md).
|
|
658
|
+
Replayable bounded and unbounded sources are specified in
|
|
659
|
+
[0151](../specs/0151-replayable-sequence-sources.md).
|
|
660
|
+
Replayable reduction-only transducer pipelines are specified in
|
|
661
|
+
[0152](../specs/0152-replayable-reducible-transducer-pipelines.md).
|
|
662
|
+
Key/value reduction is specified in
|
|
663
|
+
[0153](../specs/0153-key-value-reduction-protocol.md).
|
|
664
|
+
Map, Set, and Stack capabilities are specified in
|
|
665
|
+
[0154](../specs/0154-map-set-stack-capability-protocols.md).
|
|
666
|
+
Reversible traversal and the `last`/`reverse` fast path are specified in
|
|
667
|
+
[0155](../specs/0155-reversible-collection-traversal.md).
|
|
668
|
+
|
|
669
|
+
## Portable Sequence Compatibility Module
|
|
670
|
+
|
|
671
|
+
`sequence.eli` is the first standard-library module. It exports fresh-array,
|
|
672
|
+
non-mutating sequence operations:
|
|
673
|
+
|
|
674
|
+
```elisp
|
|
675
|
+
(import "../../stdlib/sequence.eli" map filter reduce range)
|
|
676
|
+
|
|
677
|
+
(map (lambda (value) (* value 2)) (range 1 5))
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
Available operations are `reverse`, `map`, `filter`, `reduce`, `concat`,
|
|
681
|
+
`range-by`, `range`, `take`, `drop`, `some?`, `every?`, and `find`. Every
|
|
682
|
+
declaration is a statically checked `defportable`; closure-only builds include
|
|
683
|
+
only the requested entries and their transitive helpers.
|
|
684
|
+
|
|
685
|
+
Compile all current modules and their external source maps with:
|
|
686
|
+
|
|
687
|
+
```sh
|
|
688
|
+
bun run compile:stdlib
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
Build and run a complete project that imports the `.eli` source directly:
|
|
692
|
+
|
|
693
|
+
```sh
|
|
694
|
+
bun run build:stdlib-cli
|
|
695
|
+
bun run dist/project/examples/stdlib-cli/main.mjs
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
See [specs/0023-portable-sequence-library.md](../specs/0023-portable-sequence-library.md)
|
|
699
|
+
for exact semantics and acceptance evidence, and
|
|
700
|
+
[specs/0024-project-builds.md](../specs/0024-project-builds.md) for recursive
|
|
701
|
+
source-module builds.
|
|
702
|
+
|
|
703
|
+
## Text
|
|
704
|
+
|
|
705
|
+
`text.eli` exports thirteen portable string operations for slicing, literal
|
|
706
|
+
matching, prefix and suffix removal, ASCII-boundary trimming, blank checks,
|
|
707
|
+
joining, and repetition:
|
|
708
|
+
|
|
709
|
+
```elisp
|
|
710
|
+
(import "../../stdlib/text.eli" contains? strip-prefix trim)
|
|
711
|
+
|
|
712
|
+
(trim (strip-prefix "#" "# article "))
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
Indices address ECMAScript UTF-16 code units. Matching is literal and does not
|
|
716
|
+
use host methods or regular expressions. Compile all current modules with
|
|
717
|
+
`bun run compile:stdlib`, or exercise them together with:
|
|
718
|
+
|
|
719
|
+
```sh
|
|
720
|
+
bun run build:stdlib-cli
|
|
721
|
+
bun run dist/project/examples/stdlib-cli/main.mjs
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
See [specs/0025-portable-text-library.md](../specs/0025-portable-text-library.md)
|
|
725
|
+
for exact semantics, dependency closure, and acceptance evidence.
|
|
726
|
+
|
|
727
|
+
## Object
|
|
728
|
+
|
|
729
|
+
`object.eli` exports eleven immutable operations for own keys, property checks,
|
|
730
|
+
shallow association, removal, merging, value transforms, selection, omission,
|
|
731
|
+
and updates:
|
|
732
|
+
|
|
733
|
+
```elisp
|
|
734
|
+
(import "../../stdlib/object.eli" assoc merge pick)
|
|
735
|
+
|
|
736
|
+
(pick (assoc (object :name "Eliscript") :runtime "JavaScript")
|
|
737
|
+
[:name :runtime])
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
All transforms return ordinary objects and do not mutate their inputs. The
|
|
741
|
+
module is portable and dependency-prunable; selecting `omit` includes only its
|
|
742
|
+
`keys`, `assoc`, and `key-in?` closure. See
|
|
743
|
+
[specs/0026-portable-object-library.md](../specs/0026-portable-object-library.md)
|
|
744
|
+
for primitive semantics.
|
|
745
|
+
|
|
746
|
+
## Portable Data Compatibility Module
|
|
747
|
+
|
|
748
|
+
`data.eli` exports `index-by`, `group-by`, and `count-by`. It is the first
|
|
749
|
+
standard module composed from another portable source module:
|
|
750
|
+
|
|
751
|
+
```elisp
|
|
752
|
+
(import-portable "./object.eli" assoc)
|
|
753
|
+
(import-portable "./object.eli" has?)
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
Ordinary compilation emits standard named ESM imports. A portable project build
|
|
757
|
+
verifies the imported declarations, follows the local graph, and emits a pruned
|
|
758
|
+
module tree:
|
|
759
|
+
|
|
760
|
+
```sh
|
|
761
|
+
../bin/eliscript-build --root . --portable group-by \
|
|
762
|
+
--out-dir ../dist/portable data.eli
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
See
|
|
766
|
+
[specs/0027-portable-data-indexing.md](../specs/0027-portable-data-indexing.md)
|
|
767
|
+
for keyed collection transforms and
|
|
768
|
+
[specs/0028-portable-module-composition.md](../specs/0028-portable-module-composition.md)
|
|
769
|
+
for the cross-module proof contract.
|
|
770
|
+
|
|
771
|
+
The Emacs indexing workload imports `count-by` from this module. Its portable
|
|
772
|
+
project build follows the dependency into `object.eli`, emits only `count-by`,
|
|
773
|
+
`assoc`, and `has?`, and executes the resulting graph in the worker. See
|
|
774
|
+
[specs/0029-portable-indexing-composition.md](../specs/0029-portable-indexing-composition.md).
|