@graffiticode/basis 1.6.1 → 1.6.3
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/CLAUDE.md +55 -0
- package/package.json +1 -1
- package/spec/package.json +6 -0
- package/spec/spec.html +291 -155
- package/spec/spec.md +164 -11
- package/src/compiler.js +40 -3
- package/src/lexicon.js +44 -35
package/spec/spec.html
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
<header>
|
|
13
13
|
<h1>Graffiticode Core Language Specification</h1>
|
|
14
14
|
<section id="intro">
|
|
15
|
-
<pre><code>Version: 0.1.
|
|
16
|
-
Date:
|
|
15
|
+
<pre><code>Version: 0.1.2
|
|
16
|
+
Date: 2026-01-26
|
|
17
17
|
</code></pre>
|
|
18
18
|
</section>
|
|
19
19
|
<nav class="spec-toc">
|
|
@@ -31,53 +31,66 @@ Date: 2025-04-30
|
|
|
31
31
|
<li><a href="#sec-Function-Application"><span class="spec-secid">3.2.1</span>Function Application</a></li>
|
|
32
32
|
<li><a href="#sec-Lists"><span class="spec-secid">3.2.2</span>Lists</a></li>
|
|
33
33
|
<li><a href="#sec-Records"><span class="spec-secid">3.2.3</span>Records</a></li>
|
|
34
|
-
<li><a href="#sec-
|
|
35
|
-
<li><a href="#sec-
|
|
34
|
+
<li><a href="#sec-Tags"><span class="spec-secid">3.2.4</span>Tags</a></li>
|
|
35
|
+
<li><a href="#sec-Lambdas"><span class="spec-secid">3.2.5</span>Lambdas</a></li>
|
|
36
|
+
<li><a href="#sec-Let-Bindings"><span class="spec-secid">3.2.6</span>Let Bindings</a></li>
|
|
36
37
|
</ol>
|
|
37
38
|
</li>
|
|
38
|
-
<li><a href="#sec-Pattern-Matching"><span class="spec-secid">3.3</span>Pattern Matching</a
|
|
39
|
-
<li><a href="#sec-Tag-Values"><span class="spec-secid">3.3.1</span>Tag Values</a></li>
|
|
39
|
+
<li><a href="#sec-Pattern-Matching"><span class="spec-secid">3.3</span>Pattern Matching</a></li>
|
|
40
40
|
</ol>
|
|
41
41
|
</li>
|
|
42
|
+
<li><a href="#sec-Type-System"><span class="spec-secid">4</span>Type System</a><ol>
|
|
43
|
+
<li><a href="#sec-Primitive-Types"><span class="spec-secid">4.1</span>Primitive Types</a></li>
|
|
44
|
+
<li><a href="#sec-Composite-Types"><span class="spec-secid">4.2</span>Composite Types</a></li>
|
|
45
|
+
<li><a href="#sec-Function-Types"><span class="spec-secid">4.3</span>Function Types</a></li>
|
|
46
|
+
<li><a href="#sec-Tag-Sets-and-Tag-Value-Type"><span class="spec-secid">4.4</span>Tag Sets and Tag Value Type</a><ol>
|
|
47
|
+
<li><a href="#sec-Tag-Identity-and-Type"><span class="spec-secid">4.4.1</span>Tag Identity and Type</a></li>
|
|
48
|
+
<li><a href="#sec-Tag-Sets-as-Structural-Types"><span class="spec-secid">4.4.2</span>Tag Sets as Structural Types</a></li>
|
|
49
|
+
<li><a href="#sec-Default-Type-tag-"><span class="spec-secid">4.4.3</span>Default Type: `tag`</a></li>
|
|
50
|
+
<li><a href="#sec-Example"><span class="spec-secid">4.4.4</span>Example</a></li>
|
|
42
51
|
</ol>
|
|
43
52
|
</li>
|
|
44
|
-
<li><a href="#sec-
|
|
45
|
-
<li><a href="#sec-Evaluation-Model"><span class="spec-secid">4.1</span>Evaluation Model</a></li>
|
|
46
|
-
<li><a href="#sec-Functions"><span class="spec-secid">4.2</span>Functions</a></li>
|
|
47
|
-
<li><a href="#sec-Scoping"><span class="spec-secid">4.3</span>Scoping</a></li>
|
|
48
|
-
<li><a href="#sec-Errors"><span class="spec-secid">4.4</span>Errors</a></li>
|
|
53
|
+
<li><a href="#sec-Example-Annotated-Definitions"><span class="spec-secid">4.5</span>Example: Annotated Definitions</a></li>
|
|
49
54
|
</ol>
|
|
50
55
|
</li>
|
|
51
|
-
<li><a href="#sec-
|
|
52
|
-
<li><a href="#sec-
|
|
53
|
-
<li><a href="#sec-
|
|
54
|
-
<li><a href="#sec-
|
|
55
|
-
<li><a href="#sec-
|
|
56
|
-
<li><a href="#sec-apply"><span class="spec-secid">5.2.3</span>apply</a></li>
|
|
57
|
-
<li><a href="#sec-div"><span class="spec-secid">5.2.4</span>div</a></li>
|
|
58
|
-
<li><a href="#sec-equiv"><span class="spec-secid">5.2.5</span>equiv</a></li>
|
|
59
|
-
<li><a href="#sec-filter"><span class="spec-secid">5.2.6</span>filter</a></li>
|
|
60
|
-
<li><a href="#sec-get"><span class="spec-secid">5.2.7</span>get</a></li>
|
|
61
|
-
<li><a href="#sec-hd"><span class="spec-secid">5.2.8</span>hd</a></li>
|
|
62
|
-
<li><a href="#sec-isEmpty"><span class="spec-secid">5.2.9</span>isEmpty</a></li>
|
|
63
|
-
<li><a href="#sec-map"><span class="spec-secid">5.2.10</span>map</a></li>
|
|
64
|
-
<li><a href="#sec-max"><span class="spec-secid">5.2.11</span>max</a></li>
|
|
65
|
-
<li><a href="#sec-min"><span class="spec-secid">5.2.12</span>min</a></li>
|
|
66
|
-
<li><a href="#sec-mod"><span class="spec-secid">5.2.13</span>mod</a></li>
|
|
67
|
-
<li><a href="#sec-mul"><span class="spec-secid">5.2.14</span>mul</a></li>
|
|
68
|
-
<li><a href="#sec-not"><span class="spec-secid">5.2.15</span>not</a></li>
|
|
69
|
-
<li><a href="#sec-nth"><span class="spec-secid">5.2.16</span>nth</a></li>
|
|
70
|
-
<li><a href="#sec-or"><span class="spec-secid">5.2.17</span>or</a></li>
|
|
71
|
-
<li><a href="#sec-range"><span class="spec-secid">5.2.18</span>range</a></li>
|
|
72
|
-
<li><a href="#sec-reduce"><span class="spec-secid">5.2.19</span>reduce</a></li>
|
|
73
|
-
<li><a href="#sec-set"><span class="spec-secid">5.2.20</span>set</a></li>
|
|
74
|
-
<li><a href="#sec-sub"><span class="spec-secid">5.2.21</span>sub</a></li>
|
|
75
|
-
<li><a href="#sec-tl"><span class="spec-secid">5.2.22</span>tl</a></li>
|
|
56
|
+
<li><a href="#sec-Semantics"><span class="spec-secid">5</span>Semantics</a><ol>
|
|
57
|
+
<li><a href="#sec-Evaluation-Model"><span class="spec-secid">5.1</span>Evaluation Model</a></li>
|
|
58
|
+
<li><a href="#sec-Functions"><span class="spec-secid">5.2</span>Functions</a></li>
|
|
59
|
+
<li><a href="#sec-Scoping"><span class="spec-secid">5.3</span>Scoping</a></li>
|
|
60
|
+
<li><a href="#sec-Errors"><span class="spec-secid">5.4</span>Errors</a></li>
|
|
76
61
|
</ol>
|
|
77
62
|
</li>
|
|
63
|
+
<li><a href="#sec-Base-Library"><span class="spec-secid">6</span>Base Library</a><ol>
|
|
64
|
+
<li><a href="#sec-Types"><span class="spec-secid">6.1</span>Types</a></li>
|
|
65
|
+
<li><a href="#sec-Built-in-Functions"><span class="spec-secid">6.2</span>Built-in Functions</a><ol>
|
|
66
|
+
<li><a href="#sec-add"><span class="spec-secid">6.2.1</span>add</a></li>
|
|
67
|
+
<li><a href="#sec-and"><span class="spec-secid">6.2.2</span>and</a></li>
|
|
68
|
+
<li><a href="#sec-apply"><span class="spec-secid">6.2.3</span>apply</a></li>
|
|
69
|
+
<li><a href="#sec-div"><span class="spec-secid">6.2.4</span>div</a></li>
|
|
70
|
+
<li><a href="#sec-equiv"><span class="spec-secid">6.2.5</span>equiv</a></li>
|
|
71
|
+
<li><a href="#sec-filter"><span class="spec-secid">6.2.6</span>filter</a></li>
|
|
72
|
+
<li><a href="#sec-get"><span class="spec-secid">6.2.7</span>get</a></li>
|
|
73
|
+
<li><a href="#sec-hd"><span class="spec-secid">6.2.8</span>hd</a></li>
|
|
74
|
+
<li><a href="#sec-isEmpty"><span class="spec-secid">6.2.9</span>isEmpty</a></li>
|
|
75
|
+
<li><a href="#sec-log"><span class="spec-secid">6.2.10</span>log</a></li>
|
|
76
|
+
<li><a href="#sec-map"><span class="spec-secid">6.2.11</span>map</a></li>
|
|
77
|
+
<li><a href="#sec-max"><span class="spec-secid">6.2.12</span>max</a></li>
|
|
78
|
+
<li><a href="#sec-min"><span class="spec-secid">6.2.13</span>min</a></li>
|
|
79
|
+
<li><a href="#sec-mod"><span class="spec-secid">6.2.14</span>mod</a></li>
|
|
80
|
+
<li><a href="#sec-mul"><span class="spec-secid">6.2.15</span>mul</a></li>
|
|
81
|
+
<li><a href="#sec-not"><span class="spec-secid">6.2.16</span>not</a></li>
|
|
82
|
+
<li><a href="#sec-nth"><span class="spec-secid">6.2.17</span>nth</a></li>
|
|
83
|
+
<li><a href="#sec-or"><span class="spec-secid">6.2.18</span>or</a></li>
|
|
84
|
+
<li><a href="#sec-range"><span class="spec-secid">6.2.19</span>range</a></li>
|
|
85
|
+
<li><a href="#sec-reduce"><span class="spec-secid">6.2.20</span>reduce</a></li>
|
|
86
|
+
<li><a href="#sec-set"><span class="spec-secid">6.2.21</span>set</a></li>
|
|
87
|
+
<li><a href="#sec-sub"><span class="spec-secid">6.2.22</span>sub</a></li>
|
|
88
|
+
<li><a href="#sec-tl"><span class="spec-secid">6.2.23</span>tl</a></li>
|
|
78
89
|
</ol>
|
|
79
90
|
</li>
|
|
80
|
-
|
|
91
|
+
</ol>
|
|
92
|
+
</li>
|
|
93
|
+
<li><a href="#sec-Program-Examples"><span class="spec-secid">7</span>Program Examples</a></li>
|
|
81
94
|
<li><a href="#index"><span class="spec-secid">§</span>Index</a></li>
|
|
82
95
|
</ol>
|
|
83
96
|
</nav>
|
|
@@ -119,6 +132,7 @@ map (double) [1 2 3]..
|
|
|
119
132
|
<section id="sec-Function-Application" secid="3.2.1">
|
|
120
133
|
<h3><span class="spec-secid" title="link to this section"><a href="#sec-Function-Application">3.2.1</a></span>Function Application</h3>
|
|
121
134
|
<p>Function application is written in prefix style: <code>add 1 2</code></p>
|
|
135
|
+
<p>Functions have fixed arity, so applications can be parsed unambiguously without grouping syntax. For example, <code>add 1 mul 2 3</code> parses as <code>add(1, mul(2, 3))</code> because the parser knows <code>add</code> takes 2 arguments and <code>mul</code> takes 2 arguments.</p>
|
|
122
136
|
<p>Parentheses are used to defer application: <code>map (double) [1 2 3]</code></p>
|
|
123
137
|
</section>
|
|
124
138
|
<section id="sec-Lists" secid="3.2.2">
|
|
@@ -128,24 +142,60 @@ map (double) [1 2 3]..
|
|
|
128
142
|
</section>
|
|
129
143
|
<section id="sec-Records" secid="3.2.3">
|
|
130
144
|
<h3><span class="spec-secid" title="link to this section"><a href="#sec-Records">3.2.3</a></span>Records</h3>
|
|
131
|
-
<
|
|
145
|
+
<p>Records may use <strong>shorthand syntax</strong> for fields where the value is a reference to a variable of the same name.</p>
|
|
146
|
+
<pre data-language="gc"><code>let foo = 10..
|
|
147
|
+
{foo} | equivalent to {foo: 10}
|
|
148
|
+
</code></pre>
|
|
149
|
+
<p>This provides a concise way to construct records using in-scope variable names as field keys and values.</p>
|
|
150
|
+
<p>You can also mix shorthand and explicit fields:</p>
|
|
151
|
+
<pre data-language="gc"><code>let x = 1..
|
|
152
|
+
let y = 2..
|
|
153
|
+
{x y z: 3} | equivalent to {x: 1, y: 2, z: 3}
|
|
154
|
+
</code></pre>
|
|
155
|
+
<pre data-language="gc"><code>{ name: "Alice", age: 30 }
|
|
156
|
+
</code></pre>
|
|
157
|
+
</section>
|
|
158
|
+
<section id="sec-Tags" secid="3.2.4">
|
|
159
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-Tags">3.2.4</a></span>Tags</h3>
|
|
160
|
+
<p>A <strong>tag value</strong> is an arity-0 symbolic value used to represent symbolic variants in pattern matching or other symbolic forms.</p>
|
|
161
|
+
<p>Tag values are <strong>only defined</strong> by using record shorthand syntax. For example:</p>
|
|
162
|
+
<pre data-language="gc"><code>{red blue green} | defines the tag values red, blue, and green
|
|
163
|
+
</code></pre>
|
|
164
|
+
<p>Tag values:</p>
|
|
165
|
+
<ul>
|
|
166
|
+
<li>Must be introduced via record shorthand notation</li>
|
|
167
|
+
<li>Are resolved as symbolic constants with identity semantics</li>
|
|
168
|
+
<li>Match directly in <code>case</code> expressions:</li>
|
|
169
|
+
</ul>
|
|
170
|
+
<pre><code>let color = get "red" {red blue green}
|
|
171
|
+
case color of
|
|
172
|
+
red: "warm"
|
|
173
|
+
blue: "cool"
|
|
174
|
+
_: "other"
|
|
175
|
+
end
|
|
132
176
|
</code></pre>
|
|
133
177
|
</section>
|
|
134
|
-
<section id="sec-Lambdas" secid="3.2.
|
|
135
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-Lambdas">3.2.
|
|
178
|
+
<section id="sec-Lambdas" secid="3.2.5">
|
|
179
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-Lambdas">3.2.5</a></span>Lambdas</h3>
|
|
136
180
|
<pre><code><x: add x 1>
|
|
137
181
|
</code></pre>
|
|
138
182
|
<p>Multiple parameters: <code><x y: add x y></code></p>
|
|
139
183
|
</section>
|
|
140
|
-
<section id="sec-Let-Bindings" secid="3.2.
|
|
141
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-Let-Bindings">3.2.
|
|
184
|
+
<section id="sec-Let-Bindings" secid="3.2.6">
|
|
185
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-Let-Bindings">3.2.6</a></span>Let Bindings</h3>
|
|
142
186
|
<pre><code>let double = <x: mul 2 x>..
|
|
143
187
|
</code></pre>
|
|
144
188
|
</section>
|
|
145
189
|
</section>
|
|
146
190
|
<section id="sec-Pattern-Matching" secid="3.3">
|
|
147
191
|
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Pattern-Matching">3.3</a></span>Pattern Matching</h2>
|
|
148
|
-
<p>Pattern matching is done using <code>case</code
|
|
192
|
+
<p>Pattern matching is done using <code>case</code>:</p>
|
|
193
|
+
<pre><code>case x of
|
|
194
|
+
0: "zero"
|
|
195
|
+
1: "one"
|
|
196
|
+
_: "other"
|
|
197
|
+
end
|
|
198
|
+
</code></pre>
|
|
149
199
|
<div class="spec-production" id="Supports">
|
|
150
200
|
<span class="spec-nt"><a href="#Supports" data-name="Supports">Supports</a></span><div class="spec-rhs"><span class="spec-nt"><span data-name="Literal">Literal</span></span><span class="spec-t">values</span></div>
|
|
151
201
|
<div class="spec-rhs"><span class="spec-nt"><span data-name="Tuple">Tuple</span></span><span class="spec-t">destructuring:</span><span class="spec-t">(a, b)</span></div>
|
|
@@ -153,31 +203,90 @@ map (double) [1 2 3]..
|
|
|
153
203
|
<div class="spec-rhs"><span class="spec-nt"><span data-name="Wildcard">Wildcard</span></span><span class="spec-t">_</span></div>
|
|
154
204
|
</div>
|
|
155
205
|
<p>Pattern matching on function arguments is disallowed.</p>
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
<
|
|
159
|
-
<
|
|
160
|
-
|
|
161
|
-
<
|
|
206
|
+
</section>
|
|
207
|
+
</section>
|
|
208
|
+
<section id="sec-Type-System" secid="4">
|
|
209
|
+
<h1><span class="spec-secid" title="link to this section"><a href="#sec-Type-System">4</a></span>Type System</h1>
|
|
210
|
+
<p>Graffiticode includes a implicit structural type system. Every expression has a statically inferred type, and type errors are detected at compile time. Explicit type annotations are not included in the grammar.</p>
|
|
211
|
+
<section id="sec-Primitive-Types" secid="4.1">
|
|
212
|
+
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Primitive-Types">4.1</a></span>Primitive Types</h2>
|
|
162
213
|
<ul>
|
|
163
|
-
<li>
|
|
164
|
-
<li>
|
|
165
|
-
<li>
|
|
214
|
+
<li><code>number</code> – Represents integers or floating-point numbers.</li>
|
|
215
|
+
<li><code>string</code> – Represents UTF-8 strings.</li>
|
|
216
|
+
<li><code>bool</code> – Represents Boolean values: <code>true</code> and <code>false</code>.</li>
|
|
217
|
+
<li><code>json</code> – Represents any JSON-compatible value (opaque, untyped).</li>
|
|
218
|
+
<li><code>any</code> – Used internally to denote an unconstrained type (e.g., during inference).</li>
|
|
219
|
+
</ul>
|
|
220
|
+
</section>
|
|
221
|
+
<section id="sec-Composite-Types" secid="4.2">
|
|
222
|
+
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Composite-Types">4.2</a></span>Composite Types</h2>
|
|
223
|
+
<ul>
|
|
224
|
+
<li><strong>Lists</strong> – Written as <code>[T]</code> where <code>T</code> is any type. <code> [string] | list of strings [number] | list of numbers [[bool]] | list of lists of booleans </code></li>
|
|
225
|
+
<li><strong>Records</strong> – Key-value maps with known keys and types. <code> { name: string, age: number } </code></li>
|
|
226
|
+
<li><strong>Tuples</strong> – Ordered, fixed-length collections with heterogeneous types. <code> (number, string, bool) </code></li>
|
|
166
227
|
</ul>
|
|
167
|
-
|
|
228
|
+
</section>
|
|
229
|
+
<section id="sec-Function-Types" secid="4.3">
|
|
230
|
+
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Function-Types">4.3</a></span>Function Types</h2>
|
|
231
|
+
<p>Functions are written using Graffiticode lambda signature syntax: <code><number number: number> | function taking two numbers and returning a number <string: [string]> | function taking a string and returning a list of strings <list record: record> | common signature for structural transformation</code></p>
|
|
232
|
+
<p>Function types are curried by default. That means: <code><number number: number></code> is equivalent to a function that returns another function: <code><number: <number: number>></code></p>
|
|
233
|
+
</section>
|
|
234
|
+
<section id="sec-Tag-Sets-and-Tag-Value-Type" secid="4.4">
|
|
235
|
+
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Tag-Sets-and-Tag-Value-Type">4.4</a></span>Tag Sets and Tag Value Type</h2>
|
|
236
|
+
<p>Tag values are symbolic constants introduced using record shorthand syntax. They have a default type of <code>tag</code>, and their identity is preserved across bindings.</p>
|
|
237
|
+
<section id="sec-Tag-Identity-and-Type" secid="4.4.1">
|
|
238
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-Tag-Identity-and-Type">4.4.1</a></span>Tag Identity and Type</h3>
|
|
239
|
+
<p>Tag values are symbolic constants identified <strong>solely by their name</strong>. The same tag name (e.g., <code>A</code>) refers to the same symbolic value, regardless of where it is defined.</p>
|
|
240
|
+
<p>Tag values compare equal by name. For example, <code>A</code> in <code>{A B}</code> and <code>A</code> in <code>{A C}</code> are equal.</p>
|
|
241
|
+
</section>
|
|
242
|
+
<section id="sec-Tag-Sets-as-Structural-Types" secid="4.4.2">
|
|
243
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-Tag-Sets-as-Structural-Types">4.4.2</a></span>Tag Sets as Structural Types</h3>
|
|
244
|
+
<p>Although tag values are globally identified by name, the <strong>type system tracks which tags are expected to co-occur</strong>.</p>
|
|
245
|
+
<p>For example, <code>{A B}</code> and <code>{A C}</code> are different types:</p>
|
|
246
|
+
<pre><code>{A B} | type: { A: tag, B: tag }
|
|
247
|
+
{A C} | type: { A: tag, C: tag }
|
|
248
|
+
</code></pre>
|
|
249
|
+
<p>This allows the type system to constrain the expected context for pattern matching, record shapes, or enum-style uses of tags.</p>
|
|
250
|
+
<p>Using tags not part of the expected set results in a type error.</p>
|
|
251
|
+
</section>
|
|
252
|
+
<section id="sec-Default-Type-tag-" secid="4.4.3">
|
|
253
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-Default-Type-tag-">4.4.3</a></span>Default Type: `tag`</h3>
|
|
254
|
+
<p>By default, a tag value has the type:</p>
|
|
255
|
+
<pre data-language="gc"><code>tag
|
|
256
|
+
</code></pre>
|
|
257
|
+
<p>When tags are introduced with:</p>
|
|
258
|
+
<pre><code>{A B C}
|
|
259
|
+
</code></pre>
|
|
260
|
+
<p>the resulting type is:</p>
|
|
261
|
+
<pre><code>{ A: tag, B: tag, C: tag }
|
|
262
|
+
</code></pre>
|
|
263
|
+
<p>This allows for composition and safe comparison.</p>
|
|
264
|
+
</section>
|
|
265
|
+
<section id="sec-Example" secid="4.4.4">
|
|
266
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-Example">4.4.4</a></span>Example</h3>
|
|
267
|
+
<pre data-language="gc"><code>let colors = {red blue green}..
|
|
268
|
+
case red of
|
|
168
269
|
red: "warm"
|
|
169
270
|
blue: "cool"
|
|
170
271
|
_: "other"
|
|
171
272
|
end
|
|
172
273
|
</code></pre>
|
|
173
|
-
<p>
|
|
274
|
+
<p>In this case, <code>red</code>, <code>blue</code>, and <code>green</code> are all of type <code>tag</code>, and <code>case</code> matches by identity.</p>
|
|
174
275
|
</section>
|
|
175
276
|
</section>
|
|
277
|
+
<section id="sec-Example-Annotated-Definitions" secid="4.5">
|
|
278
|
+
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Example-Annotated-Definitions">4.5</a></span>Example: Annotated Definitions</h2>
|
|
279
|
+
<pre data-language="gc"><code>let inc = <x: add x 1> | type: <number: number>
|
|
280
|
+
let greet = <name: concat ["Hello, " name]> | type: <string: string>
|
|
281
|
+
let zip = <xs ys: zipLists xs ys> | type: <[T] [U]: [(T, U)]>
|
|
282
|
+
</code></pre>
|
|
283
|
+
<p>(Note: actual Graffiticode does not use type annotations in <code>let</code> bindings; types are inferred.)</p>
|
|
176
284
|
</section>
|
|
177
|
-
|
|
178
|
-
<
|
|
179
|
-
<
|
|
180
|
-
<
|
|
285
|
+
</section>
|
|
286
|
+
<section id="sec-Semantics" secid="5">
|
|
287
|
+
<h1><span class="spec-secid" title="link to this section"><a href="#sec-Semantics">5</a></span>Semantics</h1>
|
|
288
|
+
<section id="sec-Evaluation-Model" secid="5.1">
|
|
289
|
+
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Evaluation-Model">5.1</a></span>Evaluation Model</h2>
|
|
181
290
|
<ul>
|
|
182
291
|
<li><strong>Purely functional</strong>: no side effects</li>
|
|
183
292
|
<li><strong>Strict evaluation</strong>: arguments evaluated before function application</li>
|
|
@@ -187,22 +296,22 @@ end
|
|
|
187
296
|
<p>This style enables a declarative and order-independent composition of functions. Since each function call returns a new model, multiple calls can be reordered without changing the final result, provided the functional dependencies are preserved.</p>
|
|
188
297
|
<p>This approach draws inspiration from <strong>Model-View-Update</strong> (MVU) architectures, in which the model represents the application state and functions describe pure, deterministic transformations of that state.</p>
|
|
189
298
|
</section>
|
|
190
|
-
<section id="sec-Functions" secid="
|
|
191
|
-
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Functions">
|
|
299
|
+
<section id="sec-Functions" secid="5.2">
|
|
300
|
+
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Functions">5.2</a></span>Functions</h2>
|
|
192
301
|
<ul>
|
|
193
302
|
<li><strong>Fixed arity</strong>: every function has a known number of parameters</li>
|
|
194
303
|
<li><strong>Curried by default</strong>: partial application supported</li>
|
|
195
304
|
</ul>
|
|
196
305
|
</section>
|
|
197
|
-
<section id="sec-Scoping" secid="
|
|
198
|
-
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Scoping">
|
|
306
|
+
<section id="sec-Scoping" secid="5.3">
|
|
307
|
+
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Scoping">5.3</a></span>Scoping</h2>
|
|
199
308
|
<ul>
|
|
200
309
|
<li><strong>Lexical scoping</strong></li>
|
|
201
310
|
<li><strong>Shadowing</strong> allowed within nested scopes</li>
|
|
202
311
|
</ul>
|
|
203
312
|
</section>
|
|
204
|
-
<section id="sec-Errors" secid="
|
|
205
|
-
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Errors">
|
|
313
|
+
<section id="sec-Errors" secid="5.4">
|
|
314
|
+
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Errors">5.4</a></span>Errors</h2>
|
|
206
315
|
<ul>
|
|
207
316
|
<li><strong>Syntax errors</strong>: raised during parsing</li>
|
|
208
317
|
<li><strong>Type errors</strong>: raised during compilation</li>
|
|
@@ -210,10 +319,10 @@ end
|
|
|
210
319
|
</ul>
|
|
211
320
|
</section>
|
|
212
321
|
</section>
|
|
213
|
-
<section id="sec-Base-Library" secid="
|
|
214
|
-
<h1><span class="spec-secid" title="link to this section"><a href="#sec-Base-Library">
|
|
215
|
-
<section id="sec-Types" secid="
|
|
216
|
-
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Types">
|
|
322
|
+
<section id="sec-Base-Library" secid="6">
|
|
323
|
+
<h1><span class="spec-secid" title="link to this section"><a href="#sec-Base-Library">6</a></span>Base Library</h1>
|
|
324
|
+
<section id="sec-Types" secid="6.1">
|
|
325
|
+
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Types">6.1</a></span>Types</h2>
|
|
217
326
|
<ul>
|
|
218
327
|
<li><code>number</code></li>
|
|
219
328
|
<li><code>string</code></li>
|
|
@@ -224,8 +333,8 @@ end
|
|
|
224
333
|
<li><code>json</code></li>
|
|
225
334
|
</ul>
|
|
226
335
|
</section>
|
|
227
|
-
<section id="sec-Built-in-Functions" secid="
|
|
228
|
-
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Built-in-Functions">
|
|
336
|
+
<section id="sec-Built-in-Functions" secid="6.2">
|
|
337
|
+
<h2><span class="spec-secid" title="link to this section"><a href="#sec-Built-in-Functions">6.2</a></span>Built-in Functions</h2>
|
|
229
338
|
<table>
|
|
230
339
|
<thead>
|
|
231
340
|
<tr>
|
|
@@ -281,6 +390,11 @@ end
|
|
|
281
390
|
<td align="left">Returns true if the list is empty</td>
|
|
282
391
|
</tr>
|
|
283
392
|
<tr>
|
|
393
|
+
<td align="left"><code>log</code></td>
|
|
394
|
+
<td align="left"><code><any: any></code></td>
|
|
395
|
+
<td align="left">Logs the value to console and returns it (identity function)</td>
|
|
396
|
+
</tr>
|
|
397
|
+
<tr>
|
|
284
398
|
<td align="left"><code>map</code></td>
|
|
285
399
|
<td align="left"><code><function list: list></code></td>
|
|
286
400
|
<td align="left">Applies function to each item</td>
|
|
@@ -347,14 +461,14 @@ end
|
|
|
347
461
|
</tr>
|
|
348
462
|
</tbody>
|
|
349
463
|
</table>
|
|
350
|
-
<section id="sec-add" secid="
|
|
351
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-add">
|
|
464
|
+
<section id="sec-add" secid="6.2.1">
|
|
465
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-add">6.2.1</a></span>add</h3>
|
|
352
466
|
<p>Add two numbers.</p>
|
|
353
467
|
<pre><code>add 2 3 | returns 5
|
|
354
468
|
</code></pre>
|
|
355
469
|
</section>
|
|
356
|
-
<section id="sec-and" secid="
|
|
357
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-and">
|
|
470
|
+
<section id="sec-and" secid="6.2.2">
|
|
471
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-and">6.2.2</a></span>and</h3>
|
|
358
472
|
<p>Logical AND operation</p>
|
|
359
473
|
<pre><code>and false false | returns false
|
|
360
474
|
and false true | returns false
|
|
@@ -362,20 +476,20 @@ and true false | returns false
|
|
|
362
476
|
and true true | returns true
|
|
363
477
|
</code></pre>
|
|
364
478
|
</section>
|
|
365
|
-
<section id="sec-apply" secid="
|
|
366
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-apply">
|
|
479
|
+
<section id="sec-apply" secid="6.2.3">
|
|
480
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-apply">6.2.3</a></span>apply</h3>
|
|
367
481
|
<p>Apply a function to an argument list</p>
|
|
368
482
|
<pre><code>apply add [1 2] | returns 3
|
|
369
483
|
</code></pre>
|
|
370
484
|
</section>
|
|
371
|
-
<section id="sec-div" secid="
|
|
372
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-div">
|
|
485
|
+
<section id="sec-div" secid="6.2.4">
|
|
486
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-div">6.2.4</a></span>div</h3>
|
|
373
487
|
<p>Divide the first number by the second</p>
|
|
374
488
|
<pre><code>div 10 2 | returns 5
|
|
375
489
|
</code></pre>
|
|
376
490
|
</section>
|
|
377
|
-
<section id="sec-equiv" secid="
|
|
378
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-equiv">
|
|
491
|
+
<section id="sec-equiv" secid="6.2.5">
|
|
492
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-equiv">6.2.5</a></span>equiv</h3>
|
|
379
493
|
<p>Tests if two values are strictly equivalent</p>
|
|
380
494
|
<pre><code>equiv 1 1 | returns true
|
|
381
495
|
equiv "a" "a" | returns true
|
|
@@ -384,75 +498,82 @@ equiv 1 2 | returns false
|
|
|
384
498
|
equiv "a" "b" | returns false
|
|
385
499
|
</code></pre>
|
|
386
500
|
</section>
|
|
387
|
-
<section id="sec-filter" secid="
|
|
388
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-filter">
|
|
501
|
+
<section id="sec-filter" secid="6.2.6">
|
|
502
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-filter">6.2.6</a></span>filter</h3>
|
|
389
503
|
<p>Filter elements matching predicate</p>
|
|
390
504
|
<pre><code>filter (<x: mod x 2>) [1 2 3 4] | returns [1 3]
|
|
391
505
|
</code></pre>
|
|
392
506
|
</section>
|
|
393
|
-
<section id="sec-get" secid="
|
|
394
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-get">
|
|
507
|
+
<section id="sec-get" secid="6.2.7">
|
|
508
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-get">6.2.7</a></span>get</h3>
|
|
395
509
|
<p>Retrieve a record field</p>
|
|
396
510
|
<pre><code>get "b" {a: 1, b: 2} | returns 2
|
|
397
511
|
</code></pre>
|
|
398
512
|
</section>
|
|
399
|
-
<section id="sec-hd" secid="
|
|
400
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-hd">
|
|
513
|
+
<section id="sec-hd" secid="6.2.8">
|
|
514
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-hd">6.2.8</a></span>hd</h3>
|
|
401
515
|
<p>Return the first item</p>
|
|
402
516
|
<pre><code>hd [10 20 30] | returns 10
|
|
403
517
|
</code></pre>
|
|
404
518
|
</section>
|
|
405
|
-
<section id="sec-isEmpty" secid="
|
|
406
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-isEmpty">
|
|
519
|
+
<section id="sec-isEmpty" secid="6.2.9">
|
|
520
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-isEmpty">6.2.9</a></span>isEmpty</h3>
|
|
407
521
|
<p>Return true if list is empty, otherwise return false</p>
|
|
408
522
|
<pre><code>isEmpty [] | returns true
|
|
409
523
|
</code></pre>
|
|
410
524
|
</section>
|
|
411
|
-
<section id="sec-
|
|
412
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-
|
|
525
|
+
<section id="sec-log" secid="6.2.10">
|
|
526
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-log">6.2.10</a></span>log</h3>
|
|
527
|
+
<p>Log a value to the console and return the value unchanged</p>
|
|
528
|
+
<pre><code>log "Hello" | prints "Hello" to console and returns "Hello"
|
|
529
|
+
log (add 1 2) | prints 3 to console and returns 3
|
|
530
|
+
</code></pre>
|
|
531
|
+
</section>
|
|
532
|
+
<section id="sec-map" secid="6.2.11">
|
|
533
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-map">6.2.11</a></span>map</h3>
|
|
413
534
|
<p>Apply a function to each element</p>
|
|
414
535
|
<pre><code>map (<x: add x 1>) [1 2 3] | returns [2 3 4]
|
|
415
536
|
</code></pre>
|
|
416
537
|
</section>
|
|
417
|
-
<section id="sec-max" secid="
|
|
418
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-max">
|
|
538
|
+
<section id="sec-max" secid="6.2.12">
|
|
539
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-max">6.2.12</a></span>max</h3>
|
|
419
540
|
<p>Return the larger of two numbers</p>
|
|
420
541
|
<pre><code>max 5 10 | returns 10
|
|
421
542
|
</code></pre>
|
|
422
543
|
</section>
|
|
423
|
-
<section id="sec-min" secid="
|
|
424
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-min">
|
|
544
|
+
<section id="sec-min" secid="6.2.13">
|
|
545
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-min">6.2.13</a></span>min</h3>
|
|
425
546
|
<p>Return the smaller of two numbers</p>
|
|
426
547
|
<pre><code>min 5 10 | returns 5
|
|
427
548
|
</code></pre>
|
|
428
549
|
</section>
|
|
429
|
-
<section id="sec-mod" secid="
|
|
430
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-mod">
|
|
550
|
+
<section id="sec-mod" secid="6.2.14">
|
|
551
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-mod">6.2.14</a></span>mod</h3>
|
|
431
552
|
<p>Compute the remainder</p>
|
|
432
553
|
<pre><code>mod 10 3 | returns 1
|
|
433
554
|
</code></pre>
|
|
434
555
|
</section>
|
|
435
|
-
<section id="sec-mul" secid="
|
|
436
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-mul">
|
|
556
|
+
<section id="sec-mul" secid="6.2.15">
|
|
557
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-mul">6.2.15</a></span>mul</h3>
|
|
437
558
|
<p>Multiply two numbers</p>
|
|
438
559
|
<pre><code>mul 4 3 | returns 12
|
|
439
560
|
</code></pre>
|
|
440
561
|
</section>
|
|
441
|
-
<section id="sec-not" secid="
|
|
442
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-not">
|
|
562
|
+
<section id="sec-not" secid="6.2.16">
|
|
563
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-not">6.2.16</a></span>not</h3>
|
|
443
564
|
<p>Logical NOT that inverts a boolean value</p>
|
|
444
565
|
<pre><code>not true | returns false
|
|
445
566
|
not false | returns true
|
|
446
567
|
</code></pre>
|
|
447
568
|
</section>
|
|
448
|
-
<section id="sec-nth" secid="
|
|
449
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-nth">
|
|
569
|
+
<section id="sec-nth" secid="6.2.17">
|
|
570
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-nth">6.2.17</a></span>nth</h3>
|
|
450
571
|
<p>Get the nth item (0-based)</p>
|
|
451
572
|
<pre><code>nth 1 [10 20 30] | returns 20
|
|
452
573
|
</code></pre>
|
|
453
574
|
</section>
|
|
454
|
-
<section id="sec-or" secid="
|
|
455
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-or">
|
|
575
|
+
<section id="sec-or" secid="6.2.18">
|
|
576
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-or">6.2.18</a></span>or</h3>
|
|
456
577
|
<p>Logical OR operation</p>
|
|
457
578
|
<pre><code>or false false | returns false
|
|
458
579
|
or false true | returns true
|
|
@@ -460,40 +581,40 @@ or true false | returns true
|
|
|
460
581
|
or true true | returns true
|
|
461
582
|
</code></pre>
|
|
462
583
|
</section>
|
|
463
|
-
<section id="sec-range" secid="
|
|
464
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-range">
|
|
584
|
+
<section id="sec-range" secid="6.2.19">
|
|
585
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-range">6.2.19</a></span>range</h3>
|
|
465
586
|
<p>Produce a range list from start to end (exclusive) with step</p>
|
|
466
587
|
<pre><code>range 1 10 2 | returns [1 3 5 7 9]
|
|
467
588
|
</code></pre>
|
|
468
589
|
</section>
|
|
469
|
-
<section id="sec-reduce" secid="
|
|
470
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-reduce">
|
|
590
|
+
<section id="sec-reduce" secid="6.2.20">
|
|
591
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-reduce">6.2.20</a></span>reduce</h3>
|
|
471
592
|
<p>Reduce a list to a single value, starting with an initial value</p>
|
|
472
593
|
<pre><code>reduce (<a b: add a b>) 0 [1 2 3 4] | returns 10
|
|
473
594
|
</code></pre>
|
|
474
595
|
</section>
|
|
475
|
-
<section id="sec-set" secid="
|
|
476
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-set">
|
|
596
|
+
<section id="sec-set" secid="6.2.21">
|
|
597
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-set">6.2.21</a></span>set</h3>
|
|
477
598
|
<p>Return a new record with an updated field</p>
|
|
478
599
|
<pre><code>set "a" 2 {a: 1} | returns {a: 2}
|
|
479
600
|
</code></pre>
|
|
480
601
|
</section>
|
|
481
|
-
<section id="sec-sub" secid="
|
|
482
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-sub">
|
|
602
|
+
<section id="sec-sub" secid="6.2.22">
|
|
603
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-sub">6.2.22</a></span>sub</h3>
|
|
483
604
|
<p>Subtract the second number from the first</p>
|
|
484
605
|
<pre><code>sub 5 2 | returns 3
|
|
485
606
|
</code></pre>
|
|
486
607
|
</section>
|
|
487
|
-
<section id="sec-tl" secid="
|
|
488
|
-
<h3><span class="spec-secid" title="link to this section"><a href="#sec-tl">
|
|
608
|
+
<section id="sec-tl" secid="6.2.23">
|
|
609
|
+
<h3><span class="spec-secid" title="link to this section"><a href="#sec-tl">6.2.23</a></span>tl</h3>
|
|
489
610
|
<p>Return all but the first item</p>
|
|
490
611
|
<pre><code>tl [10 20 30] | returns [20 30]
|
|
491
612
|
</code></pre>
|
|
492
613
|
</section>
|
|
493
614
|
</section>
|
|
494
615
|
</section>
|
|
495
|
-
<section id="sec-Program-Examples" secid="
|
|
496
|
-
<h1><span class="spec-secid" title="link to this section"><a href="#sec-Program-Examples">
|
|
616
|
+
<section id="sec-Program-Examples" secid="7">
|
|
617
|
+
<h1><span class="spec-secid" title="link to this section"><a href="#sec-Program-Examples">7</a></span>Program Examples</h1>
|
|
497
618
|
<pre><code>let double = <x: mul 2 x>..
|
|
498
619
|
map (double) [1 2 3]..
|
|
499
620
|
</code></pre>
|
|
@@ -536,61 +657,76 @@ Written in <a href="https://spec-md.com" target="_blank">Spec Markdown</a>.</foo
|
|
|
536
657
|
<li id="_sidebar_3.2.1"><a href="#sec-Function-Application"><span class="spec-secid">3.2.1</span>Function Application</a></li>
|
|
537
658
|
<li id="_sidebar_3.2.2"><a href="#sec-Lists"><span class="spec-secid">3.2.2</span>Lists</a></li>
|
|
538
659
|
<li id="_sidebar_3.2.3"><a href="#sec-Records"><span class="spec-secid">3.2.3</span>Records</a></li>
|
|
539
|
-
<li id="_sidebar_3.2.4"><a href="#sec-
|
|
540
|
-
<li id="_sidebar_3.2.5"><a href="#sec-
|
|
660
|
+
<li id="_sidebar_3.2.4"><a href="#sec-Tags"><span class="spec-secid">3.2.4</span>Tags</a></li>
|
|
661
|
+
<li id="_sidebar_3.2.5"><a href="#sec-Lambdas"><span class="spec-secid">3.2.5</span>Lambdas</a></li>
|
|
662
|
+
<li id="_sidebar_3.2.6"><a href="#sec-Let-Bindings"><span class="spec-secid">3.2.6</span>Let Bindings</a></li>
|
|
663
|
+
</ol>
|
|
664
|
+
</li>
|
|
665
|
+
<li id="_sidebar_3.3"><a href="#sec-Pattern-Matching"><span class="spec-secid">3.3</span>Pattern Matching</a></li>
|
|
541
666
|
</ol>
|
|
542
667
|
</li>
|
|
543
|
-
<li id="
|
|
544
|
-
<input hidden class="toggle" type="checkbox" id="
|
|
668
|
+
<li id="_sidebar_4"><a href="#sec-Type-System"><span class="spec-secid">4</span>Type System</a>
|
|
669
|
+
<input hidden class="toggle" type="checkbox" id="_toggle_4" /><label for="_toggle_4"></label>
|
|
670
|
+
<ol>
|
|
671
|
+
<li id="_sidebar_4.1"><a href="#sec-Primitive-Types"><span class="spec-secid">4.1</span>Primitive Types</a></li>
|
|
672
|
+
<li id="_sidebar_4.2"><a href="#sec-Composite-Types"><span class="spec-secid">4.2</span>Composite Types</a></li>
|
|
673
|
+
<li id="_sidebar_4.3"><a href="#sec-Function-Types"><span class="spec-secid">4.3</span>Function Types</a></li>
|
|
674
|
+
<li id="_sidebar_4.4"><a href="#sec-Tag-Sets-and-Tag-Value-Type"><span class="spec-secid">4.4</span>Tag Sets and Tag Value Type</a>
|
|
675
|
+
<input hidden class="toggle" type="checkbox" id="_toggle_4.4" /><label for="_toggle_4.4"></label>
|
|
545
676
|
<ol>
|
|
546
|
-
<li id="
|
|
677
|
+
<li id="_sidebar_4.4.1"><a href="#sec-Tag-Identity-and-Type"><span class="spec-secid">4.4.1</span>Tag Identity and Type</a></li>
|
|
678
|
+
<li id="_sidebar_4.4.2"><a href="#sec-Tag-Sets-as-Structural-Types"><span class="spec-secid">4.4.2</span>Tag Sets as Structural Types</a></li>
|
|
679
|
+
<li id="_sidebar_4.4.3"><a href="#sec-Default-Type-tag-"><span class="spec-secid">4.4.3</span>Default Type: `tag`</a></li>
|
|
680
|
+
<li id="_sidebar_4.4.4"><a href="#sec-Example"><span class="spec-secid">4.4.4</span>Example</a></li>
|
|
547
681
|
</ol>
|
|
548
682
|
</li>
|
|
683
|
+
<li id="_sidebar_4.5"><a href="#sec-Example-Annotated-Definitions"><span class="spec-secid">4.5</span>Example: Annotated Definitions</a></li>
|
|
549
684
|
</ol>
|
|
550
685
|
</li>
|
|
551
|
-
<li id="
|
|
552
|
-
<input hidden class="toggle" type="checkbox" id="
|
|
686
|
+
<li id="_sidebar_5"><a href="#sec-Semantics"><span class="spec-secid">5</span>Semantics</a>
|
|
687
|
+
<input hidden class="toggle" type="checkbox" id="_toggle_5" /><label for="_toggle_5"></label>
|
|
553
688
|
<ol>
|
|
554
|
-
<li id="
|
|
555
|
-
<li id="
|
|
556
|
-
<li id="
|
|
557
|
-
<li id="
|
|
689
|
+
<li id="_sidebar_5.1"><a href="#sec-Evaluation-Model"><span class="spec-secid">5.1</span>Evaluation Model</a></li>
|
|
690
|
+
<li id="_sidebar_5.2"><a href="#sec-Functions"><span class="spec-secid">5.2</span>Functions</a></li>
|
|
691
|
+
<li id="_sidebar_5.3"><a href="#sec-Scoping"><span class="spec-secid">5.3</span>Scoping</a></li>
|
|
692
|
+
<li id="_sidebar_5.4"><a href="#sec-Errors"><span class="spec-secid">5.4</span>Errors</a></li>
|
|
558
693
|
</ol>
|
|
559
694
|
</li>
|
|
560
|
-
<li id="
|
|
561
|
-
<input hidden class="toggle" type="checkbox" id="
|
|
695
|
+
<li id="_sidebar_6"><a href="#sec-Base-Library"><span class="spec-secid">6</span>Base Library</a>
|
|
696
|
+
<input hidden class="toggle" type="checkbox" id="_toggle_6" /><label for="_toggle_6"></label>
|
|
562
697
|
<ol>
|
|
563
|
-
<li id="
|
|
564
|
-
<li id="
|
|
565
|
-
<input hidden class="toggle" type="checkbox" id="
|
|
698
|
+
<li id="_sidebar_6.1"><a href="#sec-Types"><span class="spec-secid">6.1</span>Types</a></li>
|
|
699
|
+
<li id="_sidebar_6.2"><a href="#sec-Built-in-Functions"><span class="spec-secid">6.2</span>Built-in Functions</a>
|
|
700
|
+
<input hidden class="toggle" type="checkbox" id="_toggle_6.2" /><label for="_toggle_6.2"></label>
|
|
566
701
|
<ol>
|
|
567
|
-
<li id="
|
|
568
|
-
<li id="
|
|
569
|
-
<li id="
|
|
570
|
-
<li id="
|
|
571
|
-
<li id="
|
|
572
|
-
<li id="
|
|
573
|
-
<li id="
|
|
574
|
-
<li id="
|
|
575
|
-
<li id="
|
|
576
|
-
<li id="
|
|
577
|
-
<li id="
|
|
578
|
-
<li id="
|
|
579
|
-
<li id="
|
|
580
|
-
<li id="
|
|
581
|
-
<li id="
|
|
582
|
-
<li id="
|
|
583
|
-
<li id="
|
|
584
|
-
<li id="
|
|
585
|
-
<li id="
|
|
586
|
-
<li id="
|
|
587
|
-
<li id="
|
|
588
|
-
<li id="
|
|
702
|
+
<li id="_sidebar_6.2.1"><a href="#sec-add"><span class="spec-secid">6.2.1</span>add</a></li>
|
|
703
|
+
<li id="_sidebar_6.2.2"><a href="#sec-and"><span class="spec-secid">6.2.2</span>and</a></li>
|
|
704
|
+
<li id="_sidebar_6.2.3"><a href="#sec-apply"><span class="spec-secid">6.2.3</span>apply</a></li>
|
|
705
|
+
<li id="_sidebar_6.2.4"><a href="#sec-div"><span class="spec-secid">6.2.4</span>div</a></li>
|
|
706
|
+
<li id="_sidebar_6.2.5"><a href="#sec-equiv"><span class="spec-secid">6.2.5</span>equiv</a></li>
|
|
707
|
+
<li id="_sidebar_6.2.6"><a href="#sec-filter"><span class="spec-secid">6.2.6</span>filter</a></li>
|
|
708
|
+
<li id="_sidebar_6.2.7"><a href="#sec-get"><span class="spec-secid">6.2.7</span>get</a></li>
|
|
709
|
+
<li id="_sidebar_6.2.8"><a href="#sec-hd"><span class="spec-secid">6.2.8</span>hd</a></li>
|
|
710
|
+
<li id="_sidebar_6.2.9"><a href="#sec-isEmpty"><span class="spec-secid">6.2.9</span>isEmpty</a></li>
|
|
711
|
+
<li id="_sidebar_6.2.10"><a href="#sec-log"><span class="spec-secid">6.2.10</span>log</a></li>
|
|
712
|
+
<li id="_sidebar_6.2.11"><a href="#sec-map"><span class="spec-secid">6.2.11</span>map</a></li>
|
|
713
|
+
<li id="_sidebar_6.2.12"><a href="#sec-max"><span class="spec-secid">6.2.12</span>max</a></li>
|
|
714
|
+
<li id="_sidebar_6.2.13"><a href="#sec-min"><span class="spec-secid">6.2.13</span>min</a></li>
|
|
715
|
+
<li id="_sidebar_6.2.14"><a href="#sec-mod"><span class="spec-secid">6.2.14</span>mod</a></li>
|
|
716
|
+
<li id="_sidebar_6.2.15"><a href="#sec-mul"><span class="spec-secid">6.2.15</span>mul</a></li>
|
|
717
|
+
<li id="_sidebar_6.2.16"><a href="#sec-not"><span class="spec-secid">6.2.16</span>not</a></li>
|
|
718
|
+
<li id="_sidebar_6.2.17"><a href="#sec-nth"><span class="spec-secid">6.2.17</span>nth</a></li>
|
|
719
|
+
<li id="_sidebar_6.2.18"><a href="#sec-or"><span class="spec-secid">6.2.18</span>or</a></li>
|
|
720
|
+
<li id="_sidebar_6.2.19"><a href="#sec-range"><span class="spec-secid">6.2.19</span>range</a></li>
|
|
721
|
+
<li id="_sidebar_6.2.20"><a href="#sec-reduce"><span class="spec-secid">6.2.20</span>reduce</a></li>
|
|
722
|
+
<li id="_sidebar_6.2.21"><a href="#sec-set"><span class="spec-secid">6.2.21</span>set</a></li>
|
|
723
|
+
<li id="_sidebar_6.2.22"><a href="#sec-sub"><span class="spec-secid">6.2.22</span>sub</a></li>
|
|
724
|
+
<li id="_sidebar_6.2.23"><a href="#sec-tl"><span class="spec-secid">6.2.23</span>tl</a></li>
|
|
589
725
|
</ol>
|
|
590
726
|
</li>
|
|
591
727
|
</ol>
|
|
592
728
|
</li>
|
|
593
|
-
<li id="
|
|
729
|
+
<li id="_sidebar_7"><a href="#sec-Program-Examples"><span class="spec-secid">7</span>Program Examples</a></li>
|
|
594
730
|
<li id="_sidebar_index"><a href="#index"><span class="spec-secid">§</span>Index</a></li>
|
|
595
731
|
</ol>
|
|
596
732
|
</div>
|