on master help sign in
Merge pull request #1388 from urbit/rune-reference-fixes
158cdb8tinnus-napbus
content/docs/hoon/reference/auras.md+10−1
@@ -16,7 +16,7 @@ You can learn more about auras in [Hoon school](/docs/hoon/hoon-school/atoms-aur
16Aura Meaning Example Literal Syntax
16Aura Meaning Example Literal Syntax
17-------------------------------------------------------------------------
17-------------------------------------------------------------------------
18@ empty aura
18@ empty aura
19−@c Unicode codepoint ~-~45fed
19+@c UTF-32 ~-~45fed
20@d date
20@d date
21 @da absolute date ~2018.5.14..22.31.46..1435
21 @da absolute date ~2018.5.14..22.31.46..1435
22 @dr relative date (ie, timespan) ~h5.m30.s12
22 @dr relative date (ie, timespan) ~h5.m30.s12
@@ -66,23 +66,30 @@ two, starting from A.
66
66
67A given aura nests under any aura whose name is a substring or extension of the
67A given aura nests under any aura whose name is a substring or extension of the
68given aura:
68given aura:
69+
69```
70```
70> :- (~(nest ut [%atom %ud ~]) | [%atom %u ~])
71> :- (~(nest ut [%atom %ud ~]) | [%atom %u ~])
71 (~(nest ut [%atom %ud ~]) | [%atom %udx ~])
72 (~(nest ut [%atom %ud ~]) | [%atom %udx ~])
72[%.y %.y]
73[%.y %.y]
73```
74```
75+
74but does not nest "sideways":
76but does not nest "sideways":
77+
75```
78```
76> (~(nest ut [%atom %ud ~]) | [%atom %ux ~])
79> (~(nest ut [%atom %ud ~]) | [%atom %ux ~])
77%.n
80%.n
78```
81```
82+
79We call auras "soft types" since this nesting behavior can be ignored. Auras are
83We call auras "soft types" since this nesting behavior can be ignored. Auras are
80non-coercive, but conversions may have to go via the empty aura, e.g.
84non-coercive, but conversions may have to go via the empty aura, e.g.
85+
81```
86```
82> ^-(@ud ^-(@ 'foo'))
87> ^-(@ud ^-(@ 'foo'))
837.303.014
887.303.014
84```
89```
90+
85This is implicitly done by the irregular form of `^-`.
91This is implicitly done by the irregular form of `^-`.
92+
86```
93```
87> `@ud`'foo'
94> `@ud`'foo'
887.303.014
957.303.014
@@ -91,8 +98,10 @@ This is implicitly done by the irregular form of `^-`.
91### Bunting
98### Bunting
92
99
93The bunt value for all auras is 0 except for `@da`.
100The bunt value for all auras is 0 except for `@da`.
101+
94```
102```
95> *@da
103> *@da
96~2000.1.1
104~2000.1.1
97```
105```
106+
98A bunt value of 0 is helpful when working with loobeans.
107A bunt value of 0 is helpful when working with loobeans.
content/docs/hoon/reference/rune/_index.md+6−1
@@ -6,13 +6,14 @@ template = "sections/docs/chapters.html"
6aliases = ["docs/reference/hoon-expressions/rune/"]
6aliases = ["docs/reference/hoon-expressions/rune/"]
7insert_anchor_links = "right"
7insert_anchor_links = "right"
8+++
8+++
9+
9Runes are a way to form expressions in Hoon.
10Runes are a way to form expressions in Hoon.
10
11
11## Non-Rune Expressions
12## Non-Rune Expressions
12
13
13### [Constants](/docs/hoon/reference/rune/constants)
14### [Constants](/docs/hoon/reference/rune/constants)
14
15
15−Hoon uses runes to form expressions, but not all expressions have runes in them. First, we have constant expressions (and also expressions that would be constant, but that they allow for interpolations).
16+Hoon uses runes to form expressions, but not all expressions have runes in them. First, we have constant expressions (and also expressions that would be constant, but that they allow for interpolations).
16
17
17### [Limbs and Wings](/docs/hoon/reference/limbs/)
18### [Limbs and Wings](/docs/hoon/reference/limbs/)
18
19
@@ -68,6 +69,10 @@ Miscellaneous useful macros.
68
69
69Runes that use Nock `11` to pass non-semantic info to the interpreter.
70Runes that use Nock `11` to pass non-semantic info to the interpreter.
70
71
72+### [`/ fas` (Imports)](/docs/hoon/reference/rune/fas)
73+
74+Ford runes which import files.
75+
71### [`--`, `==` (Terminators)](/docs/hoon/reference/rune/terminators)
76### [`--`, `==` (Terminators)](/docs/hoon/reference/rune/terminators)
72
77
73Runes used to terminate expressions.
78Runes used to terminate expressions.
content/docs/hoon/reference/rune/bar.md+603−327
@@ -4,64 +4,89 @@ weight = 7
4template = "doc.html"
4template = "doc.html"
5aliases = ["docs/reference/hoon-expressions/rune/bar/"]
5aliases = ["docs/reference/hoon-expressions/rune/bar/"]
6+++
6+++
7+
7Core expressions produce cores. A core is a cell of `[battery payload]`.
8Core expressions produce cores. A core is a cell of `[battery payload]`.
8−The `battery` is code, a battery of Nock formulas. The `payload` is the data
9+The `battery` is code, a battery of Nock formulas. The `payload` is the data
9needed to run those formulas correctly.
10needed to run those formulas correctly.
10
11
11−Five core runes (`|=`, `|.`, `|-`, `|*`, and `|$`) produce a
12+Five core runes (`|=`, `|.`, `|-`, `|*`, and `|$`) produce a core with a single
12−core with a single arm, named `$`. As with all arms, we can recompute `$``
13+arm, named `$`. As with all arms, we can recompute `$` with changes, which is
13−with changes, which is useful for recursion among other things.
14+useful for recursion among other things.
14
15
15−## Runes
16+## `|$` "barbuc"
16
17
17−### |$ "barbuc"
18+Declares a mold builder wet gate with one or more molds as its sample.
18
19
19−Declares a mold builder wet gate with one or more molds as its
20+#### Syntax
20−sample.
21
21
22−##### Syntax
22+Two arguments, fixed.
23
23
24−Regular:
24+<table>
25−```hoon
25+<tr><th>Form</th><th>Syntax</th></tr>
26−|$ a=(lest term) b=spec
26+<tr>
27−```
27+<td>Tall</td>
28+<td>
29+<pre>
30+|$ sample
31+body
32+</pre>
33+</td>
34+</tr>
35+<tr>
36+<td>Wide</td>
37+<td>
38+<pre>
39+|$(sample body)
40+</pre>
41+</td>
42+</tr>
43+<tr>
44+<td>Irregular</td>
45+<td>None.</td>
46+</tr>
47+</table>
48+
49+#### AST
28
50
29−AST:
30```hoon
51```hoon
31−[%brbs sample=(lest term) body=spec]
52+[%brbc sample=(lest term) body=spec]
32```
53```
33
54
34−##### Semantics
35−
36−`|$` is used to declare a wet gate mold builder that is polymorphic in its input molds. `a` is a `lest` of `term` used as
37−identifiers for the input molds. `b` is a structure built from elements of `a`.
38−The output of `|$` is a mold builder obtained by
39−substituting the input molds parameterized by `a` into `b`.
40−
41−##### Expands to
55+#### Expands to
42
56
43```hoon
57```hoon
44|$ [a b]
58|$ [a b]
45body
59body
46```
60```
61+
47becomes
62becomes
63+
48```hoon
64```hoon
49|* [a=$~(* $-(* *)) b=$~(* $-(* *))]
65|* [a=$~(* $-(* *)) b=$~(* $-(* *))]
50^:
66^:
51body
67body
52```
68```
53
69
70+#### Semantics
71+
72+`|$` is used to declare a wet gate mold builder that is polymorphic in its input
73+molds. `a` is a `lest` of `term` used as identifiers for the input molds. `b` is
74+a structure built from elements of `a`. The output of `|$` is a mold builder
75+obtained by substituting the input molds parameterized by `a` into `b`.
76+
54−##### Discussion
77+#### Discussion
55
78
56A mold builder is a wet gate from one or more molds to a mold. A mold is a
79A mold builder is a wet gate from one or more molds to a mold. A mold is a
57function from nouns to nouns with types that may be partial, is always
80function from nouns to nouns with types that may be partial, is always
58idempotent, and usually the identity function on the noun itself.
81idempotent, and usually the identity function on the noun itself.
59
82
60−`|$` is a restricted form of `|*`. The use of `|$` over `|*` is one of style, as either could
83+`|$` is a restricted form of `|*`. The use of `|$` over `|*` is one of style, as
61−be used to make wet gates that are mold builders. The buc in `|$` is a hint that
84+either could be used to make wet gates that are mold builders. The buc in `|$`
85+is a hint that `|$` is closely related to buc runes, and thus `|$` should be
62−`|$` is closely related to buc runes, and thus `|$` should be used to make mold builders, while `|*` should be used for any other sort of
86+used to make mold builders, while `|*` should be used for any other sort of wet
87+gate. Unlike `|*`, the body of `|$` is parsed in pattern mode to a `$spec`.
63−wet gate. Thus, the second argument of `|$` is frequently a buc
88+Thus, the second argument of `|$` is frequently a buc rune. For further
64−rune. For further discussion of wet gates, see the entry for [`|*`](#bartar).
89+discussion of wet gates, see the entry for [`|*`](#-bartar).
65
90
66Like other single-arm cores, the arm for `|$` is named `$` and this can be used to
91Like other single-arm cores, the arm for `|$` is named `$` and this can be used to
67define recursive structures. Note however that Hoon is evaluated eagerly, and so
92define recursive structures. Note however that Hoon is evaluated eagerly, and so
@@ -69,53 +94,58 @@ infinite structures are not permitted.
69
94
70Proper style for `|$` is to enclose the first argument with brackets, even if it
95Proper style for `|$` is to enclose the first argument with brackets, even if it
71is only a single term. The interpeter will accept a single term without brackets
96is only a single term. The interpeter will accept a single term without brackets
72−just fine, but this style is for consistency with the fact that the first argument is a `lest`.
97+just fine, but this style is for consistency with the fact that the first
98+argument is a `lest`.
73
99
74−##### Examples
100+#### Examples
75
101
76```
102```
77−~zod:dojo> =foo |$([a b] [b a])
103+> =foo |$([a b] [b a])
78
104
79−~zod:dojo> =bar (foo [@ @tas])
105+> =bar (foo [@ @tas])
80
106
81−~zod:dojo> (bar %cat 3)
107+> (bar %cat 3)
82[%cat 3]
108[%cat 3]
83```
109```
84
110
111+---
112+
85−### `|_` "barcab"
113+## `|_` "barcab"
86
114
87Produce a **door** (a core with a sample).
115Produce a **door** (a core with a sample).
88
116
89−##### Syntax
117+#### Syntax
90
118
91−Regular:
119+One fixed argument, then a variable number of `+`-family expressions.
92
120
93−```hoon
121+<table>
122+<tr><th>Form</th><th>Syntax</th></tr>
123+<tr>
124+<td>Tall</td>
125+<td>
126+<pre>
94|_ a=spec
127|_ a=spec
95++ b=term c=hoon
128++ b=term c=hoon
96++ d=term e=hoon
129++ d=term e=hoon
97 ...
130 ...
98++ f=term g=hoon
131++ f=term g=hoon
99--
132--
100−```
133+</pre>
134+</td>
135+</tr>
136+<tr><td>Wide</td><td>None.</td></tr>
137+<tr><td>Irregular</td><td>None.</td></tr>
138+</table>
101
139
102Note: The `++` rune may be replaced with any other rune in the `+` family.
140Note: The `++` rune may be replaced with any other rune in the `+` family.
103
141
104−AST:
142+#### AST
105
143
106−```
144+```hoon
107[%brcb p=spec q=alas r=(map term tome)]
145[%brcb p=spec q=alas r=(map term tome)]
108```
146```
109
147
110−##### Semantics
111−
112−The product of a `|_` expression is a **door**, a core with one or more arms whose payload includes a sample. That is, a door is a cell of `[battery [sample context]]`, where the `battery` contains one or more arms.
113−
114−`a` defines the door sample type and usually includes a name assignment (e.g., `n=@`). `a` is followed by a series of arm definitions, each of which begins with a rune in the `+` family (most of `++`). There must be at least one arm, but there may be arbitrarily many. Each arm must include a name (`b`, `d`, and `f` above), which is followed by the expression (`c`, `e`, and `g` above) that defines the arm product.
115−
116−The context of the door is the subject of the `|_` expression.
117−
118−##### Expands to
148+#### Expands to
119
149
120```hoon
150```hoon
121=| a=spec
151=| a=spec
@@ -127,29 +157,49 @@ The context of the door is the subject of the `|_` expression.
127--
157--
128```
158```
129
159
130−##### Discussion
160+#### Semantics
161+
162+The product of a `|_` expression is a **door**, a core with one or more arms
163+whose payload includes a sample. That is, a door is a cell of `[battery [sample context]]`, where the `battery` contains one or more arms.
131
164
132−A door is the general case of a gate (function). A gate is a
165+`a` defines the door sample type and usually includes a name assignment (e.g.,
133−door with only one arm, which has the name `$`.
166+`n=@`). `a` is followed by a series of arm definitions, each of which begins
167+with a rune in the `+` family (most of `++`). There must be at least one arm,
168+but there may be arbitrarily many. Each arm must include a name (`b`, `d`, and
169+`f` above), which is followed by the expression (`c`, `e`, and `g` above) that
170+defines the arm product.
134
171
172+The context of the door is the subject of the `|_` expression.
173+
174+#### Discussion
175+
176+A door is the general case of a gate (function). A gate is a door with only one
177+arm, which has the name `$`.
178+
135−Calling a door is like calling a gate except the caller also needs
179+Calling a door is like calling a gate except the caller also needs to specify
180+the arm to be computed. So, for example, if you have some door `door` which
136−to specify the arm to be computed. So, for example, if you have some door `door` which contains some arm `arm`, and you want to pass some argument (i.e., input value `arg`), you would call it with `~(arm door arg)`.
181+contains some arm `arm`, and you want to pass some argument (i.e., input value
182+`arg`), you would call it with `~(arm door arg)`.
137
183
138−Because gates are also doors, you can call them the same way. To call the gate `foo` as a door, instead of `(foo baz)` we would write `~($ foo baz)`. This
184+Because gates are also doors, you can call them the same way. To call the gate
185+`foo` as a door, instead of `(foo baz)` we would write `~($ foo baz)`. This is
186+an irregular form for `%~($ foo baz)`,
139−is an irregular form for `%~($ foo baz)`, [%~](/docs/hoon/reference/rune/cen#censig).
187+[%~](/docs/hoon/reference/rune/cen#censig).
140
188
141−##### Examples
189+#### Examples
142
190
143A trivial door:
191A trivial door:
144
192
145```
193```
146−/~zod:dojo> =mol |_ a=@ud
194+> =mol |_ a=@ud
147− ++ succ +(a)
195+ ++ succ +(a)
148− ++ prev (dec a)
196+ ++ prev (dec a)
149− --
197+ --
198+
150−/~zod:dojo> ~(succ mol 1)
199+> ~(succ mol 1)
1512
2002
201+
152−/~zod:dojo> ~(succ mol ~(succ mol ~(prev mol 5)))
202+> ~(succ mol ~(succ mol ~(prev mol 5)))
1536
2036
154```
204```
155
205
@@ -172,174 +222,246 @@ The `ne` door prints a digit in base 10, 16, 32 or 64:
172'c'
222'c'
173```
223```
174
224
175−### `|%` "barcen"
225+---
176
226
177−Produce a core, `[battery payload]`.
227+## `|:` "barcol"
178
228
179−##### Syntax
229+Produce a gate with a custom sample.
180
230
181−Regular:
231+#### Syntax
232+
233+Two arguments, fixed.
234+
235+<table>
236+<tr><th>Form</th><th>Syntax</th></tr>
237+<tr>
238+<td>Tall</td>
239+<td>
240+<pre>
241+|: a
242+b
243+</pre>
244+</td>
245+</tr>
246+<tr>
247+<td>Wide</td>
248+<td>
249+<pre>
250+|:(a b)
251+</pre>
252+</td>
253+</tr>
254+<tr>
255+<td>Irregular</td>
256+<td>None.</td>
257+</tr>
258+</table>
259+
260+#### AST
182
261
183```hoon
262```hoon
184−|%
263+[%brcl p=hoon q=hoon]
185−++ a=term b=hoon
186−++ c=term d=hoon
187− ...
188−++ e=term f=hoon
189−--
190```
264```
191
265
192−Note: The `++` rune may be replaced with any other rune in the `+` family.
266+#### Semantics
193
267
194−AST:
268+`a` is a Hoon expression whose product type defines which values the gate accepts, and it usually includes a name (e.g., `n=1`). The product of `a` also serves as the default value of the sample. `b` is a Hoon expression that determines the product value of the gate.
195
269
270+#### Expands to
271+
196−```
272+```hoon
197−[%brcn p=(unit term) q=(map term tome)]
273+=+ a
274+|. b
198```
275```
199
276
200−##### Semantics
277+#### Discussion
201
278
202−The product of a `|%` expression is a dry core with one or more arms in the battery.
279+Pick your own default value for the sample. Note that `a` is an ordinary
280+expression, not a type; `|:` doesn't bunt a sample as [`|=`](#bartis) does.
203
281
204−The `|%` rune is followed by a series of arm definitions, each of which begins with a rune in the `+` family (most of `++`). There must be at least one arm, but there may be arbitrarily many. Each arm must include a name (`a`, `c`, and `e` above), which is followed by the expression (`b`, `d`, and `f` above) that defines the arm product.
282+This is useful if you want a gate to have a sample of a particular type, but you don't want the default value of the gate to be the default value of that type.
205
283
206−The core payload is the subject of the `|%` expression.
284+#### Examples
207
285
208−##### Discussion
286+```
287+> =add-ten |:(n=`@`2 (add n 10))
209
288
210−A core is a cell of `[battery payload]`, where the `battery` is code and the `payload` is data. The `battery` is one or more arms. An arm is a computation that takes the core itself as its subject.
289+> (add-ten 10)
290+20
211
291
212−The `|%` rune is used to construct a core from a series of arm definitions. Each arm definition in the expression begins with an arm rune (`++`, `+$`, or `+*`). These arms make up the `battery`. The subject of the `|%` expression is used to make the core's `payload`.
292+> (add-ten)
293+12
294+```
213
295
214−A core is like an "object" in a conventional language, but its
296+---
215−attributes (_arms_) are functions on the core, not the core and
216−an argument. A "method" on a core is an arm that produces a gate.
217
297
218−##### Examples
298+## `|%` "barcen"
219
299
220−A trivial core:
300+Produce a core, `[battery payload]`.
221
301
222−```
302+#### Syntax
223−~zod:dojo> =foo =+ x=58
224− |%
225− ++ n (add 42 x)
226− ++ g |= b=@
227− (add b n)
228− --
229−~zod:dojo> n.foo
230−100
231−~zod:dojo> (g.foo 1)
232−101
233−```
234
303
235−### `|:` "barcol"
304+Argument: a variable number of `+`-family expressions.
236
305
237−Produce a gate with a custom sample.
306+<table>
307+<tr><th>Form</th><th>Syntax</th></tr>
308+<tr>
309+<td>Tall</td>
310+<td>
311+<pre>
312+|%
313+++ a=term b=hoon
314+++ c=term d=hoon
315+ ...
316+++ e=term f=hoon
317+--
318+</pre>
319+</td>
320+</tr>
321+<tr><td>Wide</td><td>None.</td></tr>
322+<tr><td>Irregular</td><td>None.</td></tr>
323+</table>
238
324
239−##### Syntax
325+Note: The `++` rune may be replaced with any other rune in the `+` family.
240
326
241−Regular:
327+#### AST
242
328
243```hoon
329```hoon
244−|: a=hoon b=hoon
330+[%brcn p=(unit term) q=(map term tome)]
245```
331```
246
332
247−AST:
333+#### Semantics
248
334
249−```
335+The product of a `|%` expression is a dry core with one or more arms in the
250−[%brcl p=hoon q=hoon]
336+battery.
251−```
252
337
253−##### Semantics
338+The `|%` rune is followed by a series of arm definitions, each of which begins
339+with a rune in the `+` family (most of `++`). There must be at least one arm,
340+but there may be arbitrarily many. Each arm must include a name (`a`, `c`, and
341+`e` above), which is followed by the expression (`b`, `d`, and `f` above) that
342+defines the arm product.
254
343
255−`a` is a Hoon expression whose product type defines which values the gate accepts, and it usually includes a name (e.g., `n=1`). The product of `a` also serves as the default value of the sample. `b` is a Hoon expression that determines the product value of the gate.
344+The core payload is the subject of the `|%` expression.
256
345
257−##### Expands to
346+#### Discussion
258
347
259−```hoon
348+A core is a cell of `[battery payload]`, where the `battery` is code and the
260−=> ^~ a
349+`payload` is data. The `battery` is one or more arms. An arm is a computation
261− |. b
350+that takes the core itself as its subject.
262−```
263
351
264−##### Discussion
352+The `|%` rune is used to construct a core from a series of arm definitions. Each
353+arm definition in the expression begins with an arm rune (`++`, `+$`, or `+*`).
354+These arms make up the `battery`. The subject of the `|%` expression is used to
355+make the core's `payload`.
265
356
266−Pick your own default value for the sample. Note that `a` is an ordinary expression, not a type; `|:` doesn't bunt a sample as
357+A core is like an "object" in a conventional language, but its attributes
267−[`|=`](#bartis) does.
358+(_arms_) are functions on the core, not the core and an argument. A "method" on
359+a core is an arm that produces a gate.
268
360
269−This is useful if you want a gate to have a sample of a particular type, but you don't want the default value of the gate to be the default value of that type.
361+#### Examples
270
362
271−##### Examples
363+A trivial core:
272
364
273```
365```
274−> =add-ten |:(n=`@`2 (add n 10))
366+> =foo =+ x=58
367+ |%
368+ ++ n (add 42 x)
369+ ++ g |= b=@
370+ (add b n)
371+ --
275
372
276−> (add-ten 10)
373+> n.foo
277−20
374+100
278
375
279−> (add-ten)
376+> (g.foo 1)
280−12
377+101
281```
378```
282
379
283−### `|.` "bardot"
380+---
284
381
285−Produce a trap (a core with one arm `$`).
382+## `|.` "bardot"
286
383
287−##### Syntax
384+Produce a trap (a core with one arm `$`).
288
385
289−Regular:
386+#### Syntax
387+
388+One argument, fixed.
389+
390+<table>
391+<tr><th>Form</th><th>Syntax</th></tr>
392+<tr>
393+<td>Tall</td>
394+<td>
395+<pre>
396+|. a
397+</pre>
398+</td>
399+</tr>
400+<tr>
401+<td>Wide</td>
402+<td>
403+<pre>
404+|.(a)
405+</pre>
406+</td>
407+</tr>
408+<tr>
409+<td>Irregular</td>
410+<td>None.</td>
411+</tr>
412+</table>
413+
414+#### AST
290
415
291```hoon
416```hoon
292−|. a=hoon
293−```
294−
295−AST:
296−
297−```
298[%brdt p=hoon]
417[%brdt p=hoon]
299```
418```
300
419
301−##### Semantics
302−
303−A `|.` expression produces a core with a single arm, `$`. The core isn't explicitly given a sample. `a` is a Hoon expression that defines the computation of the `$` arm.
304−
305−The payload of the core is the subject of the `|.` expression.
306−
307−##### Expands to
420+#### Expands to
308
421
309```hoon
422```hoon
310|% ++ $ a=hoon
423|% ++ $ a=hoon
311--
424--
312```
425```
313
426
427+#### Semantics
428+
429+A `|.` expression produces a core with a single arm, `$`. The core isn't
430+explicitly given a sample. `a` is a Hoon expression that defines the computation
431+of the `$` arm.
432+
433+The payload of the core is the subject of the `|.` expression.
434+
314−##### Discussion
435+#### Discussion
315
436
316A trap is generally used to defer a computation.
437A trap is generally used to defer a computation.
317
438
318−##### Examples
439+#### Examples
319
440
320A trivial trap:
441A trivial trap:
321
442
322```
443```
323−~zod:dojo> =foo |.(42)
444+> =foo |.(42)
324
445
325−~zod:dojo> $:foo
446+> $:foo
32642
44742
327
448
328−~zod:dojo> (foo)
449+> (foo)
32942
45042
330```
451```
331
452
332A more interesting trap:
453A more interesting trap:
333
454
334```
455```
335−~zod:dojo> =foo =/ reps 10
456+> =foo =/ reps 10
336− =/ step 0
457+ =/ step 0
337− =/ outp 0
458+ =/ outp 0
338− |.
459+ |.
339− ?: =(step reps)
460+ ?: =(step reps)
340− outp
461+ outp
341− $(outp (add outp 2), step +(step))
462+ $(outp (add outp 2), step +(step))
463+
342−~zod:dojo> (foo)
464+> (foo)
34320
46520
344```
466```
345
467
@@ -348,92 +470,43 @@ trap, since it's a core with an `$` arm.
348
470
349> `$(...)` expands to `%=($ ...)` (["centis"](/docs/hoon/reference/rune/cen#centis)).
471> `$(...)` expands to `%=($ ...)` (["centis"](/docs/hoon/reference/rune/cen#centis)).
350
472
351−### `|-` "barhep"
473+---
352−
353−Produce a trap (a core with one arm `$`) and evaluate it.
354−
355−##### Syntax
356−
357−Regular:
358−
359−```hoon
360−|- a=hoon
361−```
362−
363−AST:
364−
365−```
366−[%brhp p=hoon]
367−```
368−
369−##### Semantics
370−
371−A `|-` expression produces a core with one arm named `$` and immediately evaluates `$`. `a` is a Hoon expression that determines what `$` evaluates to.
372
474
373−##### Expands to
374−
375−```hoon
376−=<($ |.(a=hoon))
377−```
378−
379−##### Discussion
380−
381−The `|-` rune can be thought of as a 'recursion point' or a 'loop starting point'. Since `|-` makes a `|.` (["bardot"](#bardot), a core with one arm named `$`, we can recurse back into it with `$()`.
382−
383−> `$(...)` expands to `%=($ ...)` (["centis"](/docs/hoon/reference/rune/cen#centis)).
384−
385−##### Examples
386−
387−A trivial computation doesn't recurse:
388−
389−```
390−~zod:dojo> |-(42)
391−42
392−```
393−
394−The classic loop is a decrement:
395−
396−```
397−~zod:dojo> =foo =/ a 42
398− =/ b 0
399− |-
400− ?: =(a +(b))
401− b
402− $(b +(b))
403−~zod:dojo> foo
404−41
405−```
406−
407−### `|^` "barket"
475+## `|^` "barket"
408
476
409Produce a core whose battery includes a `$` arm and compute the latter.
477Produce a core whose battery includes a `$` arm and compute the latter.
410
478
411−##### Syntax
479+#### Syntax
412
480
413−Regular:
481+One fixed argument, then a variable number of `+`-family expressions.
414
482
415−```hoon
483+<table>
484+<tr><th>Form</th><th>Syntax</th></tr>
485+<tr>
486+<td>Tall</td>
487+<td>
488+<pre>
416|^ a=hoon
489|^ a=hoon
417++ b=term c=hoon
490++ b=term c=hoon
418++ d=term e=hoon
491++ d=term e=hoon
419 ...
492 ...
420++ f=term g=hoon
493++ f=term g=hoon
421--
494--
422−```
495+</pre>
496+</td>
497+</tr>
498+<tr>
499+<td>Wide</td><td>None.</td></tr>
500+<tr><td>Irregular</td><td>None.</td></tr>
501+</table>
423
502
424−Note: The `++` rune may be replaced with any other rune in the `+` family.
425−
426−AST:
503+#### AST
427
504
428−```
505+```hoon
429[%brkt p=hoon q=(map term tome)]
506[%brkt p=hoon q=(map term tome)]
430```
507```
431
508
432−##### Semantics
433−
434−A `|^` expression produces a multi-arm core whose battery includes a `$` arm, which is evaluated immediately. `a` is a Hoon expression that defines the product of the `$` arm. `a` is followed by a series of arm definitions for the rest of the core battery arms. There must be at least one arm other than the `$` arm.
435−
436−##### Expands to
509+#### Expands to
437
510
438```hoon
511```hoon
439=> |%
512=> |%
@@ -446,86 +519,218 @@ A `|^` expression produces a multi-arm core whose battery includes a `$` arm, wh
446$
519$
447```
520```
448
521
449−##### Discussion
522+#### Semantics
523+
524+A `|^` expression produces a multi-arm core whose battery includes a `$` arm,
525+which is evaluated immediately. `a` is a Hoon expression that defines the
526+product of the `$` arm. `a` is followed by a series of arm definitions for the
527+rest of the core battery arms. There must be at least one arm other than the `$`
528+arm.
450
529
451−The `|^` rune is useful when you define a multi-arm core in your code and a particular arm in it is to be evaluated immediately.
530+#### Discussion
452
531
532+The `|^` rune is useful when you define a multi-arm core in your code and a
533+particular arm in it is to be evaluated immediately.
534+
453−##### Examples
535+#### Examples
454
536
455A trivial example:
537A trivial example:
456
538
457```
539```
458−~zod:dojo> |^
540+> |^
459− (add n g)
541+ (add n g)
460− ++ n 42
542+ ++ n 42
461− ++ g 58
543+ ++ g 58
462− --
544+ --
463100
545100
464```
546```
465
547
466−### `|~` "barsig"
548+---
467
549
468−Produce an iron gate.
550+## `|-` "barhep"
469
551
470−##### Syntax
552+Produce a trap (a core with one arm `$`) and evaluate it.
471
553
472−Regular:
554+#### Syntax
555+
556+One argument, fixed.
557+
558+<table>
559+<tr><th>Form</th><th>Syntax</th></tr>
560+<tr>
561+<td>Tall</td>
562+<td>
563+<pre>
564+|- a
565+</pre>
566+</td>
567+</tr>
568+<tr>
569+<td>Wide</td>
570+<td>
571+<pre>
572+|-(a)
573+</pre>
574+</td>
575+</tr>
576+<tr>
577+<td>Irregular</td>
578+<td>None.</td>
579+</tr>
580+</table>
581+
582+#### AST
473
583
474```hoon
584```hoon
475−|~ a=spec b=hoon
585+[%brhp p=hoon]
476```
586```
477
587
478−AST:
588+#### Expands to
479
589
590+```hoon
591+=<($ |.(a=hoon))
480```
592```
481−[%brsg p=spec q=hoon]
593+
594+#### Semantics
595+
596+A `|-` expression produces a core with one arm named `$` and immediately
597+evaluates `$`. `a` is a Hoon expression that determines what `$` evaluates to.
598+
599+#### Discussion
600+
601+The `|-` rune can be thought of as a 'recursion point' or a 'loop starting
602+point'. Since `|-` makes a `|.` (["bardot"](#bardot), a core with one arm named
603+`$`, we can recurse back into it with `$()`.
604+
605+> `$(...)` expands to `%=($ ...)` (["centis"](/docs/hoon/reference/rune/cen#centis)).
606+
607+#### Examples
608+
609+A trivial computation doesn't recurse:
610+
611+```
612+> |-(42)
613+42
614+```
615+
616+The classic loop is a decrement:
617+
618+```
619+> =foo =/ a 42
620+ =/ b 0
621+ |-
622+ ?: =(a +(b))
623+ b
624+ $(b +(b))
625+
626+> foo
627+41
482```
628```
483
629
484−##### Semantics
630+---
631+
632+## `|~` "barsig"
633+
634+Produce an iron gate.
635+
636+#### Syntax
637+
638+Two arguments, fixed.
639+
640+<table>
641+<tr><th>Form</th><th>Syntax</th></tr>
642+<tr>
643+<td>Tall</td>
644+<td>
645+<pre>
646+|~ a
647+b
648+</pre>
649+</td>
650+</tr>
651+<tr>
652+<td>Wide</td>
653+<td>
654+<pre>
655+|~(a b)
656+</pre>
657+</td>
658+</tr>
659+<tr>
660+<td>Irregular</td>
661+<td>None.</td>
662+</tr>
663+</table>
664+
665+#### AST
485
666
486−A `|~` expression produces an iron gate. `a` defines the sample, and `b` defines the output value of the gate.
667+```hoon
668+[%brsg p=spec q=hoon]
669+```
487
670
488−##### Expands to
671+#### Expands to
489
672
490```hoon
673```hoon
491^| |=(a b)
674^| |=(a b)
492```
675```
493
676
677+#### Semantics
678+
679+A `|~` expression produces an iron gate. `a` defines the sample, and `b` defines
680+the output value of the gate.
681+
494−##### Discussion
682+#### Discussion
495
683
496See [this discussion of core variance models](/docs/hoon/reference/advanced)
684See [this discussion of core variance models](/docs/hoon/reference/advanced)
497
685
498−##### Examples
686+#### Examples
499
687
500```
688```
501−~zod:dojo> => ~ ^+(|~(a=@ *@) |=(a=* *@))
689+> => ~ ^+(|~(a=@ *@) |=(a=* *@))
502<1|usl {a/@ $~}>
690<1|usl {a/@ $~}>
503```
691```
504
692
505−### `|*` "bartar"
693+---
506
694
507−Produce a wet gate (one-armed core with sample).
695+## `|*` "bartar"
508
696
509−##### Syntax
697+Produce a wet gate (one-armed core with sample).
510
698
511−Regular:
699+#### Syntax
700+
701+Two arguments, fixed.
702+
703+<table>
704+<tr><th>Form</th><th>Syntax</th></tr>
705+<tr>
706+<td>Tall</td>
707+<td>
708+<pre>
709+|* a b
710+</pre>
711+</td>
712+</tr>
713+<tr>
714+<td>Wide</td>
715+<td>
716+<pre>
717+|*(a b)
718+</pre>
719+</td>
720+</tr>
721+<tr>
722+<td>Irregular</td>
723+<td>None.</td>
724+</tr>
725+</table>
726+
727+#### AST
512
728
513```hoon
729```hoon
514−|* a=spec b=hoon
515−```
516−
517−AST:
518−
519−```
520[%brtr p=spec q=hoon]
730[%brtr p=spec q=hoon]
521```
731```
522
732
523−##### Semantics
524−
525−A `|*` expression produces a wet gate. `a` defines the gate's sample, and `b`
526−is a Hoon expression that determines the output value of the gate.
527−
528−##### Expands to
733+#### Expands to
529
734
530```hoon
735```hoon
531=| a
736=| a
@@ -535,14 +740,19 @@ is a Hoon expression that determines the output value of the gate.
535--
740--
536```
741```
537
742
743+#### Semantics
744+
745+A `|*` expression produces a wet gate. `a` defines the gate's sample, and `b` is
746+a Hoon expression that determines the output value of the gate.
747+
538−##### Discussion
748+#### Discussion
539
749
540In a normal (dry) gate, your argument is converted into the
750In a normal (dry) gate, your argument is converted into the
541−sample type. In a generic (wet) gate, your argument type
751+sample type. In a generic (wet) gate, your argument type
542passes through the function, rather as if it were a macro (there
752passes through the function, rather as if it were a macro (there
543is still only one copy of the code, however).
753is still only one copy of the code, however).
544
754
545−Genericity is a powerful and dangerous tool. Use wet gates only if
755+Genericity is a powerful and dangerous tool. Use wet gates only if
546you know what you're doing.
756you know what you're doing.
547
757
548Just as with a [gate](#bartis), we can recurse back into a wet gate
758Just as with a [gate](#bartis), we can recurse back into a wet gate
@@ -553,58 +763,83 @@ with `$()`.
553`|*` can be used to make wet gates that produce structures, but this usage is
763`|*` can be used to make wet gates that produce structures, but this usage is
554discouraged in favor of `|$`.
764discouraged in favor of `|$`.
555
765
556−##### Examples
766+#### Examples
557
767
558Wet and dry gates in a nutshell:
768Wet and dry gates in a nutshell:
559
769
560```
770```
561−~zod:dojo> =foo |=([a=* b=*] [b a])
771+> =foo |=([a=* b=*] [b a])
562
772
563−~zod:dojo> =bar |*([a=* b=*] [b a])
773+> =bar |*([a=* b=*] [b a])
564
774
565−~zod:dojo> (foo %cat %dog)
775+> (foo %cat %dog)
566[6.778.724 7.627.107]
776[6.778.724 7.627.107]
567
777
568−~zod:dojo> (bar %cat %dog)
778+> (bar %cat %dog)
569[%dog %cat]
779[%dog %cat]
570```
780```
571
781
572The dry gate does not preserve the type of `a` and `b`; the wet
782The dry gate does not preserve the type of `a` and `b`; the wet
573gate does.
783gate does.
574
784
575−### `|=` "bartis"
785+---
576
786
577−Produce a gate (a one-armed core with a sample).
787+## `|=` "bartis"
578
788
579−##### Syntax
789+Produce a gate (a one-armed core with a sample).
580
790
581−Regular:
791+#### Syntax
792+
793+Two arguments, fixed.
794+
795+<table>
796+<tr><th>Form</th><th>Syntax</th></tr>
797+<tr>
798+<td>Tall</td>
799+<td>
800+<pre>
801+|= a
802+b
803+</pre>
804+</td>
805+</tr>
806+<tr>
807+<td>Wide</td>
808+<td>
809+<pre>
810+|=(a b)
811+</pre>
812+</td>
813+</tr>
814+<tr>
815+<td>Irregular</td>
816+<td>None.</td>
817+</tr>
818+</table>
819+
820+#### AST
582
821
583```hoon
822```hoon
584−|= a=spec b=hoon
585−```
586−
587−AST:
588−
589−```
590[%brts p=spec q=hoon]
823[%brts p=spec q=hoon]
591```
824```
592
825
593−##### Definition
594−
595−The product of a `|=` expression is a dry **gate**, i.e., a Hoon function.
596−
597−`p` defines the gate sample type -- i.e., the input value type -- and usually includes a sample name assignment (e.g., `a=@`). `q` is an expression that determines the output value of the gate.
598−
599−##### Expands to
826+#### Expands to
600
827
601```hoon
828```hoon
602−=| a=spec
829+=+ ^~(*a=spec)
603|% ++ $ b=hoon
830|% ++ $ b=hoon
604--
831--
605```
832```
606
833
834+#### Definition
835+
836+The product of a `|=` expression is a dry **gate**, i.e., a Hoon function.
837+
838+`p` defines the gate sample type -- i.e., the input value type -- and usually
839+includes a sample name assignment (e.g., `a=@`). `q` is an expression that
840+determines the output value of the gate.
841+
607−##### Discussion
842+#### Discussion
608
843
609Dry gates are used for the vast majority of ordinary functions in Hoon.
844Dry gates are used for the vast majority of ordinary functions in Hoon.
610
845
@@ -612,97 +847,138 @@ A gate is a core with one arm named `$`, so we can recurse back into it with `$(
612
847
613> `$(...)` expands to `%=($ ...)` (["centis"](/docs/hoon/reference/rune/cen#centis)).
848> `$(...)` expands to `%=($ ...)` (["centis"](/docs/hoon/reference/rune/cen#centis)).
614
849
615−##### Examples
850+#### Examples
616
851
617A trivial gate:
852A trivial gate:
618
853
619```
854```
620−~zod:dojo> =foo |=(a=@ +(a))
855+> =foo |=(a=@ +(a))
621
856
622−~zod:dojo> (foo 20)
857+> (foo 20)
62321
85821
624```
859```
625
860
626A slightly less trivial gate:
861A slightly less trivial gate:
627
862
628```
863```
629−~zod:dojo> =foo |= [a=@ b=@]
864+> =foo |= [a=@ b=@]
630− (add a b)
865+ (add a b)
866+
631−~zod:dojo> (foo 30 400)
867+> (foo 30 400)
632430
868430
633```
869```
634
870
871+---
872+
635−### `|@` "barpat"
873+## `|@` "barpat"
636
874
637Produce a 'wet' core `[battery payload]`.
875Produce a 'wet' core `[battery payload]`.
638
876
639−##### Syntax
877+#### Syntax
640
878
641−Regular:
879+Arguments: a variable number of `+`-family expressions.
642
880
643−```hoon
881+<table>
882+<tr><th>Form</th><th>Syntax</th></tr>
883+<tr>
884+<td>Tall</td>
885+<td>
886+<pre>
644|@
887|@
645++ a=term b=hoon
888++ a=term b=hoon
646++ c=term d=hoon
889++ c=term d=hoon
647 ...
890 ...
648++ e=term f=hoon
891++ e=term f=hoon
649--
892--
650−```
893+</pre>
894+</td>
895+</tr>
896+<tr><td>Wide</td><td>None.</td></tr>
897+<tr><td>Irregular</td><td>None.</td></tr>
898+</table>
651
899
652Note: The `++` rune may be replaced with any other rune in the `+` family.
900Note: The `++` rune may be replaced with any other rune in the `+` family.
653
901
654−AST:
902+#### AST
655
903
656−```
904+```hoon
657[%brpt p=(unit term) q=(map term tome)]
905[%brpt p=(unit term) q=(map term tome)]
658```
906```
659
907
660−##### Semantics
908+#### Semantics
661
909
662−A `|@` expression produces a 'wet' core whose payload is the expression's subject. The various arms in the battery are each named (`a`, `c`, and `e` above) and defined explicitly with a Hoon expression (with `b`, `d`, and `f` above).
910+A `|@` expression produces a 'wet' core whose payload is the expression's
911+subject. The various arms in the battery are each named (`a`, `c`, and `e`
912+above) and defined explicitly with a Hoon expression (with `b`, `d`, and `f`
913+above).
663
914
664−##### Discussion
915+#### Discussion
665
916
917+The `|@` rune is just like the `|%` rune except that instead of producing a
918+'dry' core, it produces a 'wet' one. This allows for type polymorphism of its
666−The `|@` rune is just like the `|%` rune except that instead of producing a 'dry' core, it produces a 'wet' one. This allows for type polymorphism of its arms, using 'genericity'. See [Advanced types](/docs/hoon/reference/advanced).
919+arms, using 'genericity'. See [Advanced types](/docs/hoon/reference/advanced).
667
920
668−### `|?` "barwut"
921+---
669
922
670−Produce a lead trap.
923+## `|?` "barwut"
671
924
672−##### Syntax
925+Produce a lead trap.
673
926
674−Regular:
927+#### Syntax
928+
929+One argument, fixed.
930+
931+<table>
932+<tr><th>Form</th><th>Syntax</th></tr>
933+<tr>
934+<td>Tall</td>
935+<td>
936+<pre>
937+|? a
938+</pre>
939+</td>
940+</tr>
941+<tr>
942+<td>Wide</td>
943+<td>
944+<pre>
945+|?(a)
946+</pre>
947+</td>
948+</tr>
949+<tr>
950+<td>Irregular</td>
951+<td>None.</td>
952+</tr>
953+</table>
954+
955+#### AST
675
956
676```hoon
957```hoon
677−|? a=hoon
678−```
679−
680−AST:
681−
682−```
683[%brwt p=hoon]
958[%brwt p=hoon]
684```
959```
685
960
686−##### Semantics
687−
688−A `|?` expression produces a lead trap (i.e., a lead core with one arm named `$`). `a` is a Hoon expression that defines what the `$` arm does.
689−
690−##### Expands to
961+#### Expands to
691
962
692```hoon
963```hoon
693^? |. a
964^? |. a
694```
965```
695
966
967+#### Semantics
968+
969+A `|?` expression produces a lead trap (i.e., a lead core with one arm named
970+`$`). `a` is a Hoon expression that defines what the `$` arm does.
971+
696−##### Discussion
972+#### Discussion
697
973
698See this [discussion of the core variance model](/docs/hoon/reference/advanced).
974See this [discussion of the core variance model](/docs/hoon/reference/advanced).
699
975
700−##### Examples
976+#### Examples
701
977
702```
978```
703−~zod:dojo> => ~ ^+ |?(%a) |.(%a)
979+> => ~ ^+ |?(%a) |.(%a)
704<1?pqz $~>
980<1?pqz $~>
705
981
706−~zod:dojo> => ~ ^+ |?(%a) |.(%b)
982+> => ~ ^+ |?(%a) |.(%b)
707nest-fail
983nest-fail
708```
984```
content/docs/hoon/reference/rune/buc.md+624−215
@@ -5,7 +5,7 @@ template = "doc.html"
5aliases = ["docs/reference/hoon-expressions/rune/buc/"]
5aliases = ["docs/reference/hoon-expressions/rune/buc/"]
6+++
6+++
7
7
8−The `$` family of runes is used for defining custom types. Strictly speaking,
8+The `$` family of runes is used for defining custom types. Strictly speaking,
9these runes are used to produce `spec`s, which we call 'structures'.
9these runes are used to produce `spec`s, which we call 'structures'.
10
10
11## Overview
11## Overview
@@ -46,35 +46,45 @@ it's generally a faux pas to validate structure at runtime -- or even in userspa
46Nonetheless they are sometimes utilized for types that will be more performant
46Nonetheless they are sometimes utilized for types that will be more performant
47if they satisfy some validating gate.
47if they satisfy some validating gate.
48
48
49−## Base Structures
49+---
50
50
51−`[%base p=$@(?(%noun %cell %flag %null %void) [%atom p=aura])]`: trivial structures (types).
51+## `$|` "bucbar"
52
52
53−##### Produces
53+Structure that satisfies a validator.
54
54
55−A structure is a noun produced, usually at compile-time, for use in tracking types. In most cases, structures don't exist in the runtime semantics.
56−
57−A structure for the base in `p`. `%noun` is any noun; `%atom` is any
58−atom; `%cell` is a cell of nouns; `%flag` is a loobean, ``?(`@f`0
59−`@f`1)``. `%null` is zero with aura `@n`, `%void` is the empty set.
60−
61−##### Syntax
55+#### Syntax
62−
63−Irregular: `*` makes `%noun`, `^` makes `%cell`, `?` makes
64−`%bean`, `~` makes `%null`, `@aura` makes atom `aura`.
65−
66−
67−## Runes
68−
69−### $| "bucbar"
70−
71−`[%bsbr p=spec q=hoon]`: structure that satisfies a validator.
72
56
57+Two arguments, fixed.
58+
59+<table>
73−##### Syntax
60+<tr><th>Form</th><th>Syntax</th></tr>
61+<tr>
62+<td>Tall</td>
63+<td>
64+<pre>
65+$| p
66+q
67+</pre>
68+</td>
69+</tr>
70+<tr>
71+<td>Wide</td>
72+<td>
73+<pre>
74+$|(p q)
75+</pre>
76+</td>
77+</tr>
78+<tr><td>Irregular</td><td>None.</td></tr>
79+</table>
80+
81+#### AST
74
82
75−Regular: **2-fixed**
83+```hoon
84+[%bcbr p=spec q=hoon]
85+```
76
86
77−##### Discussion
87+#### Discussion
78
88
79`$|` is used for validation of values at a finer level than that of types.
89`$|` is used for validation of values at a finer level than that of types.
80Recall that a given value of `type` can be equivalently defined by more than one
90Recall that a given value of `type` can be equivalently defined by more than one
@@ -106,316 +116,584 @@ expecting a certain order. This is not the same thing as casting - it is forcing
106a type to have a more specific set of values than its mold would suggest. This
116a type to have a more specific set of values than its mold would suggest. This
107rune should rarely be used, but it is extremely important when it is.
117rune should rarely be used, but it is extremely important when it is.
108
118
109−##### Examples
119+#### Examples
110
120
111```
121```
112−~zod:dojo> =foo $| (list @)
122+> =foo $| (list @)
113− |=(a=(list) (lth (lent a) 4))
123+ |=(a=(list) (lth (lent a) 4))
114```
124```
125+
115This creates a structure `foo` whose values are `list`s with length less than 4.
126This creates a structure `foo` whose values are `list`s with length less than 4.
127+
116```
128```
117> (foo ~[1 2 3])
129> (foo ~[1 2 3])
118~[1 2 3]
130~[1 2 3]
131+
119> (foo ~[1 2 3 4])
132> (foo ~[1 2 3 4])
120ford: %ride failed to execute:
133ford: %ride failed to execute:
121```
134```
122
135
123−
124The definition of `+set` in `hoon.hoon` is the following:
136The definition of `+set` in `hoon.hoon` is the following:
137+
125```hoon
138```hoon
126++ set
139++ set
127− |$ [item] :: set
140+ |$ [item]
128 $| (tree item)
141 $| (tree item)
129− |=(a=(tree) ~(apt in a))
142+ |=(a=(tree) ?:(=(~ a) & ~(apt in a)))
130```
143```
131−Here [`|$`](/docs/hoon/reference/rune/bar#barbuc) is used to
132−define a mold builder that takes in a mold (given the face `item`) and creates a
133−structure consisting of a `tree` of `item`s with `$|` that is validated with the
134−gate `|=(a=(tree) ~(apt in a))`. `in` is a door in `hoon.hoon` with functions
135−for handling `set`s, and `apt` is an arm in that door that checks that the
136−values in the `tree` are arranged in the particular way that `set`s are arranged
137−in Hoon, namely 'ascending `+mug` hash order'.
138
144
145+Here [`|$`](/docs/hoon/reference/rune/bar#barbuc) is used to define a mold
146+builder that takes in a mold (given the face `item`) and creates a structure
147+consisting of a `tree` of `item`s with `$|` that is validated with the gate
148+`|=(a=(tree) ?:(=(~ a) & ~(apt in a)))`. `in` is a door in `hoon.hoon` with
149+functions for handling `set`s, and `apt` is an arm in that door that checks that
150+the values in the `tree` are arranged in the particular way that `set`s are
151+arranged in Hoon, namely 'ascending `+mug` hash order'.
152+
153+---
139
154
140−### `$_` "buccab"
155+## `$_` "buccab"
141
156
142−`[%bscb p=hoon]`: structure that normalizes to an example.
157+Structure that normalizes to an example.
158+
159+#### Syntax
143
160
144−##### Expands to
161+One argument, fixed.
162+
163+<table>
164+<tr><th>Form</th><th>Syntax</th></tr>
165+<tr>
166+<td>Tall</td>
167+<td>
168+<pre>
169+$_ p
170+</pre>
171+</td>
172+</tr>
173+<tr>
174+<td>Wide</td>
175+<td>
176+<pre>
177+$_(p)
178+</pre>
179+</td>
180+</tr>
181+<tr>
182+<td>Irregular</td>
183+<td>
184+<pre>
185+_p
186+</pre>
187+</td>
188+</tr>
189+</table>
190+
191+#### AST
145
192
146```hoon
193```hoon
147−|=(* p)
194+[%bccb p=hoon]
148```
195```
149
196
150−##### Syntax
197+#### Expands to
151−
152−Regular: **1-fixed**.
153
198
154−Irregular: `_foo` is `$_(foo)`.
199+```hoon
200+|=(* p)
201+```
155
202
156−##### Discussion
203+#### Discussion
157
204
158−`$_` discards the sample it's supposedly normalizing
205+`$_` discards the sample it's supposedly normalizing and produces its
159−and produces its **example** instead.
206+**example** instead.
160
207
161−##### Examples
208+#### Examples
162
209
163```
210```
164−~zod:dojo> =foo $_([%foobaz %moobaz])
211+> =foo $_([%foobaz %moobaz])
165
212
166−~zod:dojo> (foo %foo %baz)
213+> (foo %foo %baz)
167[%foobaz %moobaz]
214[%foobaz %moobaz]
168
215
169−~zod:dojo> `foo`[%foobaz %moobaz]
216+> `foo`[%foobaz %moobaz]
170[%foobaz %moobaz]
217[%foobaz %moobaz]
171
218
172−~zod:dojo $:foo
219+> $:foo
173[%foobaz %moobaz]
220[%foobaz %moobaz]
174```
221```
175
222
176−### `$%` "buccen"
223+---
177
224
178−`[%bscn p=(list spec)]`: structure which recognizes a union tagged by head atom.
225+## `$%` "buccen"
179
226
180−##### Defaults to
227+Structure which recognizes a union tagged by head atom.
181
228
182−The default of the last item `i` in `p`. Crashes if `p` is empty.
229+#### Syntax
230+
231+A variable number of arguments.
232+
233+<table>
234+<tr><th>Form</th><th>Syntax</th></tr>
235+<tr>
236+<td>Tall</td>
237+<td>
238+<pre>
239+$% [%p1 ...]
240+ [%p2 ...]
241+ [%p3 ...]
242+ [%pn ...]
243+==
244+</pre>
245+</td>
246+</tr>
247+<tr>
248+<td>Wide</td>
249+<td>
250+<pre>
251+$%([%p1 ...] [%p2 ...] [%p3 ...] [%pn ...])
252+</pre>
253+</td>
254+</tr>
255+<tr><td>Irregular</td><td>None.</td></tr>
256+</table>
257+
258+Each item may be an atom or (more commonly) a cell. The atom or head of the cell
259+_must_ be a constant (`%foo`, `%1`, `%.y`, etc).
260+
261+#### AST
262+
263+```hoon
264+[%bccn p=(list spec)]
265+```
183
266
184−##### Syntax
267+#### Defaults to
185
268
186−Regular form: **2-running**.
269+The default of the last item `i` in `p`. Crashes if `p` is empty.
187
270
188−##### Discussion
271+#### Discussion
189
272
190A `$%` is a tagged union, a common data model.
273A `$%` is a tagged union, a common data model.
191
274
192Make sure the last item in your `$%` terminates, or the default will
275Make sure the last item in your `$%` terminates, or the default will
193−be an infinite loop! Alteratively, you can use `$~` to define a custom
276+be an infinite loop! Alteratively, you can use `$~` to define a custom
194type default value.
277type default value.
195
278
196−##### Examples
279+#### Examples
197
280
198```
281```
199−~zod:dojo> =foo $%([%foo p=@ud q=@ud] [%baz p=@ud])
282+> =foo $%([%foo p=@ud q=@ud] [%baz p=@ud])
200
283
201−~zod:dojo> (foo [%foo 4 2])
284+> (foo [%foo 4 2])
202[%foo p=4 q=2]
285[%foo p=4 q=2]
203
286
204−~zod:dojo> (foo [%baz 37])
287+> (foo [%baz 37])
205[%baz p=37]
288[%baz p=37]
206
289
207−~zod:dojo> $:foo
290+> $:foo
208[%baz p=0]
291[%baz p=0]
209```
292```
210
293
211−### `$:` "buccol"
294+---
212
295
213−`[%bscl p=(list spec)]`: form a cell type.
296+## `$:` "buccol"
214
297
215−##### Normalizes to
298+Form a cell type.
216
299
217−The tuple the length of `p`, normalizing each item.
300+#### Syntax
218
301
219−##### Defaults to
302+A variable number of arguments.
303+
304+<table>
305+<tr><th>Form</th><th>Syntax</th></tr>
306+<tr>
307+<td>Tall</td>
308+<td>
309+<pre>
310+$: p1
311+ p2
312+ p3
313+ pn
314+==
315+</pre>
316+</td>
317+</tr>
318+<tr>
319+<td>Wide</td>
320+<td>
321+<pre>
322+$:(p1 p2 p3 pn)
323+</pre>
324+</td>
325+</tr>
326+<tr>
327+<td>Irregular (noun mode)</td>
328+<td>
329+<pre>
330+,[p1 p2 p3 pn]
331+</pre>
332+</td>
333+</tr>
334+<tr>
335+<td>Irregular (structure mode)</td>
336+<td>
337+<pre>
338+[p1 p2 p3 pn]
339+</pre>
340+</td>
341+</tr>
342+</table>
343+
344+#### AST
220
345
221−The tuple the length of `p`.
346+```hoon
347+[%bccl p=(list spec)]
348+```
349+
350+#### Normalizes to
222
351
223−##### Syntax
352+The tuple the length of `p`, normalizing each item.
224
353
225−Regular: **running**.
354+#### Defaults to
226
355
227−Irregular (noun mode): `,[a b c]` is `$:(a b c)`.
356+The tuple the length of `p`.
228−Irregular (structure mode): `[a b c]` is `$:(a b c)`.
229
357
230−##### Examples
358+#### Examples
231
359
232```
360```
233−~zod:dojo> =foo $:(p=@ud q=@tas)
361+> =foo $:(p=@ud q=@tas)
234
362
235−~zod:dojo> (foo 33 %foo)
363+> (foo 33 %foo)
236[p=33 q=%foo]
364[p=33 q=%foo]
237
365
238−~zod:dojo> `foo`[33 %foo]
366+> `foo`[33 %foo]
239[p=33 q=%foo]
367[p=33 q=%foo]
240
368
241−~zod:dojo> $:foo
369+> $:foo
242[p=0 q=%$]
370[p=0 q=%$]
243```
371```
244
372
373+---
245
374
246−### `$<` "bucgal"
375+## `$<` "bucgal"
247
376
248−`[%bsld p=spec q=spec]`: Filters a pre-existing mold to obtain a mold
377+Filters a pre-existing mold to obtain a mold that excludes a particular
249−that excludes a particular structure.
378+structure.
250
379
251−##### Syntax
380+#### Syntax
252
381
253−Regular: **2-fixed**.
382+Two arguments, fixed.
383+
384+<table>
385+<tr><th>Form</th><th>Syntax</th></tr>
386+<tr>
387+<td>Tall</td>
388+<td>
389+<pre>
390+$< p
391+q
392+</pre>
393+</td>
394+</tr>
395+<tr>
396+<td>Wide</td>
397+<td>
398+<pre>
399+$<(p q)
400+</pre>
401+</td>
402+</tr>
403+<tr><td>Irregular</td><td>None.</td></tr>
404+</table>
405+
406+#### AST
254
407
408+```hoon
409+[%bcgl p=spec q=spec]
410+```
411+
255−##### Discussion
412+#### Discussion
256
413
257This can be used to obtain type(s) from a list of types `q` that do not satisfy a
414This can be used to obtain type(s) from a list of types `q` that do not satisfy a
258requirement given by `p`.
415requirement given by `p`.
259
416
260−##### Examples
417+#### Examples
261
418
262```
419```
263−~zod:dojo> =foo $%([%bar p=@ud q=@ud] [%baz p=@ud])
420+> =foo $%([%bar p=@ud q=@ud] [%baz p=@ud])
264
421
265−~zod:dojo> =m $<(%bar foo)
422+> =m $<(%bar foo)
266
423
267−~zod:dojo> (m [%bar 2 4])
424+> (m [%bar 2 4])
268ford: %ride failed to execute:
425ford: %ride failed to execute:
269
426
270−~zod:dojo> (m [%baz 2])
427+> (m [%baz 2])
271[%baz p=2]
428[%baz p=2]
272
429
273−~zod:dojo> ;;($<(%foo [@tas *]) [%foo 1])
430+> ;;($<(%foo [@tas *]) [%foo 1])
274ford: %ride failed to execute:
431ford: %ride failed to execute:
275
432
276−~zod:dojo> ;;($<(%foo [@tas *]) [%bar 1])
433+> ;;($<(%foo [@tas *]) [%bar 1])
277[%bar 1]
434[%bar 1]
278− ```
435+```
279
436
437+---
280
438
281−### `$>` "bucgar"
439+## `$>` "bucgar"
282
440
283−`[%bsbn p=spec q=spec]`: Filters a mold to obtain a new mold
284−matching a particular structure.
441+Filters a mold to obtain a new mold matching a particular structure.
285
442
286−##### Syntax
443+#### Syntax
287
444
288−Regular: **2-fixed**.
445+Two arguments, fixed.
446+
447+<table>
448+<tr><th>Form</th><th>Syntax</th></tr>
449+<tr>
450+<td>Tall</td>
451+<td>
452+<pre>
453+$> p
454+q
455+</pre>
456+</td>
457+</tr>
458+<tr>
459+<td>Wide</td>
460+<td>
461+<pre>
462+$>(p q)
463+</pre>
464+</td>
465+</tr>
466+<tr><td>Irregular</td><td>None.</td></tr>
467+</table>
468+
469+#### AST
289
470
471+```hoon
472+[%bcgr p=spec q=spec]
473+```
474+
290−##### Discussion
475+#### Discussion
291
476
292This can be used to obtain type(s) from a list of types `q` that satisfy a
477This can be used to obtain type(s) from a list of types `q` that satisfy a
293requirement given by `p`.
478requirement given by `p`.
294
479
295−##### Examples
480+#### Examples
296
481
297Examples with `$%`:
482Examples with `$%`:
483+
298```
484```
299−~zod:dojo> =foo $%([%bar p=@ud q=@ud] [%baz p=@ud])
485+> =foo $%([%bar p=@ud q=@ud] [%baz p=@ud])
300
486
301−~zod:dojo> =m $>(%bar foo)
487+> =m $>(%bar foo)
302
488
303−~zod:dojo> (m [%bar 2 4])
489+> (m [%bar 2 4])
304[%bar p=2 q=4]
490[%bar p=2 q=4]
305
491
306−>~zod:dojo> (m [%baz 2])
492+> (m [%baz 2])
307ford: %ride failed to execute:
493ford: %ride failed to execute:
308```
494```
309
495
310Examples with `;;`:
496Examples with `;;`:
497+
311```
498```
312−~zod:dojo> ;;([@tas *] [%foo 1])
499+> ;;([@tas *] [%foo 1])
313[%foo 1]
500[%foo 1]
314
501
315−~zod:dojo> ;;([@tas *] [%bar 1])
502+> ;;([@tas *] [%bar 1])
316[%bar 1]
503[%bar 1]
317
504
318−~zod:dojo> ;;($>(%foo [@tas *]) [%foo 1])
505+> ;;($>(%foo [@tas *]) [%foo 1])
319[%foo 1]
506[%foo 1]
320
507
321−~zod:dojo> ;;($>(%foo [@tas *]) [%bar 1])
508+> ;;($>(%foo [@tas *]) [%bar 1])
322ford: %ride failed to execute:
509ford: %ride failed to execute:
323− ```
510+```
511+
512+---
324
513
514+## `$-` "buchep"
325
515
326−### `$-` "buchep"
516+Structure that normalizes to an example gate.
327
517
328−`[%bshp p=spec q=spec]`: structure that normalizes to an example gate.
518+#### AST
519+
520+```hoon
521+[%bchp p=spec q=spec]
522+```
329
523
330−##### Expands to
524+#### Expands to
331
525
332```hoon
526```hoon
333$_ ^|
527$_ ^|
334|=(p $:q)
528|=(p $:q)
335```
529```
336
530
337−##### Syntax
531+#### Syntax
532+
533+Two arguments, fixed.
338
534
339−Regular: **2-fixed**.
535+<table>
536+<tr><th>Form</th><th>Syntax</th></tr>
537+<tr>
538+<td>Tall</td>
539+<td>
540+<pre>
541+$- p
542+q
543+</pre>
544+</td>
545+</tr>
546+<tr>
547+<td>Wide</td>
548+<td>
549+<pre>
550+$-(p q)
551+</pre>
552+</td>
553+</tr>
554+<tr><td>Irregular</td><td>None.</td></tr>
555+</table>
340
556
341−##### Discussion
557+`p` is the type the gate takes and `q` is the type the gate produces.
342
558
343−Since a `$-` reduces to a [`$_`](#buccab), it is not useful for normalizing, just for typechecking. In particular, the existence of `$-`s does **not** let us send gates or other cores over the network!
559+#### Discussion
344
560
561+Since a `$-` reduces to a [`$_`](#buccab), it is not useful for normalizing, just for typechecking. In particular, the existence of `$-`s does **not** let us send gates or other cores over the network!
562+
345−##### Examples
563+#### Examples
346
564
347```
565```
348−~zod:dojo> =foo $-(%foo %baz)
566+> =foo $-(%foo %baz)
349
567
350−~zod:dojo> ($:foo %foo)
568+> ($:foo %foo)
351%baz
569%baz
352```
570```
353
571
572+---
573+
574+## `$^` "bucket"
575+
576+Structure which normalizes a union tagged by head depth (cell).
577+
578+#### Syntax
354
579
355−### `$^` "bucket"
580+Two arguments, fixed.
581+
582+<table>
583+<tr><th>Form</th><th>Syntax</th></tr>
584+<tr>
585+<td>Tall</td>
586+<td>
587+<pre>
588+$^ p
589+q
590+</pre>
591+</td>
592+</tr>
593+<tr>
594+<td>Wide</td>
595+<td>
596+<pre>
597+$^(p q)
598+</pre>
599+</td>
600+</tr>
601+<tr><td>Irregular</td><td>None.</td></tr>
602+</table>
603+
604+#### AST
356
605
357−`[%bskt p=spec q=spec]`: structure which normalizes a union tagged by head depth (cell).
606+```hoon
607+[%bckt p=spec q=spec]
608+```
358
609
359−##### Normalizes to
610+#### Normalizes to
360
611
361Default, if the sample is an atom; `p`, if the head of the sample
612Default, if the sample is an atom; `p`, if the head of the sample
362is an atom; `q` otherwise.
613is an atom; `q` otherwise.
363
614
364−##### Defaults to
615+#### Defaults to
365
616
366The default of `p`.
617The default of `p`.
367
618
368−##### Syntax
369−
370−Regular: **2-fixed**.
371−
372−##### Examples
619+#### Examples
373
620
374```
621```
375−~zod:dojo> =a $%([%foo p=@ud q=@ud] [%baz p=@ud])
622+> =a $%([%foo p=@ud q=@ud] [%baz p=@ud])
376
623
377−~zod:dojo> =b $^([a a] a)
624+> =b $^([a a] a)
378
625
379−~zod:dojo> (b [[%baz 33] [%foo 19 22]])
626+> (b [[%baz 33] [%foo 19 22]])
380[[%baz p=33] [%foo p=19 q=22]]
627[[%baz p=33] [%foo p=19 q=22]]
381
628
382−~zod:dojo> (b [%foo 19 22])
629+> (b [%foo 19 22])
383[%foo p=19 q=22]
630[%foo p=19 q=22]
384
631
385−~zod:dojo> $:b
632+> $:b
386[%baz p=0]
633[%baz p=0]
387```
634```
388
635
389−### $& "bucpam"
636+---
390
637
391−`[%bspd p=spec q=hoon]`: repair a value of a tagged union type
638+## `$&` "bucpam"
392
639
393−##### Syntax
640+Repair a value of a tagged union type.
394
641
395−Regular: **2-fixed**.
642+#### Syntax
643+
644+Two arguments, fixed.
645+
646+<table>
647+<tr><th>Form</th><th>Syntax</th></tr>
648+<tr>
649+<td>Tall</td>
650+<td>
651+<pre>
652+$& p
653+q
654+</pre>
655+</td>
656+</tr>
657+<tr>
658+<td>Wide</td>
659+<td>
660+<pre>
661+$&(p q)
662+</pre>
663+</td>
664+</tr>
665+<tr><td>Irregular</td><td>None.</td></tr>
666+</table>
396
667
397```hoon
668```hoon
398$&(combined-mold=spec normalizing-gate=hoon)
669$&(combined-mold=spec normalizing-gate=hoon)
399```
670```
400−Here `combined-mold` is a tagged union type (typically made with `$%`) and `normalizing-gate` is a
401−gate which accepts values of `combined-mold` and normalizes them to be of one particular type
402−in `combined-mold`.
403
671
672+Here `combined-mold` is a tagged union type (typically made with `$%`) and
673+`normalizing-gate` is a gate which accepts values of `combined-mold` and
674+normalizes them to be of one particular type in `combined-mold`.
675+
676+#### AST
677+
678+```hoon
679+[%bcpm p=spec q=hoon]
680+```
681+
404−##### Normalizes to
682+#### Normalizes to
405
683
406The product of the normalizing gate and sample.
684The product of the normalizing gate and sample.
407
685
408−##### Defaults to
686+#### Defaults to
409
687
410The default of the last type listed in `p`, normalized with the normalizing gate.
688The default of the last type listed in `p`, normalized with the normalizing gate.
411
689
412−##### Discussion
690+#### Discussion
413
691
414This rune is used to "upgrade" or "repair" values of a structure, typically from
692This rune is used to "upgrade" or "repair" values of a structure, typically from
415−an old version to a new version. For example, this may happen when migrating state after
693+an old version to a new version. For example, this may happen when migrating
416−updating an app.
694+state after updating an app.
417
695
418−##### Examples
696+#### Examples
419
697
420```hoon
698```hoon
421+$ old [%0 @]
699+$ old [%0 @]
@@ -423,39 +701,69 @@ updating an app.
423+$ combined $%(old new)
701+$ combined $%(old new)
424+$ adapting $&(combined |=(?-(-.a %0 [%1 1 +.a], %1 a)))
702+$ adapting $&(combined |=(?-(-.a %0 [%1 1 +.a], %1 a)))
425```
703```
704+
426Here `adapting` is a structure that bunts to `[%1 ^]` but also normalizes from
705Here `adapting` is a structure that bunts to `[%1 ^]` but also normalizes from
427`[%0 @]` if called on such a noun.
706`[%0 @]` if called on such a noun.
428
707
708+---
429
709
430−### `$~` "bucsig"
710+## `$~` "bucsig"
431−
432−`[%bssg p=hoon q=spec]`: define a custom type default value
433
711
434−##### Product
712+Define a custom type default value.
435
713
436−Creates a structure (custom type) just like `q`, except its default value is `p`.
714+#### Syntax
437
715
438−##### Defaults to
716+Two arguments, fixed.
717+
718+<table>
719+<tr><th>Form</th><th>Syntax</th></tr>
720+<tr>
721+<td>Tall</td>
722+<td>
723+<pre>
724+$~ p
725+q
726+</pre>
727+</td>
728+</tr>
729+<tr>
730+<td>Wide</td>
731+<td>
732+<pre>
733+$~(p q)
734+</pre>
735+</td>
736+</tr>
737+<tr><td>Irregular</td><td>None.</td></tr>
738+</table>
739+
740+`p` defines the default value, and `q` defines everything else about the
741+structure.
742+
743+#### AST
439
744
440−The product of `p`.
745+```hoon
746+[%bcsg p=hoon q=spec]
747+```
441
748
442−##### Syntax
749+#### Product
443
750
444−Regular: **2-fixed**.
751+Creates a structure (custom type) just like `q`, except its default value is `p`.
445
752
446−```hoon
753+#### Defaults to
447−$~ p=hoon q=spec
448−```
449
754
450−`p` defines the default value, and `q` defines everything else about the structure.
755+The product of `p`.
451
756
452−##### Discussion
757+#### Discussion
453
758
454−You should make sure that the product type of `p` nests under `q`. You can check the default value of some structure (custom type) `r` with `*r`. (See the [`^*` rune](/docs/hoon/reference/rune/ket#kettar).)
759+You should make sure that the product type of `p` nests under `q`. You can check
760+the default value of some structure (custom type) `r` with `*r`. (See the [`^*`
761+rune](/docs/hoon/reference/rune/ket#kettar).)
455
762
763+Do not confuse the `$~` rune with the constant type for null, `$~`. (The latter
456−Do not confuse the `$~` rune with the constant type for null, `$~`. (The latter uses older Hoon syntax that is still accepted. Preferably it would be `%~`.)
764+uses older Hoon syntax that is still accepted. Preferably it would be `%~`.)
457
765
458−##### Examples
766+#### Examples
459
767
460First, let's define a type without using `$~`:
768First, let's define a type without using `$~`:
461
769
@@ -491,116 +799,217 @@ Using `$~`:
491%default-value
799%default-value
492```
800```
493
801
494−### `$@` "bucpat"
802+---
495
803
496−`[%bsvt p=spec q=spec]`: structure which normalizes a union tagged by head depth (atom).
804+## `$@` "bucpat"
497
805
498−##### Normalizes to
806+Structure which normalizes a union tagged by head depth (atom).
499
807
500−`p`, if the sample is an atom; `q`, if the sample is a cell.
808+#### Syntax
501
809
502−##### Defaults to
810+Two arguments, fixed.
811+
812+<table>
813+<tr><th>Form</th><th>Syntax</th></tr>
814+<tr>
815+<td>Tall</td>
816+<td>
817+<pre>
818+$@ p
819+q
820+</pre>
821+</td>
822+</tr>
823+<tr>
824+<td>Wide</td>
825+<td>
826+<pre>
827+$@(p q)
828+</pre>
829+</td>
830+</tr>
831+<tr><td>Irregular</td><td>None.</td></tr>
832+</table>
833+
834+#### AST
503
835
504−The default of `p`.
836+```hoon
837+[%bcpt p=spec q=spec]
838+```
505
839
506−#### Syntax
840+#### Normalizes to
841+
842+`p`, if the sample is an atom; `q`, if the sample is a cell.
507
843
508−Regular: **2-fixed**.
844+#### Defaults to
509
845
510−Product: a structure which applies `p` if its sample is an atom,
846+The default of `p`.
511−`q` if its sample is a cell.
512
847
513−Regular form: **2-fixed**.
848+#### Produces
514
849
515−Example:
850+A structure which applies `p` if its sample is an atom, `q` if its sample is a
851+cell.
852+
853+#### Examples
516
854
517```
855```
518−~zod:dojo> =a $@(%foo $:(p=%baz q=@ud))
856+> =a $@(%foo $:(p=%baz q=@ud))
519
857
520−~zod:dojo> (a %foo)
858+> (a %foo)
521%foo
859%foo
522
860
523−~zod:dojo> `a`[%baz 99]
861+> `a`[%baz 99]
524[p=%baz q=99]
862[p=%baz q=99]
525
863
526−~zod:dojo> $:a
864+> $:a
527%foo
865%foo
528```
866```
529
867
868+---
869+
870+## `$=` "buctis"
530
871
531−### `$=` "buctis"
872+Structure which wraps a face around another structure.
532
873
533−`[%bsts p=skin q=spec]`: structure which wraps a face around another structure.
874+#### Syntax
534
875
535−##### Expands to
876+Two arguments, fixed.
877+
878+<table>
879+<tr><th>Form</th><th>Syntax</th></tr>
880+<tr>
881+<td>Tall</td>
882+<td>
883+<pre>
884+$= p
885+q
886+</pre>
887+</td>
888+</tr>
889+<tr>
890+<td>Wide</td>
891+<td>
892+<pre>
893+$=(p q)
894+</pre>
895+</td>
896+</tr>
897+<tr>
898+<td>Irregular</td>
899+<td>
900+<pre>
901+p=q
902+</pre>
903+</td>
904+</tr>
905+</table>
906+
907+#### AST
536
908
537```hoon
909```hoon
538−|= *
910+[%bcts p=skin q=spec]
539−^=(p %-(q +6))
540```
911```
541
912
542−##### Syntax
913+#### Expands to
543
914
544−Regular: **2-fixed**.
915+```hoon
545−
916+|= *
546−Irregular (structure mode): `foo=baz` is `$=(foo baz)`.
917+^=(p %-(q +6))
918+```
547
919
548−##### Discussion
920+#### Discussion
549
921
550Note that the Hoon compiler is at least slightly clever about
922Note that the Hoon compiler is at least slightly clever about
551compiling structures, and almost never has to actually put in a gate
923compiling structures, and almost never has to actually put in a gate
552layer (as seen in the expansion above) to apply a `$=`.
924layer (as seen in the expansion above) to apply a `$=`.
553
925
554−##### Examples
926+#### Examples
555
927
556```
928```
557−~zod:dojo> =a $=(p %foo)
929+> =a $=(p %foo)
558
930
559−~zod:dojo> (a %foo)
931+> (a %foo)
560p=%foo
932p=%foo
561
933
562−~zod:dojo> (a %baz)
934+> (a %baz)
563ford: %ride failed to execute:
935ford: %ride failed to execute:
564```
936```
565
937
566−### `$?` "bucwut"
938+---
567
939
568−`[%bswt p=(list spec)]`: form a type from a union of other types.
940+## `$?` "bucwut"
569
941
570−##### Normalizes to
942+Form a type from a union of other types.
571
943
572−The first item in `p` which normalizes the sample to itself.
944+#### Syntax
573
945
574−Void, if `p` is empty.
946+Variable number of arguments.
947+
948+<table>
949+<tr><th>Form</th><th>Syntax</th></tr>
950+<tr>
951+<td>Tall</td>
952+<td>
953+<pre>
954+$? p1
955+ p2
956+ p3
957+ pn
958+==
959+</pre>
960+</td>
961+</tr>
962+<tr>
963+<td>Wide</td>
964+<td>
965+<pre>
966+$?(p1 p2 p3 pn)
967+</pre>
968+</td>
969+</tr>
970+<tr>
971+<td>Irregular</td>
972+<td>
973+<pre>
974+?(p1 p2 p3 pn)
975+</pre>
976+</td>
977+</tr>
978+</table>
979+
980+#### AST
981+
982+```hoon
983+[%bcwt p=(list spec)]
984+```
575
985
576−##### Defaults to
986+#### Normalizes to
577
987
578−The first item in `p`.
988+The last item in `p` which normalizes the sample to itself.
579
989
580−##### Syntax
990+Void, if `p` is empty.
581
991
582−Regular: **running**.
992+#### Defaults to
583
993
584−Irregular: `?(%foo %baz)` is `$?(%foo %baz)`.
994+The last item in `p`.
585
995
586−##### Discussion
996+#### Discussion
587
997
588−For a union of atoms, a `$?` is fine. For more complex nouns,
998+For a union of atoms, a `$?` is fine. For more complex nouns, always try to use
589−always try to use a [`$%`](#buccen), [`$@`](#bucpat) or
999+a [`$%`](#buccen), [`$@`](#bucpat) or [`$^`](#bucket), at least if you expect
590−[`$^`](#bucket), at least if you expect your structure to be used as a
1000+your structure to be used as a normalizer.
591−normalizer.
592
1001
593−##### Examples
1002+#### Examples
594
1003
595```
1004```
596−~zod:dojo> =a ?(%foo %baz %baz)
1005+> =a ?(%foo %baz %baz)
597
1006
598−~zod:dojo> (a %baz)
1007+> (a %baz)
599%baz
1008%baz
600
1009
601−~zod:dojo> (a [37 45])
1010+> (a [37 45])
602ford: %ride failed to execute:
1011ford: %ride failed to execute:
603
1012
604−~zod:dojo> $:a
1013+> $:a
605%baz
1014%baz
606```
1015```
content/docs/hoon/reference/rune/cen.md+468−187
@@ -4,109 +4,175 @@ weight = 10
4template = "doc.html"
4template = "doc.html"
5aliases = ["docs/reference/hoon-expressions/rune/cen/"]
5aliases = ["docs/reference/hoon-expressions/rune/cen/"]
6+++
6+++
7−The `%` family of runes is used for making 'function calls' in Hoon. To be more precise, these runes evaluate the `$` arm in cores, usually after modifying the sample. (The default sample is replaced with the input values given in the call.)
8
7
9−These runes reduce to the `%=` rune.
8+The `%` family of runes is used for making 'function calls' in Hoon. To be more
9+precise, these runes evaluate the `$` arm in cores, usually after modifying the
10+sample. (The default sample is replaced with the input values given in the
11+call.)
10
12
11−## Runes
13+These runes reduce to the `%=` rune.
12
14
13−### `%_` "cencab"
15+## `%_` "cencab"
14
16
15Resolve a wing with changes, preserving type.
17Resolve a wing with changes, preserving type.
16
18
17−##### Syntax
19+#### Syntax
18
20
19−Regular, tall:
21+One fixed argument, then a variable number of pairs.
20
22
21−```hoon
23+<table>
24+<tr><th>Form</th><th>Syntax</th></tr>
25+<tr>
26+<td>Tall style #1</td>
27+<td>
28+<pre>
22%_ a=wing
29%_ a=wing
23 b=wing c=hoon
30 b=wing c=hoon
24 d=wing e=hoon
31 d=wing e=hoon
25− ...
26 f=wing g=hoon
32 f=wing g=hoon
27==
33==
28−```
34+</pre>
29−
35+</td>
30−Regular, flat:
36+</tr>
31−
37+<tr>
38+<td>Tall style #2</td>
39+<td>
40+<pre>
41+%_ a=wing
42+ b=wing
32−```hoon
43+ c=hoon
44+::
45+ d=wing
46+ e=hoon
47+::
48+ f=wing
49+ g=hoon
50+==
51+</pre>
52+</td>
53+</tr>
54+<tr>
55+<td>Wide</td>
56+<td>
57+<pre>
33%_(a=wing b=wing c=hoon, d=wing e=hoon, ...)
58%_(a=wing b=wing c=hoon, d=wing e=hoon, ...)
34−```
59+</pre>
60+</td>
61+</tr>
62+<tr>
63+<td>Irregular</td>
64+<td>None.</td>
65+</tr>
66+</table>
35
67
36−AST:
68+#### AST
37
69
38−```
70+```hoon
39[%cncb p=wing q=(list (pair wing hoon))]
71[%cncb p=wing q=(list (pair wing hoon))]
40```
72```
41
73
42−##### Semantics
43−
44−A `%_` expression resolves to the value of the subject at wing `a`, but modified according to a series of changes: `b` is replaced with the product of `c`, `d` with the product of `e`, and so on. At compile time a type check is performed to ensure that the resulting value is of the same type as `a`.
45−
46−##### Expands to
74+#### Expands to
47
75
48```hoon
76```hoon
49^+(a %=(a b c, d e, ...))
77^+(a %=(a b c, d e, ...))
50```
78```
51
79
52−##### Discussion
80+#### Semantics
81+
82+A `%_` expression resolves to the value of the subject at wing `a`, but modified
83+according to a series of changes: `b` is replaced with the product of `c`, `d`
84+with the product of `e`, and so on. At compile time a type check is performed to
85+ensure that the resulting value is of the same type as `a`.
53
86
87+#### Discussion
88+
54−`%_` is different from `%=` because `%=` can change the type of a wing with mutations. `%_` preserves the wing type.
89+`%_` is different from `%=` because `%=` can change the type of a wing with
90+mutations. `%_` preserves the wing type.
55
91
56See [how wings are resolved](/docs/hoon/reference/limbs/).
92See [how wings are resolved](/docs/hoon/reference/limbs/).
57
93
58−##### Examples
94+#### Examples
59
95
60```
96```
61−~zod:dojo> =foo [p=42 q=6]
97+> =foo [p=42 q=6]
62
98
63−~zod:dojo> foo(p %baz)
99+> foo(p %baz)
64[p=%baz q=6]
100[p=%baz q=6]
65
101
66−~zod:dojo> foo(p [55 99])
102+> foo(p [55 99])
67[p=[55 99] q=6]
103[p=[55 99] q=6]
68
104
69−~zod:dojo> %_(foo p %baz)
105+> %_(foo p %baz)
70[p=7.496.034 99]
106[p=7.496.034 99]
71
107
72−~zod:dojo> %_(foo p [55 99])
108+> %_(foo p [55 99])
73! nest-fail
109! nest-fail
74```
110```
75
111
112+---
113+
76−### `%:` "cencol"
114+## `%:` "cencol"
77
115
78Call a gate with many arguments.
116Call a gate with many arguments.
79
117
80−##### Syntax
118+#### Syntax
81
119
82−Regular:
120+One fixed argument, then a variable number of arguments.
83
121
84−```hoon
122+<table>
123+<tr><th>Form</th><th>Syntax</th></tr>
124+<tr>
125+<td>Tall</td>
126+<td>
127+<pre>
85%: a=hoon
128%: a=hoon
86 b=hoon
129 b=hoon
87 c=hoon
130 c=hoon
88 ...
131 ...
89 d=hoon
132 d=hoon
90==
133==
91−```
134+</pre>
92−
135+</td>
136+</tr>
137+<tr>
138+<td>Wide</td>
139+<td>
140+<pre>
141+%:(a b c d)
142+</pre>
143+</td>
144+</tr>
145+<tr>
146+<td>Irregular</td>
147+<td>
148+<pre>
149+(a b c d)
150+</pre>
151+</td>
152+</tr>
153+</table>
154+
93−AST:
155+#### AST
94
156
95−```
157+```hoon
96[%cncl p=hoon q=(list hoon)]
158[%cncl p=hoon q=(list hoon)]
97```
159```
98
160
99−##### Semantics
161+#### Semantics
100
162
101−A `%:` expression calls a gate with many arguments. `a` is the gate to be called, and `b` through `d` are the arguments. If there is only one subexpression after `a`, its product is the sample. Otherwise, a single argument is constructed by evaluating all of `b` through `d` -- however many subexpressions there are -- and putting the result in a cell: `[b c ... d]`.
163+A `%:` expression calls a gate with many arguments. `a` is the gate to be
164+called, and `b` through `d` are the arguments. If there is only one
165+subexpression after `a`, its product is the sample. Otherwise, a single argument
166+is constructed by evaluating all of `b` through `d` -- however many
167+subexpressions there are -- and putting the result in a cell: `[b c ... d]`.
102
168
103−##### Discussion
169+#### Discussion
104
170
105When `%:` is used in tall-form syntax, the series of expressions after `p` must be terminated with `==`.
171When `%:` is used in tall-form syntax, the series of expressions after `p` must be terminated with `==`.
106
172
107−##### Examples
173+#### Examples
108
174
109−```hoon
175+```
110> %: add 22 33 ==
176> %: add 22 33 ==
11155
17755
112
178
@@ -123,211 +189,342 @@ When `%:` is used in tall-form syntax, the series of expressions after `p` must
123> %: adder 22 33 44 55 ==
189> %: adder 22 33 44 55 ==
124154
190154
125
191
126−> %:(adder 22 33 44 ~)
192+> %:(adder 22 33 44)
193+99
194+
195+> (adder 22 33 44)
12799
19699
128```
197```
129
198
130−### `%.` "cendot"
199+---
131
200
132−Call a gate (function), inverted.
201+## `%.` "cendot"
133
202
134−##### Syntax
203+Call a gate (function), inverted.
135
204
136−Regular:
205+#### Syntax
206+
207+Two arguments, fixed.
208+
209+<table>
210+<tr><th>Form</th><th>Syntax</th></tr>
211+<tr>
212+<td>Tall</td>
213+<td>
214+<pre>
215+%. a b
216+</pre>
217+</td>
218+</tr>
219+<tr>
220+<td>Wide</td>
221+<td>
222+<pre>
223+%.(a b)
224+</pre>
225+</td>
226+</tr>
227+<tr>
228+<td>Irregular</td>
229+<td>None.</td>
230+</tr>
231+</table>
232+
233+#### AST
137
234
138```hoon
235```hoon
139−%. a=hoon b=hoon
140−```
141−
142−AST:
143−
144−```
145[%cndt p=hoon q=hoon]
236[%cndt p=hoon q=hoon]
146```
237```
147
238
148−##### Semantics
239+#### Semantics
149
240
150−The `%.` rune is for evaluating the `$` arm of a gate, i.e., calling a function. `a` is for the desired sample value (i.e., input value), and `b` is the gate.
241+The `%.` rune is for evaluating the `$` arm of a gate, i.e., calling a function.
242+`a` is for the desired sample value (i.e., input value), and `b` is the gate.
151
243
152−##### Expands to
244+#### Expands to
153
245
154```hoon
246```hoon
155%-(b=hoon a=hoon)
247%-(b=hoon a=hoon)
156```
248```
157
249
158−##### Discussion
250+#### Discussion
159
251
160−`%.` is just like `%-`, but with its subexpressions reversed; the argument comes first, and then the gate.
252+`%.` is just like `%-`, but with its subexpressions reversed; the argument comes
253+first, and then the gate.
161
254
162−##### Examples
255+#### Examples
163
256
164```
257```
165−~zod:dojo> =add-triple |=([a=@ b=@ c=@] :(add a b c))
258+> =add-triple |=([a=@ b=@ c=@] :(add a b c))
166
259
167−~zod:dojo> %.([1 2 3] add-triple)
260+> %.([1 2 3] add-triple)
1686
2616
169```
262```
170
263
171−### `%-` "cenhep" {#cenhep}
264+---
172−
173−Call a gate (function).
174−
175−##### Syntax
176
265
177−Regular:
266+## `%-` "cenhep" {#cenhep}
178
267
179−```hoon
268+Call a gate (function).
180−%- a=hoon b=hoon
181−```
182
269
270+#### Syntax
271+
272+<table>
273+<tr><th>Form</th><th>Syntax</th></tr>
274+<tr>
275+<td>Tall</td>
276+<td>
277+<pre>
278+%- a
279+b
280+</pre>
281+</td>
282+</tr>
283+<tr>
284+<td>Wide</td>
285+<td>
286+<pre>
287+%-(a b)
288+</pre>
289+</td>
290+</tr>
291+<tr>
183−Irregular:
292+<td>Irregular</td>
293+<td>
294+<pre>
295+(a b)
296+</pre>
297+</td>
298+</tr>
299+</table>
300+
301+#### AST
184
302
185```hoon
303```hoon
186−(a=hoon b=hoon)
187−```
188−
189−AST:
190−
191−```
192[%cnhp p=hoon q=hoon]
304[%cnhp p=hoon q=hoon]
193```
305```
194
306
195−##### Semantics
307+#### Semantics
196
308
197−This rune is for evaluating the `$` arm of a gate, i.e., calling a gate as a function. `a` is the gate, and `b` is the desired sample value (i.e., input value) for the gate.
309+This rune is for evaluating the `$` arm of a gate, i.e., calling a gate as a
310+function. `a` is the gate, and `b` is the desired sample value (i.e., input
311+value) for the gate.
198
312
199−##### Expands to
313+#### Expands to
200
314
201```hoon
315```hoon
202%~($ a b)
316%~($ a b)
203```
317```
204
318
205−##### Discussion
319+#### Discussion
206
320
207−`%-` is used to call a function; `a` is the function ([`gate`](/docs/hoon/reference/rune/bar#bartis),
321+`%-` is used to call a function; `a` is the function
322+([`gate`](/docs/hoon/reference/rune/bar#bartis), `q` the argument. `%-` is a
208−`q` the argument. `%-` is a special case of [`%~` ("censig")](#censig), and a gate is a special case of a [door](/docs/hoon/reference/rune/bar#barcab).
323+special case of [`%~` ("censig")](#censig), and a gate is a special case of a
324+[door](/docs/hoon/reference/rune/bar#barcab).
209
325
210−##### Examples
326+#### Examples
211
327
212```
328```
213−~zod:dojo> =add-triple |=([a=@ b=@ c=@] :(add a b c))
329+> =add-triple |=([a=@ b=@ c=@] :(add a b c))
330+
214−~zod:dojo> (add-triple 1 2 3)
331+> (add-triple 1 2 3)
2156
3326
333+
216−~zod:dojo> %-(add-triple [1 2 3])
334+> %-(add-triple [1 2 3])
2176
3356
218```
336```
219
337
220−### `%^` "cenket"
338+---
221
339
222−Call gate with triple sample.
340+## `%^` "cenket"
223
341
224−##### Syntax
342+Call gate with triple sample.
225
343
226−Regular:
344+#### Syntax
345+
346+Four arguments, fixed.
347+
348+<table>
349+<tr><th>Form</th><th>Syntax</th></tr>
350+<tr>
351+<td>Tall</td>
352+<td>
353+<pre>
354+%^ a
355+ b
356+ c
357+d
358+</pre>
359+</td>
360+</tr>
361+<tr>
362+<td>Wide</td>
363+<td>
364+<pre>
365+%^(a b c d)
366+</pre>
367+</td>
368+</tr>
369+<tr>
370+<td>Irregular</td>
371+<td>
372+<pre>
373+(a b c d)
374+</pre>
375+</td>
376+</tr>
377+</table>
378+
379+#### AST
227
380
228```hoon
381```hoon
229−%^ a=hoon b=hoon c=hoon d=hoon
230−```
231−
232−AST:
233−
234−```
235[%cnkt p=hoon q=hoon r=hoon s=hoon]
382[%cnkt p=hoon q=hoon r=hoon s=hoon]
236```
383```
237
384
238−
239−##### Expands to
385+#### Expands to
240
386
241```hoon
387```hoon
242%-(a=hoon [b=hoon c=hoon d=hoon])
388%-(a=hoon [b=hoon c=hoon d=hoon])
243```
389```
244
390
245−##### Examples
391+#### Examples
246
392
247```
393```
248−~zod:dojo> =add-triple |=([a=@ b=@ c=@] :(add a b c))
394+> =add-triple |=([a=@ b=@ c=@] :(add a b c))
249
395
250−~zod:dojo> %^(add-triple 1 2 3)
396+> %^(add-triple 1 2 3)
2516
3976
252```
398```
253
399
254−### `%+` "cenlus"
400+---
255
401
256−Call gate with a cell sample.
402+## `%+` "cenlus"
257
403
258−##### Syntax
404+Call gate with a cell sample.
259
405
260−Regular:
406+#### Syntax
407+
408+Three arguments, fixed.
409+
410+<table>
411+<tr><th>Form</th><th>Syntax</th></tr>
412+<tr>
413+<td>Tall</td>
414+<td>
415+<pre>
416+%+ a
417+ b
418+c
419+</pre>
420+</td>
421+</tr>
422+<tr>
423+<td>Wide</td>
424+<td>
425+<pre>
426+%+(a b c)
427+</pre>
428+</td>
429+</tr>
430+<tr>
431+<td>Irregular</td>
432+<td>
433+<pre>
434+(a b c)
435+</pre>
436+</td>
437+</tr>
438+</table>
439+
440+#### AST
261
441
262```hoon
442```hoon
263−%+ a=hoon b=hoon c=hoon
264−```
265−
266−AST:
267−
268−```
269[%cnls p=hoon q=hoon r=hoon]
443[%cnls p=hoon q=hoon r=hoon]
270```
444```
271
445
272−##### Semantics
446+#### Semantics
273
447
274−A `%+` expression is for calling a gate with a cell sample. `a` is the gate to be called, `b` is for the head of the sample, and `c` is for the sample tail.
448+A `%+` expression is for calling a gate with a cell sample. `a` is the gate to
449+be called, `b` is for the head of the sample, and `c` is for the sample tail.
275
450
276−##### Expands to
451+#### Expands to
277
452
278```hoon
453```hoon
279%-(a=hoon [b=hoon c=hoon])
454%-(a=hoon [b=hoon c=hoon])
280```
455```
281
456
282−##### Examples
457+#### Examples
283
458
284```
459```
285−~zod:dojo> =add-triple |=([a=@ b=@ c=@] :(add a b c))
460+> =add-triple |=([a=@ b=@ c=@] :(add a b c))
286
461
287−~zod:dojo> %+(add-triple 1 [2 3])
462+> %+(add-triple 1 [2 3])
2886
4636
289```
464```
290
465
291−### `%~` "censig"
466+---
292−
293−Evaluate an arm in a door.
294−
295−##### Syntax
296−
297−Regular: **3-fixed**
298−
299−```hoon
300−%~ a=wing b=hoon c=hoon
301−```
302−
303−Irregular: **variadic**
304−
305−`~(a b c)` is `%~(a b c)`.
306−`~(a b c d e)` is `%~(a b [c d e])`.
307−
308−AST:
309−
310−```
311−[%cnsg p=wing q=hoon r=(list hoon)]
312−```
313−
314−##### Semantics
315
467
316−A `%~` expression evaluates the arm of a door (i.e., a core with a sample). `a` is a wing that resolves to the arm from within the door in question. `b` is the door itself. If there is only one subexpression after `b`, `c`, then the product of `c` becomes the door's sample value. If there are multiple subexpressions after `b`, their products are made into a cell, `[c d ... e]`, and that becomes the door's sample value.
468+## `%~` "censig"
317
469
318−##### Discussion
470+Evaluate an arm in a door.
319
471
472+#### Syntax
473+
474+Three arguments, fixed.
475+
476+<table>
477+<tr><th>Form</th><th>Syntax</th></tr>
478+<tr>
479+<td>Tall</td>
480+<td>
481+<pre>
482+%~ p q
483+r
484+</pre>
485+</td>
486+</tr>
487+<tr>
488+<td>Wide</td>
489+<td>
490+<pre>
491+%~(p q r)
492+</pre>
493+</td>
494+</tr>
495+<tr>
496+<td>Irregular</td>
497+<td>
498+<pre>
499+~(p q r1 r2 rn)
500+</pre>
501+</td>
502+</tr>
503+</table>
504+
505+In the irregular form, `r` may be split into multiple parts. Multiple parts of
506+`r` will be formed into a cell.
507+
508+#### Semantics
509+
510+A `%~` expression evaluates the arm of a door (i.e., a core with a sample). `a`
511+is a wing that resolves to the arm from within the door in question. `b` is the
512+door itself. `c` is the sample of the door.
513+
514+#### Discussion
515+
320−`%~` is the general case of a function call, `%-`. In both, we replace the sample (`+6`) of a core. In `%-` the core is a gate and the `$` arm is evaluated. In `%~` the core is a door and any arm may be evaluated. You must identify the arm to be run: `%~(arm door arg)`.
516+`%~` is the general case of a function call, `%-`. In both, we replace the sample (`+6`) of a core. In `%-` the core is a gate and the `$` arm is evaluated. In `%~` the core is a door and any arm may be evaluated. You must identify the arm to be run: `%~(arm door arg)`.
321
517
322See also [`|_`](/docs/hoon/reference/rune/bar#barcab).
518See also [`|_`](/docs/hoon/reference/rune/bar#barcab).
323
519
324−##### Examples
520+#### Examples
325
521
326−```hoon
522+```
327> =mycore |_ a=@
523> =mycore |_ a=@
328 ++ plus-two (add 2 a)
524 ++ plus-two (add 2 a)
329 ++ double (mul 2 a)
525 ++ double (mul 2 a)
330 --
526 --
527+
331> ~(plus-two mycore 10)
528> ~(plus-two mycore 10)
33212
52912
333
530
@@ -335,34 +532,72 @@ See also [`|_`](/docs/hoon/reference/rune/bar#barcab).
33520
53220
336```
533```
337
534
535+---
536+
338−### `%*` "centar"
537+## `%*` "centar"
339
538
340Evaluate an expression, then resolve a wing with changes.
539Evaluate an expression, then resolve a wing with changes.
341
540
342−##### Syntax
541+#### Syntax
343
542
344−Regular:
543+Two fixed arguments, then a variable number of pairs.
345
544
346−```hoon
545+<table>
546+<tr><th>Form</th><th>Syntax</th></tr>
547+<tr>
548+<td>Tall style #1</td>
549+<td>
550+<pre>
347%* a=wing b=hoon
551%* a=wing b=hoon
348 c=wing d=hoon
552 c=wing d=hoon
349 e=wing f=hoon
553 e=wing f=hoon
350 ...
554 ...
351 g=wing h=hoon
555 g=wing h=hoon
352==
556==
353−```
557+</pre>
354−
558+</td>
559+</tr>
560+<tr>
561+<td>Tall style #2</td>
562+<td>
563+<pre>
564+%* a=wing b=hoon
565+ c=wing
566+ d=hoon
567+::
568+ e=wing
569+ f=hoon
570+::
571+ g=wing
572+ h=hoon
573+==
574+</pre>
575+</td>
576+</tr>
577+<tr>
578+<td>Wide</td>
579+<td>
580+<pre>
581+%*(a b c d, e f, g h)
582+</pre>
583+</td>
584+</tr>
585+<tr><td>Irregular</td><td>None.</td></tr>
586+</table>
587+
355−AST:
588+#### AST
356
589
357−```
590+```hoon
358[%cntr p=wing q=hoon r=(list (pair wing hoon))]
591[%cntr p=wing q=hoon r=(list (pair wing hoon))]
359```
592```
360
593
361−##### Semantics
594+#### Semantics
362
595
596+A `%*` expression evaluates some arbitrary Hoon expression, `b`, and then
363−A `%*` expression evaluates some arbitrary Hoon expression, `b`, and then resolves a wing of that result, with changes. `a` is the wing to be resolved, and one or more changes is defined by the subexpressions after `b`.
597+resolves a wing of that result, with changes. `a` is the wing to be resolved,
598+and one or more changes is defined by the subexpressions after `b`.
364
599
365−##### Expands to
600+#### Expands to
366
601
367```hoon
602```hoon
368=+ b=hoon
603=+ b=hoon
@@ -374,7 +609,7 @@ A `%*` expression evaluates some arbitrary Hoon expression, `b`, and then resolv
374==
609==
375```
610```
376
611
377−##### Examples
612+#### Examples
378
613
379```
614```
380> %*($ add a 2, b 3)
615> %*($ add a 2, b 3)
@@ -398,52 +633,96 @@ A `%*` expression evaluates some arbitrary Hoon expression, `b`, and then resolv
398[a=1 b=7 c=10]
633[a=1 b=7 c=10]
399```
634```
400
635
636+---
637+
401−### `%=` "centis"
638+## `%=` "centis"
402
639
403Resolve a wing with changes.
640Resolve a wing with changes.
404
641
405−##### Syntax
642+#### Syntax
406
643
407−Regular:
644+One fixed argument, then a variable number of pairs.
408
645
409−```hoon
646+<table>
647+<tr><th>Form</th><th>Syntax</th></tr>
648+<tr>
649+<td>Tall style #1</td>
650+<td>
651+<pre>
410%= a=wing
652%= a=wing
411 b=wing c=hoon
653 b=wing c=hoon
412 d=wing e=hoon
654 d=wing e=hoon
413 ...
655 ...
414 f=wing g=hoon
656 f=wing g=hoon
415==
657==
416−```
658+</pre>
417−
659+</td>
660+</tr>
661+<tr>
662+<td>Tall style #2</td>
663+<td>
664+<pre>
665+%= a=wing
666+ b=wing
667+ c=hoon
668+::
669+ d=wing
670+ e=hoon
671+::
672+ f=wing
673+ g=hoon
674+==
675+</pre>
676+</td>
677+</tr>
678+<tr>
679+<td>Wide</td>
680+<td>
681+<pre>
682+%=(a b c, d e, f g)
683+</pre>
684+</td>
685+</tr>
686+<tr>
418−Irregular:
687+<td>Irregular</td>
419−
688+<td>
420−`foo(x 1, y 2, z 3)` is `%=(foo x 1, y 2, z 3)`.
689+<pre>
421−
690+a(b c, d e, f g)
691+</pre>
692+</td>
693+</tr>
694+</table>
695+
422−AST:
696+#### AST
423
697
424−```
698+```hoon
425[%cnts p=wing q=(list (pair wing hoon))]
699[%cnts p=wing q=(list (pair wing hoon))]
426```
700```
427
701
428−##### Semantics
702+#### Semantics
429
703
430A `%=` expression resolves a wing of the subject, but with changes made.
704A `%=` expression resolves a wing of the subject, but with changes made.
431
705
432−If `a` resolves to a leg, a series of changes are made to wings of that leg (`b`, `d`, and `f` above are replaced with the respective products of `c`, `e`, and `g` above). The modified leg is returned.
706+If `a` resolves to a leg, a series of changes are made to wings of that leg
707+(`b`, `d`, and `f` above are replaced with the respective products of `c`, `e`,
708+and `g` above). The modified leg is returned.
433
709
434−If `a` resolves to an arm, a series of changes are made to wings of the parent core of that arm. (Again, `b`, `d`, and `f` are replaced with the respective products of `c`, `e`, and `g`.) The arm is computed with the modified core as the subject, and the product is returned.
710+If `a` resolves to an arm, a series of changes are made to wings of the parent
711+core of that arm. (Again, `b`, `d`, and `f` are replaced with the respective
712+products of `c`, `e`, and `g`.) The arm is computed with the modified core as
713+the subject, and the product is returned.
435
714
436−##### Discussion
715+#### Discussion
437
716
438−Note that `a` is a wing, not just any expression. Knowing that a function
717+Note that `a` is a wing, not just any expression. Knowing that a function call
439−call `(foo baz)` involves evaluating `foo`, replacing its sample
718+`(foo baz)` involves evaluating `foo`, replacing its sample at slot `+6` with
440−at slot `+6` with `baz`, and then resolving to the `$` limb, you might think
719+`baz`, and then resolving to the `$` limb, you might think `(foo baz)` would
441−`(foo baz)` would mean `%=(foo +6 baz)`.
720+mean `%=(foo +6 baz)`.
442
721
443−But it's actually `=+(foo =>(%=(+2 +6 baz) $))`. Even if `foo` is
722+But it's actually `=+(foo =>(%=(+2 +6 baz) $))`. Even if `foo` is a wing, we
444−a wing, we would just be mutating `+6` within the core that defines the
723+would just be mutating `+6` within the core that defines the `foo` arm. Instead
445−`foo` arm. Instead we want to modify the **product** of `foo` -- the gate
724+we want to modify the **product** of `foo` -- the gate -- so we have to pin it
446−-- so we have to pin it into the subject.
725+into the subject.
447
726
448Here's that again in tall form:
727Here's that again in tall form:
449
728
@@ -455,12 +734,14 @@ Here's that again in tall form:
455 $
734 $
456```
735```
457
736
458−##### Examples
737+#### Examples
459
738
460```
739```
461−~zod:dojo> =foo [p=5 q=6]
740+> =foo [p=5 q=6]
741+
462−~zod:dojo> foo(p 42)
742+> foo(p 42)
463[p=42 q=6]
743[p=42 q=6]
744+
464−~zod:dojo> foo(+3 99)
745+> foo(+3 99)
465[p=5 99]
746[p=5 99]
466```
747```
content/docs/hoon/reference/rune/col.md+364−143
@@ -4,157 +4,404 @@ weight = 9
4template = "doc.html"
4template = "doc.html"
5aliases = ["docs/reference/hoon-expressions/rune/col/"]
5aliases = ["docs/reference/hoon-expressions/rune/col/"]
6+++
6+++
7−The `:` ("col") expressions are used to produce cells, which are pairs of values. E.g., `:-(p q)` produces the cell `[p q]`. All `:` runes reduce to `:-`.
8
7
9−## Runes
8+The `:` ("col") expressions are used to produce cells, which are pairs of
10−
9+values. E.g., `:-(p q)` produces the cell `[p q]`. All `:` runes reduce to `:-`.
11−### `:_` "colcab"
10+
12−
11+## `:-` "colhep"
13−`[%clcb p=hoon q=hoon]`; construct a cell, inverted.
12+
14−
13+Construct a cell (2-tuple).
15−##### Expands to
14+
15+#### Syntax
16+
17+Two arguments, fixed.
18+
19+<table>
20+<tr><th>Form</th><th>Syntax</th></tr>
21+<tr>
22+<td>Tall</td>
23+<td>
24+<pre>
25+:- p
26+q
27+</pre>
28+</td>
29+</tr>
30+<tr>
31+<td>Wide</td>
32+<td>
33+<pre>
34+:-(p q)
35+</pre>
36+</td>
37+</tr>
38+<tr>
39+<td>Irregular #1</td>
40+<td>
41+<pre>
42+[p q]
43+</pre>
44+</td>
45+</tr>
46+<tr>
47+<td>Irregular #2</td>
48+<td>
49+<pre>
50+p^q
51+</pre>
52+</td>
53+</tr>
54+</table>
55+
56+#### AST
16
57
17```hoon
58```hoon
18−:-(q p)
59+[%clhp p=hoon q=hoon]
19```
60```
20
61
21−##### Syntax
62+#### Produces
22
63
23−Regular: **2-fixed**.
64+The cell of `p` and `q`.
24
65
25−##### Examples
66+#### Discussion
26
67
27−```
68+Hoon expressions actually use the same "autocons" pattern as Nock
28−~zod:dojo> :_(1 2)
69+formulas. If you're assembling expressions (which usually only the
29−[2 1]
70+compiler does), `[a b]` is the same as `:-(a b)`.
30−```
31−
32−### `::` "colcol"
33
71
34−Code comment
72+#### Examples
35
73
36−##### Syntax
74+```
75+> :-(1 2)
76+[1 2]
37
77
38−:: any text you like!
78+~zod:dojo> 1^2
79+[1 2]
80+```
39
81
40−##### Examples
82+---
83+
84+## `:_` "colcab"
85+
86+Construct a cell, inverted.
87+
88+#### Syntax
89+
90+Two arguments, fixed.
91+
92+<table>
93+<tr><th>Form</th><th>Syntax</th></tr>
94+<tr>
95+<td>Tall</td>
96+<td>
97+<pre>
98+:_ p
99+q
100+</pre>
101+</td>
102+</tr>
103+<tr>
104+<td>Wide</td>
105+<td>
106+<pre>
107+:_(p q)
108+</pre>
109+</td>
110+</tr>
111+<tr>
112+<td>Irregular</td>
113+<td>None.</td>
114+</tr>
115+</table>
116+
117+#### AST
41
118
42```hoon
119```hoon
43−::
120+[%clcb p=hoon q=hoon]
44−:: this is commented code
45−::
46−|= a=@ :: a gate
47−(add 2 a) :: that adds 2
48− :: to the input
49```
121```
50
122
51−### `:-` "colhep"
123+#### Expands to
52−
53−`[%clhp p=hoon q=hoon]`: construct a cell (2-tuple).
54−
55−##### Produces
56−
57−The cell of `p` and `q`.
58−
59−##### Syntax
60−
61−Regular: **2-fixed**.
62−
63−Irregular: `[a b]` is `:-(a b)`.
64−
65−Irregular: `[a b c]` is `[a [b c]]`.
66−
67−Irregular: `a^b^c` is `[a b c]`.
68−
69−Irregular: `a/b` is `[%a b]`.
70
124
71−Irregular: `` `a `` is `[~ a]`.
125+```hoon
126+:-(q p)
127+```
72
128
73−Irregular: `~[a b]` is `[a b ~]`.
129+#### Examples
74
130
75−Irregular: `[a b c]~` is `[[a b c] ~]`.
131+```
132+> :_(1 2)
133+[2 1]
134+```
76
135
77−## Discussion
136+---
137+
138+## `:+` "collus"
139+
140+Construct a triple (3-tuple).
141+
142+#### Syntax
143+
144+Three arguments, fixed.
145+
146+<table>
147+<tr><th>Form</th><th>Syntax</th></tr>
148+<tr>
149+<td>Tall</td>
150+<td>
151+<pre>
152+:+ p
153+ q
154+r
155+</pre>
156+</td>
157+</tr>
158+<tr>
159+<td>Wide</td>
160+<td>
161+<pre>
162+:+(p q r)
163+</pre>
164+</td>
165+</tr>
166+<tr>
167+<td>Irregular</td>
168+<td>
169+<pre>
170+[p q r]
171+</pre>
172+</td>
173+</tr>
174+</table>
175+
176+#### AST
78
177
79−Hoon expressions actually use the same "autocons" pattern as Nock
178+```hoon
80−formulas. If you're assembling expressions (which usually only the
179+[%clls p=hoon q=hoon r=hoon]
81−compiler does), `[a b]` is the same as `:-(a b)`.
180+```
82
181
83−##### Examples
182+#### Expands to:
84
183
184+```hoon
185+:-(p :-(q r))
85```
186```
86−~zod:dojo> :-(1 2)
87−[1 2]
88
187
89−~zod:dojo> 1^2
188+#### Examples
90−[1 2]
91
189
92−~zod:dojo> 1/2
190+```
191+> :+ 1
192+ 2
193+ 3
93−[%1 2]
194+[1 2 3]
94
195
95−~zod:dojo> `1
196+> :+(%a ~ 'b')
96−[~ 1]
197+[%a ~ 'b']
97```
198```
98
199
200+---
201+
99−### `:^` "colket"
202+## `:^` "colket"
203+
204+Construct a quadruple (4-tuple).
205+
206+#### Syntax
207+
208+Four arguments, fixed.
209+
210+<table>
211+<tr><th>Form</th><th>Syntax</th></tr>
212+<tr>
213+<td>Tall</td>
214+<td>
215+<pre>
216+:^ p
217+ q
218+ r
219+s
220+</pre>
221+</td>
222+</tr>
223+<tr>
224+<td>Wide</td>
225+<td>
226+<pre>
227+:^(p q r s)
228+</pre>
229+</td>
230+</tr>
231+<tr>
232+<td>Irregular</td>
233+<td>
234+<pre>
235+[p q r s]
236+</pre>
237+</td>
238+</tr>
239+</table>
240+
241+#### AST
100
242
243+```hoon
101−`[%clkt p=hoon q=hoon r=hoon s=hoon]`: construct a quadruple (4-tuple).
244+[%clkt p=hoon q=hoon r=hoon s=hoon]
245+```
102
246
103−##### Expands to
247+#### Expands to
104
248
105```hoon
249```hoon
106:-(p :-(q :-(r s)))
250:-(p :-(q :-(r s)))
107```
251```
108
252
109−##### Syntax
110−
111−Regular: **4-fixed**.
112−
113−##### Examples
253+#### Examples
114
254
115```
255```
116−~zod:dojo> :^(1 2 3 4)
256+> :^(1 2 3 4)
117[1 2 3 4]
257[1 2 3 4]
118
258
119−~zod:dojo> :^ 5
259+> :^ 5
120− 6
260+ 6
121− 7
261+ 7
122− 8
262+ 8
123[5 6 7 8]
263[5 6 7 8]
124```
264```
125
265
126−### `:+` "collus"
266+---
267+
268+## `:*` "coltar"
269+
270+Construct an n-tuple.
271+
272+#### Syntax
273+
274+Variable number of arguments.
275+
276+<table>
277+<tr><th>Form</th><th>Syntax</th></tr>
278+<tr>
279+<td>Tall</td>
280+<td>
281+<pre>
282+:* p1
283+ p2
284+ p3
285+ pn
286+==
287+</pre>
288+</td>
289+</tr>
290+<tr>
291+<td>Wide</td>
292+<td>
293+<pre>
294+:*(p1 p2 p3 pn)
295+</pre>
296+</td>
297+</tr>
298+<tr>
299+<td>Irregular</td>
300+<td>
301+<pre>
302+[p1 p2 p3 pn]
303+</pre>
304+</td>
305+</tr>
306+</table>
307+
308+#### AST
127
309
310+```hoon
311+[%cltr p=(list hoon)]
312+```
128
313
129−`[%clls p=hoon q=hoon r=hoon]`: construct a triple (3-tuple).
314+#### Expands to
130
315
131−##### Expands to:
316+**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
132
317
133```hoon
318```hoon
134−:-(p :-(q r))
319+:-(a :-(b :-(c :-(... z)))))
135```
320```
136
321
137−##### Syntax
322+#### Desugaring
138
323
139−Regular: **3-fixed**.
324+```hoon
325+|-
326+?~ p
327+ !!
328+?~ t.p
329+ i.p
330+:- i.p
331+$(p t.p)
332+```
140
333
141−##### Examples
334+#### Examples
142
335
143```
336```
144−/~zod:dojo> :+ 1
337+> :*(5 3 4 1 4 9 0 ~ 'a')
145− 2
338+[5 3 4 1 4 9 0 ~ 'a']
146− 3
147−[1 2 3]
148
339
149−~zod:dojo> :+(%a ~ 'b')
340+> [5 3 4 1 4 9 0 ~ 'a']
150−[%a ~ 'b']
341+[5 3 4 1 4 9 0 ~ 'a']
342+
343+> :* 5
344+ 3
345+ 4
346+ 1
347+ 4
348+ 9
349+ 0
350+ ~
351+ 'a'
352+ ==
353+[5 3 4 1 4 9 0 ~ 'a']
151```
354```
152
355
356+---
357+
153−### `:~` "colsig"
358+## `:~` "colsig"
359+
360+Construct a null-terminated list.
361+
362+#### Syntax
363+
364+Variable number of arguments.
365+
366+<table>
367+<tr><th>Form</th><th>Syntax</th></tr>
368+<tr>
369+<td>Tall</td>
370+<td>
371+<pre>
372+:~ p1
373+ p2
374+ p3
375+ pn
376+==
377+</pre>
378+</td>
379+</tr>
380+<tr>
381+<td>Wide</td>
382+<td>
383+<pre>
384+:~(p1 p2 p3 pn)
385+</pre>
386+</td>
387+</tr>
388+<tr>
389+<td>Irregular</td>
390+<td>
391+<pre>
392+~[p1 p2 p3 pn]
393+</pre>
394+</td>
395+</tr>
396+</table>
397+
398+#### AST
154
399
400+```hoon
155−`[%clsg p=(list hoon)]`: construct a null-terminated list.
401+[%clsg p=(list hoon)]
402+```
156
403
157−##### Expands to
404+#### Expands to
158
405
159**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
406**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
160
407
@@ -162,7 +409,7 @@ Regular: **3-fixed**.
162:-(a :-(b :-(c :-(... :-(z ~)))))
409:-(a :-(b :-(c :-(... :-(z ~)))))
163```
410```
164
411
165−##### Desugaring
412+#### Desugaring
166
413
167```hoon
414```hoon
168|-
415|-
@@ -172,74 +419,48 @@ Regular: **3-fixed**.
172$(p t.p)
419$(p t.p)
173```
420```
174
421
175−##### Syntax
422+#### Discussion
176
423
177−Regular: **running**.
424+Note that this does not produce a `list` type, it just produces a
425+null-terminated n-tuple. To make it a proper `list` it must be cast or molded.
178
426
179−##### Examples
427+#### Examples
180
428
181```
429```
182−~zod:dojo> :~(5 3 4 2 1)
430+> :~(5 3 4 2 1)
183[5 3 4 2 1 ~]
431[5 3 4 2 1 ~]
184
432
185−~zod:dojo> ~[5 3 4 2 1]
433+> ~[5 3 4 2 1]
186[5 3 4 2 1 ~]
434[5 3 4 2 1 ~]
187
435
188−~zod:dojo> :~ 5
436+> :~ 5
189− 3
437+ 3
190− 4
438+ 4
191− 2
439+ 2
192− 1
440+ 1
193− ==
441+ ==
194[5 3 4 2 1 ~]
442[5 3 4 2 1 ~]
195```
443```
196
444
197−### `:*` "coltar"
445+---
198
446
199−`[%cltr p=(list hoon)]`: construct an n-tuple.
447+## `::` "colcol"
200
448
201−##### Expands to
449+Code comment.
202
450
203−**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
451+#### Syntax
204
452
205```hoon
453```hoon
206−:-(a :-(b :-(c :-(... z)))))
454+:: any text you like!
207```
455```
208
456
209−##### Desugaring
457+#### Examples
210
458
211```hoon
459```hoon
212−|-
460+::
213−?~ p
461+:: this is commented code
214− !!
462+::
215−?~ t.p
463+|= a=@ :: a gate
216− i.p
464+(add 2 a) :: that adds 2
217−:- i.p
465+ :: to the input
218−$(p t.p)
219−```
220−
221−##### Syntax
222−
223−Regular: **running**.
224−
225−##### Examples
226−
227−```
228−~zod:dojo> :*(5 3 4 1 4 9 0 ~ 'a')
229−[5 3 4 1 4 9 0 ~ 'a']
230−
231−~zod:dojo> [5 3 4 1 4 9 0 ~ 'a']
232−[5 3 4 1 4 9 0 ~ 'a']
233−
234−~zod:dojo> :* 5
235− 3
236− 4
237− 1
238− 4
239− 9
240− 0
241− ~
242− 'a'
243− ==
244−[5 3 4 1 4 9 0 ~ 'a']
245```
466```
content/docs/hoon/reference/rune/constants.md+101−82
@@ -4,35 +4,33 @@ weight = 1
4template = "doc.html"
4template = "doc.html"
5aliases = ["docs/reference/hoon-expressions/rune/constants/"]
5aliases = ["docs/reference/hoon-expressions/rune/constants/"]
6+++
6+++
7+
7The simplest expressions in every language are constants:
8The simplest expressions in every language are constants:
8−atoms, strings, paths. (Strings and paths aren't all constants per
9+atoms, strings, paths. (Strings and paths aren't all constants per
9se, because they have interpolations.)
10se, because they have interpolations.)
10
11
11−## Expressions
12−
13−### `:_ "Cold Atom"`
12+## "Cold Atom"
14
13
15−`[%rock p=term q=@]`; a constant, cold atom.
14+A constant, cold atom.
16−
17−A cold atom is one whose type is inferred to be of a single atom constant.
18
15
19−##### Produces
16+#### Syntax
20
17
21−A cold (fixed) atom `q` with aura `p`.
18+Any [warm atom](#warm) form, prefixed with `%`.
22
19
23−##### Syntax
20+#### AST
24
21
25−Irregular: any [warm atom](#warm) form, prefixed with `%`.
22+```hoon
23+[%rock p=term q=*]
24+```
26
25
27−Irregular: e.g., `%hi`. Character constraints: `a-z`
26+#### Discussion
28−lowercase to start, `a-z` or `0-9` thereafter, with infix
29−hyphens (`hep`), "kebab-case."
30
27
31−Irregular: `~`.
28+A cold atom is one whose type is inferred to be of a single atom constant.
32
29
33−##### Examples
30+#### Examples
34
31
35−We can see the contrast with warm atoms by using the compiler parser function, `ream`:
32+We can see the contrast with warm atoms by using the compiler parser function,
33+`ream`:
36
34
37```
35```
38> (ream '%hi')
36> (ream '%hi')
@@ -45,20 +43,22 @@ We can see the contrast with warm atoms by using the compiler parser function, `
45[%rock p=%ud q=12]
43[%rock p=%ud q=12]
46```
44```
47
45
46+---
47+
48−### `:_` "Paths"
48+## "Paths"
49
49
50−`[%path p=(list (each @ta hoon))]`: path with interpolation.
50+Path with interpolation.
51
51
52−##### Produces
52+#### Syntax
53
53
54−A null-terminated list of the items in `p`, which are either constant
54+`/this/is/a/path`
55−`@ta` atoms (`knots`), or expressions producing a `knot`.
56
55
57−##### Syntax
56+#### Produces
58
57
59−Irregular: `/this/is/a/path`.
58+A null-terminated list of the items, which are either constant `@ta` atoms
59+(`knots`), or expressions producing a `knot`.
60
60
61−##### Examples
61+#### Examples
62
62
63```
63```
64> `path`/this/is/a/path
64> `path`/this/is/a/path
@@ -74,19 +74,19 @@ Irregular: `/this/is/a/path`.
74~
74~
75```
75```
76
76
77−### `:_` "Strings with Interpolation"
77+---
78
78
79−`[%knit p=(list (each @t hoon))]`: text string with interpolation.
79+## "Strings with Interpolation"
80
80
81−##### Produces
81+Text string with interpolation.
82
82
83−A tape.
83+#### Syntax
84
84
85−##### Syntax
85+A [$tape](/docs/hoon/reference/stdlib/2q#tape)
86
86
87−Irregular: `"abcdefg"`.
87+`"abcdefg"`
88
88
89−Irregular: `"abc{(weld "lmnop" "xyz")}defg"`.
89+`"abc{(weld "lmnop" "xyz")}defg"`
90
90
91```
91```
92> "abcdefg"
92> "abcdefg"
@@ -99,7 +99,17 @@ Irregular: `"abc{(weld "lmnop" "xyz")}defg"`.
99[%knit p=~[97 98 99 100 101 102 103]]
99[%knit p=~[97 98 99 100 101 102 103]]
100```
100```
101
101
102+#### AST
103+
104+```hoon
105+[%knit p=(list woof)]
106+```
107+
108+#### Produces
109+
110+A tape.
111+
102−##### Examples
112+#### Examples
103
113
104String:
114String:
105
115
@@ -122,11 +132,63 @@ String with interpolated prettyprinting:
122"hello, %world."
132"hello, %world."
123```
133```
124
134
135+---
136+
125−### `:_` "Warm Atoms" {#warm}
137+## "Warm Atoms" {#warm}
138+
139+A constant, warm atom.
140+
141+#### Syntax
142+
143+A table of examples:
144+
145+```
146+Aura Meaning Example Literal Syntax
147+-------------------------------------------------------------------------
148+@ empty aura
149+@c UTF-32 ~-~45fed
150+@d date
151+ @da absolute date ~2018.5.14..22.31.46..1435
152+ @dr relative date (ie, timespan) ~h5.m30.s12
153+@f Loobean (for compiler, not castable) &
154+@i Internet address
155+ @if IPv4 address .195.198.143.90
156+ @is IPv6 address .0.0.0.0.0.1c.c3c6.8f5a
157+@n nil (for compiler, not castable) ~
158+@p phonemic base (ship name) ~sorreg-namtyv
159+@q phonemic base, unscrambled .~litsyn-polbel
160+@r IEEE-754 floating-point
161+ @rh half precision (16 bits) .~~3.14
162+ @rs single precision (32 bits) .6.022141e23
163+ @rd double precision (64 bits) .~6.02214085774e23
164+ @rq quad precision (128 bits) .~~~6.02214085774e23
165+@s signed integer, sign bit low
166+ @sb signed binary --0b11.1000
167+ @sd signed decimal --1.000.056
168+ @sv signed base32 -0v1df64.49beg
169+ @sw signed base64 --0wbnC.8haTg
170+ @sx signed hexadecimal -0x5f5.e138
171+@t UTF-8 text (cord) 'howdy'
172+ @ta ASCII text (knot) ~.howdy
173+ @tas ASCII text symbol (term) %howdy
174+@u unsigned integer
175+ @ub unsigned binary 0b11.1000
176+ @ud unsigned decimal 1.000.056
177+ @uv unsigned base32 0v1df64.49beg
178+ @uw unsigned base64 0wbnC.8haTg
179+ @ux unsigned hexadecimal 0x5f5.e138
180+```
181+
182+#### AST
126
183
184+```hoon
127−`[%sand p=term q=@]`; a constant, warm atom.
185+[%sand p=term q=*]
186+```
187+
188+#### Discussion
128
189
129−A 'warm' atom is one whose type is inferred to be general, i.e., not just a single atom type.
190+A 'warm' atom is one whose type is inferred to be general, i.e., not just a
191+single atom type.
130
192
131```
193```
132> `@`12
194> `@`12
@@ -136,9 +198,10 @@ A 'warm' atom is one whose type is inferred to be general, i.e., not just a sing
136nest-fail
198nest-fail
137```
199```
138
200
139−##### Produces
201+#### Produces
140
202
141−A warm (variable) atom `q` with aura `p`. Use the Hoon compiler parser function `ream` to take a closer look:
203+A warm (variable) atom `q` with aura `p`. Use the Hoon compiler parser function
204+`ream` to take a closer look:
142
205
143```
206```
144> (ream '12')
207> (ream '12')
@@ -147,47 +210,3 @@ A warm (variable) atom `q` with aura `p`. Use the Hoon compiler parser function
147> (ream '\'Hello!\'')
210> (ream '\'Hello!\'')
148[%sand p=%t q=36.762.444.129.608]
211[%sand p=%t q=36.762.444.129.608]
149```
212```
150−
151−##### Syntax by example
152−
153−Irregular. A table of examples:
154−
155−```
156−@c UTF-32 ~-foobar
157−@da 128-bit absolute date ~2016.4.23..20.09.26..f27b..dead..beef..babe
158− ~2016.4.23
159−@dr 128-bit relative date ~s17 (17 seconds)
160− ~m20 (20 minutes)
161− ~d42 (42 days)
162−@f loobean & (0, yes)
163− | (1, no)
164−@p ~zod (0)
165−@rd 64-bit IEEE float .~3.14 (pi)
166− .~-3.14 (negative pi)
167−@rs 32-bit IEEE float .3.14 (pi)
168− .-3.14 (negative pi)
169−@rq 128-bit IEEE float .~~~3.14 (pi)
170−@rh 16-bit IEEE float .~~3.14 (pi)
171−@sb signed binary --0b10 (2)
172− -0b101 (-5)
173−@sd signed decimal --2 (2)
174− -5 (-5)
175−@sv signed base32 --0v68 (200)
176− -0vfk (-500)
177−@sw signed base64 --0w38 (200)
178− -0w7Q (500)
179−@sx signed hexadecimal --0x2 (2)
180− -0x5 -5
181−@t UTF-8 text (cord) 'foobar'
182−@ta ASCII text (knot) ~.foobar
183−@ub unsigned binary 0b10 (2)
184−@uc bitcoin address 0c1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
185−@ud unsigned decimal 42 (42)
186− 1.420 (1420)
187−@uv unsigned base32 0v3ic5h.6urr6
188−@uw unsigned base64 0wsC5.yrSZC
189−@ux unsigned hexadecimal 0xcafe.babe
190−```
191−
192−The `@uv` characters are `0-9`, `a-v`. The `@uw` characters are
193−`0-9`, `a-z`, `A-Z`, `-` and `~`.
content/docs/hoon/reference/rune/dot.md+243−74
@@ -7,17 +7,61 @@ aliases = ["docs/reference/hoon-expressions/rune/dot/"]
7
7
8Anything Nock can do, Hoon can do also. These runes are used for carrying out Nock operations in Hoon.
8Anything Nock can do, Hoon can do also. These runes are used for carrying out Nock operations in Hoon.
9
9
10−## Runes
11−
12−### `.^` "dotket"
10+## `.^` "dotket"
13−
11+
14−`[%dtkt p=spec q=hoon]`: load from the Arvo namespace with a fake Nock instruction: 'Nock `12`''.
12+Load from the Arvo namespace (scry) with a fake Nock instruction: Nock 12.
13+
14+#### Syntax
15+
16+Two arguments, with the second optionally split into an arbitrary number of
17+elements.
18+
19+While this rune technically takes a fixed number of arguments, `q` is usually
20+split into at least two parts, and the tall form of this rune must be terminated
21+with a `==`. Note also that the `==` does not make the arguments into a list as
22+you might expect, so `q` must be explicitly null-terminated if its elements are
23+specified separately.
24+
25+<table>
26+<tr><th>Form</th><th>Syntax</th></tr>
27+<tr>
28+<td>Tall</td>
29+<td>
30+<pre>
31+.^ p
32+ q1
33+ q2
34+ q3
35+ qn
36+==
37+</pre>
38+</td>
39+</tr>
40+<tr>
41+<td>Wide</td>
42+<td>
43+<pre>
44+.^(p q1 q2)
45+</pre>
46+</td>
47+</tr>
48+<tr>
49+<td>Irregular</td>
50+<td>None.</td>
51+</tr>
52+</table>
53+
54+#### AST
55+
56+```hoon
57+[%dtkt p=spec q=hoon]
58+```
15
59
16−##### Produces
60+#### Produces
17
61
18The noun `q`, cast to the type `p`.
62The noun `q`, cast to the type `p`.
19
63
20−##### Discussion
64+#### Discussion
21
65
22Nock has no `12` instruction! But the virtual Nock
66Nock has no `12` instruction! But the virtual Nock
23used to run userspace code does. Nock `12` loads from a
67used to run userspace code does. Nock `12` loads from a
@@ -29,7 +73,7 @@ Ordinarily a Hoon expression has access to no information but whatever can be fo
29
73
30In principle `.^` takes two subexpressions, but in practice `q` is often given in two parts: the first part includes the vane to be queried (e.g., `%a` for Ames, `%b` for Behn, `%c` for Clay, etc.) and the kind of request. The second part is a path that corresponds to the kind of request.
74In principle `.^` takes two subexpressions, but in practice `q` is often given in two parts: the first part includes the vane to be queried (e.g., `%a` for Ames, `%b` for Behn, `%c` for Clay, etc.) and the kind of request. The second part is a path that corresponds to the kind of request.
31
75
32−##### Examples
76+#### Examples
33
77
34In the dojo we can ask Clay -- the Arvo filesystem -- for a listing of the files at our current path, `%`:
78In the dojo we can ask Clay -- the Arvo filesystem -- for a listing of the files at our current path, `%`:
35
79
@@ -37,17 +81,14 @@ In the dojo we can ask Clay -- the Arvo filesystem -- for a listing of the files
37> .^(arch %cy %)
81> .^(arch %cy %)
38[ fil=~
82[ fil=~
39 dir
83 dir
40− { [p=~.web q=~]
41− [p=~.LICENSE q=~]
42− [p=~.app q=~]
84+ { [p=~.app q=~]
43− [p=~.lib q=~]
44− [p=~.sec q=~]
45− [p=~.sys q=~]
46− [p=~.ren q=~]
47 [p=~.sur q=~]
85 [p=~.sur q=~]
48− [p=~.tests q=~]
49− [p=~.mar q=~]
50 [p=~.gen q=~]
86 [p=~.gen q=~]
87+ [p=~.lib q=~]
88+ [p=~.mar q=~]
89+ [p=~.ted q=~]
90+ [p=~.desk q=~]
91+ [p=~.sys q=~]
51 }
92 }
52]
93]
53```
94```
@@ -67,38 +108,69 @@ You can modify the time of the file listing quite simply and ask for a listing f
67> .^(arch %cy /(scot %p our)/base/(scot %da (sub now ~h5)))
108> .^(arch %cy /(scot %p our)/base/(scot %da (sub now ~h5)))
68[ fil=~
109[ fil=~
69 dir
110 dir
70− { [p=~.web q=~]
71− [p=~.LICENSE q=~]
72− [p=~.app q=~]
111+ { [p=~.app q=~]
73− [p=~.lib q=~]
74− [p=~.sec q=~]
75− [p=~.sys q=~]
76− [p=~.ren q=~]
77 [p=~.sur q=~]
112 [p=~.sur q=~]
78− [p=~.tests q=~]
79− [p=~.mar q=~]
80 [p=~.gen q=~]
113 [p=~.gen q=~]
114+ [p=~.lib q=~]
115+ [p=~.mar q=~]
116+ [p=~.ted q=~]
117+ [p=~.desk q=~]
118+ [p=~.sys q=~]
81 }
119 }
82]
120]
83```
121```
84
122
85`our` is the value for your ship's name.
123`our` is the value for your ship's name.
86
124
125+---
126+
87−### `.+` "dotlus"
127+## `.+` "dotlus"
88−
128+
129+Increment an atom with Nock `4`.
130+
131+#### Syntax
132+
133+One argument, fixed.
134+
135+<table>
136+<tr><th>Form</th><th>Syntax</th></tr>
137+<tr>
138+<td>Tall</td>
139+<td>
140+<pre>
141+.+ p
142+</pre>
143+</td>
144+</tr>
145+<tr>
146+<td>Wide</td>
147+<td>
148+<pre>
149+.+(p)
150+</pre>
151+</td>
152+</tr>
153+<tr>
154+<td>Irregular</td>
155+<td>
156+<pre>
157++(p)
158+</pre>
159+</td>
160+</tr>
161+</table>
162+
163+#### AST
164+
165+```hoon
89−`[%dtls p=hoon]`: increment an atom with Nock `4`.
166+[%dtls p=hoon]
167+```
90
168
91−##### Produces
169+#### Produces
92
170
93`p` plus `1` if `p` is an atom; otherwise, crashes. The product atom has no aura.
171`p` plus `1` if `p` is an atom; otherwise, crashes. The product atom has no aura.
94
172
95−##### Syntax
96−
97−Regular: **1-fixed**.
98−
99−Irregular: `+(6)` is `.+(6)`.
100−
101−##### Examples
173+#### Examples
102
174
103```
175```
104> .+(6)
176> .+(6)
@@ -114,19 +186,52 @@ Irregular: `+(6)` is `.+(6)`.
114nest-fail
186nest-fail
115```
187```
116
188
117−### `.*` "dottar"
189+---
118
190
119−`[%dttr p=hoon q=hoon]`: evaluate with Nock `2`.
191+## `.*` "dottar"
120
192
121−##### Produces
193+Evaluate with Nock `2`.
122
194
123−Nock of formula `q` and subject `p`, with type `%noun`.
195+#### Produces
124
196
125−##### Syntax
197+Nock of formula `q` and subject `p`, with type `%noun`.
126
198
127−Regular: **2-fixed**.
199+#### Syntax
200+
201+Two arguments, fixed.
202+
203+<table>
204+<tr><th>Form</th><th>Syntax</th></tr>
205+<tr>
206+<td>Tall</td>
207+<td>
208+<pre>
209+.* p
210+q
211+</pre>
212+</td>
213+</tr>
214+<tr>
215+<td>Wide</td>
216+<td>
217+<pre>
218+.*(p q)
219+</pre>
220+</td>
221+</tr>
222+<tr>
223+<td>Irregular</td>
224+<td>None.</td>
225+</tr>
226+</table>
227+
228+#### AST
229+
230+```hoon
231+[%dttr p=hoon q=hoon]
232+```
128
233
129−##### Discussion
234+#### Discussion
130
235
131`.*(p q)` is used to run Nock formula `q` on the subject `p` from within Hoon.
236`.*(p q)` is used to run Nock formula `q` on the subject `p` from within Hoon.
132
237
@@ -135,7 +240,7 @@ Keep in mind that `p` and `q` can be arbitrary Hoon expressions, as long as they
135Note also that `.*` ("dottar") can be used to bypass the type system. It's
240Note also that `.*` ("dottar") can be used to bypass the type system. It's
136therefore possible to use Hoon as a typeless language.
241therefore possible to use Hoon as a typeless language.
137
242
138−##### Examples
243+#### Examples
139
244
140```
245```
141> .*([20 30] [0 2])
246> .*([20 30] [0 2])
@@ -157,32 +262,64 @@ therefore possible to use Hoon as a typeless language.
1571
2621
158```
263```
159
264
265+---
266+
160−### `.=` "dottis" {#dottis}
267+## `.=` "dottis" {#dottis}
161−
268+
162−`[%dtts p=hoon q=hoon]`: test for equality with Nock `5`.
269+Test for equality with Nock `5`.
270+
271+#### Syntax
272+
273+Two arguments, fixed.
274+
275+<table>
276+<tr><th>Form</th><th>Syntax</th></tr>
277+<tr>
278+<td>Tall</td>
279+<td>
280+<pre>
281+.= p
282+q
283+</pre>
284+</td>
285+</tr>
286+<tr>
287+<td>Wide</td>
288+<td>
289+<pre>
290+.=(p q)
291+</pre>
292+</td>
293+</tr>
294+<tr>
295+<td>Irregular</td>
296+<td>
297+<pre>
298+=(p q)
299+</pre>
300+</td>
301+</tr>
302+</table>
303+
304+#### AST
305+
306+```hoon
307+[%dtts p=hoon q=hoon]
308+```
163
309
164−##### Produces
310+#### Produces
165
311
166`%.y` if `p` equals `q`; otherwise `%.n`.
312`%.y` if `p` equals `q`; otherwise `%.n`.
167
313
168−##### Syntax
169−
170−Regular: **2-fixed**.
171−
172−Irregular: `=(a b)` is `.=(a b)`.
173−
174−##### Discussion
314+#### Discussion
175−
176−The test for equality includes a type check. Either the type of `p` must nest under the type of `q`, or _vice versa_. Otherwise the result is a crash.
177
315
178Like Nock equality, `.=` ("dottis") tests whether two nouns are the same,
316Like Nock equality, `.=` ("dottis") tests whether two nouns are the same,
179−ignoring invisible pointer structure. Because in a conventional
317+ignoring invisible pointer structure. Because in a conventional noun
180−noun implementation each noun has a lazy short hash, comparisons
318+implementation each noun has a lazy short hash, comparisons are fast unless the
181−are fast unless the hash needs to be computed, or we are comparing
319+hash needs to be computed, or we are comparing separate copies of identical
182−separate copies of identical nouns. (Comparing large duplicates
183−is a common cause of performance bugs.)
320+nouns. (Comparing large duplicates is a common cause of performance bugs.)
184
321
185−##### Examples
322+#### Examples
186
323
187```
324```
188> .=(0 0)
325> .=(0 0)
@@ -198,22 +335,54 @@ is a common cause of performance bugs.)
198%.n
335%.n
199
336
200> =(12 [12 14])
337> =(12 [12 14])
201−nest-fail
338+%.n
202```
339```
203
340
341+---
342+
204−### `.?` "dotwut"
343+## `.?` "dotwut"
205−
344+
206−`[%dtwt p=hoon]`: test for cell or atom with Nock `3`.
345+Test for cell or atom with Nock `3`.
346+
347+#### Syntax
348+
349+One argument, fixed.
350+
351+<table>
352+<tr><th>Form</th><th>Syntax</th></tr>
353+<tr>
354+<td>Tall</td>
355+<td>
356+<pre>
357+.? p
358+</pre>
359+</td>
360+</tr>
361+<tr>
362+<td>Wide</td>
363+<td>
364+<pre>
365+.?(p)
366+</pre>
367+</td>
368+</tr>
369+<tr>
370+<td>Irregular</td>
371+<td>None.</td>
372+</tr>
373+</table>
374+
375+#### AST
376+
377+```hoon
378+[%dtwt p=hoon]
379+```
207
380
208−##### Produces
381+#### Produces
209
382
210`%.y` if `p` is a cell; otherwise `%.n`.
383`%.y` if `p` is a cell; otherwise `%.n`.
211
384
212−##### Syntax
213−
214−Regular: **1-fixed**.
215−
216−##### Examples
385+#### Examples
217
386
218```
387```
219> .?(42)
388> .?(42)
content/docs/hoon/reference/rune/fas.mdnew file+257
@@ -0,0 +1,257 @@
1++++
2+title = "Imports / ('fas')"
3+weight = 15
4+template = "doc.html"
5++++
6+
7+Fas (`/`) runes are not technically hoon runes, but instead are instructions to
8+Arvo's build system. In the past, the build system was its own vane called
9+[Ford](/docs/arvo/ford/ford). Ford has since been merged into the filesystem
10+vane [Clay](/docs/arvo/clay/clay), but these are still referred to as "Ford
11+runes".
12+
13+Ford runes are used at the top of a hoon file, and they typically specify
14+imports.
15+
16+## `/-` "fashep"
17+
18+Import structure libraries from `/sur`.
19+
20+#### Syntax
21+
22+```hoon
23+/- foo, bar, baz
24+```
25+
26+Note there is only a single space between each item.
27+
28+#### Semantics
29+
30+Names correspond to files in the `/sur` directory of the same desk as this file, e.g.
31+`/sur/foo.hoon` for `foo`. Names containing hyphens, e.g. `foo-abc`, will first
32+resolve to `/sur/foo-abc.hoon`, and if that doesn't exist, it will try
33+`/sur/foo/abc.hoon`.
34+
35+Imports may be given a different face by doing `xyz=foo`. Imports may have their
36+face stripped (so you can directly reference their wings) with `*foo`.
37+
38+---
39+
40+## `/+` "faslus"
41+
42+Import libraries from `/lib`.
43+
44+#### Syntax
45+
46+```hoon
47+/+ foo, bar, baz
48+```
49+
50+Note there is only a single space between each item.
51+
52+#### Semantics
53+
54+Names correspond to files in the `/lib` directory of the same desk as this file,
55+e.g. `/lib/foo.hoon` for `foo`. Names containing hyphens, e.g. `foo-abc`, will
56+first resolve to `/lib/foo-abc.hoon`, and if that doesn't exist, it will try
57+`/lib/foo/abc.hoon`.
58+
59+Imports may be given a different face by doing `xyz=foo`. Imports may have their
60+face stripped (so you can directly reference their wings) with `*foo`.
61+
62+---
63+
64+## `/=` "fastis"
65+
66+Build and import a hoon file at the specified path.
67+
68+#### Syntax
69+
70+Two arguments.
71+
72+```hoon
73+/= some-face /path/to/file
74+```
75+
76+#### Semantics
77+
78+This lets you build and import a hoon file from anywhere in the desk.
79+
80+The first argument is the face to pin it as. The second argument is the path to
81+the file in the same desk as this file. The file must be a `%hoon` file, and the
82+trailing mark (`hoon`) must be omitted from the path.
83+
84+#### Examples
85+
86+To build and import `/foo/bar.hoon` you would do:
87+
88+```hoon
89+/= foobar /foo/bar
90+```
91+
92+---
93+
94+## `/*` "fastar"
95+
96+Import the file at the specified path as the specified mark.
97+
98+#### Syntax
99+
100+Three arguments.
101+
102+```hoon
103+/* some-face %as-mark /path/to/file
104+```
105+
106+#### Semantics
107+
108+The first argument is the face to pin it as. The second argument is the mark it
109+should be converted to. The third argument is the path to the file in the same
110+desk as this file, with the trailing mark included.
111+
112+The mark specified may be different to the mark of the file, as long as
113+conversion is possible. Note that a `%hoon` file will not be built like with
114+`/=`: the type of a `%hoon` file is a `@t` so that is what will be pinned.
115+
116+#### Examples
117+
118+To import `/foo/bar.hoon` you would do:
119+
120+```hoon
121+/* foobar %hoon /foo/bar/hoon
122+```
123+
124+`foobar` would then be an `@t` of the contents of that file.
125+
126+---
127+
128+## `/$` "fasbuc"
129+
130+Import mark conversion gate.
131+
132+#### Syntax
133+
134+Three arguments.
135+
136+```hoon
137+/$ some-face %from-mark %to-mark
138+```
139+
140+#### Semantics
141+
142+The first argument is the face to pin it as. The second argument is the mark to
143+convert _from_. The third argument is the mark to convert _to_.
144+
145+The result will be a gate of `$-(type-1 type-2)`, pinned with the specified
146+face. The types are the data types of the _from_ mark and _to_ mark,
147+respectively.
148+
149+The mark conversion gate will be built from marks in `/mar` on the same desk as
150+this file.
151+
152+#### Examples
153+
154+To build a mark conversion gate from `%txt` to `%mime`, you would do:
155+
156+```hoon
157+/$ txt-to-mime %txt %mime
158+```
159+
160+`txt-to-mime` would be a gate of `$-(wain mime)`. You could then call the gate
161+like:
162+
163+```
164+> (txt-to-mime ~['first line' 'second line'])
165+[p=/text/plain q=[p=22 q=37.949.953.370.267.411.298.483.129.707.945.775.026.849.432.323.909.990]]
166+```
167+
168+---
169+
170+## `/~` "fassig"
171+
172+Import, build, evaluate and pin the results of many hoon files in a directory.
173+
174+#### Syntax
175+
176+Three arguments.
177+
178+```hoon
179+/~ some-face some-type /some/directory
180+```
181+
182+#### Semantics
183+
184+The first argument is the face to pin the results with. The second argument is
185+the type each hoon file produces when evaluated. The third argument is the path
186+to a directory in the same desk as this file, containing `%hoon` files.
187+
188+Each hoon file in the specified directory will be built and evalutated. The
189+result of evaluating each file will be added to a
190+[`++map`](/docs/hoon/reference/stdlib/2o#map) and pinned with the specified face
191+(`some-face`). The keys of the map will be the name of each file, and the values
192+of the map will be the result of evaluating each file and casting its result to
193+the type specified (`some-type`).
194+
195+All of the hoon files in the specified directory, when evaluated, must produce
196+data of a type that nests under the type specified (`some-type`). File with a
197+mark other than `%hoon` will be ignored.
198+
199+The type of the map will be `(map knot some-type)`.
200+
201+#### Examples
202+
203+If the `/foo/bar` directory contains three files:
204+
205+- `x.hoon` containing `(silt ~[1 2 3 4 5])`
206+- `y.hoon` containing `(silt ~[99 100])`
207+- `z.hoon` containing `(silt ~[22 33 44])`
208+
209+Then the following `/~` expression:
210+
211+```hoon
212+/~ foo (set @ud) /foo/bar
213+```
214+
215+...will pin a `(map knot (set @ud))` with a face of `foo` which contains:
216+
217+```
218+{[p=~.y q={100 99}] [p=~.z q={22 33 44}] [p=~.x q={5 1 2 3 4}]}
219+```
220+
221+---
222+
223+## `/%` "fascen"
224+
225+Build and import a mark core.
226+
227+#### Syntax
228+
229+Two arguments.
230+
231+```hoon
232+/% some-face %some-mark
233+```
234+
235+#### Semantics
236+
237+The first argument is a face to pin the mark core with. The second argument is a
238+mark.
239+
240+The static mark core (a `nave:clay`) for the specified mark (which resides in
241+the same desk as the file) is built and pinned to the subject with the specified
242+face.
243+
244+#### Examples
245+
246+To build the mark core for the `%txt` mark:
247+
248+```hoon
249+/% foo %txt
250+```
251+
252+Its arms can then be accessed like:
253+
254+```
255+> form:foo
256+%txt-diff
257+```
content/docs/hoon/reference/rune/ket.md+436−128
@@ -4,28 +4,56 @@ weight = 11
4template = "doc.html"
4template = "doc.html"
5aliases = ["docs/reference/hoon-expressions/rune/ket/"]
5aliases = ["docs/reference/hoon-expressions/rune/ket/"]
6+++
6+++
7−[`^-` ("kethep")](#kethep), [`^+` ("ketlus")](#ketlus), and
8−[`^=` ("kettis")](#kettis) let us adjust types without violating type
9−constraints.
10
7
8+[`^-` ("kethep")](#kethep), [`^+` ("ketlus")](#ketlus), and [`^=`
9+("kettis")](#kettis) let us adjust types without violating type constraints.
10+
11−The `nest` algorithm which tests subtyping is conservative;
11+The `nest` algorithm which tests subtyping is conservative; it never allows
12−it never allows invalid nests, it sometimes rejects valid nests.
12+invalid nests, it sometimes rejects valid nests.
13+
14+## `^|` "ketbar"
15+
16+Convert a gold core to an iron core (contravariant).
17+
18+#### Syntax
19+
20+One argument, fixed.
21+
22+<table>
23+<tr><th>Form</th><th>Syntax</th></tr>
24+<tr>
25+<td>Tall</td>
26+<td>
27+<pre>
28+^| p
29+</pre>
30+</td>
31+</tr>
32+<tr>
33+<td>Wide</td>
34+<td>
35+<pre>
36+^|(p)
37+</pre>
38+</td>
39+</tr>
40+<tr>
41+<td>Irregular</td>
42+<td>None.</td>
43+</tr>
44+</table>
45+
46+#### AST
13
47
14−## Runes
48+```hoon
15−
49+[%ktbr p=hoon]
16−### `^|` "ketbar"
50+```
17−
18−`[%ktbr p=hoon]`: convert a gold core to an iron core (contravariant).
19
51
20−##### Produces
52+#### Produces
21
53
22`p` as an iron core; crash if not a gold core.
54`p` as an iron core; crash if not a gold core.
23
55
24−##### Syntax
25−
26−Regular: **1-fixed**.
27−
28−##### Discussion
56+#### Discussion
29
57
30An iron core is an opaque function (gate or door).
58An iron core is an opaque function (gate or door).
31
59
@@ -37,7 +65,7 @@ Informally, a function fits an interface if the function has a
37more specific result and/or a less specific argument than the
65more specific result and/or a less specific argument than the
38interface.
66interface.
39
67
40−##### Examples
68+#### Examples
41
69
42The prettyprinter shows the core metal (`.` gold, `|` iron):
70The prettyprinter shows the core metal (`.` gold, `|` iron):
43
71
@@ -49,34 +77,68 @@ The prettyprinter shows the core metal (`.` gold, `|` iron):
49<1|gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
77<1|gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
50```
78```
51
79
80+---
81+
52−### `^:` "ketcol"
82+## `^:` "ketcol"
83+
84+Mold gate for type `p`.
85+
86+**Note this rune is now redundant.**
53
87
54−`[%ktcl p=spec]`: mold gate for type `p`.
88+#### Syntax
55
89
56−##### Produces
90+One argument, fixed.
57
91
58−A gate that returns the sample value if it's of the correct type, but crashes otherwise.
92+<table>
93+<tr><th>Form</th><th>Syntax</th></tr>
94+<tr>
95+<td>Tall</td>
96+<td>
97+<pre>
98+^: p
99+</pre>
100+</td>
101+</tr>
102+<tr>
103+<td>Wide</td>
104+<td>
105+<pre>
106+^:(p)
107+</pre>
108+</td>
109+</tr>
110+<tr>
111+<td>Irregular</td>
112+<td>None.</td>
113+</tr>
114+</table>
59
115
60−##### Syntax
116+#### AST
61
117
62−Regular: **1-fixed**.
118+```hoon
119+[%ktcl p=spec]
120+```
121+
122+#### Produces
63
123
64−##### Discussion
124+A gate that returns the sample value if it's of the correct type, but crashes
125+otherwise.
65
126
66−A mold is an idempotent gate that is guaranteed to produce a noun of that type.
127+#### Discussion
67−If an input value isn't of the correct type, the bunt value of that type is
68−returned. (See `^*`.)
69
128
70−`^:` is used to produce a gate that is much like a mold, except that instead of
129+`^:` is used to produce a mold that crashes if its sample is of the wrong type.
71−producing a bunt value when the input value is of the wrong type, it crashes.
130+
131+Molds used to produced their bunt value if they couldn't mold their sample. This
132+is no longer the case: molds now crash if molding fails, so **this rune is
133+redundant**.
72
134
73One may expect that `^:(path /foo)` would result in a syntax error since `^:`
135One may expect that `^:(path /foo)` would result in a syntax error since `^:`
74−only takes one child, but instead it will parse as `=< ^ %:(path /foo)`. Since
136+only takes one child, but instead it will parse as `=< ^ %:(path /foo)`. Since
75`:` is the irregular syntax for `=<` this is is parsed as "get `^` (i.e. the
137`:` is the irregular syntax for `=<` this is is parsed as "get `^` (i.e. the
76mold for cells) from a subject of `(path /foo)`", with `:` being the irregular
138mold for cells) from a subject of `(path /foo)`", with `:` being the irregular
77syntax for `=<`.
139syntax for `=<`.
78
140
79−##### Examples
141+#### Examples
80
142
81```
143```
82> ^: @
144> ^: @
@@ -94,31 +156,60 @@ syntax for `=<`.
94ford: %ride failed to execute:
156ford: %ride failed to execute:
95```
157```
96
158
159+---
160+
97−### `^.` "ketdot"
161+## `^.` "ketdot"
98−
162+
99−`[%ktdt p=hoon q=hoon]`: typecast on value produced by passing `q` to `p`.
163+Typecast on value produced by passing `q` to `p`.
100−
164+
101−##### Expands to
165+#### Syntax
166+
167+Two arguments, fixed.
168+
169+<table>
170+<tr><th>Form</th><th>Syntax</th></tr>
171+<tr>
172+<td>Tall</td>
173+<td>
174+<pre>
175+^. p
176+q
177+</pre>
178+</td>
179+</tr>
180+<tr>
181+<td>Wide</td>
182+<td>
183+<pre>
184+^.(p q)
185+</pre>
186+</td>
187+</tr>
188+<tr>
189+<td>Irregular</td>
190+<td>None.</td>
191+</tr>
192+</table>
193+
194+#### AST
102
195
103```hoon
196```hoon
104−^+(%:(p q) q)
197+[%ktdt p=hoon q=hoon]
105```
198```
106
199
107−##### Syntax
200+#### Expands to
108−
109−Regular: **2-fixed**.
110
201
111```hoon
202```hoon
112−^. p=hoon q=hoon
203+^+(%:(p q) q)
113```
204```
114
205
115−##### Discussion
206+#### Discussion
116
207
117`p` produces a gate and q is any Hoon expression.
208`p` produces a gate and q is any Hoon expression.
118
209
119−`^.` is particularly useful when `p` is a gate that 'cleans up' the type information about some piece of data. For example, `limo` is used to turn a raw noun of the appropriate shape into a genuine list. Hence we can use `^.` to cast with `limo` and similar gates, ensuring that the product has the desired type.
210+`^.` is particularly useful when `p` is a gate that 'cleans up' the type information about some piece of data. For example, `limo` is used to turn a raw noun of the appropriate shape into a genuine list. Hence we can use `^.` to cast with `limo` and similar gates, ensuring that the product has the desired type.
120
211
121−##### Examples
212+#### Examples
122
213
123```
214```
124> =mylist [11 22 33 ~]
215> =mylist [11 22 33 ~]
@@ -135,31 +226,66 @@ mint-vain
135~[22 33]
226~[22 33]
136```
227```
137
228
229+---
230+
138−### `^-` "kethep"
231+## `^-` "kethep"
232+
233+Typecast by explicit type label.
234+
235+#### Syntax
236+
237+Two arguments, fixed.
238+
239+<table>
240+<tr><th>Form</th><th>Syntax</th></tr>
241+<tr>
242+<td>Tall</td>
243+<td>
244+<pre>
245+^- p
246+q
247+</pre>
248+</td>
249+</tr>
250+<tr>
251+<td>Wide</td>
252+<td>
253+<pre>
254+^-(p q)
255+</pre>
256+</td>
257+</tr>
258+<tr>
259+<td>Irregular</td>
260+<td>
261+<pre>
262+`p`q
263+</pre>
264+</td>
265+</tr>
266+</table>
267+
268+#### AST
139
269
270+```hoon
140−`[%kthp p=spec q=hoon]`: typecast by explicit type label.
271+[%kthp p=spec q=hoon]
272+```
141
273
142−##### Expands to
274+#### Expands to
143
275
144```hoon
276```hoon
145^+(^*(p) q)
277^+(^*(p) q)
146```
278```
147
279
148−##### Syntax
149−
150−Regular: **2-fixed**.
151−
152−Irregular: `` `foo`baz`` is `^-(foo ^-(@ baz))`.
153−
154−##### Discussion
280+#### Discussion
155
281
156It's a good practice to put a `^-` ("kethep") at the top of every arm
282It's a good practice to put a `^-` ("kethep") at the top of every arm
157−(including gates, loops, etc). This cast is strictly necessary
283+(including gates, loops, etc). This cast is strictly necessary
158only in the presence of head recursion (otherwise you'll get a
284only in the presence of head recursion (otherwise you'll get a
159`rest-loop` error, or if you really screw up spectacularly an
285`rest-loop` error, or if you really screw up spectacularly an
160infinite loop in the compiler).
286infinite loop in the compiler).
161
287
162−##### Examples
288+#### Examples
163
289
164```
290```
165~zod:dojo> (add 90 7)
291~zod:dojo> (add 90 7)
@@ -179,44 +305,103 @@ infinite loop in the compiler).
179[~ ~.a]
305[~ ~.a]
180```
306```
181
307
182−### `^+` "ketlus"
308+## `^+` "ketlus"
309+
310+Typecast by inferred type.
311+
312+#### Syntax
313+
314+Two arguments, fixed.
315+
316+<table>
317+<tr><th>Form</th><th>Syntax</th></tr>
318+<tr>
319+<td>Tall</td>
320+<td>
321+<pre>
322+^+ p
323+q
324+</pre>
325+</td>
326+</tr>
327+<tr>
328+<td>Wide</td>
329+<td>
330+<pre>
331+^+(p q)
332+</pre>
333+</td>
334+</tr>
335+<tr><td>Irregular</td><td>None.</td></tr>
336+</table>
337+
338+#### AST
183
339
340+```hoon
184−`[%ktls p=hoon q=hoon]`: typecast by inferred type.
341+[%ktls p=hoon q=hoon]
185−
342+```
186−##### Produces
187−
188−The value of `q` with the type of `p`, if the type of `q` nests within the type of `p`. Otherwise, `nest-fail`.
189
343
190−##### Syntax
344+#### Produces
191
345
192−Regular: **2-fixed**.
346+The value of `q` with the type of `p`, if the type of `q` nests within the type
347+of `p`. Otherwise, `nest-fail`.
193
348
194−##### Examples
349+#### Examples
195
350
196```
351```
197~zod:dojo> ^+('text' %a)
352~zod:dojo> ^+('text' %a)
198'a'
353'a'
199```
354```
200
355
201−### `^&` "ketpam"
356+---
202
357
203−`[%ktpm p=hoon]`: convert a core to a zinc core (covariant).
358+## `^&` "ketpam"
204
359
205−##### Produces
360+Convert a core to a zinc core (covariant).
206
361
207−`p` as a zinc core; crash if `p` isn't a gold or zinc core.
362+#### Syntax
363+
364+One argument, fixed.
365+
366+<table>
367+<tr><th>Form</th><th>Syntax</th></tr>
368+<tr>
369+<td>Tall</td>
370+<td>
371+<pre>
372+^& p
373+</pre>
374+</td>
375+</tr>
376+<tr>
377+<td>Wide</td>
378+<td>
379+<pre>
380+^&(p)
381+</pre>
382+</td>
383+</tr>
384+<tr><td>Irregular</td><td>None.</td></tr>
385+</table>
386+
387+#### AST
208
388
209−##### Syntax
389+```hoon
390+[%ktpm p=hoon]
391+```
210
392
211−Regular: **1-fixed**.
393+#### Produces
394+
395+`p` as a zinc core; crash if `p` isn't a gold or zinc core.
212
396
213−##### Discussion
397+#### Discussion
214
398
215−A zinc core has a read-only sample and an opaque context. See [Advanced types](/docs/hoon/reference/advanced).
399+A zinc core has a read-only sample and an opaque context. See [Advanced types](/docs/hoon/reference/advanced).
216
400
217−##### Examples
401+#### Examples
218
402
219−The prettyprinter shows the core metal in the arm labels `1.xoz` and `1&xoz` below (`.` is gold, `&` is zinc):
403+The prettyprinter shows the core metal in the arm labels `1.xoz` and `1&xoz`
404+below (`.` is gold, `&` is zinc):
220
405
221```
406```
222> |=(@ 1)
407> |=(@ 1)
@@ -251,53 +436,112 @@ ford: %slim failed:
251ford: %ride failed to compute type:
436ford: %ride failed to compute type:
252```
437```
253
438
254−### `^~` "ketsig"
439+---
255
440
256−`[%ktsg p=hoon]`: fold constant at compile time.
441+## `^~` "ketsig"
257
442
258−##### Produces
443+Fold constant at compile time.
259
444
260−`p`, folded as a constant if possible.
445+#### Syntax
261
446
262−##### Syntax
447+One argument, fixed.
263
448
264−Regular: **1-fixed**.
449+<table>
450+<tr><th>Form</th><th>Syntax</th></tr>
451+<tr>
452+<td>Tall</td>
453+<td>
454+<pre>
455+^~ p
456+</pre>
457+</td>
458+</tr>
459+<tr>
460+<td>Wide</td>
461+<td>
462+<pre>
463+^~(p)
464+</pre>
465+</td>
466+</tr>
467+<tr><td>Irregular</td><td>None.</td></tr>
468+</table>
265
469
266−##### Examples
470+#### AST
267
471
472+```hoon
473+[%ktsg p=hoon]
268```
474```
269−~zod:dojo> (make '|-(42)')
270−[%8 p=[%1 p=[1 42]] q=[%9 p=2 q=[%0 p=1]]]
271
475
272−~zod:dojo> (make '^~(|-(42))')
476+#### Produces
273−[%1 p=42]
274−```
275
477
276−### `^*` "kettar"
478+`p`, folded as a constant if possible.
277
479
278−`[%kttr p=spec]`: Produce example type value.
480+#### Examples
279
481
280−##### Produces
482+```
483+> (make '|-(42)')
484+[%8 p=[%1 p=[1 42]] q=[%9 p=2 q=[%0 p=1]]]
281
485
282−A default value (i.e., 'bunt value') of the type `p`.
486+> (make '^~(|-(42))')
487+[%1 p=42]
488+```
283
489
490+---
491+
492+## `^*` "kettar"
493+
494+Produce example type value.
495+
284−##### Syntax
496+#### Syntax
497+
498+One argument, fixed.
499+
500+<table>
501+<tr><th>Form</th><th>Syntax</th></tr>
502+<tr>
503+<td>Tall</td>
504+<td>
505+<pre>
506+^* p
507+</pre>
508+</td>
509+</tr>
510+<tr>
511+<td>Wide</td>
512+<td>
513+<pre>
514+^*(p)
515+</pre>
516+</td>
517+</tr>
518+<tr>
519+<td>Irregular</td>
520+<td>
521+<pre>
522+*p
523+</pre>
524+</td>
525+</tr>
526+</table>
527+
528+`p` is any structure expression.
285
529
286−Regular: **1-fixed**.
530+#### AST
287
531
288```hoon
532```hoon
289−^* p=spec
533+[%kttr p=spec]
290```
534```
291
535
292−Irregular: `*p`.
536+#### Produces
293
537
294−`p` is any structure expression.
538+A default value (i.e., 'bunt value') of the type `p`.
295
539
296−##### Examples
540+#### Examples
297
541
298Regular:
542Regular:
299
543
300−```hoon
544+```
301> ^* @
545> ^* @
3020
5460
303
547
@@ -313,7 +557,7 @@ Regular:
313
557
314Irregular:
558Irregular:
315
559
316−```hoon
560+```
317> *@
561> *@
3180
5620
319
563
@@ -324,55 +568,119 @@ Irregular:
324""
568""
325```
569```
326
570
571+---
572+
327−### `^=` "kettis"
573+## `^=` "kettis"
328−
574+
329−`[%ktts p=skin q=hoon]`: Bind name to a value.
575+Bind name to a value.
330−
576+
331−##### Produces
577+#### Syntax
332−
578+
333−If `p` is a term, the product `q` with type `[%face p q]`. `p`
579+Two arguments, fixed.
334−may also be a tuple of terms, or a term-skin pair; the type of
580+
335−`q` must divide evenly into cells to match it.
581+<table>
582+<tr><th>Form</th><th>Syntax</th></tr>
583+<tr>
584+<td>Tall</td>
585+<td>
586+<pre>
587+^= p
588+q
589+</pre>
590+</td>
591+</tr>
592+<tr>
593+<td>Wide</td>
594+<td>
595+<pre>
596+^=(p q)
597+</pre>
598+</td>
599+</tr>
600+<tr>
601+<td>Irregular</td>
602+<td>
603+<pre>
604+p=q
605+</pre>
606+</td>
607+</tr>
608+</table>
609+
610+#### AST
336
611
337−##### Syntax
612+```hoon
613+[%ktts p=skin q=hoon]
614+```
338
615
339−Regular: **2-fixed**.
616+#### Produces
340
617
341−Irregular: `foo=baz` is `^=(foo baz)`.
618+If `p` is a term, the product `q` with type `[%face p q]`. `p` may also be a
619+tuple of terms, or a term-skin pair; the type of `q` must divide evenly into
620+cells to match it.
342
621
343−##### Examples
622+#### Examples
344
623
345```
624```
346−~zod:dojo> a=1
625+> a=1
347a=1
626a=1
348
627
349−~zod:dojo> ^= a
628+> ^= a
350− 1
629+ 1
351a=1
630a=1
352
631
353−~zod:dojo> ^=(a 1)
632+> ^=(a 1)
354a=1
633a=1
355
634
356−~zod:dojo> [b c d]=[1 2 3 4]
635+> [b c d]=[1 2 3 4]
357[b=1 c=2 d=[3 4]]
636[b=1 c=2 d=[3 4]]
358
637
359−~zod:dojo> [b c d=[x y]]=[1 2 3 4]
638+> [b c d=[x y]]=[1 2 3 4]
360[b=1 c=2 d=[x=3 y=4]]
639[b=1 c=2 d=[x=3 y=4]]
361```
640```
362
641
363−### `^?` "ketwut"
642+---
364
643
365−`[%ktwt p=hoon]`: convert any core to a lead core (bivariant).
644+## `^?` "ketwut"
366
645
367−##### Produces
646+Convert any core to a lead core (bivariant).
368
647
369−`p` as a lead core; crash if not a core.
648+#### Syntax
370
649
371−##### Syntax
650+One argument, fixed.
372
651
373−Regular: **1-fixed**.
652+<table>
653+<tr><th>Form</th><th>Syntax</th></tr>
654+<tr>
655+<td>Tall</td>
656+<td>
657+<pre>
658+^? p
659+</pre>
660+</td>
661+</tr>
662+<tr>
663+<td>Wide</td>
664+<td>
665+<pre>
666+^?(p)
667+</pre>
668+</td>
669+</tr>
670+<tr><td>Irregular</td><td>None.</td></tr>
671+</table>
374
672
673+#### AST
674+
675+```hoon
676+[%ktwt p=hoon]
677+```
678+
679+#### Produces
680+
681+`p` as a lead core; crash if not a core.
682+
375−##### Discussion
683+#### Discussion
376
684
377A lead core is an opaque generator; the payload can't be read or
685A lead core is an opaque generator; the payload can't be read or
378written.
686written.
@@ -383,14 +691,14 @@ Theorem: if type `x` nests within type `a`, a lead core producing
383Informally, a more specific generator can be used as a less
691Informally, a more specific generator can be used as a less
384specific generator.
692specific generator.
385
693
386−##### Examples
694+#### Examples
387
695
388The prettyprinter shows the core metal (`.` gold, `?` lead):
696The prettyprinter shows the core metal (`.` gold, `?` lead):
389
697
390```
698```
391−~zod:dojo> |=(@ 1)
699+> |=(@ 1)
392<1.gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
700<1.gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
393
701
394−~zod:dojo> ^?(|=(@ 1))
702+> ^?(|=(@ 1))
395<1?gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
703<1?gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
396```
704```
content/docs/hoon/reference/rune/lus.md+107−41
@@ -4,33 +4,53 @@ weight = 8
4template = "doc.html"
4template = "doc.html"
5+++
5+++
6
6
7−A core is a cell of `[battery payload]`. The battery is made of one or more arms, each of which is a computation on its parent core.
7+A core is a cell of `[battery payload]`. The battery is made of one or more
8+arms, each of which is a computation on its parent core.
8
9
10+Arm runes are used to define arms in a core, and thus can only be used from
9−Arm runes are used to define arms in a core, and thus can only be used from within an expression that produces a multi-arm core. That means arm runes cannot be used to mark the beginning of a first-class expression -- there is no such thing in Hoon as an arm without a core.
11+within an expression that produces a multi-arm core. That means arm runes cannot
12+be used to mark the beginning of a first-class expression -- there is no such
13+thing in Hoon as an arm without a core.
10
14
11−There are various arm runes you can use to produce different kinds of arms. Normal arms use `++`; arms defining a structure (or 'mold') use `+$`; and constructor arms use `+*`.
15+There are various arm runes you can use to produce different kinds of arms.
16+Normal arms use `++`; arms defining a structure (or 'mold') use `+$`; and
17+constructor arms use `+*`.
12
18
13−## Runes
19+## `+|` "lusbar"
14
20
15−### `+|` "lusbar"
21+Chapter label (not useful)
16
22
17−Chapter label.
23+#### Syntax
18
24
19−##### Syntax
25+One argument, fixed.
20
26
21−Regular: **1-fixed**.
27+<table>
22−
28+<tr><th>Form</th><th>Syntax</th></tr>
23−```hoon
29+<tr>
30+<td>Tall</td>
31+<td>
32+<pre>
24+| %label
33+| %label
25−```
34+</pre>
35+</td>
36+</tr>
37+<tr><td>Wide</td><td>None.</td></tr>
38+<tr><td>Irregular</td><td>None.</td></tr>
39+</table>
26
40
27−##### Discussion
41+#### Discussion
28
42
43+The `+|` doesn't produce an arm. It instead provides a label for the arms that
44+follow it. The arms of a core can be divided into **chapters** for
29−The `+|` doesn't produce an arm. It instead provides a label for the arms that follow it. The arms of a core can be divided into **chapters** for 'organization'. Chapter labels aren't part of the underlying noun of the core; they're stored as type system metadata only.
45+'organization'. Chapter labels aren't part of the underlying noun of the core;
46+they're stored as type system metadata only.
30
47
31−See `tome` in the Hoon standard library.
48+See [`tome`](/docs/hoon/reference/stdlib/4o#tome) in the Hoon standard library.
32
49
50+**Note:** The `+|` rune has little practical utility. Chapter labels cannot be
51+referenced short of manually processing the `$type` of a core.
52+
33−##### Examples
53+#### Examples
34
54
35Let's look at what the Hoon compiler's parser, `ream`, does with the `+|` rune:
55Let's look at what the Hoon compiler's parser, `ream`, does with the `+|` rune:
36
56
@@ -46,7 +66,7 @@ Let's look at what the Hoon compiler's parser, `ream`, does with the `+|` rune:
46]
66]
47```
67```
48
68
49−Notice that `p.q` has the label `%numbers`. Contrast with:
69+Notice that `p.q` has the label `%numbers`. Contrast with:
50
70
51```
71```
52> (ream '|% ++ two 2 ++ three 3 --')
72> (ream '|% ++ two 2 ++ three 3 --')
@@ -60,27 +80,42 @@ Notice that `p.q` has the label `%numbers`. Contrast with:
60]
80]
61```
81```
62
82
83+---
84+
63−### `+$` "lusbuc"
85+## `+$` "lusbuc"
64
86
65Produce a structure arm (type definition).
87Produce a structure arm (type definition).
66
88
67−##### Syntax
89+#### Syntax
68
90
69−Regular: **2-fixed**.
91+Two arguments, fixed.
70
92
71−```hoon
93+<table>
94+<tr><th>Form</th><th>Syntax</th></tr>
95+<tr>
96+<td>Tall</td>
97+<td>
98+<pre>
72+$ p=term q=spec
99+$ p=term q=spec
73−```
100+</pre>
101+</td>
102+</tr>
103+<tr><td>Wide</td><td>None.</td></tr>
104+<tr><td>Irregular</td><td>None.</td></tr>
105+</table>
74
106
75`p` is an arm name, and `q` is any structure expression.
107`p` is an arm name, and `q` is any structure expression.
76
108
77−##### Discussion
109+#### Discussion
78
110
79−Arms produced by `+$` are essentially type definitions. They should be used when one wants to define custom types using core arms.
111+Arms produced by `+$` are essentially type definitions. They should be used when one wants to define custom types using core arms.
80
112
81−The Hoon subexpression, `q`, must be a structure expression. That is, it must be either a basic structure expression (`*`, `~`, `^`, `?`, and `@`), or a complex expression made with the `$` family of runes (including irregular variants). Names of structures are also permitted (e.g., `tape`).
113+The Hoon subexpression, `q`, must be a structure expression. That is, it must be
114+either a basic structure expression (`*`, `~`, `^`, `?`, and `@`), or a complex
115+expression made with the `$` family of runes (including irregular variants).
116+Names of structures are also permitted (e.g., `tape`).
82
117
83−##### Examples
118+#### Examples
84
119
85```
120```
86> =c |%
121> =c |%
@@ -98,27 +133,41 @@ nest-fail
98[%.y 22]
133[%.y 22]
99```
134```
100
135
136+---
137+
101−### `++` "luslus"
138+## `++` "luslus"
102
139
103Produce a normal arm.
140Produce a normal arm.
104
141
105−##### Syntax
142+#### Syntax
106
143
107−Regular: **2-fixed**.
144+Two arguments, fixed.
108
145
109−```hoon
146+<table>
147+<tr><th>Form</th><th>Syntax</th></tr>
148+<tr>
149+<td>Tall</td>
150+<td>
151+<pre>
110++ p=term q=hoon
152++ p=term q=hoon
111−```
153+</pre>
154+</td>
155+</tr>
156+<tr><td>Wide</td><td>None.</td></tr>
157+<tr><td>Irregular</td><td>None.</td></tr>
158+</table>
112
159
113`p` is the arm name, and `q` is any Hoon expression.
160`p` is the arm name, and `q` is any Hoon expression.
114
161
115−##### Discussion
162+#### Discussion
116
163
117−All arms must have a name (e.g., `add`). An arm is computed by name resolution. (This resolution is implicit in the case of `$` arms. See `|=`, `|-`, and `|^`.) The `++` rune is used for explicitly giving a name to an arm.
164+All arms must have a name (e.g., `add`). An arm is computed by name resolution.
165+(This resolution is implicit in the case of `$` arms. See `|=`, `|-`, and `|^`.)
166+The `++` rune is used for explicitly giving a name to an arm.
118
167
119Any Hoon expression, `q`, may be used to define the arm computation.
168Any Hoon expression, `q`, may be used to define the arm computation.
120
169
121−##### Examples
170+#### Examples
122
171
123```
172```
124> =c |%
173> =c |%
@@ -133,20 +182,32 @@ Any Hoon expression, `q`, may be used to define the arm computation.
13312
18212
134```
183```
135
184
185+---
186+
136−### `+*` "lustar"
187+## `+*` "lustar"
137
188
138Defines deferred expressions within doors.
189Defines deferred expressions within doors.
139
190
140−##### Syntax
191+#### Syntax
141
192
142−Regular: **variadic**.
193+Arguments: A variable number of pairs.
143
194
144−```hoon
195+<table>
196+<tr><th>Form</th><th>Syntax</th></tr>
197+<tr>
198+<td>Tall</td>
199+<td>
200+<pre>
145+* a=term b=hoon
201+* a=term b=hoon
146 c=term d=hoon
202 c=term d=hoon
147 ...
203 ...
148 e=term f=hoon
204 e=term f=hoon
149−```
205+</pre>
206+</td>
207+</tr>
208+<tr><td>Wide</td><td>None.</td></tr>
209+<tr><td>Irregular</td><td>None.</td></tr>
210+</table>
150
211
151`a`, `c`, `e` are arm names and `b`, `d`, `f` are any Hoon expression. Note that
212`a`, `c`, `e` are arm names and `b`, `d`, `f` are any Hoon expression. Note that
152unlike all other runes with a variable number of arguments, the list of
213unlike all other runes with a variable number of arguments, the list of
@@ -155,7 +216,7 @@ arguments of `+*` does not end with a terminator.
155`+*` arms must always come at the beginning of the battery, before any other
216`+*` arms must always come at the beginning of the battery, before any other
156type of lus arm.
217type of lus arm.
157
218
158−##### Discussion
219+#### Discussion
159
220
160The primary use of `+*` is to create deferred expressions within doors (see
221The primary use of `+*` is to create deferred expressions within doors (see
161Examples below). This is a name for an expressions that will be evaluated in
222Examples below). This is a name for an expressions that will be evaluated in
@@ -178,7 +239,9 @@ compiled from this Hoon expression
178++ y (sub z n)
239++ y (sub z n)
179--
240--
180```
241```
242+
181as being identical the Nock compiled from this one:
243as being identical the Nock compiled from this one:
244+
182```hoon
245```hoon
183=| z=@ud
246=| z=@ud
184|%
247|%
@@ -191,13 +254,15 @@ as being identical the Nock compiled from this one:
191--
254--
192```
255```
193
256
194−##### Examples
257+#### Examples
195
258
196To assign an alias to a door, we often write the following.
259To assign an alias to a door, we often write the following.
260+
197```hoon
261```hoon
198|_ foo
262|_ foo
199+* this .
263+* this .
200```
264```
265+
201This is the idomatic way to assign the alias `this` to the door.
266This is the idomatic way to assign the alias `this` to the door.
202
267
203Sometimes cores, such as Gall app cores, have a fixed number of arms, but you'd
268Sometimes cores, such as Gall app cores, have a fixed number of arms, but you'd
@@ -211,6 +276,7 @@ Gall app core. This usage of `+*` is controversial and should be minimized.
211 samp +<
276 samp +<
212 cont +>
277 cont +>
213```
278```
279+
214This assigns the door the alias `this`, the sample of the door `samp`, and the
280This assigns the door the alias `this`, the sample of the door `samp`, and the
215context of the door `cont`.
281context of the door `cont`.
216
282
@@ -218,7 +284,7 @@ You may also call functions with `+*` by making use of e.g. the `%~` rune.
218
284
219```hoon
285```hoon
220=<
286=<
221− |_ a=@
287+ |_ a=@
222 +* do ~(. +> a)
288 +* do ~(. +> a)
223 ++ stuff foo:do
289 ++ stuff foo:do
224::etc
290::etc
content/docs/hoon/reference/rune/mic.md+384−143
@@ -7,13 +7,53 @@ aliases = ["docs/reference/hoon-expressions/rune/mic/"]
7
7
8Miscellaneous useful macros.
8Miscellaneous useful macros.
9
9
10−## Runes
10+## `;:` "miccol"
11+
12+Call a binary function as an n-ary function.
13+
14+#### Syntax
15+
16+One fixed argument, then a variable number of arguments.
17+
18+<table>
19+<tr><th>Form</th><th>Syntax</th></tr>
20+<tr>
21+<td>Tall</td>
22+<td>
23+<pre>
24+;: p
25+ q1
26+ q2
27+ qn
28+==
29+</pre>
30+</td>
31+</tr>
32+<tr>
33+<td>Wide</td>
34+<td>
35+<pre>
36+;:(p q1 q2 qn)
37+</pre>
38+</td>
39+</tr>
40+<tr>
41+<td>Irregular</td>
42+<td>
43+<pre>
44+:(p q1 q2 qn)
45+</pre>
46+</td>
47+</tr>
48+</table>
49+
50+#### AST
11
51
12−### `;:` "miccol"
52+```hoon
13−
14−`[%mccl p=hoon q=(list hoon)]`: call a binary function as an n-ary function.
53+[%mccl p=hoon q=(list hoon)]
54+```
15
55
16−##### Expands to
56+#### Expands to
17
57
18**Pseudocode**: `a`, `b`, `c`, ... as elements of `q`:
58**Pseudocode**: `a`, `b`, `c`, ... as elements of `q`:
19
59
@@ -29,7 +69,7 @@ Irregular form:
29(p a (p b (p c ...)))
69(p a (p b (p c ...)))
30```
70```
31
71
32−##### Desugaring
72+#### Desugaring
33
73
34```hoon
74```hoon
35|-
75|-
@@ -40,35 +80,57 @@ Irregular form:
40(p i.q $(q t.q))
80(p i.q $(q t.q))
41```
81```
42
82
43−##### Syntax
44−
45−Regular: **1-fixed**, then **running**.
46−
47−Irregular: `:(add a b c)` is `;:(add a b c)`.
48−
49−##### Examples
83+#### Examples
50
84
51```
85```
52−~zod:dojo> (add 3 (add 4 5))
86+> (add 3 (add 4 5))
5312
8712
54
88
55−~zod:dojo> ;:(add 3 4 5)
89+> ;:(add 3 4 5)
5612
9012
57
91
58−~zod:dojo> :(add 3 4 5)
92+> :(add 3 4 5)
5912
9312
94+
95+> `@t`:((cury cat 3) 'a' 'b' 'c' 'd')
96+'abcd'
60```
97```
61
98
99+---
100+
62−### `;<` "micgal"
101+## `;<` "micgal"
102+
103+Monadic do notation.
104+
105+#### Syntax
63
106
64−`[%mcgl p=spec q=hoon r=hoon s=hoon]`: monadic do notation.
107+Four arguments, fixed.
65
108
109+<table>
66−##### Syntax
110+<tr><th>Form</th><th>Syntax</th></tr>
111+<tr>
112+<td>Tall</td>
113+<td>
114+<pre>
115+;< mold bind expr1 expr2
116+</pre>
117+</td>
118+</tr>
119+<tr>
120+<td>Wide</td>
121+<td>
122+<pre>
123+;<(mold bind expr1 expr2)
124+</pre>
125+</td>
126+</tr>
127+<tr><td>Irregular</td><td>None.</td></tr>
128+</table>
67
129
68−Regular: **4-fixed**
130+#### AST
69
131
70```hoon
132```hoon
71−;< mold=mold bind=hoon expr1=hoon expr2=hoon
133+[%mcgl p=spec q=hoon r=hoon s=hoon]
72```
134```
73
135
74#### Semantics
136#### Semantics
@@ -77,7 +139,7 @@ A `;<` is for sequencing two computations, `expr1` and `expr2`, using a provided
77implementation of monadic bind. This rune takes a gate `bind` which takes a mold
139implementation of monadic bind. This rune takes a gate `bind` which takes a mold
78`mold` and produces an implementation of monadic bind.
140`mold` and produces an implementation of monadic bind.
79
141
80−##### Desugaring
142+#### Desugaring
81
143
82```hoon
144```hoon
83%+ (bind mold)
145%+ (bind mold)
@@ -86,7 +148,7 @@ implementation of monadic bind. This rune takes a gate `bind` which takes a mold
86expr2
148expr2
87```
149```
88
150
89−##### Discussion
151+#### Discussion
90
152
91`;<` is much like Haskell `do` notation. You have a sequence of events you'd
153`;<` is much like Haskell `do` notation. You have a sequence of events you'd
92like to run such that each past the first depends on the output of the previous
154like to run such that each past the first depends on the output of the previous
@@ -103,72 +165,102 @@ external data.
103
165
104We remark that you can switch binds in the middle of a sequence of `;<`.
166We remark that you can switch binds in the middle of a sequence of `;<`.
105
167
106−##### Examples
168+#### Examples
107
169
108[`+biff`](/docs/hoon/reference/stdlib/2a/#biff) is the unit monad's
170[`+biff`](/docs/hoon/reference/stdlib/2a/#biff) is the unit monad's
109implementation of monadic bind. That is to say, it takes a unit `a` and a gate
171implementation of monadic bind. That is to say, it takes a unit `a` and a gate
110`b` that accepts a noun that produces a unit, and extracts the value from `a` to
172`b` that accepts a noun that produces a unit, and extracts the value from `a` to
111−pass as a sample to `b`.
173+pass as a sample to `b`.
112
174
113We illustrate the usage of `;<` with `+biff` with a `map` of atoms:
175We illustrate the usage of `;<` with `+biff` with a `map` of atoms:
176+
114```
177```
115−~zod:dojo> =m (my ~[[1 3] [2 2] [3 1]])
178+> =m (my ~[[1 3] [2 2] [3 1]])
116− > (~(get by m) 1)
179+> (~(get by m) 1)
117− [~ 3]
180+[~ 3]
118```
181```
182+
119A single usage of `;<` only serves to apply the binding function to the output
183A single usage of `;<` only serves to apply the binding function to the output
120of `expr1`:
184of `expr1`:
185+
121```
186```
122−~zod:dojo> ;< a=@ _biff (~(get by m) 1)
187+> ;< a=@ _biff (~(get by m) 1)
123− a
188+ a
124− 3
189+3
125```
190```
191+
126Here we see the result of chaining them together:
192Here we see the result of chaining them together:
193+
127```
194```
128−~zod:dojo> ;< a=@ _biff (~(get by m) 1)
195+> ;< a=@ _biff (~(get by m) 1)
129− ;< b=@ _biff (~(get by m) a)
196+ ;< b=@ _biff (~(get by m) a)
130− b
197+ b
131− 1
198+1
132```
199```
133
200
201+---
134
202
135−
136−### `;+` "miclus"
203+## `;+` "miclus"
137
204
138make a single XML node (Sail)
205make a single XML node (Sail)
139
206
140−##### Produces
207+#### Syntax
141−
208+
142−A `marl`, i.e., a list of `manx`. A `manx` is a noun that represents a single XML node.
209+One argument, fixed.
210+
211+<table>
212+<tr><th>Form</th><th>Syntax</th></tr>
213+<tr>
214+<td>Tall</td>
215+<td>
216+<pre>
217+;+ p
218+</pre>
219+</td>
220+</tr>
221+<tr>
222+<td>Wide</td>
223+<td>
224+<pre>
225+;+(p)
226+</pre>
227+</td>
228+</tr>
229+<tr><td>Irregular</td><td>None.</td></tr>
230+</table>
143
231
144−##### Syntax
232+`p` is a Hoon expression that produces a `manx`.
145−
146−**1-fixed**
147
233
148−```hoon
234+#### Produces
149−;+ p=hoon
150−```
151
235
152−`p` is a Hoon expression that produces a `manx`.
236+A [`marl`](/docs/hoon/reference/stdlib/5e#marl), i.e., a list of
237+[`manx`](/docs/hoon/reference/stdlib/5e#manx). A `manx` is a noun that
238+represents a single XML node.
153
239
154−##### Discussion
240+#### Discussion
155
241
156tl;dr -- `;+` converts a `manx` to a `marl`.
242tl;dr -- `;+` converts a `manx` to a `marl`.
157
243
244+`;+` is a Sail rune. Sail is a part of Hoon used for creating and operating on
158−`;+` is a Sail rune. Sail is a part of Hoon used for creating and operating on nouns that represent XML nodes. With the appropriate rendering pipeline, a Sail document can be used to generate a static website.
245+nouns that represent XML nodes. With the appropriate rendering pipeline, a Sail
246+document can be used to generate a static website.
159
247
248+In Sail a single XML node is represented by a `manx`. A single
160−In Sail a single XML node is represented by a `manx`. A single <code>&lt;p&gt;</code> node `manx` can be produced in the following way:
249+<code>&lt;p&gt;</code> node `manx` can be produced in the following way:
161
250
162```
251```
163> ;p: This will be rendered as an XML node.
252> ;p: This will be rendered as an XML node.
164[[%p ~] [[%$ [%$ "This will be rendered as an XML node."] ~] ~] ~]
253[[%p ~] [[%$ [%$ "This will be rendered as an XML node."] ~] ~] ~]
165```
254```
166
255
167−Sometimes what is needed is a `marl`, i.e., a list of `manx`. To convert a single `manx` to a `marl`, use the `;+` rune.
256+Sometimes what is needed is a `marl`, i.e., a list of `manx`. To convert a
257+single `manx` to a `marl`, use the `;+` rune.
168
258
169−One interesting thing about Sail is that it allows you to use complex Hoon expressions to choose from among several nodes to render. The `;+` rune can take such a complex expression.
259+One interesting thing about Sail is that it allows you to use complex Hoon
260+expressions to choose from among several nodes to render. The `;+` rune can take
261+such a complex expression.
170
262
171−##### Examples
263+#### Examples
172
264
173```
265```
174> ^- marl
266> ^- marl
@@ -192,11 +284,45 @@ One interesting thing about Sail is that it allows you to use complex Hoon expre
192]
284]
193```
285```
194
286
287+---
288+
195−### `;;` "micmic"
289+## `;;` "micmic"
290+
291+Normalize with a mold, asserting fixpoint.
196
292
197−`[%mcmc p=spec q=hoon]`: normalize with a mold, asserting fixpoint.
293+#### Syntax
198
294
295+Two arguments, fixed.
296+
297+<table>
298+<tr><th>Form</th><th>Syntax</th></tr>
299+<tr>
300+<td>Tall</td>
301+<td>
302+<pre>
303+;; p
304+q
305+</pre>
306+</td>
307+</tr>
308+<tr>
309+<td>Wide</td>
310+<td>
311+<pre>
312+;;(p q)
313+</pre>
314+</td>
315+</tr>
316+<tr><td>Irregular</td><td>None.</td></tr>
317+</table>
318+
319+#### AST
320+
321+```hoon
322+[%mcmc p=spec q=hoon]
323+```
324+
199−##### Expands to
325+#### Expands to
200
326
201```hoon
327```hoon
202=+ a=(p q)
328=+ a=(p q)
@@ -206,68 +332,130 @@ a
206
332
207> Note: the expansion implementation is hygienic -- it doesn't actually add the `a` face to the subject.
333> Note: the expansion implementation is hygienic -- it doesn't actually add the `a` face to the subject.
208
334
209−##### Syntax
210−
211−Regular: **2-fixed**.
212−
213−##### Examples
335+#### Examples
214
336
215Fails because of auras:
337Fails because of auras:
216
338
217```
339```
218−~zod:dojo> ^-(tape ~[97 98 99])
340+> ^-(tape ~[97 98 99])
219mint-nice
341mint-nice
342+-need.?(%~ [i=@tD t=""])
343+-have.[@ud @ud @ud %~]
220nest-fail
344nest-fail
221−ford: %slim failed:
345+dojo: hoon expression failed
222−ford: %ride failed to compute type:
223```
346```
224
347
225Succeeds because molds don't care about auras:
348Succeeds because molds don't care about auras:
226
349
227```
350```
228−~zod:dojo> ;;(tape ~[97 98 99])
351+> ;;(tape ~[97 98 99])
229"abc"
352"abc"
230```
353```
231
354
232Fails because not a fixpoint:
355Fails because not a fixpoint:
233
356
234```
357```
235−~zod:dojo> ;;(tape [50 51 52])
358+> ;;(tape [50 51 52])
236−ford: %ride failed to execute:
359+dojo: hoon expression failed
237```
360```
238
361
362+---
363+
239−### `;/` "micfas"
364+## `;/` "micfas"
365+
366+Tape as XML element.
240
367
241−`[%mcnt p=hoon]`: tape as XML element.
368+#### Syntax
242
369
243−##### Expands to
370+One argument, fixed.
371+
372+<table>
373+<tr><th>Form</th><th>Syntax</th></tr>
374+<tr>
375+<td>Tall</td>
376+<td>
377+<pre>
378+;/ p
379+</pre>
380+</td>
381+</tr>
382+<tr>
383+<td>Wide</td>
384+<td>
385+<pre>
386+;/(p)
387+</pre>
388+</td>
389+</tr>
390+<tr><td>Irregular</td><td>None.</td></tr>
391+</table>
392+
393+#### AST
244
394
245```hoon
395```hoon
246−~[%$ ~[%$ 'p']]
396+[%mcnt p=hoon]
247```
397```
248
398
249−##### Examples
399+#### Expands to
250
400
401+```hoon
402+~[%$ ~[%$ 'p']]
251```
403```
252−~zod/try=> ;/ "foo"
404+
253−[[%~. [%~. "foo] ~] ~]
405+#### Examples
254−```
255
406
256```
407```
257−~zod/try=> :/"foo"
408+> ;/ "foo"
258−[[%~. [%~. "foo] ~] ~]
409+[[%~. [%~. "foo"] ~] ~]
259```
410```
260
411
412+---
413+
261−### `;~` "micsig"
414+## `;~` "micsig"
415+
416+Glue a pipeline together with a product-sample adapter.
262
417
263−`[%mcsg p=hoon q=(list hoon)]`: glue a pipeline together with a
418+#### Syntax
264−product-sample adapter.
265
419
266−##### Produces
420+One fixed argument, then a variable number of arguments.
421+
422+<table>
423+<tr><th>Form</th><th>Syntax</th></tr>
424+<tr>
425+<td>Tall</td>
426+<td>
427+<pre>
428+;~ p
429+ q1
430+ q2
431+ qn
432+==
433+</pre>
434+</td>
435+</tr>
436+<tr>
437+<td>Wide</td>
438+<td>
439+<pre>
440+;~(p q1 q2 qn)
441+</pre>
442+</td>
443+</tr>
444+<tr><td>Irregular</td><td>None.</td></tr>
445+</table>
446+
447+#### AST
448+
449+```hoon
450+[%mcsg p=hoon q=(list hoon)]
451+```
267
452
268−The gates in `q` are composed together using the gate `p` as an intermediate function, which transforms a `q` product and a `q` gate into a `q` sample.
453+#### Produces
269
454
455+The gates in `q` are composed together using the gate `p` as an intermediate
456+function, which transforms a `q` product and a `q` gate into a `q` sample.
457+
270−##### Expands to
458+#### Expands to
271
459
272**Note: these are structurally correct, but elide some type-system complexity.**
460**Note: these are structurally correct, but elide some type-system complexity.**
273
461
@@ -289,7 +477,7 @@ The gates in `q` are composed together using the gate `p` as an intermediate fun
289|. (a (c arg) d(+6 arg))
477|. (a (c arg) d(+6 arg))
290```
478```
291
479
292−##### Desugaring
480+#### Desugaring
293
481
294```hoon
482```hoon
295?~ q !!
483?~ q !!
@@ -301,12 +489,11 @@ The gates in `q` are composed together using the gate `p` as an intermediate fun
301|. (p (b c) a(,.+6 c))
489|. (p (b c) a(,.+6 c))
302```
490```
303
491
304−##### Discussion
492+#### Discussion
305
493
306−Apparently `;~` is a "Kleisli arrow." It's also
494+Apparently `;~` is a "Kleisli arrow." It's also a close cousin of the infamous
307−a close cousin of the infamous "monad." Don't let that bother
308−you. Hoon doesn't know anything about category theory,
495+"monad." Don't let that bother you. Hoon doesn't know anything about category
309−so you don't need to either.
496+theory, so you don't need to either.
310
497
311`;~` is often used in parsers, but is not only for parsers.
498`;~` is often used in parsers, but is not only for parsers.
312
499
@@ -315,80 +502,105 @@ nesting the gates in `q`, each is passed individually to `p` with the product
315of the previous gate, allowing arbitrary filtering, transformation, or
502of the previous gate, allowing arbitrary filtering, transformation, or
316conditional application.
503conditional application.
317
504
318−##### Syntax
319−
320−Regular: **1-fixed**, then **running**.
321−
322−##### Examples
505+#### Examples
323
506
324−A simple "parser." `trip` converts a `cord` (atomic string) to
507+A simple "parser." `trip` converts a `cord` (atomic string) to
325a `tape` (linked string).
508a `tape` (linked string).
326
509
327```
510```
328−~zod:dojo> =cmp |=([a=tape b=$-(char tape)] `tape`?~(a ~ (weld (b i.a) t.a)))
511+> =cmp |=([a=tape b=$-(char tape)] `tape`?~(a ~ (weld (b i.a) t.a)))
329−~zod:dojo> ;~(cmp trip)
512+> ;~(cmp trip)
330<1.zje {a/@ <409.yxa 110.lxv 1.ztu $151>}>
513<1.zje {a/@ <409.yxa 110.lxv 1.ztu $151>}>
331−
332```
514```
333
515
334With just one gate in the pipeline `q`, the glue `p` is unused:
516With just one gate in the pipeline `q`, the glue `p` is unused:
335
517
336```
518```
337−~zod:dojo> (;~(cmp trip) 'a')
519+> (;~(cmp trip) 'a')
338"a"
520"a"
339```
521```
340
522
341But for multiple gates, we need it to connect the pipeline:
523But for multiple gates, we need it to connect the pipeline:
342
524
343```
525```
344−~zod:dojo> (;~(cmp trip |=(a=@ ~[a a])) 'a')
526+> (;~(cmp trip |=(a=@ ~[a a])) 'a')
345"aa"
527"aa"
528+
346−~zod:dojo> (;~(cmp trip |=(a=@ ~[a a])) '')
529+> (;~(cmp trip |=(a=@ ~[a a])) '')
347""
530""
348```
531```
349
532
350A more complicated example:
533A more complicated example:
351
534
352```
535```
353−~zod:dojo> (;~(cmp trip ;~(cmp |=(a=@ ~[a a]) |=(a=@ <(dec a)>))) 'b')
536+> (;~(cmp trip ;~(cmp |=(a=@ ~[a a]) |=(a=@ <(dec a)>))) 'b')
354"97b"
537"97b"
538+
355−~zod:dojo> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'b')
539+> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'b')
356"97b"
540"97b"
541+
357−~zod:dojo> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) '')
542+> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) '')
358""
543""
544+
359−~zod:dojo> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'a')
545+> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'a')
360"96a"
546"96a"
547+
361−~zod:dojo> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'acd')
548+> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'acd')
362"96acd"
549"96acd"
363```
550```
364
551
552+---
553+
365−### `;*` "mictar"
554+## `;*` "mictar"
366
555
367make a list of XML nodes from complex Hoon expression (Sail)
556make a list of XML nodes from complex Hoon expression (Sail)
368
557
369−##### Produces
558+#### Syntax
559+
560+One argument, fixed.
561+
562+<table>
563+<tr><th>Form</th><th>Syntax</th></tr>
564+<tr>
565+<td>Tall</td>
566+<td>
567+<pre>
568+;* p
569+</pre>
570+</td>
571+</tr>
572+<tr>
573+<td>Wide</td>
574+<td>
575+<pre>
576+;*(p)
577+</pre>
578+</td>
579+</tr>
580+<tr><td>Irregular</td><td>None.</td></tr>
581+</table>
370
582
371−A `marl`, i.e., a list of `manx`. A `manx` is a noun that represents a single XML node.
583+`p` is a Hoon expression that produces a `marl`.
372
584
373−##### Syntax
585+#### Produces
374
586
375−**1-fixed**
587+A [`marl`](/docs/hoon/reference/stdlib/5e#marl), i.e., a list of
588+[`manx`](/docs/hoon/reference/stdlib/5e#manx). A `manx` is a noun that
589+represents a single XML node.
376
590
377−```hoon
591+#### Discussion
378−;* p=hoon
379−```
380
592
381−`p` is a Hoon expression that produces a `marl`.
593+`;*` is a Sail rune. Sail is a part of Hoon used for creating and operating on
594+nouns that represent XML nodes. With the appropriate rendering pipeline, a Sail
595+document can be used to generate a static website.
382
596
383−##### Discussion
597+If you need a complex Hoon expression to produce a `marl`, use the `;*` rune.
384−
385−`;*` is a Sail rune. Sail is a part of Hoon used for creating and operating on nouns that represent XML nodes. With the appropriate rendering pipeline, a Sail document can be used to generate a static website.
386−
387−If you need a complex Hoon expression to produce a `marl`, use the `;*` rune. Often this rune is used with an expression, `p`, that includes one or more `;=` subexpressions.
598+Often this rune is used with an expression, `p`, that includes one or more `;=`
599+subexpressions.
388
600
389(See also [`;=`](#mictis).)
601(See also [`;=`](#mictis).)
390
602
391−##### Examples
603+#### Examples
392
604
393```
605```
394> ;* ?: (gth 3 2)
606> ;* ?: (gth 3 2)
@@ -414,40 +626,69 @@ If you need a complex Hoon expression to produce a `marl`, use the `;*` rune. O
414]
626]
415```
627```
416
628
417−### `;=` "mictis"
629+---
418−
419−make a list of XML nodes (Sail)
420−
421−##### Produces
422−
423−A `marl`, i.e., a list of `manx`. A `manx` is a noun that represents a single XML node.
424−
425−##### Syntax
426−
427−**running**
428−
429−```hoon
430−;= p=hoon q=hoon ... z=hoon ==
431−```
432−
433−`p`-`z` are Hoon expressions, each of which poduces a `manx`.
434
630
435−##### Discussion
631+## `;=` "mictis"
436
632
437−`;=` is a Sail rune. Sail is a part of Hoon used for creating and operating on nouns that represent XML nodes. With the appropriate rendering pipeline, a Sail document can be used to generate a static website.
633+make a list of XML nodes (Sail)
438
634
635+#### Syntax
636+
637+A variable number of arguments.
638+
639+<table>
640+<tr><th>Form</th><th>Syntax</th></tr>
641+<tr>
642+<td>Tall</td>
643+<td>
644+<pre>
645+;= p1
646+ p2
647+ p3
648+ pn
649+==
650+</pre>
651+</td>
652+</tr>
653+<tr>
654+<td>Wide</td>
655+<td>
656+<pre>
657+;=(p1 p2 p3 pn)
658+</pre>
659+</td>
660+</tr>
661+<tr><td>Irregular</td><td>None.</td></tr>
662+</table>
663+
664+`p1`-`pn` are Hoon expressions, each of which poduces a `manx`.
665+
666+#### Produces
667+
668+A [`marl`](/docs/hoon/reference/stdlib/5e#marl), i.e., a list of
669+[`manx`](/docs/hoon/reference/stdlib/5e#manx). A `manx` is a noun that
670+represents a single XML node.
671+
672+#### Discussion
673+
674+`;=` is a [Sail](/docs/hoon/guides/sail) rune. Sail is a part of Hoon used for
675+creating and operating on nouns that represent XML nodes. With the appropriate
676+rendering pipeline, a Sail document can be used to generate a static website.
677+
439−In Sail a single XML node is represented by a `manx`. A single `<p>` node `manx` can be produced in the following way:
678+In Sail a single XML node is represented by a `manx`. A single `<p>` node `manx`
679+can be produced in the following way:
440
680
441```
681```
442> ;p: This will be rendered as an XML node.
682> ;p: This will be rendered as an XML node.
443[[%p ~] [[%$ [%$ "This will be rendered as an XML node."] ~] ~] ~]
683[[%p ~] [[%$ [%$ "This will be rendered as an XML node."] ~] ~] ~]
444```
684```
445
685
446−Sometimes what is needed is a `marl`, i.e., a list of `manx`. To convert a series of `manx` nodes to a `marl`, use the `;=` rune.
686+Sometimes what is needed is a `marl`, i.e., a list of `manx`. To convert a
687+series of `manx` nodes to a `marl`, use the `;=` rune.
447
688
448(See also [`;*`](#mictar).)
689(See also [`;*`](#mictar).)
449
690
450−##### Examples
691+#### Examples
451
692
452```
693```
453> ;= ;p: This is the first node.
694> ;= ;p: This is the first node.
content/docs/hoon/reference/rune/sig.md+582−167
@@ -3,35 +3,69 @@ title = "Hints ~ ('sig')"
3weight = 14
3weight = 14
4template = "doc.html"
4template = "doc.html"
5+++
5+++
6+
6Runes that use Nock `11` to pass non-semantic info to the interpreter. A
7Runes that use Nock `11` to pass non-semantic info to the interpreter. A
7mnemonic to remember what sig runes are for is "we're *sig*naling some
8mnemonic to remember what sig runes are for is "we're *sig*naling some
8information to the interpreter".
9information to the interpreter".
9
10
11+## `~>` "siggar"
12+
13+Raw hint, applied to computation.
14+
15+#### Syntax
16+
17+Two arguments, fixed.
18+
19+<table>
20+<tr><th>Form</th><th>Syntax</th></tr>
21+<tr>
22+<td>Tall</td>
23+<td>
24+<pre>
25+~> p
26+q
27+</pre>
28+</td>
29+</tr>
30+<tr>
31+<td>Wide</td>
32+<td>
33+<pre>
34+~>(p q)
35+</pre>
36+</td>
37+</tr>
38+<tr>
39+<td>Irregular</td>
40+<td>None.</td>
41+</tr>
42+</table>
43+
44+#### AST
10
45
11−## Runes
46+```hoon
12−
13−### `~>` "siggar"
14−
15−`[%sggr p=$@(term [p=term q=hoon]) q=hoon]`: raw hint, applied
47+[%sggr p=$@(term [p=term q=hoon]) q=hoon]
16−to computation.
48+```
17
49
18−##### Expands to
50+#### Expands to
19
51
20`q`.
52`q`.
21
53
22−##### Syntax
54+#### Semantics
23
55
24−Regular: **2-fixed**. For the dynamic form, write `%term.hoon`.
56+`p` may either be a single `%term` or a pair of `[term hoon]`, the latter of
57+which may optionally be be written `%foo.some-hoon`. `p` will be passed to the
58+interpreter and `q` will be evaluated and its result produced like normal.
25
59
26−##### Discussion
60+#### Discussion
27
61
28Hoon has no way of telling what hints are used and what aren't.
62Hoon has no way of telling what hints are used and what aren't.
29Hints are all conventions at the interpreter level.
63Hints are all conventions at the interpreter level.
30
64
31−##### Examples
65+#### Examples
32
66
33```
67```
34−~zod:dojo> ~>(%a 42)
68+> ~>(%a 42)
3542
6942
36```
70```
37
71
@@ -45,24 +79,56 @@ Running the compiler:
45[%11 p=[p=97 q=[%4 p=[%1 p=2]]] q=[%1 p=42]]
79[%11 p=[p=97 q=[%4 p=[%1 p=2]]] q=[%1 p=42]]
46```
80```
47
81
82+---
83+
48−### `~|` "sigbar"
84+## `~|` "sigbar"
49−
85+
86+Tracing printf.
87+
88+#### Syntax
89+
90+Two arguments, fixed.
91+
92+<table>
93+<tr><th>Form</th><th>Syntax</th></tr>
94+<tr>
95+<td>Tall</td>
96+<td>
97+<pre>
98+~| p
99+q
100+</pre>
101+</td>
102+</tr>
103+<tr>
104+<td>Wide</td>
105+<td>
106+<pre>
107+~|(p q)
108+</pre>
109+</td>
110+</tr>
111+<tr>
112+<td>Irregular</td>
113+<td>None.</td>
114+</tr>
115+</table>
116+
117+#### AST
50
118
119+```hoon
51−`[%sgbr p=hoon q=hoon]`: tracing printf.
120+[%sgbr p=hoon q=hoon]
121+```
52
122
53−##### Expands to
123+#### Expands to
54
124
55`q`.
125`q`.
56
126
57−##### Convention
127+#### Convention
58
128
59Prettyprints `p` in stack trace if `q` crashes.
129Prettyprints `p` in stack trace if `q` crashes.
60
130
61−##### Syntax
62−
63−Regular: **2-fixed**.
64−
65−##### Examples
131+#### Examples
66
132
67```
133```
68> ~|('sample error message' !!)
134> ~|('sample error message' !!)
@@ -75,46 +141,138 @@ dojo: hoon expression failed
75dojo: hoon expression failed
141dojo: hoon expression failed
76```
142```
77
143
144+---
145+
78−### `~$` "sigbuc"
146+## `~$` "sigbuc"
147+
148+Profiling hit counter.
149+
150+#### Syntax
151+
152+Two arguments, fixed.
153+
154+<table>
155+<tr><th>Form</th><th>Syntax</th></tr>
156+<tr>
157+<td>Tall</td>
158+<td>
159+<pre>
160+~& p
161+q
162+</pre>
163+</td>
164+</tr>
165+<tr>
166+<td>Wide</td>
167+<td>
168+<pre>
169+~&(p q)
170+</pre>
171+</td>
172+</tr>
173+<tr>
174+<td>Irregular</td>
175+<td>None.</td>
176+</tr>
177+</table>
178+
179+#### AST
79
180
181+```hoon
80−`[%sgbc p=term q=hoon]`: profiling hit counter.
182+[%sgbc p=term q=hoon]
183+```
81
184
82−##### Expands to
185+#### Expands to
83
186
84`q`.
187`q`.
85
188
86−##### Convention
189+#### Discussion
87
190
88−If profiling is on, adds 1 to the hit counter for `p`.
191+If profiling is on, adds 1 to the hit counter `p`, which is a `term` like
192+`%foo`. Profiling is enabled by passing the `-P` flag to the `urbit` binary.
193+Profiling results are saved in `/path/to/pier/.urb/put/profile/~some.date.txt`.
89
194
90−##### Syntax
195+#### Examples
91
196
92−Regular: **2-fixed**.
197+```
198+> ~$(%foo 3)
199+3
200+```
93
201
94−##### Examples
202+Assuming we have the binary running with the `-P` flag, if we do this:
95
203
96```
204```
97−~zod:dojo> ~$(%foo 3)
205+> =z |= a=@
98−3
206+ ?: =(a 0)
207+ a
208+ ~$ %my-hit-counter
209+ $(a (dec a))
210+
211+> (z 42)
212+0
99```
213```
100
214
101−### `~_` "sigcab"
215+...then look in `/path/to/pier/.urb/put/profile/~some.date.txt`, we'll see this
216+line near the top of the file:
102
217
218+```
219+my-hit-counter: 42
220+```
221+
222+---
223+
224+## `~_` "sigcab"
225+
226+User-formatted tracing printf.
227+
228+#### Syntax
229+
230+Two arguments, fixed.
231+
232+<table>
233+<tr><th>Form</th><th>Syntax</th></tr>
234+<tr>
235+<td>Tall</td>
236+<td>
237+<pre>
238+~_ p
239+q
240+</pre>
241+</td>
242+</tr>
243+<tr>
244+<td>Wide</td>
245+<td>
246+<pre>
247+~_(p q)
248+</pre>
249+</td>
250+</tr>
251+<tr>
252+<td>Irregular</td>
253+<td>None.</td>
254+</tr>
255+</table>
256+
257+#### AST
258+
259+```hoon
103−`[%sgcb p=hoon q=hoon]`: user-formatted tracing printf.
260+[%sgcb p=hoon q=hoon]
261+```
104
262
105−##### Expands to
263+#### Expands to
106
264
107`q`.
265`q`.
108
266
109−##### Convention
267+#### Convention
110
268
111Shows `p` in stacktrace if `q` crashes.
269Shows `p` in stacktrace if `q` crashes.
112
270
113−##### Discussion
271+#### Discussion
114
272
115−`p` must produce a `tank` (prettyprint source).
273+`p` must produce a `tank` (pretty-print source).
116
274
117−##### Examples
275+#### Examples
118
276
119```
277```
120> ~_([%leaf "sample error message"] !!)
278> ~_([%leaf "sample error message"] !!)
@@ -127,52 +285,81 @@ sample error message
127dojo: hoon expression failed
285dojo: hoon expression failed
128```
286```
129
287
288+---
289+
130−### `~%` "sigcen"
290+## `~%` "sigcen"
291+
292+Jet registration.
131
293
132−`[%sgcn p=term q=wing r=(list [term hoon]) s=hoon]`: jet registration.
294+#### Syntax
133
295
296+Four arguments. Two fixed arguments, then a third which may be `~` if empty or
297+else a variable number of pairs sandwiched between two `==`s, then a fourth
298+fixed argument.
299+
300+<table>
301+<tr><th>Form</th><th>Syntax</th></tr>
302+<tr>
303+<td>Tall</td>
304+<td>
305+<pre>
306+~% p q
307+ ==
308+ r1a r1b
309+ r2a r2b
310+ rna rnb
311+ ==
312+s
313+</pre>
314+</td>
315+</tr>
316+<tr><td>Wide</td><td>None.</td></tr>
317+<tr><td>Irregular</td><td>None.</td></tr>
318+</table>
319+
320+#### AST
321+
322+```hoon
323+[%sgcn p=chum q=hoon r=tyre s=hoon]
324+```
325+
134−##### Expands to
326+#### Expands to
135
327
136`s`.
328`s`.
137
329
138−##### Convention
330+#### Convention
139
331
140Register a core with name `p`, with parent at leg `q`, exporting
332Register a core with name `p`, with parent at leg `q`, exporting
141the named formulas `r`, constructed by `s`.
333the named formulas `r`, constructed by `s`.
142
334
143−##### Syntax
144−
145−Regular: **4-fixed**. For `r`, use `~` if empty. Otherwise, **jogging**
146−between opening and closing `==`.
147−
148−##### Discussion
335+#### Discussion
149
336
150−`~%` is for registering cores. A registered core declares its
337+`~%` is for registering cores. A registered core declares its
151formal identity to the interpreter, which may or may not be able
338formal identity to the interpreter, which may or may not be able
152to recognize and/or accelerate it.
339to recognize and/or accelerate it.
153
340
154Registered cores are organized in a containment hierarchy.
341Registered cores are organized in a containment hierarchy.
155−The parent core is at any leg within the child core. When we
342+The parent core is at any leg within the child core. When we
156register a core, we state the leg to its parent, in the form of
343register a core, we state the leg to its parent, in the form of
157−wing `q`. We assume the parent is already registered -- as it
344+wing `q`. We assume the parent is already registered -- as it
158must be, if (a) we registered it on creation, (b) the child was
345must be, if (a) we registered it on creation, (b) the child was
159created by an arm defined on the parent.
346created by an arm defined on the parent.
160
347
161−(Cores are actually managed by their formula/battery. Any
348+(Cores are actually managed by their formula/battery. Any
162function call will create a new core with a new sample, but
349function call will create a new core with a new sample, but
163−batteries are constant. But it is not sufficient to match the
350+batteries are constant. But it is not sufficient to match the
164battery -- matching the semantics constrains the payload as well,
351battery -- matching the semantics constrains the payload as well,
165since the semantics of a battery may depend on any parent core
352since the semantics of a battery may depend on any parent core
166and/or payload constant.)
353and/or payload constant.)
167
354
168−The purpose of registration is always performance-related. It
355+The purpose of registration is always performance-related. It
169may involve (a) a special-purpose optimizer or "jet", written
356may involve (a) a special-purpose optimizer or "jet", written
170for a specific core and checked with a Merkle hash; (b) a
357for a specific core and checked with a Merkle hash; (b) a
171general-purpose hotspot optimizer or "JIT"; or (c) merely a
358general-purpose hotspot optimizer or "JIT"; or (c) merely a
172hotspot declaration for profiling.
359hotspot declaration for profiling.
173
360
174As always with hints, the programmer has no idea which of (a),
361As always with hints, the programmer has no idea which of (a),
175−(b), and (c) will be applied. Use `~%`
362+(b), and (c) will be applied. Use `~%`
176indiscriminately on all hotspots, bottlenecks, etc, real or
363indiscriminately on all hotspots, bottlenecks, etc, real or
177suspected.
364suspected.
178
365
@@ -181,7 +368,7 @@ implementors with named Nock formulas that act on the core.
181In complex systems, jet implementations are often partial and
368In complex systems, jet implementations are often partial and
182want to call back into userspace.
369want to call back into userspace.
183
370
184−The child core contains the parent, of course. When we register
371+The child core contains the parent, of course. When we register
185a core, we state the leg to its parent, in the form of wing `q`.
372a core, we state the leg to its parent, in the form of wing `q`.
186We assume that the parent -- any core within the payload -- is
373We assume that the parent -- any core within the payload -- is
187already registered.
374already registered.
@@ -190,55 +377,80 @@ already registered.
190
377
191Registers a jet in core `s` so that it can be called when that code is run.
378Registers a jet in core `s` so that it can be called when that code is run.
192
379
193−Regular form: **4-fixed**
380+#### Examples
194
381
195−##### Examples
196−
197−Here's the AES
382+Here's the beginning of the AES core in `zuse.hoon`:
198
383
199```hoon
384```hoon
200− ++ aesc :: AES-256
385+++ aes !.
201− ~% %aesc + ~
386+ ~% %aes ..part ~
202− |%
387+ |%
203− ++ en :: ECB enc
388+ ++ ahem
204− ~/ %en
389+ |= [nnk=@ nnb=@ nnr=@]
205− |= [a=@I b=@H] ^- @uxH
390+ =>
206− =+ ahem
391+ =+ => [gr=(ga 8 0x11b 3) few==>(fe .(a 5))]
207− (be & (ex a) b)
392+ [pro=pro.gr dif=dif.gr pow=pow.gr ror=ror.few]
208− ++ de :: ECB dec
393+ => |%
209− ~/ %de
394+ ..........
210− |= [a=@I b=@H] ^- @uxH
211− =+ ahem
212− (be | (ix (ex a)) b)
213− --
214```
395```
215
396
216−Here we label the entire `++aesc` core for optimization. You can see the
397+Here we label the entire `++aes` core for optimization.
217−jet in `jets/e/aesc.c`.
218
398
399+---
219
400
220−### `~<` "siggal"
401+## `~<` "siggal"
221
402
403+Raw hint, applied to product.
222
404
223−`[%sggl p=$@(term [p=term q=hoon]) q=hoon]`: raw hint, applied to
405+#### Syntax
224−product.
225
406
226−##### Expands to
407+Two arguments, fixed.
227
408
228−`q`.
409+<table>
410+<tr><th>Form</th><th>Syntax</th></tr>
411+<tr>
412+<td>Tall</td>
413+<td>
414+<pre>
415+~< p
416+q
417+</pre>
418+</td>
419+</tr>
420+<tr>
421+<td>Wide</td>
422+<td>
423+<pre>
424+~<(p q)
425+</pre>
426+</td>
427+</tr>
428+<tr>
429+<td>Irregular</td>
430+<td>None.</td>
431+</tr>
432+</table>
433+
434+`p` may either be a a `term` or a pair of `[term hoon]`. If it's the latter, `p`
435+may optionally be written as `%foo.some-hoon`.
436+
437+#### AST
229
438
230−##### Syntax
439+```hoon
440+[%sggl p=$@(term [p=term q=hoon]) q=hoon]
441+```
231
442
232−Regular: **2-fixed**. For the dynamic form, write `%term.hoon`.
443+#### Expands to
444+
445+`q`.
233
446
234−##### Discussion
447+#### Discussion
235
448
236−`~<` is only used for jet hints ([`~/`](#sigfas)
449+`~<` is only used for jet hints ([`~/`](#sigfas) and [`~%`](#sigcen)) at the
237−and [`~%`](#sigcen)) at the moment; we are not telling the
238−interpreter something about the computation we're about to perform, but
450+moment; we are not telling the interpreter something about the computation we're
239−rather about its product.
451+about to perform, but rather about its product.
240
452
241−##### Examples
453+#### Examples
242
454
243```
455```
244> (make '~<(%a 42)')
456> (make '~<(%a 42)')
@@ -247,64 +459,129 @@ rather about its product.
247[%7 p=[%1 p=42] q=[%11 p=[p=97 q=[%4 p=[%0 p=1]]] q=[%0 p=1]]]
459[%7 p=[%1 p=42] q=[%11 p=[p=97 q=[%4 p=[%0 p=1]]] q=[%0 p=1]]]
248```
460```
249
461
462+---
463+
250−### `~+` "siglus"
464+## `~+` "siglus"
465+
466+Cache a computation.
467+
468+#### Syntax
469+
470+One argument, fixed.
471+
472+<table>
473+<tr><th>Form</th><th>Syntax</th></tr>
474+<tr>
475+<td>Tall</td>
476+<td>
477+<pre>
478+~+ p
479+</pre>
480+</td>
481+</tr>
482+<tr>
483+<td>Wide</td>
484+<td>
485+<pre>
486+~+(p)
487+</pre>
488+</td>
489+</tr>
490+<tr>
491+<td>Irregular</td>
492+<td>None.</td>
493+</tr>
494+</table>
495+
496+#### AST
251
497
498+```hoon
252−`[%sgls p=hoon]`: cache a computation.
499+[%sgls p=hoon]
500+```
253
501
254−##### Expands to
502+#### Expands to
255
503
256`p`.
504`p`.
257
505
258−##### Convention
506+#### Convention
259
507
260Caches the formula and subject of `p` in a local cache (generally
508Caches the formula and subject of `p` in a local cache (generally
261transient in the current event).
509transient in the current event).
262
510
263−##### Syntax
264−
265−Regular: **1-fixed**.
266−
267−##### Examples
511+#### Examples
268
512
269This may pause for a second:
513This may pause for a second:
270
514
271```
515```
272−~zod:dojo> %.(25 |=(a=@ ?:((lth a 2) 1 (add $(a (sub a 2)) $(a (dec a))))))
516+> %.(25 |=(a=@ ?:((lth a 2) 1 (add $(a (sub a 2)) $(a (dec a))))))
273121.393
517121.393
274```
518```
275
519
276This may make you want to press `ctrl-c`:
520This may make you want to press `ctrl-c`:
277
521
278```
522```
279−~zod:dojo> %.(30 |=(a=@ ?:((lth a 2) 1 (add $(a (sub a 2)) $(a (dec a))))))
523+> %.(30 |=(a=@ ?:((lth a 2) 1 (add $(a (sub a 2)) $(a (dec a))))))
2801.346.269
5241.346.269
281```
525```
282
526
283This should work fine:
527This should work fine:
284
528
285```
529```
286−~zod:dojo> %.(100 |=(a=@ ~+(?:((lth a 2) 1 (add $(a (sub a 2)) $(a (dec a)))))))
530+> %.(100 |=(a=@ ~+(?:((lth a 2) 1 (add $(a (sub a 2)) $(a (dec a)))))))
287573.147.844.013.817.084.101
531573.147.844.013.817.084.101
288```
532```
289
533
534+---
535+
290−### `~/` "sigfas"
536+## `~/` "sigfas"
537+
538+Jet registration for gate with registered context.
539+
540+#### Syntax
541+
542+Two arguments, fixed.
543+
544+<table>
545+<tr><th>Form</th><th>Syntax</th></tr>
546+<tr>
547+<td>Tall</td>
548+<td>
549+<pre>
550+~/ p
551+q
552+</pre>
553+</td>
554+</tr>
555+<tr>
556+<td>Wide</td>
557+<td>
558+<pre>
559+~/(p q)
560+</pre>
561+</td>
562+</tr>
563+<tr>
564+<td>Irregular</td>
565+<td>None.</td>
566+</tr>
567+</table>
568+
569+#### AST
291
570
571+```hoon
292−`[%sgfs p=term q=hoon]`: jet registration for gate with
572+[%sgfs p=term q=hoon]
293−registered context.
573+```
294
574
295−##### Expands to
575+#### Expands to
296
576
297```hoon
577```hoon
298~%(p +7 ~ q)
578~%(p +7 ~ q)
299```
579```
300
580
301−##### Syntax
302−
303−Regular: **2-fixed**.
304−
305−##### Examples
581+#### Examples
306
582
307From the kernel:
583From the kernel:
584+
308```hoon
585```hoon
309++ add
586++ add
310 ~/ %add
587 ~/ %add
@@ -314,139 +591,277 @@ From the kernel:
314 $(a (dec a), b +(b))
591 $(a (dec a), b +(b))
315```
592```
316
593
594+---
595+
317−### `~&` "sigpam"
596+## `~&` "sigpam"
597+
598+Debugging printf.
599+
600+#### Syntax
601+
602+Two arguments, fixed.
603+
604+<table>
605+<tr><th>Form</th><th>Syntax</th></tr>
606+<tr>
607+<td>Tall</td>
608+<td>
609+<pre>
610+~& p
611+q
612+</pre>
613+</td>
614+</tr>
615+<tr>
616+<td>Wide</td>
617+<td>
618+<pre>
619+~&(p q)
620+</pre>
621+</td>
622+</tr>
623+<tr>
624+<td>Irregular</td>
625+<td>None.</td>
626+</tr>
627+</table>
628+
629+#### AST
318
630
631+```hoon
319−`[%sgpm p=hoon q=hoon]`: debugging printf.
632+[%sgpm p=hoon q=hoon]
633+```
320
634
321−##### Expands to
635+#### Expands to
322
636
323`q`.
637`q`.
324
638
325−##### Product
639+#### Product
326
640
327Pretty-prints `p` on the console before computing `q`.
641Pretty-prints `p` on the console before computing `q`.
328
642
329−##### Discussion
643+#### Discussion
330
644
331−This rune has no semantic effect beyond the Hoon expression `q`. It's used solely to create a side-effect: printing the value of `p` to the console.
645+This rune has no semantic effect beyond the Hoon expression `q`. It's used
646+solely to create a side-effect: printing the value of `p` to the console.
332
647
333It's most useful for debugging programs.
648It's most useful for debugging programs.
334
649
335−##### Syntax
336−
337−Regular: **2-fixed**.
338−
339−##### Examples
650+#### Examples
340
651
341```
652```
342−~zod:dojo> ~&('halp' ~)
653+> ~&('halp' ~)
343'halp'
654'halp'
344~
655~
345
656
346−~zod:dojo> ~& 'halp'
657+> ~& 'halp'
347− ~
658+ ~
348'halp'
659'halp'
349~
660~
350```
661```
351
662
663+---
664+
352−### `~=` "sigtis"
665+## `~=` "sigtis"
666+
667+Detect duplicate.
668+
669+#### Syntax
670+
671+Two arguments, fixed.
672+
673+<table>
674+<tr><th>Form</th><th>Syntax</th></tr>
675+<tr>
676+<td>Tall</td>
677+<td>
678+<pre>
679+~= p
680+q
681+</pre>
682+</td>
683+</tr>
684+<tr>
685+<td>Wide</td>
686+<td>
687+<pre>
688+~=(p q)
689+</pre>
690+</td>
691+</tr>
692+<tr>
693+<td>Irregular</td>
694+<td>None.</td>
695+</tr>
696+</table>
697+
698+#### AST
353
699
700+```hoon
354−`[%sgts p=hoon q=hoon]`: detect duplicate.
701+[%sgts p=hoon q=hoon]
702+```
355
703
356−##### Expands to
704+#### Expands to
357
705
358`q`.
706`q`.
359
707
360−##### Convention
708+#### Convention
361
709
362If `p` equals `q`, produce `p` instead of `q`.
710If `p` equals `q`, produce `p` instead of `q`.
363
711
364−##### Discussion
712+#### Discussion
365
713
366Duplicate nouns are especially bad news in Hoon, because comparing them
714Duplicate nouns are especially bad news in Hoon, because comparing them
367−takes O(n) time. Use `~=` to avoid this inefficiency.
715+takes O(n) time. Use `~=` to avoid this inefficiency.
368
716
369−##### Examples
717+#### Examples
370
718
371This code traverses a tree and replaces all instances of `32` with
719This code traverses a tree and replaces all instances of `32` with
372`320`:
720`320`:
373
721
374```
722```
375−~zod:dojo> =foo |= a=(tree)
723+> =foo |= a=(tree)
376− ?~(a ~ ~=(a [?:(=(n.a 32) 320 n.a) $(a l.a) $(a r.a)]))
724+ ?~(a ~ ~=(a [?:(=(n.a 32) 320 n.a) $(a l.a) $(a r.a)]))
377
725
378−~zod:dojo> (foo 32 ~ ~)
726+> (foo 32 ~ ~)
379[320 ~ ~]
727[320 ~ ~]
380```
728```
381
729
382−Without `~=`, it would build a copy of a completely unchanged tree. Sad!
730+Without `~=`, it would build a copy of a completely unchanged tree. Sad!
383−
731+
732+---
733+
384−### `~?` "sigwut"
734+## `~?` "sigwut"
735+
736+Conditional debug printf.
737+
738+#### Syntax
739+
740+Three arguments, fixed.
741+
742+<table>
743+<tr><th>Form</th><th>Syntax</th></tr>
744+<tr>
745+<td>Tall</td>
746+<td>
747+<pre>
748+~? p
749+ q
750+r
751+</pre>
752+</td>
753+</tr>
754+<tr>
755+<td>Wide</td>
756+<td>
757+<pre>
758+~?(p q r)
759+</pre>
760+</td>
761+</tr>
762+<tr>
763+<td>Irregular</td>
764+<td>None.</td>
765+</tr>
766+</table>
767+
768+#### AST
385
769
770+```hoon
386−`[%sgwt p=hoon q=hoon r=hoon]`: conditional debug printf.
771+[%sgwt p=hoon q=hoon r=hoon]
772+```
387
773
388−##### Expands to
774+#### Expands to
389
775
390`r`.
776`r`.
391
777
392−##### Convention
778+#### Convention
393
779
394If `p` is true, prettyprints `q` on the console before computing `r`.
780If `p` is true, prettyprints `q` on the console before computing `r`.
395
781
396−##### Syntax
397−
398−Regular: **3-fixed**.
399−
400−##### Examples
782+#### Examples
401
783
402```
784```
403−~zod:dojo> ~?((gth 1 2) 'oops' ~)
785+> ~?((gth 1 2) 'oops' ~)
404~
786~
405
787
406−~zod:dojo> ~?((gth 1 0) 'oops' ~)
788+> ~?((gth 1 0) 'oops' ~)
407'oops'
789'oops'
408~
790~
409
791
410−~zod:dojo> ~? (gth 1 2)
792+> ~? (gth 1 2)
411− 'oops'
793+ 'oops'
412− ~
794+ ~
413~
795~
414
796
415−~zod:dojo> ~? (gth 1 0)
797+> ~? (gth 1 0)
416− 'oops'
798+ 'oops'
417− ~
799+ ~
418'oops'
800'oops'
419~
801~
420```
802```
421
803
804+---
805+
422−### `~!` "sigzap"
806+## `~!` "sigzap"
807+
808+Print type on compilation fail.
809+
810+#### Syntax
811+
812+Two arguments, fixed.
813+
814+<table>
815+<tr><th>Form</th><th>Syntax</th></tr>
816+<tr>
817+<td>Tall</td>
818+<td>
819+<pre>
820+~! p
821+q
822+</pre>
823+</td>
824+</tr>
825+<tr>
826+<td>Wide</td>
827+<td>
828+<pre>
829+~!(p q)
830+</pre>
831+</td>
832+</tr>
833+<tr>
834+<td>Irregular</td>
835+<td>None.</td>
836+</tr>
837+</table>
838+
839+#### AST
423
840
841+```hoon
424−`[%sgzp p=hoon q=hoon]`: print type on compilation fail.
842+[%sgzp p=hoon q=hoon]
843+```
425
844
426−##### Expands to
845+#### Expands to
427
846
428`q`.
847`q`.
429
848
430−##### Convention
849+#### Convention
431
850
432If compilation of `q` fails, prints the type of `p` in the trace.
851If compilation of `q` fails, prints the type of `p` in the trace.
433
852
434−##### Syntax
435−
436−Regular: **2-fixed**.
437−
438−##### Examples
853+#### Examples
439
854
440```
855```
441−~zod:dojo> a
856+> a
442! -find.a
857! -find.a
443
858
444−~zod:dojo> ~!('foo' a)
859+> ~!('foo' a)
445! @t
860! @t
446! find.a
861! find.a
447
862
448−~zod:dojo> ~! 'foo'
863+> ~! 'foo'
449− a
864+ a
450! @t
865! @t
451! find.a
866! find.a
452```
867```
content/docs/hoon/reference/rune/terminators.md+25−14
@@ -1,23 +1,26 @@
1+++
1+++
2title = "Terminators -- and =="
2title = "Terminators -- and =="
3−weight = 15
3+weight = 16
4template = "doc.html"
4template = "doc.html"
5+++
5+++
6−The `--` and `==` are used as terminators: `--` for core expressions, and `==` for terminating a 'running' or 'jogging' series of Hoon expressions.
7
6
8−## Runes
7+The `--` and `==` are used as terminators: `--` for core expressions, and `==`
8+for terminating a 'running' or 'jogging' series of Hoon expressions.
9
9
10−### `--` "hephep"
10+## `--` "hephep"
11
11
12−##### Syntax
12+#### Syntax
13
13
14The `--` rune is used to indicate the end of a core expression.
14The `--` rune is used to indicate the end of a core expression.
15
15
16−##### Discussion
16+#### Discussion
17
17
18+The `|%`, `|_`, and `|^` runes are used to create cores that can have
18−The `|%`, `|_`, and `|^` runes are used to create cores that can have arbitrarily many arms. When you have defined all the desired arms in a core expression (using the `++`, `+$`, and `+*` runes), use `--` to terminate the expression.
19+arbitrarily many arms. When you have defined all the desired arms in a core
20+expression (using the `++`, `+$`, and `+*` runes), use `--` to terminate the
21+expression.
19
22
20−##### Examples
23+#### Examples
21
24
22```
25```
23> =num |%
26> =num |%
@@ -36,17 +39,25 @@ The `|%`, `|_`, and `|^` runes are used to create cores that can have arbitraril
3624
3924
37```
40```
38
41
39−### `==` "tistis"
42+---
40
43
41−##### Syntax
44+## `==` "tistis"
42
45
43−The `==` rune is used to indicate the end of a 'jogging' or 'running' series of Hoon expressions.
46+#### Syntax
44
47
45−##### Discussion
48+The `==` rune is used to indicate the end of a 'jogging' or 'running' series of
49+Hoon expressions (runes that take a variable number of arguments).
46
50
47−Certain runes are used to create expressions that may include arbitrarily many subexpressions. Such expressions are terminated with the `==` rune. For example, the `:*` and `:~` runes are used to create a cell of any length. (The latter is just like the former except that it adds a null value at the end of the cell.) For another example, the `%=` rune used used to make arbitrarily many changes to a given wing value.
51+#### Discussion
48
52
53+Certain runes are used to create expressions that may include arbitrarily many
54+subexpressions. Such expressions are terminated with the `==` rune. For example,
55+the `:*` and `:~` runes are used to create a cell of any length. (The latter is
56+just like the former except that it adds a null value at the end of the cell.)
57+For another example, the `%=` rune used used to make arbitrarily many changes to
58+a given wing value.
59+
49−##### Examples
60+#### Examples
50
61
51```
62```
52> :* 2
63> :* 2
content/docs/hoon/reference/rune/tis.md+749−202
@@ -4,127 +4,287 @@ weight = 5
4template = "doc.html"
4template = "doc.html"
5+++
5+++
6
6
7−These runes modify the subject. (Or more precisely, they
7+These runes modify the subject. (Or more precisely, they
8evaluate at least one of their subexpressions with a modified subject.)
8evaluate at least one of their subexpressions with a modified subject.)
9
9
10## Overview
10## Overview
11
11
12−Hoon doesn't have variables in the ordinary sense. If you want to bind a name
12+Hoon doesn't have variables in the ordinary sense. If you want to bind a name
13to a value, e.g., `a` to `12`, you do so by pinning `12` to the subject and
13to a value, e.g., `a` to `12`, you do so by pinning `12` to the subject and
14−associating the name with it. This sort of operation is done with the `=`
14+associating the name with it. This sort of operation is done with the `=`
15family of runes.
15family of runes.
16
16
17−Let's say you have some old subject `p`. To 'pin' a value to the head means to
17+Let's say you have some old subject `p`. To 'pin' a value to the head means to
18−modify the subject by repacing it with a cell of `[new-value p]`. The head of
18+modify the subject by repacing it with a cell of `[new-value p]`. The head of
19−the cell is the new value. So to pin `12` with the face `a` the new subject
19+the cell is the new value. So to pin `12` with the face `a` the new subject
20would be: `[a=12 p]`.
20would be: `[a=12 p]`.
21
21
22Of course there are many variations on ways to modify the subject, useful for
22Of course there are many variations on ways to modify the subject, useful for
23−different situations. Hence the whole family of `=` runes.
23+different situations. Hence the whole family of `=` runes.
24+
25+---
26+
27+## `=>` "tisgar"
28+
29+Compose two expressions.
30+
31+#### Syntax
32+
33+Two arguments, fixed.
34+
35+<table>
36+<tr><th>Form</th><th>Syntax</th></tr>
37+<tr>
38+<td>Tall</td>
39+<td>
40+<pre>
41+=> p
42+q
43+</pre>
44+</td>
45+</tr>
46+<tr>
47+<td>Wide</td>
48+<td>
49+<pre>
50+=>(p q)
51+</pre>
52+</td>
53+</tr>
54+<tr>
55+<td>Irregular</td>
56+<td>None.</td>
57+</tr>
58+</table>
59+
60+#### AST
24
61
25−## Runes
62+```hoon
26−
27−### `=>` "tisgar"
28−
29−`[%tsgr p=hoon q=hoon]`: compose two expressions.
63+[%tsgr p=hoon q=hoon]
64+```
30
65
31−##### Produces
66+#### Produces
32
67
33the product of `q`, with the product of `p` taken as the subject.
68the product of `q`, with the product of `p` taken as the subject.
34
69
35−##### Syntax
36−
37−Regular: **2-fixed**.
38−
39−##### Examples
70+#### Examples
40
71
41```
72```
42> =>([a=1 b=2 c=3] b)
73> =>([a=1 b=2 c=3] b)
432
742
44
75
76+> => 9 .
77+9
78+
45> =>((add 2 4) [. .])
79> =>((add 2 4) [. .])
46[6 6]
80[6 6]
47−```
48
81
49−### `=|` "tisbar"
82+> =>
83+ |%
84+ ++ foo
85+ |= [a=@ b=@]
86+ [b a]
87+ --
88+ (foo 42 27)
89+[27 42]
90+```
50
91
92+---
93+
94+## `=|` "tisbar"
95+
96+Combine a named noun with the subject by "bunting" (producing the default value)
97+of a given mold.
98+
99+#### Syntax
100+
101+Two arguments, fixed.
102+
103+<table>
104+<tr><th>Form</th><th>Syntax</th></tr>
105+<tr>
106+<td>Tall</td>
107+<td>
108+<pre>
109+=| p
110+q
111+</pre>
112+</td>
113+</tr>
114+<tr>
115+<td>Wide</td>
116+<td>
117+<pre>
118+=|(p q)
119+</pre>
120+</td>
121+</tr>
122+<tr>
123+<td>Irregular</td>
124+<td>None.</td>
125+</tr>
126+</table>
127+
128+#### AST
51
129
130+```hoon
52−`[%tsbr p=spec q=hoon]`: combine a default type value with the subject.
131+[%tsbr p=spec q=hoon]
132+```
53
133
54−##### Expands to
134+#### Expands to
55
135
56```hoon
136```hoon
57=+(*p q)
137=+(*p q)
58```
138```
59
139
60−##### Syntax
140+#### Discussion
61−
62−Regular: **2-fixed**.
63
141
64−##### Discussion
142+The default (or 'bunt') value of `p` is pinned to the head of the subject.
143+Usually `p` includes a name for ease of reference.
65
144
66−The default (or 'bunt') value of `p` is pinned to the head of the subject. Usually `p` includes a name for ease of reference.
145+Speaking more loosely, `=|` usually "declares a variable" which is
146+"uninitialized," presumably because you'll set it in a loop or similar.
67
147
68−Speaking more loosely, `=|` usually "declares a variable" which is "uninitialized," presumably because you'll set it in a loop or similar.
69−
70−##### Examples
148+#### Examples
71
149
72```
150```
73−~zod:dojo> =foo |= a=@
151+> =| a=@ud a
74− =| b=@
152+0
75− =- :(add a b c)
153+
76− c=2
154+> =| a=[@t @t @t] a
77−~zod:dojo> (foo 5)
155+['' '' '']
78−7
79```
156```
80
157
158+---
159+
81−### `=:` "tiscol"
160+## `=:` "tiscol"
82
161
83−`[%tscl p=(list (pair wing hoon)) q=hoon]`: change multiple legs in the subject.
162+Change multiple legs in the subject.
84
163
85−##### Expands to
164+#### Syntax
165+
166+Two arguments: the first a variable number of pairs, the second is fixed.
167+
168+<table>
169+<tr><th>Form</th><th>Syntax</th></tr>
170+<tr>
171+<td>Tall</td>
172+<td>
173+<pre>
174+=: p1a p1b
175+ p2a p2b
176+ p3a p3b
177+ ==
178+q
179+</pre>
180+</td>
181+</tr>
182+<tr>
183+<td>Wide</td>
184+<td>
185+<pre>
186+=:(p1a p1b, p2a p2b, p3a p3b q)
187+</pre>
188+</td>
189+</tr>
190+<tr>
191+<td>Irregular</td>
192+<td>None.</td>
193+</tr>
194+</table>
195+
196+#### AST
86
197
87```hoon
198```hoon
88−=>(%_(. p) q)
199+[%tscl p=(list (pair wing hoon)) q=hoon]
89```
200```
90
201
91−##### Syntax
202+#### Expands to
92
203
93−Regular: **jogging**, then **1-fixed**.
204+```hoon
205+=>(%_(. p) q)
206+```
94
207
95−##### Discussion
208+#### Discussion
96
209
97This rune is like `=.`, but for modifying the values of multiple legs of the subject.
210This rune is like `=.`, but for modifying the values of multiple legs of the subject.
98
211
99−##### Examples
212+#### Examples
100
213
101```
214```
102−~zod:dojo> =+ a=[b=1 c=2]
215+> =+ a=[b=1 c=2]
103− =: c.a 4
216+ =: c.a 4
104− b.a 3
217+ b.a 3
105− ==
218+ ==
106− a
219+ a
107[b=3 c=4]
220[b=3 c=4]
108```
221```
109
222
223+---
224+
110−### `=,` "tiscom"
225+## `=,` "tiscom"
226+
227+Expose namespace.
228+
229+#### Syntax
230+
231+Two arguments, fixed.
232+
233+<table>
234+<tr><th>Form</th><th>Syntax</th></tr>
235+<tr>
236+<td>Tall</td>
237+<td>
238+<pre>
239+=, p
240+q
241+</pre>
242+</td>
243+</tr>
244+<tr>
245+<td>Wide</td>
246+<td>
247+<pre>
248+=,(p q)
249+</pre>
250+</td>
251+</tr>
252+<tr>
253+<td>Irregular</td>
254+<td>None.</td>
255+</tr>
256+</table>
257+
258+#### AST
111
259
260+```hoon
112−`[%tscm p=hoon q=hoon]`: expose namespace
261+[%tscm p=hoon q=hoon]
262+```
113
263
114−`p` evaluates to a noun with some namespace. From within `q` you may access `p`'s names without a wing path (i.e., you can use face `b` rather than `b.p`). This is especially useful for calling arms from an imported library core or for calling arms from a stdlib core repeatedly.
264+#### Produces
115
265
116−##### Syntax
266+`p` evaluates to a noun with some namespace. From within `q` you may access
267+`p`'s names without a wing path (i.e., you can use face `b` rather than `b.p`).
117
268
118−Regular: **2-fixed**.
269+#### Discussion
270+
271+This is especially useful for calling arms from an imported library core or for
272+calling arms from a stdlib core repeatedly. For example, JSON reparsers like
273+`so:dejs:format` and `of:dejs:format` can be called as `so` and `of` after
274+doing:
275+
276+```hoon
277+=, dejs:format
278+```
119
279
120−##### Examples
280+#### Examples
121
281
122With an imported core:
282With an imported core:
123
283
124```
284```
125> (sum -7 --7)
285> (sum -7 --7)
126-find.sum
286-find.sum
127−[crash message]
287+dojo: hoon expression failed
128
288
129> (sum:si -7 --7)
289> (sum:si -7 --7)
130--0
290--0
@@ -142,26 +302,61 @@ With a dojo-defined face:
142[2 4]
302[2 4]
143```
303```
144
304
305+---
306+
145−### `=.` "tisdot"
307+## `=.` "tisdot"
308+
309+Change one leg in the subject.
310+
311+#### Syntax
146
312
147−`[%tsdt p=wing q=hoon r=hoon]`: change one leg in the subject.
313+Three arguments, fixed.
148
314
149−##### Expands to
315+<table>
316+<tr><th>Form</th><th>Syntax</th></tr>
317+<tr>
318+<td>Tall</td>
319+<td>
320+<pre>
321+=. p q
322+r
323+</pre>
324+</td>
325+</tr>
326+<tr>
327+<td>Wide</td>
328+<td>
329+<pre>
330+=.(p q r)
331+</pre>
332+</td>
333+</tr>
334+<tr>
335+<td>Irregular</td>
336+<td>None.</td>
337+</tr>
338+</table>
339+
340+#### AST
150
341
151```hoon
342```hoon
152−=>(%_(. p q) r)
343+[%tsdt p=wing q=hoon r=hoon]
153```
344```
154
345
155−##### Syntax
346+#### Expands to
156
347
157−Regular: **3-fixed**.
348+```hoon
349+=>(%_(. p q) r)
350+```
158
351
159−##### Discussion
352+#### Discussion
160
353
161−Technically the `=.` rune doesn't change the subject. It creates
354+Technically the `=.` rune doesn't change the subject. It creates a new subject
162−a new subject just like the old one except for a changed value at `p`. Note that the mutation uses [`%_` ("cencab")](/docs/hoon/reference/rune/cen#cencab), so the type at `p` doesn't change. Trying to change the value type results in a `nest-fail`.
355+just like the old one except for a changed value at `p`. Note that the mutation
356+uses [`%_` ("cencab")](/docs/hoon/reference/rune/cen#cencab), so the type at `p`
357+doesn't change. Trying to change the value type results in a `nest-fail`.
163
358
164−##### Examples
359+#### Examples
165
360
166```
361```
167> =+ a=[b=1 c=2]
362> =+ a=[b=1 c=2]
@@ -178,62 +373,138 @@ a new subject just like the old one except for a changed value at `p`. Note tha
178nest-fail
373nest-fail
179```
374```
180
375
376+---
377+
181−### `=-` "tishep"
378+## `=-` "tishep"
379+
380+Combine a new noun with the subject, inverted.
381+
382+#### Syntax
383+
384+Two arguments, fixed.
385+
386+<table>
387+<tr><th>Form</th><th>Syntax</th></tr>
388+<tr>
389+<td>Tall</td>
390+<td>
391+<pre>
392+=- p
393+q
394+</pre>
395+</td>
396+</tr>
397+<tr>
398+<td>Wide</td>
399+<td>
400+<pre>
401+=-(p q)
402+</pre>
403+</td>
404+</tr>
405+<tr>
406+<td>Irregular</td>
407+<td>None.</td>
408+</tr>
409+</table>
410+
411+#### AST
182
412
413+```hoon
183−`[%tshp p=hoon q=hoon]`: combine a new noun with the subject, inverted.
414+[%tshp p=hoon q=hoon]
415+```
184
416
185−##### Expands to
417+#### Expands to
186
418
187```hoon
419```hoon
188=>([q .] p)
420=>([q .] p)
189```
421```
190
422
191−##### Syntax
423+#### Discussion
192−
193−Regular: **2-fixed**.
194
424
195−##### Discussion
425+`=-` is just like `=+` but its subexpressions are reversed. `=-` looks better
426+than `=+` when the expression you're pinning to the subject is much smaller than
427+the expression that uses it.
196
428
197−`=-` is just like `=+` but its subexpressions are reversed. `=-` looks better than `=+` when the expression you're pinning to the subject is much smaller than the expression that uses it.
198−
199−##### Examples
429+#### Examples
200
430
201```
431```
202−~zod:dojo> =foo |= a=@
432+> =foo |= a=@
203− =+ b=1
433+ =+ b=1
204− =- (add a b c)
434+ =- (add a b c)
205− c=2
435+ c=2
206−~zod:dojo> (foo 5)
436+> (foo 5)
2078
4378
208```
438```
209
439
440+---
441+
210−### `=^` "tisket"
442+## `=^` "tisket"
443+
444+Pin the head of a pair; change a leg with the tail.
211
445
212−`[%tskt p=skin q=wing r=hoon s=hoon]`: pin the head of a pair; change
446+#### Syntax
213−a leg with the tail.
214
447
215−##### Expands to
448+Four arguments, fixed.
449+
450+<table>
451+<tr><th>Form</th><th>Syntax</th></tr>
452+<tr>
453+<td>Tall</td>
454+<td>
455+<pre>
456+=^ p q
457+ r
458+s
459+</pre>
460+</td>
461+</tr>
462+<tr>
463+<td>Wide</td>
464+<td>
465+<pre>
466+=^(p q r s)
467+</pre>
468+</td>
469+</tr>
470+<tr>
471+<td>Irregular</td>
472+<td>None.</td>
473+</tr>
474+</table>
475+
476+#### AST
216
477
217```hoon
478```hoon
218−=/(p -.r =.(q +.r s))
479+[%tskt p=skin q=wing r=hoon s=hoon]
219```
480```
220
481
221−##### Syntax
482+#### Expands to
483+
484+```hoon
485+=/(p -.r =.(q +.r s))
486+```
222
487
223−Regular: **4-fixed**.
488+#### Discussion
224
489
225−##### Discussion
490+- `p` is a new name (optionally with type) to pin to the subject.
491+- `q` is the name of an existing wing of the subject.
492+- `r` is an expression that produces `[p-value new-q-value]`.
493+- `s` is some more code to be evaluted against the modified subject.
226
494
227−`p` is a new name (possibly with type annotation, e.g., `a=@`) of a value to be pinned to the subject. The value of `p` is the head of the product of `r`. `q` is given the value of the tail of `r`'s product. Then `s` is evaluated against this new subject.
495+This is a bit like doing `=/` and `=.` at the same time. It's useful for state
496+machines, where you want to produce both effects and a new state. For example,
497+many arms of a Gall agent produce `[effects new-state]` in the form of a `(quip card _this)`. In the `++on-poke` arm, you might have something like:
228
498
229−We generally use `=^` when we have a state machine with a function, `r`, that
499+```hoon
230−produces a cell, whose head is a result and whose tail is a new
500+=^ cards state
231−state. The head value is given a new name `p`, and the
501+ (handle-poke !<(action vase))
232−tail is stuffed back into wherever we stored the old state, `q`.
502+[cards this]
503+```
233
504
234This may also remind you of Haskell's State monad.
505This may also remind you of Haskell's State monad.
235
506
236−##### Examples
507+#### Examples
237
508
238The `og` core is a stateful pseudo-random number generator.
509The `og` core is a stateful pseudo-random number generator.
239We have to change the core state every time we generate a
510We have to change the core state every time we generate a
@@ -247,114 +518,269 @@ random number, so we use `=^`:
247[99 46]
518[99 46]
248```
519```
249
520
521+---
522+
250−### `=<` "tisgal"
523+## `=<` "tisgal"
524+
525+Compose two expressions, inverted.
526+
527+#### Syntax
528+
529+Two arguments, fixed
530+
531+<table>
532+<tr><th>Form</th><th>Syntax</th></tr>
533+<tr>
534+<td>Tall</td>
535+<td>
536+<pre>
537+=< p
538+q
539+</pre>
540+</td>
541+</tr>
542+<tr>
543+<td>Wide</td>
544+<td>
545+<pre>
546+=<(p q)
547+</pre>
548+</td>
549+</tr>
550+<tr>
551+<td>Irregular</td>
552+<td>
553+<pre>
554+p:q
555+</pre>
556+</td>
557+</tr>
558+</table>
559+
560+#### AST
251
561
562+```hoon
252−`[%tsgl p=hoon q=hoon]`: compose two expressions, inverted.
563+[%tsgl p=hoon q=hoon]
564+```
253
565
254−##### Expands to
566+#### Expands to
255
567
256```hoon
568```hoon
257=>(q p)
569=>(q p)
258```
570```
259
571
260−##### Syntax
261−
262−Regular: **2-fixed**.
263−
264−Irregular: `foo:baz` is `=<(foo baz)`.
265−
266−##### Discussion
572+#### Discussion
267
573
268`=<` is just `=>` backwards.
574`=<` is just `=>` backwards.
269
575
270−##### Examples
576+#### Examples
271
577
272```
578```
273−~zod:dojo> =<(b [a=1 b=2 c=3])
579+> =<(b [a=1 b=2 c=3])
2742
5802
275
581
276−~zod:dojo> =< b
582+> =< b
277− [a=1 b=2 c=3]
583+ [a=1 b=2 c=3]
2782
5842
279
585
280−~zod:dojo> b:[a=1 b=2 c=3]
586+> b:[a=1 b=2 c=3]
2812
5872
282
588
283−~zod:dojo> [. .]:(add 2 4)
589+> [. .]:(add 2 4)
284[6 6]
590[6 6]
285```
591```
286
592
593+---
594+
287−### `=+` "tislus"
595+## `=+` "tislus"
288−
596+
597+Combine a new noun with the subject.
598+
599+#### Syntax
600+
601+Two arguments, fixed.
602+
603+<table>
604+<tr><th>Form</th><th>Syntax</th></tr>
605+<tr>
606+<td>Tall</td>
607+<td>
608+<pre>
609+=+ p
610+q
611+</pre>
612+</td>
613+</tr>
614+<tr>
615+<td>Wide</td>
616+<td>
617+<pre>
618+=+(p q)
619+</pre>
620+</td>
621+</tr>
622+<tr>
623+<td>Irregular</td>
624+<td>None.</td>
625+</tr>
626+</table>
627+
628+#### AST
289
629
630+```hoon
290−`[%tsls p=hoon q=hoon]`: combine a new noun with the subject.
631+[%tsls p=hoon q=hoon]
632+```
291
633
292−##### Expands to
634+#### Expands to
293
635
294```hoon
636```hoon
295=>([p .] q)
637=>([p .] q)
296```
638```
297
639
298−##### Syntax
640+#### Discussion
299
641
300−Regular: **2-fixed**.
642+The subject of the `=+` expression, call it `a`, becomes the cell `[p a]` for
643+the evaluation of `q`. That is, `=+` 'pins a value', `p`, to the head of the
644+subject.
301
645
302−##### Discussion
646+Loosely speaking, `=+` is the simplest way of "declaring a variable."
303
647
304−The subject of the `=+` expression, call it `a`, becomes the cell `[p a]` for the evaluation of `q`. That is, `=+` 'pins a value', `p`, to the head of the subject.
648+#### Examples
305
649
306−Loosely speaking, `=+` is the simplest way of "declaring a variable."
650+```
651+> =+ 42 -
652+42
307
653
308−##### Examples
654+> =+ x=42 x
655+42
309
656
310−### `=;` "tismic"
657+> =+ [a='foo' b='bar'] a
658+'foo'
659+```
311
660
312−`[%tsmc p=skin q=hoon r=hoon]`: combine a named noun with the subject, possibly with type annotation; inverted order.
661+---
313
662
314−##### Expands to
663+## `=;` "tismic"
664+
665+Combine a named noun with the subject, possibly with type annotation; inverted
666+order.
667+
668+#### Syntax
669+
670+Three arguments, fixed.
671+
672+<table>
673+<tr><th>Form</th><th>Syntax</th></tr>
674+<tr>
675+<td>Tall</td>
676+<td>
677+<pre>
678+=; p
679+ q
680+r
681+</pre>
682+</td>
683+</tr>
684+<tr>
685+<td>Wide</td>
686+<td>
687+<pre>
688+=;(p q r)
689+</pre>
690+</td>
691+</tr>
692+<tr>
693+<td>Irregular</td>
694+<td>None.</td>
695+</tr>
696+</table>
697+
698+#### AST
315
699
316```hoon
700```hoon
317−=/(p r q)
701+[%tsmc p=skin q=hoon r=hoon]
318```
702```
319
703
320−##### Syntax
704+#### Expands to
321
705
322−Regular: **3-fixed**.
706+```hoon
707+=/(p r q)
708+```
323
709
324−##### Discussion
710+#### Discussion
325
711
326−`=;` is exactly like `=/` except that the order of its last two subexpressions is reversed.
712+`=;` is exactly like `=/` except that the order of its last two subexpressions
713+is reversed.
327
714
328−##### Examples
715+#### Examples
329
716
330```
717```
331−~zod:dojo> =foo |= a=@
718+> =foo |= a=@
332− =/ b 1
719+ =/ b 1
720+ =; c=@
333− =; c=@ :(add a b c)
721+ :(add a b c)
334− 2
722+ 2
335−~zod:dojo> (foo 5)
723+> (foo 5)
3368
7248
337```
725```
338
726
727+---
728+
339−### `=/` "tisfas"
729+## `=/` "tisfas"
730+
731+Combine a named noun with the subject, possibly with type annotation.
732+
733+#### Syntax
734+
735+Three arguments, fixed.
736+
737+<table>
738+<tr><th>Form</th><th>Syntax</th></tr>
739+<tr>
740+<td>Tall</td>
741+<td>
742+<pre>
743+=/ p
744+ q
745+r
746+</pre>
747+</td>
748+</tr>
749+<tr>
750+<td>Wide</td>
751+<td>
752+<pre>
753+=/(p q r)
754+</pre>
755+</td>
756+</tr>
757+<tr>
758+<td>Irregular</td>
759+<td>None.</td>
760+</tr>
761+</table>
762+
763+#### AST
340
764
765+```hoon
341−`[%tsfs p=skin q=hoon r=hoon]`: combine a named noun with the subject, possibly with type annotation.
766+[%tsfs p=skin q=hoon r=hoon]
767+```
342
768
343−##### Expands to
769+#### Expands to
344
770
345−**if `p` is a name**, (e.g. `a`):
771+if `p` is a name, (e.g. `a`):
346
772
347```hoon
773```hoon
348=+(^=(p q) r)
774=+(^=(p q) r)
349```
775```
350
776
351−**if `p` is a name with a type** (e.g., `a=@`):
777+if `p` is a name with a type (e.g., `a=@`):
352
778
353```hoon
779```hoon
354=+(^-(p q) r)
780=+(^-(p q) r)
355```
781```
356
782
357−##### Desugaring
783+#### Desugaring
358
784
359```hoon
785```hoon
360?@ p
786?@ p
@@ -364,76 +790,155 @@ Regular: **3-fixed**.
364r
790r
365```
791```
366
792
367−##### Syntax
793+#### Discussion
368
794
369−Regular: **3-fixed**.
795+`p` can be either a name or a `name=type`. If it's just a name, `=/` ("tisfas")
796+"declares a type-inferred variable." If it has a type, `=/` "declares a
797+type-checked variable."
370
798
371−##### Discussion
799+#### Examples
372
800
373−`p` can be either a name or a name=type. If it's just a name,
801+```
374−`=/` ("tisfas") "declares a type-inferred variable." If it has a type, `=/`
802+> =/ a=@t 'hello' a
375−"declares a type-checked variable."
803+'hello'
376
804
377−##### Examples
805+> =/ x [1 2 3] x
806+[1 2 3]
378
807
379−```
380−~zod:dojo> =foo |= a=@
808+> =foo |= a=@
381− =/ b 1
809+ =/ b 1
382− =/ c=@ 2
810+ =/ c=@ 2
383− :(add a b c)
811+ :(add a b c)
384−~zod:dojo> (foo 5)
812+> (foo 5)
3858
8138
386```
814```
387
815
816+---
817+
388−### `=~` "tissig"
818+## `=~` "tissig"
389−
819+
820+Compose many expressions.
821+
822+#### Syntax
823+
824+Variable number of arguments.
825+
826+<table>
827+<tr><th>Form</th><th>Syntax</th></tr>
828+<tr>
829+<td>Tall</td>
830+<td>
831+<pre>
832+=~ p1
833+ p2
834+ p3
835+ pn
836+==
837+</pre>
838+</td>
839+</tr>
840+<tr>
841+<td>Wide</td>
842+<td>
843+<pre>
844+=~(p1 p2 p3 pn)
845+</pre>
846+</td>
847+</tr>
848+<tr>
849+<td>Irregular</td>
850+<td>None.</td>
851+</tr>
852+</table>
853+
854+#### AST
390
855
856+```hoon
391−`[%tssg p=(list hoon)]`: compose many expressions.
857+[%tssg p=(list hoon)]
858+```
392
859
393−##### Produces
860+#### Produces
394
861
395The product of the chain composition.
862The product of the chain composition.
396
863
397−##### Syntax
398−
399−Regular: **running**.
400−
401−##### Examples
864+#### Examples
402
865
403```
866```
867+> =~ 10
868+ [20 .]
869+ [30 .]
870+ [40 .]
871+ .
872+ ==
873+[40 30 20 10]
874+
404−~zod:dojo> =~ [sub (mul 3 20) (add 10 20)]
875+> =~ [sub (mul 3 20) (add 10 20)]
405 (sub +)
876 (sub +)
406 +(.)
877 +(.)
407 ==
878 ==
40831
87931
409
880
410−~zod:dojo> =foo =| n=@
881+> =foo =| n=@
411− =< =~ increment
882+ =< =~ increment
412− increment
883+ increment
413− increment
884+ increment
414− n
885+ n
415− ==
886+ ==
416− |%
887+ |%
417− ++ increment
888+ ++ increment
418− ..increment(n +(n))
889+ ..increment(n +(n))
419− --
890+ --
420−~zod:dojo> foo
891+> foo
4213
8923
422```
893```
423
894
424−### `=*` "tistar" {#tistar}
895+---
425
896
426−`[%tstr p=term q=hoon r=hoon]`: define a deferred expression.
897+## `=*` "tistar" {#tistar}
427
898
428−##### Produces
899+Define a deferred expression.
429
900
430−`r`, compiled with a subject in which `p` is a deferred expression for `q`.
901+#### Syntax
431
902
432−##### Syntax
903+Three arguments, fixed.
433
904
434−Regular: **3-fixed**.
905+<table>
906+<tr><th>Form</th><th>Syntax</th></tr>
907+<tr>
908+<td>Tall</td>
909+<td>
910+<pre>
911+=* p
912+ q
913+r
914+</pre>
915+</td>
916+</tr>
917+<tr>
918+<td>Wide</td>
919+<td>
920+<pre>
921+=*(p q r)
922+</pre>
923+</td>
924+</tr>
925+<tr>
926+<td>Irregular</td>
927+<td>None.</td>
928+</tr>
929+</table>
930+
931+#### AST
435
932
933+```hoon
934+[%tstr p=term q=hoon r=hoon]
935+```
936+
937+#### Produces
938+
939+`r`, compiled with a subject in which `p` is a deferred expression for `q`.
940+
436−##### Discussion
941+#### Discussion
437
942
438`=*` assigns a name to an expression that will be evaluated in each place the
943`=*` assigns a name to an expression that will be evaluated in each place the
439name is dereferenced. This allows you to "write" through it to the original
944name is dereferenced. This allows you to "write" through it to the original
@@ -443,47 +948,89 @@ calculated every time you use `p`.
443This rune has some similarities with macros, and some similarities with aliases,
948This rune has some similarities with macros, and some similarities with aliases,
444but it is not really either.
949but it is not really either.
445
950
446−##### Examples
951+This rune is commonly used to give a Gall agent's state the name `state` like:
447
952
953+```hoon
954+=* state -
448```
955```
449−~zod:dojo>
956+
957+This lets you reference the whole `state` while also being able to reference its
958+individual elements like `foo` and `bar`, without having to do `foo.state`,
959+`bar.state`, etc.
960+
961+#### Examples
962+
963+```
450− =+ a=1
964+> =+ a=1
451− =* b a
965+ =* b a
452− [a b]
966+ [a b]
453[1 1]
967[1 1]
454
968
455−~zod:dojo>
456− =+ a=1
969+> =+ a=1
457− =* b a
970+ =* b a
458− =. a 2
971+ =. a 2
459− [a b]
972+ [a b]
460[2 2]
973[2 2]
461```
974```
462
975
463−### `=?` "tiswut"
976+---
464
977
465−`[$tswt p=wing q=hoon r=hoon s=hoon]`: conditionally change one leg in the subject.
978+## `=?` "tiswut"
466
979
467−##### Expands to
980+Conditionally change one leg in the subject.
468
981
469−```hoon
982+#### Syntax
983+
984+Four arguments, fixed.
985+
986+<table>
987+<tr><th>Form</th><th>Syntax</th></tr>
988+<tr>
989+<td>Tall</td>
990+<td>
991+<pre>
470−=. p ?:(q r p)
992+=? p q
993+ r
471s
994s
995+</pre>
996+</td>
997+</tr>
998+<tr>
999+<td>Wide</td>
1000+<td>
1001+<pre>
1002+=?(p q r s)
1003+</pre>
1004+</td>
1005+</tr>
1006+<tr>
1007+<td>Irregular</td>
1008+<td>None.</td>
1009+</tr>
1010+</table>
1011+
1012+#### AST
1013+
1014+```hoon
1015+[%tswt p=wing q=hoon r=hoon s=hoon]
472```
1016```
473
1017
474−##### Syntax
1018+#### Expands to
475
1019
476−Regular: **4-fixed**.
1020+```hoon
1021+=. p ?:(q r p)
1022+s
1023+```
477
1024
478−##### Discussion
1025+#### Discussion
479
1026
480Use `=?` to replace the value of leg `p` with `r` on condition `q`. As
1027Use `=?` to replace the value of leg `p` with `r` on condition `q`. As
481usual, we are not actually mutating the subject, just creating
1028usual, we are not actually mutating the subject, just creating
482−a new subject with a changed value. The change in value includes a
1029+a new subject with a changed value. The change in value includes a
483type check against the old subject; the type of `r` must nest under
1030type check against the old subject; the type of `r` must nest under
484the type of `p`.
1031the type of `p`.
485
1032
486−##### Examples
1033+#### Examples
487
1034
488```
1035```
489> =a 12
1036> =a 12
content/docs/hoon/reference/rune/wut.md+756−254
@@ -4,9 +4,10 @@ weight = 6
4template = "doc.html"
4template = "doc.html"
5aliases = ["docs/reference/hoon-expressions/rune/wut/"]
5aliases = ["docs/reference/hoon-expressions/rune/wut/"]
6+++
6+++
7+
7−Hoon has the usual program control branches. It also has the usual logical
8+Hoon has the usual program control branches. It also has the usual logical
8−operators: AND `?&`, OR `?|`, and NOT `?!`. It also has a `?=` rune that tests
9+operators: AND `?&`, OR `?|`, and NOT `?!`. It also has a `?=` rune that tests
9−whether a value matches a given type. In the course of type inference, Hoon
10+whether a value matches a given type. In the course of type inference, Hoon
10learns from `?=` tests in the test condition of [`?:` ("wutcol")](#wutcol)
11learns from `?=` tests in the test condition of [`?:` ("wutcol")](#wutcol)
11expressions.
12expressions.
12
13
@@ -16,321 +17,634 @@ All `?` runes reduce to `?:` and/or `?=`.
16
17
17If the condition of an `?:` is a `?=`, **and** the `?=` is
18If the condition of an `?:` is a `?=`, **and** the `?=` is
18testing a leg of the subject, the compiler specializes the subject
19testing a leg of the subject, the compiler specializes the subject
19−type for the branches of the `?:`. Branch inference also works
20+type for the branches of the `?:`. Branch inference also works
20for expressions which expand to `?:`.
21for expressions which expand to `?:`.
21
22
22The test does not have to be a single `?=`; the compiler can
23The test does not have to be a single `?=`; the compiler can
23analyze arbitrary boolean logic ([`?&` ("wutpam")](#wutpam),
24analyze arbitrary boolean logic ([`?&` ("wutpam")](#wutpam),
24[`?|` ("wutbar")](#wutbar), [`?!` ("wutzap")](#wutzap)) with full
25[`?|` ("wutbar")](#wutbar), [`?!` ("wutzap")](#wutzap)) with full
25−short-circuiting. Equality tests ([`.=` ("dottis")](/docs/hoon/reference/rune/dot#dottis)) are **not**
26+short-circuiting. Equality tests ([`.=` ("dottis")](/docs/hoon/reference/rune/dot#dottis)) are **not**
26analyzed.
27analyzed.
27
28
28If the compiler detects that the branch is degenerate (only one
29If the compiler detects that the branch is degenerate (only one
29side is taken), it fails with an error.
30side is taken), it fails with an error.
30
31
31−## Runes
32+---
33+
34+## `?|` "wutbar"
35+
36+Logical OR.
37+
38+#### Syntax
39+
40+Variable number of arguments.
41+
42+<table>
43+<tr><th>Form</th><th>Syntax</th></tr>
44+<tr>
45+<td>Tall</td>
46+<td>
47+<pre>
48+?| p1
49+ p2
50+ p3
51+ pn
52+==
53+</pre>
54+</td>
55+</tr>
56+<tr>
57+<td>Wide</td>
58+<td>
59+<pre>
60+?|(p1 p2 p3 pn)
61+</pre>
62+</td>
63+</tr>
64+<tr>
65+<td>Irregular</td>
66+<td>
67+<pre>
68+|(p1 p2 p3 pn)
69+</pre>
70+</td>
71+</tr>
72+</table>
73+
74+#### AST
32
75
33−### `?>` "wutgar"
76+```hoon
77+[%wtbr p=(list hoon)]
78+```
34
79
35−`[%wtgr p=hoon q=hoon]`: positive assertion.
80+#### Expands to
36
81
37−##### Expands to
82+**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
38
83
39```hoon
84```hoon
40−?.(p !! q)
85+?:(a & ?:(b & ?:(c & ?:(... ?:(z & |)))))
41```
86```
42
87
43−##### Syntax
88+#### Desugaring
44−
45−Regular: **2-fixed**.
46
89
47−##### Discussion
90+```hoon
91+|-
92+?~ p
93+ |
94+?: i.p
95+ &
96+$(p t.p)
97+```
48
98
49−`?>` is used to force a crash when some condition `p` doesn't yield 'yes', `%.y`.
99+#### Produces
50
100
51−It can be used for type inference, with the `?=` rune, to specify the type of a value.
101+If any argument evaluates to true (`%.y`), true. If all arguments evaluate to
102+false (`%.n`), false.
52
103
53−##### Examples
104+#### Examples
54
105
55```
106```
56−> ?>(=(3 3) %foo)
107+> |(=(6 42) =(42 42))
57−%foo
108+%.y
58−
59−> ?>(=(3 4) %foo)
60−ford: build failed
61−
62−> =a `*`123
63−
64−> `@`a
65−nest-fail
66
109
67−> ?>(?=(@ a) `@`a)
110+> |(=(6 42) =(42 43))
68−123
111+%.n
69```
112```
70
113
71−### `?|` "wutbar"
114+---
115+
116+## `?-` "wuthep"
117+
118+Switch against a union, with no default.
119+
120+#### Syntax
121+
122+One fixed argument, then a variable number of pairs.
123+
124+<table>
125+<tr><th>Form</th><th>Syntax</th></tr>
126+<tr>
127+<td>Tall style #1</td>
128+<td>
129+<pre>
130+?- p
131+ q1a q1b
132+ q2a q2b
133+ qna qnb
134+==
135+</pre>
136+</td>
137+</tr>
138+<tr>
139+<td>Tall style #2</td>
140+<td>
141+<pre>
142+?- p
143+ q1a
144+ q1b
145+::
146+ q2a
147+ q2b
148+::
149+ qna
150+ qnb
151+==
152+</pre>
153+</td>
154+</tr>
155+<tr>
156+<td>Wide</td>
157+<td>
158+<pre>
159+?-(p q1a q1b, q2a q2b, qna qnb)
160+</pre>
161+</td>
162+</tr>
163+<tr>
164+<td>Irregular</td>
165+<td>None.</td>
166+</tr>
167+</table>
168+
169+#### AST
72
170
73−`[%wtbr p=(list hoon)]`: logical OR.
171+```hoon
172+[%wthp p=wing q=(list (pair spec value))]
173+```
74
174
75−##### Expands to
175+#### Expands to
76
176
77−**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
177+**Pseudocode**: `a`, `b`, `c`, ... as elements of `q`:
78
178
79```hoon
179```hoon
80−?:(a & ?:(b & ?:(c & ?:(... ?:(z & |)))))
180+?: ?=(p.a p) q.a
181+?: ?=(p.b p) q.b
182+?: ?=(p.c p) q.c
183+...
184+~|(%mint-lost !!)
81```
185```
82
186
83−##### Desugaring
187+#### Desugaring
84
188
85```hoon
189```hoon
86|-
190|-
87−?~ p
191+?. q
88− |
192+ ~|(%mint-lost !!)
89−?: i.p
193+?: ?=(p.i.q p)
90− &
194+ q.i.q
91−$(p t.p)
195+$(q t.q)
92```
196```
93
197
94−##### Syntax
198+#### Discussion
199+
200+The `?-` rune is for a conditional expression in which the type of `p`
201+determines which branch is taken. Usually the type of `p` is a union of other
202+types. There is no default branch.
95
203
96−Regular: **running**.
204+The compiler makes sure that your code neither misses a case of the union, nor
205+includes a double case that isn't there. This is not special handling for `?-`,
206+just a consequence of the semantics of `?:`, which `?-` reduces to.
97
207
98−Irregular: `|(foo bar baz)` is `?|(foo bar baz)`.
208+A missing case will throw the `mint-lost` error. An extra case will throw
209+`mint-vain`.
99
210
100−##### Examples
211+#### Examples
101
212
102```
213```
103−~zod:dojo> |(=(6 42) =(42 42))
214+> =cor |= vat=?(%a %b)
104−%.y
215+ ?- vat
216+ %a 20
217+ %b 42
218+ ==
105
219
106−~zod:dojo> |(=(6 42) =(42 43))
220+> (cor %a)
107−%.n
221+20
222+
223+> (cor %b)
224+42
225+
226+> (cor %c)
227+! nest-fail
108```
228```
109
229
110−### `?:` "wutcol" {#wutcol}
230+---
111
231
112−`[%wtcl p=hoon q=hoon r=hoon]`: branch on a boolean test.
232+## `?:` "wutcol" {#wutcol}
113
233
114−##### Produces
234+Branch on a boolean test.
115
235
116−If `p` produces yes, `%.y`, then `q`. If `p` produces no, `%.n`, then `r`.
236+#### Syntax
117−If `p` is not a boolean, compiler yells at you.
118
237
119−##### Type inference
238+Three arguments, fixed.
120
239
121−The subject types of `q` and `r` are constrained to match any pattern-matching algebra in `p`. The analysis, which is conservative, understands any combination of [`?=`](#wuttis), [`?&`](#wutpam), [`?|`](#wutbar), and [`?!`](#wutzap), and infers the type of the subject appropriately when compiling.
240+<table>
241+<tr><th>Form</th><th>Syntax</th></tr>
242+<tr>
243+<td>Tall</td>
244+<td>
245+<pre>
246+?: p
247+ q
248+r
249+</pre>
250+</td>
251+</tr>
252+<tr>
253+<td>Wide</td>
254+<td>
255+<pre>
256+?:(p q r)
257+</pre>
258+</td>
259+</tr>
260+<tr>
261+<td>Irregular</td>
262+<td>None.</td>
263+</tr>
264+</table>
265+
266+#### AST
122
267
123−If test analysis reveals that either branch is never taken, or if `p` is not a boolean, compilation fails. An untaken branch is indicated with `mint-lost`.
268+```hoon
269+[%wtcl p=hoon q=hoon r=hoon]
270+```
124
271
125−##### Syntax
272+#### Produces
126
273
127−Regular: **3-fixed**.
274+If `p` produces true (`%.y`), then `q`. If `p` produces false (`%.n`), then `r`.
275+If `p` is not a boolean, compiler yells at you.
128
276
129−##### Discussion
277+#### Discussion
130
278
131−Short-circuiting in boolean tests works as you'd expect
279+If test analysis reveals that either branch is never taken, or if `p` is not a
132−and includes the expected inference. For instance,
280+boolean, compilation fails. An untaken branch is indicated with `mint-lost`.
133−if you write `?&(a b)`, `b` is only executed if `a` is
134−positive, and compiled with that assumption.
135
281
136Note also that all other branching expressions reduce to `?:`.
282Note also that all other branching expressions reduce to `?:`.
137
283
138−##### Examples
284+#### Examples
139
285
140```
286```
141−~zod:dojo> ?:((gth 1 0) 3 4)
287+> ?:((gth 1 0) 3 4)
1423
2883
143
289
144−~zod:dojo> ?: (gth 1 0)
290+> ?: (gth 1 0)
145− 3
291+ 3
146− 4
292+ 4
1473
2933
148
294
149−~zod:dojo> ?:((gth 1 2) 3 4)
295+> ?:((gth 1 2) 3 4)
1504
2964
151
297
152−~zod:dojo> ?: (gth 1 2)
298+> ?: (gth 1 2)
153− 3
299+ 3
154− 4
300+ 4
1554
3014
156```
302```
157
303
158−### `?.` "wutdot"
304+---
159
305
160−`[%wtdt p=hoon q=hoon r=hoon]`: branch on a boolean test, inverted.
306+## `?.` "wutdot"
161
307
162−##### Expands to
308+Branch on a boolean test, inverted.
309+
310+#### Syntax
311+
312+Three arguments, fixed.
313+
314+<table>
315+<tr><th>Form</th><th>Syntax</th></tr>
316+<tr>
317+<td>Tall</td>
318+<td>
319+<pre>
320+?. p
321+ q
322+r
323+</pre>
324+</td>
325+</tr>
326+<tr>
327+<td>Wide</td>
328+<td>
329+<pre>
330+?.(p q r)
331+</pre>
332+</td>
333+</tr>
334+<tr>
335+<td>Irregular</td>
336+<td>None.</td>
337+</tr>
338+</table>
339+
340+#### AST
163
341
164```hoon
342```hoon
165−?:(p r q)
343+[%wtdt p=hoon q=hoon r=hoon]
166```
344```
167
345
168−##### Syntax
346+#### Expands to
169
347
170−Regular: **3-fixed**.
348+```hoon
349+?:(p r q)
350+```
171
351
172−##### Discussion
352+#### Discussion
173
353
174`?.` is just like `?:`, but with its last two subexpressions reversed.
354`?.` is just like `?:`, but with its last two subexpressions reversed.
175
355
176−As is usual with inverted forms, use `?.` when the yes-case expression is much taller and/or wider than the no-case expression.
356+As is usual with inverted forms, use `?.` when the true-case expression is much
357+taller and/or wider than the false-case expression.
177
358
178−##### Examples
359+#### Examples
179
360
180```
361```
181−~zod:dojo> ?.((gth 1 2) 3 4)
362+> ?.((gth 1 2) 3 4)
1823
3633
183
364
184−~zod:dojo> ?.(?=(%a 'a') %not-a %yup)
365+> ?.(?=(%a 'a') %not-a %yup)
185%yup
366%yup
186
367
187−~zod:dojo> ?. %.y
368+> ?. %.y
188− 'this false case is less heavy than the true case'
369+ 'this false case is less heavy than the true case'
189− ?: =(2 3)
370+ ?: =(2 3)
190− 'two not equal to 3'
371+ 'two not equal to 3'
191− 'but see how \'r is much heavier than \'q?'
372+ 'but see how \'r is much heavier than \'q?'
192'but see how \'r is much heavier than \'q?'
373'but see how \'r is much heavier than \'q?'
193```
374```
194
375
195−### `?-` "wuthep"
376+---
196
377
197−`[%wthp p=wing q=(list (pair spec value))]`: switch against a union, with no default.
378+## `?^` "wutket"
198
379
199−##### Expands to
380+Branch on whether a wing of the subject is a cell.
200
381
201−**Pseudocode**: `a`, `b`, `c`, ... as elements of `q`:
382+#### Syntax
202
383
203−```hoon
384+Three arguments, fixed.
204−?: ?=(p.a p) q.a
205−?: ?=(p.b p) q.b
206−?: ?=(p.c p) q.c
207−...
208−~|(%mint-lost !!)
209−```
210
385
211−##### Desugaring
386+<table>
387+<tr><th>Form</th><th>Syntax</th></tr>
388+<tr>
389+<td>Tall</td>
390+<td>
391+<pre>
392+?^ p
393+ q
394+r
395+</pre>
396+</td>
397+</tr>
398+<tr>
399+<td>Wide</td>
400+<td>
401+<pre>
402+?^(p q r)
403+</pre>
404+</td>
405+</tr>
406+<tr>
407+<td>Irregular</td>
408+<td>None.</td>
409+</tr>
410+</table>
411+
412+#### AST
212
413
213```hoon
414```hoon
214−|-
415+[%wtkt p=wing q=hoon r=hoon]
215−?. q
216− ~|(%mint-lost !!)
217−?: ?=(p.i.q p)
218− q.i.q
219−$(q t.q)
220```
416```
221
417
222−##### Syntax
418+#### Expands to
223
419
224−Regular: **1-fixed**, then **jogging**.
420+```hoon
421+?:(?=(^ p) q r)
422+```
225
423
226−##### Discussion
424+#### Discussion
227
425
228−The `?-` rune is for a conditional expression in which the type of `p` determines which branch is taken. Usually the type of `p` is a union of other types. There is no default branch.
426+The type of the wing, `p`, must not be known to be either an atom or a cell, or
427+else you'll get a `mint-vain` error at compile time. `mint-vain` means that one
428+of the `?^` branches, `q` or `r`, is never taken.
229
429
230−The compiler makes sure that your code neither misses a case of
430+#### Examples
231−the union, nor includes a double case that isn't there. This is
232−not special handling for `?-`, just a consequence of the
233−semantics of `?:`, which `?-` reduces to.
234
431
235−A missing case will throw the `mint-lost` error. An extra case
432+```
433+> ?^(0 1 2)
236−will throw `mint-vain`.
434+! mint-vain
435+! exit
237
436
238−##### Examples
437+> ?^(`*`0 1 2)
438+2
239
439
440+> ?^(`*`[1 2] 3 4)
441+3
240```
442```
241−~zod:dojo> =cor |= vat=?(%a %b)
242− ?- vat
243− %a 20
244− %b 42
245− ==
246
443
247−~zod:dojo> (cor %a)
444+---
248−20
249
445
250−~zod:dojo> (cor %b)
446+## `?<` "wutgal"
251−42
252
447
253−~zod:dojo> (cor %c)
448+Negative assertion.
254−! nest-fail
255−```
256
449
257−### `?^` "wutket"
450+#### Syntax
258
451
259−`[%wtkt p=wing q=hoon r=hoon]`: branch on whether a wing
452+Two arguments, fixed.
260−of the subject is a cell.
261
453
262−##### Expands to
454+<table>
455+<tr><th>Form</th><th>Syntax</th></tr>
456+<tr>
457+<td>Tall</td>
458+<td>
459+<pre>
460+?< p
461+q
462+</pre>
463+</td>
464+</tr>
465+<tr>
466+<td>Wide</td>
467+<td>
468+<pre>
469+?<(p q)
470+</pre>
471+</td>
472+</tr>
473+<tr>
474+<td>Irregular</td>
475+<td>None.</td>
476+</tr>
477+</table>
478+
479+#### AST
263
480
264```hoon
481```hoon
265−?:(?=(^ p) q r)
482+[%wtgl p=hoon q=hoon]
266```
483```
267
484
268−##### Syntax
485+#### Expands to
269
486
270−Regular: **3-fixed**.
487+```hoon
488+?:(p !! q)
489+```
271
490
272−##### Discussion
491+#### Discussion
273
492
274−The type of the wing, `p`, must not be known to be either an atom or a cell, or else you'll get a `mint-vain` error at compile time. `mint-vain` means that one of the `?^` branches, `q` or `r`, is never taken.
493+`?<` is used to force a crash when some condition `p` doesn't yield false
494+(`%.n`). It can be used for type inference with the `?=` rune, much like the
495+`?>` rune.
275
496
276−##### Examples
497+#### Examples
277
498
278```
499```
279−~zod:dojo> ?^(0 1 2)
500+> ?<(=(3 4) %foo)
280−! mint-vain
501+%foo
281−! exit
282
502
283−~zod:dojo> ?^(`*`0 1 2)
503+> ?<(=(3 3) %foo)
284−2
504+dojo: hoon expression failed
285
505
286−~zod:dojo> ?^(`*`[1 2] 3 4)
506+> =a `*`[12 14]
287−3
507+
508+> `^`a
509+nest-fail
510+
511+> ?<(?=(@ a) `^`a)
512+[12 14]
288```
513```
289
514
290−### `?<` "wutgal"
515+---
516+
517+## `?>` "wutgar"
291
518
292−`[%wtgl p=hoon q=hoon]`: negative assertion.
519+Positive assertion.
293
520
294−##### Expands to
521+#### Syntax
522+
523+Two arguments, fixed.
524+
525+<table>
526+<tr><th>Form</th><th>Syntax</th></tr>
527+<tr>
528+<td>Tall</td>
529+<td>
530+<pre>
531+?> p
532+q
533+</pre>
534+</td>
535+</tr>
536+<tr>
537+<td>Wide</td>
538+<td>
539+<pre>
540+?>(p q)
541+</pre>
542+</td>
543+</tr>
544+<tr>
545+<td>Irregular</td>
546+<td>None.</td>
547+</tr>
548+</table>
549+
550+#### AST
295
551
296```hoon
552```hoon
297−?:(p !! q)
553+[%wtgr p=hoon q=hoon]
298```
554```
299
555
300−##### Syntax
556+#### Expands to
301−
302−Regular: **2-fixed**.
303
557
304−##### Discussion
558+```hoon
559+?.(p !! q)
560+```
305
561
306−`?<` is used to force a crash when some condition `p` doesn't yield 'no', `%.n`.
562+#### Discussion
307
563
564+`?>` is used to force a crash when some condition `p` doesn't yield true
308−It can be used for type inference with the `?=` rune, much like the `?>` rune.
565+(`%.y`). It can be used for type inference, with the `?=` rune, to specify the
566+type of a value.
309
567
310−##### Examples
568+#### Examples
311
569
312```
570```
313−> ?<(=(3 4) %foo)
571+> ?>(=(3 3) %foo)
314%foo
572%foo
315
573
316−> ?<(=(3 3) %foo)
574+> ?>(=(3 4) %foo)
317−ford: build failed
575+dojo: hoon expression failed
318
576
319−> =a `*`[12 14]
577+> =a `*`123
320
578
321−> `^`a
579+> `@`a
322nest-fail
580nest-fail
323
581
324−> ?<(?=(@ a) `^`a)
582+> ?>(?=(@ a) `@`a)
325−[12 14]
583+123
326```
584```
327
585
586+---
587+
328−### `?+` "wutlus"
588+## `?+` "wutlus"
589+
590+Switch against a union, with a default.
591+
592+#### Syntax
593+
594+Two fixed arguments, then a variable number of pairs.
595+
596+<table>
597+<tr><th>Form</th><th>Syntax</th></tr>
598+<tr>
599+<td>Tall style #1</td>
600+<td>
601+<pre>
602+?+ p q
603+ r1a r1b
604+ r2a r2b
605+ rna rnb
606+==
607+</pre>
608+</td>
609+</tr>
610+<tr>
611+<td>Tall style #2</td>
612+<td>
613+<pre>
614+?+ p q
615+ r1a
616+ r1b
617+::
618+ r2a
619+ r2b
620+::
621+ rna
622+ rnb
623+==
624+</pre>
625+</td>
626+</tr>
627+<tr>
628+<td>Wide</td>
629+<td>
630+<pre>
631+?+(p q r1a r1b, r2a r2b, rna rnb)
632+</pre>
633+</td>
634+</tr>
635+<tr>
636+<td>Irregular</td>
637+<td>None.</td>
638+</tr>
639+</table>
640+
641+#### AST
329
642
643+```hoon
330−`[%wtls p=wing q=hoon r=(list (pair spec hoon))]`: switch against
644+[%wtls p=wing q=hoon r=(list (pair spec hoon))]
331−a union, with a default.
645+```
332
646
333−##### Expands to
647+#### Expands to
334
648
335**Pseudocode**: `a`, `b`, `c`, ... as elements of `r`:
649**Pseudocode**: `a`, `b`, `c`, ... as elements of `r`:
336
650
@@ -342,7 +656,7 @@ a union, with a default.
342q
656q
343```
657```
344
658
345−##### Desugaring
659+#### Desugaring
346
660
347```hoon
661```hoon
348|-
662|-
@@ -353,40 +667,82 @@ q
353$(r t.r)
667$(r t.r)
354```
668```
355
669
356−##### Syntax
357−
358−Regular: **2-fixed**, then **jogging**.
359−
360−##### Discussion
670+#### Discussion
361
671
672+The `?+` rune is for a conditional expression in which the type of `p`
362−The `?+` rune is for a conditional expression in which the type of `p` determines which branch is taken. Usually the type of `p` is a union of other types. If `p`'s type doesn't match the case for any given branch, the default expression, `q`, is evaluated.
673+determines which branch is taken. Usually the type of `p` is a union of other
674+types. If `p`'s type doesn't match the case for any given branch, the default
675+expression, `q`, is evaluated.
363
676
364If there is a case that is never taken you'll get a `mint-vain` error.
677If there is a case that is never taken you'll get a `mint-vain` error.
365
678
366−##### Examples
679+#### Examples
367
680
368```
681```
369−~zod:dojo> =cor |= vat=@tas
682+> =cor |= vat=@tas
370− ?+ vat 240
683+ ?+ vat 240
371− %a 20
684+ %a 20
372− %b 42
685+ %b 42
373− ==
686+ ==
374
687
375−~zod:dojo> (cor %a)
688+> (cor %a)
37620
68920
377
690
378−~zod:dojo> (cor %b)
691+> (cor %b)
37942
69242
380
693
381−~zod:dojo> (cor %c)
694+> (cor %c)
382240
695240
383```
696```
384
697
698+---
699+
385−### `?&` "wutpam"
700+## `?&` "wutpam"
701+
702+Logical AND.
703+
704+#### Syntax
705+
706+Variable arguments.
707+
708+<table>
709+<tr><th>Form</th><th>Syntax</th></tr>
710+<tr>
711+<td>Tall</td>
712+<td>
713+<pre>
714+?& p1
715+ p2
716+ pn
717+==
718+</pre>
719+</td>
720+</tr>
721+<tr>
722+<td>Wide</td>
723+<td>
724+<pre>
725+?&(p1 p2 pn)
726+</pre>
727+</td>
728+</tr>
729+<tr>
730+<td>Irregular</td>
731+<td>
732+<pre>
733+&(p1 p2 pn)
734+</pre>
735+</td>
736+</tr>
737+</table>
738+
739+#### AST
386
740
741+```hoon
387−`[%wtpm p=(list hoon)]`: logical AND.
742+[%wtpm p=(list hoon)]
743+```
388
744
389−##### Expands to
745+#### Expands to
390
746
391**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
747**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
392
748
@@ -394,7 +750,7 @@ If there is a case that is never taken you'll get a `mint-vain` error.
394?.(a | ?.(b | ?.(c | ?.(... ?.(z | &)))))
750?.(a | ?.(b | ?.(c | ?.(... ?.(z | &)))))
395```
751```
396
752
397−##### Desugaring
753+#### Desugaring
398
754
399```hoon
755```hoon
400|-
756|-
@@ -405,136 +761,282 @@ If there is a case that is never taken you'll get a `mint-vain` error.
405$(p t.p)
761$(p t.p)
406```
762```
407
763
408−##### Syntax
764+#### Produces
409−
410−Regular: **running**.
411
765
412−Irregular: `&(foo bar baz)` is `?&(foo bar baz)`.
766+If ALL arguments evaluate to true (`%.y`), true (`%.y`). If one or more evalute
767+to false (`%.n`), false (`%.n`).
413
768
414−##### Examples
769+#### Examples
415
770
416```
771```
417−~zod:dojo> &(=(6 6) =(42 42))
772+> &(=(6 6) =(42 42))
418%.y
773%.y
419
774
420−~zod:dojo> &(=(6 7) =(42 43))
775+> &(=(6 7) =(42 42))
421%.n
776%.n
422```
777```
423
778
424−### `?~` "wutsig"
779+---
425
780
426−`[%wtsg p=wing q=hoon r=hoon]`: branch on whether a wing of the subject is null.
781+## `?@` "wutpat"
427
782
428−##### Expands to
783+Branch on whether a wing of the subject is an atom.
784+
785+#### Syntax
786+
787+Three arguments, fixed.
788+
789+<table>
790+<tr><th>Form</th><th>Syntax</th></tr>
791+<tr>
792+<td>Tall</td>
793+<td>
794+<pre>
795+?@ p
796+ q
797+r
798+</pre>
799+</td>
800+</tr>
801+<tr>
802+<td>Wide</td>
803+<td>
804+<pre>
805+?@(p q r)
806+</pre>
807+</td>
808+</tr>
809+<tr>
810+<td>Irregular</td>
811+<td>None.</td>
812+</tr>
813+</table>
814+
815+#### AST
429
816
430```hoon
817```hoon
818+[%wtpt p=wing q=hoon r=hoon]
819+```
820+
821+#### Expands to
822+
823+```hoon
431−?:(?=($~ p) q r)
824+?:(?=(@ p) q r)
432```
825```
433
826
434−##### Syntax
827+#### Produces
435
828
436−Regular: **3-fixed**.
829+If `p` is an atom, `q`. If `p` is a cell, `r`.
437
830
438−##### Discussion
831+#### Discussion
439
832
440−It's bad style to use `?~` to test for any zero atom. Use it only for a true null, `~`.
833+The type of the wing, `p`, must not be known to be either an atom or a cell, or
834+else you'll get a `mint-vain` error at compile time. `mint-vain` means that one
835+of the `?@` branches, `q` or `r`, is never taken.
441
836
442−##### Examples
837+#### Examples
443
838
444```
839```
445−~zod:dojo> =foo ""
840+> ?@(0 1 2)
841+! mint-vain
842+! exit
446
843
447−~zod:dojo> ?~(foo 1 2)
844+> ?@(`*`0 1 2)
4481
8451
846+
847+> ?@(`*`[1 2] 3 4)
848+4
449```
849```
450
850
451−### `?=` "wuttis"
851+---
852+
853+## `?~` "wutsig"
452
854
453−`[%wtts p=spec q=wing]`: test pattern match.
855+Branch on whether a wing of the subject is null.
454
856
455−##### Produces
857+#### Syntax
456
858
457−`%.y` (yes) if the noun at `q` is in the type of `p`; `%.n` (no) otherwise.
859+Three arguments, fixed.
458
860
861+<table>
459−##### Syntax
862+<tr><th>Form</th><th>Syntax</th></tr>
863+<tr>
864+<td>Tall</td>
865+<td>
866+<pre>
867+?~ p
868+ q
869+r
870+</pre>
871+</td>
872+</tr>
873+<tr>
874+<td>Wide</td>
875+<td>
876+<pre>
877+?~(p q r)
878+</pre>
879+</td>
880+</tr>
881+<tr>
882+<td>Irregular</td>
883+<td>None.</td>
884+</tr>
885+</table>
886+
887+#### AST
460
888
461−Regular: **2-fixed**.
889+```hoon
890+[%wtsg p=wing q=hoon r=hoon]
891+```
462
892
463−##### Discussion
893+#### Expands to
464
894
465−`?=` is not as powerful as it might seem. For instance, it
895+```hoon
466−can't generate a loop -- you cannot (and should not) use it to
896+?:(?=($~ p) q r)
467−test whether a `*` is a `(list @)`. Nor can it validate atomic
897+```
468−auras.
469
898
470−Patterns should be as weak as possible. Unpack one layer of
899+#### Produces
471−union at a time. Don't confirm things the type system knows.
472
900
473−For example, when matching from a tagged union for the type `[%foo p=@
901+If `p` is null (`~`), `q`. If `p` is non-null, `r`.
474−q=[@ @]]`, the appropriate pattern is `[%foo *]`. You have one
475−question, which is whether the head of the noun is `%foo`.
476
902
477−A common error is `find.$`, meaning `p` is not a type.
903+#### Discussion
904+
905+It's bad style to use `?~` to test for any zero atom. Use it only for a true
906+null, `~`.
478
907
479−##### Examples
908+#### Examples
480
909
481```
910```
482−~zod:dojo> =bar [%foo %bar %baz]
911+> =foo ""
483−~zod:dojo> ?=([%foo *] bar)
912+
484−%.y
913+> ?~(foo 1 2)
914+1
485```
915```
486
916
487−### `?@` "wutpat"
917+---
918+
919+## `?=` "wuttis"
920+
921+Test pattern match.
922+
923+#### Syntax
488
924
489−`[%wtpt p=wing q=hoon r=hoon]`: branch on whether a wing of the subject is an atom.
925+Two arguments, fixed.
490
926
491−##### Expands to
927+<table>
928+<tr><th>Form</th><th>Syntax</th></tr>
929+<tr>
930+<td>Tall</td>
931+<td>
932+<pre>
933+?= p
934+q
935+</pre>
936+</td>
937+</tr>
938+<tr>
939+<td>Wide</td>
940+<td>
941+<pre>
942+?=(p q)
943+</pre>
944+</td>
945+</tr>
946+<tr>
947+<td>Irregular</td>
948+<td>None.</td>
949+</tr>
950+</table>
951+
952+#### AST
492
953
493```hoon
954```hoon
494−?:(?=(@ p) q r)
955+[%wtts p=spec q=wing]
495```
956```
496
957
497−##### Syntax
958+#### Produces
498
959
499−Regular: **3-fixed**.
960+`%.y` (true) if the noun at `q` is in the type of `p`; `%.n` (false) otherwise.
500
961
501−##### Discussion
962+#### Discussion
502
963
503−The type of the wing, `p`, must not be known to be either an atom or a cell, or else you'll get a `mint-vain` error at compile time. `mint-vain` means that one of the `?@` branches, `q` or `r`, is never taken.
964+`?=` is not as powerful as it might seem. For instance, it
965+can't generate a loop -- you cannot (and should not) use it to
966+test whether a `*` is a `(list @)`. Nor can it validate atomic
967+auras.
504
968
505−##### Examples
969+Patterns should be as weak as possible. Unpack one layer of
970+union at a time. Don't confirm things the type system knows.
506
971
507−```
972+For example, when matching from a tagged union for the type `[%foo p=@ q=[@ @]]`, the appropriate pattern is `[%foo *]`. You have one
508−~zod:dojo> ?@(0 1 2)
973+question, which is whether the head of the noun is `%foo`.
509−! mint-vain
510−! exit
511
974
512−~zod:dojo> ?@(`*`0 1 2)
975+A common error is `find.$`, meaning `p` is not a type.
513−1
976+
977+#### Examples
514
978
515−~zod:dojo> ?@(`*`[1 2] 3 4)
979+```
516−4
980+> =bar [%foo %bar %baz]
981+> ?=([%foo *] bar)
982+%.y
517```
983```
518
984
985+---
986+
519−### `?!` "wutzap"
987+## `?!` "wutzap"
988+
989+Logical NOT.
990+
991+#### Syntax
992+
993+One argument, fixed.
994+
995+<table>
996+<tr><th>Form</th><th>Syntax</th></tr>
997+<tr>
998+<td>Tall</td>
999+<td>
1000+<pre>
1001+?! p
1002+</pre>
1003+</td>
1004+</tr>
1005+<tr>
1006+<td>Wide</td>
1007+<td>
1008+<pre>
1009+?!(p)
1010+</pre>
1011+</td>
1012+</tr>
1013+<tr>
1014+<td>Irregular</td>
1015+<td>
1016+<pre>
1017+!p
1018+</pre>
1019+</td>
1020+</tr>
1021+</table>
1022+
1023+#### AST
520
1024
1025+```hoon
521−`[%wtzp p=hoon]`: logical NOT.
1026+[%wtzp p=hoon]
1027+```
522
1028
523−##### Expands to
1029+#### Expands to
524
1030
525```hoon
1031```hoon
526.=(| p)
1032.=(| p)
527```
1033```
528
1034
529−Produces the logical NOT of `p`.
1035+#### Produces
530−
531−##### Syntax
532−
533−Regular: **1-fixed**.
534
1036
535−Irregular: `!foo` is `?!(foo)`.
1037+The logical NOT of `p`, which must evaluate to either `%.y` or `%.n`.
536
1038
537−##### Examples
1039+#### Examples
538
1040
539```
1041```
540~zod:dojo> ?!(.=(1 2))
1042~zod:dojo> ?!(.=(1 2))
content/docs/hoon/reference/rune/zap.md+514−122
@@ -5,60 +5,179 @@ template = "doc.html"
5aliases = ["docs/reference/hoon-expressions/rune/zap/"]
5aliases = ["docs/reference/hoon-expressions/rune/zap/"]
6+++
6+++
7
7
8−## Runes
8+## `!,` "zapcom"
9+
10+Produce the Hoon AST of an expression.
11+
12+#### Syntax
13+
14+Two arguments, fixed.
15+
16+<table>
17+<tr><th>Form</th><th>Syntax</th></tr>
18+<tr>
19+<td>Tall</td>
20+<td>
21+<pre>
22+!, p
23+q
24+</pre>
25+</td>
26+</tr>
27+<tr>
28+<td>Wide</td>
29+<td>
30+<pre>
31+!,(p q)
32+</pre>
33+</td>
34+</tr>
35+<tr>
36+<td>Irregular</td>
37+<td>None.</td>
38+</tr>
39+</table>
40+
41+#### AST
9
42
10−### `!>` "zapgar"
43+```hoon
44+[%zpcm p=hoon q=hoon]
45+```
11
46
12−`[%zpgr p=hoon]`: wrap a noun in its type.
47+#### Discussion
13
48
14−##### Produces
49+This produces the [`$hoon`](/docs/hoon/reference/stdlib/4o#hoon) AST of
50+expression `q`. The first argument, `p`, is always an example of the `$hoon`
51+type, typically just the `*hoon` bunt value, and is used for type inference. The
52+reason for `p` is just to handle transitions if the `$hoon` type changes.
15
53
16−A cell whose tail is the product of `p`, and whose head is the static type of `p`.
54+#### Examples
17
55
18−##### Syntax
56+```
57+> !, *hoon [1 1]
58+[%cltr p=~[[%sand p=%ud q=1] [%sand p=%ud q=1]]]
19
59
20−Regular: **1-fixed**.
60+> !, *hoon (add 1 1)
61+[%cncl p=[%wing p=~[%add]] q=~[[%sand p=%ud q=1] [%sand p=%ud q=1]]]
62+```
21
63
22−##### Discussion
64+---
65+
66+## `!>` "zapgar"
67+
68+Wrap a noun in its type (form a [`vase`](/docs/hoon/reference/stdlib/4o#vase)).
69+
70+#### Syntax
71+
72+One argument, fixed.
73+
74+<table>
75+<tr><th>Form</th><th>Syntax</th></tr>
76+<tr>
77+<td>Tall</td>
78+<td>
79+<pre>
80+!> p
81+</pre>
82+</td>
83+</tr>
84+<tr>
85+<td>Wide</td>
86+<td>
87+<pre>
88+!>(p)
89+</pre>
90+</td>
91+</tr>
92+<tr>
93+<td>Irregular</td>
94+<td>None.</td>
95+</tr>
96+</table>
97+
98+#### AST
23
99
24−In Hoon, a dynamic type is a static type compiled at runtime. This type-noun cell is generally called a `vase`.
100+```hoon
101+[%zpgr p=hoon]
102+```
25
103
104+#### Produces
105+
106+A cell whose tail is the product of `p`, and whose head is the static type of `p`.
107+
108+#### Discussion
109+
110+In Hoon, a dynamic type is a static type compiled at runtime. This type-noun
111+cell is generally called a [`vase`](/docs/hoon/reference/stdlib/4o#vase).
112+
26−##### Examples
113+#### Examples
27
114
28```
115```
29> !>(1)
116> !>(1)
30[#t/@ud q=1]
117[#t/@ud q=1]
31```
118```
32
119
33−If you want just the type value, use a 'type spear'. This is `-:!>`, i.e., the head of the cell produced by `!>`:
120+If you want just the type value, use a 'type spear'. This is `-:!>`, i.e., the
121+head of the cell produced by `!>`:
34
122
35```
123```
36> -:!>(1)
124> -:!>(1)
37#t/@ud
125#t/@ud
38```
126```
39
127
128+---
129+
40−### `!<` "zapgal"
130+## `!<` "zapgal"
41−
131+
42−`[%zpld p=spec q=hoon]`
132+Extracts a [`vase`](/docs/hoon/reference/stdlib/4o#vase) to the given mold if
133+its type nests.
134+
135+#### Syntax
136+
137+Two arguments, fixed.
138+
139+<table>
140+<tr><th>Form</th><th>Syntax</th></tr>
141+<tr>
142+<td>Tall</td>
143+<td>
144+<pre>
145+!< p
146+q
147+</pre>
148+</td>
149+</tr>
150+<tr>
151+<td>Wide</td>
152+<td>
153+<pre>
154+!<(p q)
155+</pre>
156+</td>
157+</tr>
158+<tr>
159+<td>Irregular</td>
160+<td>None.</td>
161+</tr>
162+</table>
163+
164+#### AST
43
165
44−Takes a mold and a `vase` and dynamically checks that the type in the `vase`
166+```hoon
45−matches the mold.
167+[%zpgl p=spec q=hoon]
168+```
46
169
47−##### Produces
170+#### Produces
48
171
49−The value of `vase` typed with the type of the mold if possible, else a
172+The value of vase `q` typed with the type of mold `p` if possible, else a
50`nest-fail`.
173`nest-fail`.
51
174
52−##### Syntax
175+#### Discussion
53−
54−Regular: **2-fixed**
55
176
56−##### Discussion
177+This is something like a partial inverse to the `!>` rune and can be used to
178+extract a typed value from a `vase`.
57
179
58−This is something like a partial inverse to the `!>` rune and can be used to extract
59−a typed value from a `vase`.
60−
61−##### Examples
180+#### Examples
62
181
63```
182```
64> !< @ !> ~zod
183> !< @ !> ~zod
@@ -67,105 +186,124 @@ a typed value from a `vase`.
67> !< @p !> 0
186> !< @p !> 0
68nest-fail
187nest-fail
69
188
70−> =m !> 0
189+> !< tape !>("foobar")
71−> =n !> 1
190+"foobar"
72−> !< [@ @] (slop m n)
73−[0 1]
74```
191```
75
192
76−### `!:` "zapcol"
193+---
77−
194+
78−`[%dbug p=hoon]`: turn on stack trace
195+## `!;` "zapmic"
79−
196+
80−##### Produces
197+Wrap a noun in its type (raw).
81−
198+
82−The product of `p` unless `p` crashes, in which case a stack trace is given.
83−
84−##### Syntax
199+#### Syntax
85−
200+
86−Regular: **1-fixed**.
201+Two arguments, fixed.
202+
203+<table>
204+<tr><th>Form</th><th>Syntax</th></tr>
205+<tr>
206+<td>Tall</td>
207+<td>
208+<pre>
209+!; p
210+q
211+</pre>
212+</td>
213+</tr>
214+<tr>
215+<td>Wide</td>
216+<td>
217+<pre>
218+!;(p q)
219+</pre>
220+</td>
221+</tr>
222+<tr>
223+<td>Irregular</td>
224+<td>None.</td>
225+</tr>
226+</table>
227+
228+#### AST
87
229
88```hoon
230```hoon
89−!: p=hoon
231+[%zpmc p=hoon q=hoon]
90−```
91−
92−##### Discussion
93−
94−`!:` is used to turn on a debugging stack trace option for any code you have in `p`.
95−
96−##### Examples
97−
98```
232```
99−> ?:(=(0 1) 123 !!)
100−ford: %ride failed to execute:
101
233
102−> !: ?:(=(0 1) 123 !!)
234+#### Discussion
103−/~zod/base/~2018.10.15..19.50.06..74af:<[1 5].[1 22]>
104−/~zod/base/~2018.10.15..19.50.06..74af:<[1 19].[1 21]>
105−ford: %ride failed to execute:
106−```
107
235
108−### `!.` "zapdot"
236+This wraps the product of `q` in its inferred type. It's a raw version of
237+[`!>`](#-zapgar). Unlike zapgar, `q` is not given a `p` face and its type
238+information is not stripped to a raw noun.
109
239
110−Turn off stack trace for a subexpression `p`
240+The first field, `p`, must be an example of the
241+[`$type`](/docs/hoon/reference/stdlib/4o#type) type, typically just `*type` (the
242+bunt of `$type`). The `p` argument is just so transitions can be handled if the
243+`$type` type changes.
111
244
112−##### Produces
245+It's unlikely you'd use this rune directly; [`!>`](#-zapgar) is much more
246+typical.
113
247
114−The product of `p`. If `p` crashes, no stack trace entries are given for that code.
248+#### Examples
115−
116−##### Syntax
117−
118−Regular: **1-fixed**.
119
249
120−```hoon
121−!. p=hoon
122```
250```
251+> !; *type [1 1]
252+[#t/[@ud @ud] 1 1]
123
253
124−`p` is any Hoon expression.
254+> !; *type 'foo'
125−
255+[#t/@t 'foo']
126−##### Discussion
127−
128−`!.` is used to turn off a debugging stack trace option for any code you have in `p`. This rune can be embedded under a `!:` rune for inner loops of your code that you don't want or need to trace. This is especially useful if a trace overflows the stack.
129−
130−##### Examples
131−
132```
256```
133−> %.(1 |=(a=@ ^-(@ ?:(=(a 10) !! $(a +(a))))))
134−ford: %ride failed to execute:
135
257
136−> !: %.(1 |=(a=@ ^-(@ ?:(=(a 10) !! $(a +(a))))))
258+---
137−/~zod/base/~2018.10.15..20.01.21..6b0c:<[1 5].[1 49]>
259+
138−/~zod/base/~2018.10.15..20.01.21..6b0c:<[1 17].[1 47]>
260+## `!=` "zaptis"
139−/~zod/base/~2018.10.15..20.01.21..6b0c:<[1 22].[1 46]>
261+
140−/~zod/base/~2018.10.15..20.01.21..6b0c:<[1 36].[1 45]>
262+Make the Nock formula for a Hoon expression.
141−...skipping some lines...
263+
142−/~zod/base/~2018.10.15..20.01.21..6b0c:<[1 17].[1 47]>
264+#### Syntax
143−/~zod/base/~2018.10.15..20.01.21..6b0c:<[1 22].[1 46]>
265+
144−/~zod/base/~2018.10.15..20.01.21..6b0c:<[1 33].[1 35]>
266+One argument, fixed.
145−ford: %ride failed to execute:
267+
268+<table>
269+<tr><th>Form</th><th>Syntax</th></tr>
270+<tr>
271+<td>Tall</td>
272+<td>
273+<pre>
274+!= p
275+</pre>
276+</td>
277+</tr>
278+<tr>
279+<td>Wide</td>
280+<td>
281+<pre>
282+!=(p)
283+</pre>
284+</td>
285+</tr>
286+<tr>
287+<td>Irregular</td>
288+<td>None.</td>
289+</tr>
290+</table>
291+
292+#### AST
146
293
147−> !: %.(1 !.(|=(a=@ ^-(@ ?:(=(a 10) !! $(a +(a)))))))
294+```hoon
148−/~zod/base/~2018.10.15..20.01.35..0529:<[1 5].[1 53]>
295+[%zpts p=hoon]
149−ford: %ride failed to execute:
150```
296```
151
297
152−### `!=` "zaptis"
153−
154−`[%zpts p=hoon]`: make the Nock formula for a Hoon expression.
155−
156−##### Produces
298+#### Produces
157
299
158The Nock generated by `p`.
300The Nock generated by `p`.
159
301
160−##### Syntax
161−
162−Regular: **1-fixed**.
163−
164−##### Discussion
302+#### Discussion
165
303
166Don't confuse `!=` with a negation, `!`, followed by a test for equality, `=(10 11)`.
304Don't confuse `!=` with a negation, `!`, followed by a test for equality, `=(10 11)`.
167
305
168−##### Examples
306+#### Examples
169
307
170```
308```
171> !=(20)
309> !=(20)
@@ -188,53 +326,307 @@ Don't confuse the `!=` rune with:
188%.n
326%.n
189```
327```
190
328
191−The syntax difference is that a test for equality takes two subexpressions, and the `!=` rune only one.
329+The syntax difference is that a test for equality takes two subexpressions, and
330+the `!=` rune only one.
331+
332+---
333+
334+## `!?` "zapwut"
335+
336+Restrict Hoon version.
337+
338+#### Syntax
339+
340+Two arguments, fixed.
341+
342+<table>
343+<tr><th>Form</th><th>Syntax</th></tr>
344+<tr>
345+<td>Tall</td>
346+<td>
347+<pre>
348+!? p
349+q
350+</pre>
351+</td>
352+</tr>
353+<tr>
354+<td>Wide</td>
355+<td>
356+<pre>
357+!?(p q)
358+</pre>
359+</td>
360+</tr>
361+<tr>
362+<td>Irregular</td>
363+<td>None.</td>
364+</tr>
365+</table>
366+
367+#### AST
368+
369+```hoon
370+[%zpwt p=$@(p=@ [p=@ q=@]) q=hoon]
371+```
192
372
193−### `!?` "zapwut"
373+#### Produces
194
374
195−`[%zpwt p=@ q=hoon]`: restrict Hoon version.
375+When `p` is an atom:
196
376
197−##### Produces
377+- `q` if `p` ≥ Hoon kelvin version, otherwise crash.
198
378
199−`q`, if `p` is greater than or equal to the Hoon kelvin version.
379+When `p` is a cell:
200−(Versions count down; the current version is 140.)
201
380
202−##### Syntax
381+- `q`, if `p.p` ≥ Hoon kelvin version ≥ `q.p`, otherwise crash.
203
382
204−Regular: **2-fixed**.
383+(Versions count down; the current version is 140.)
205
384
206−##### Examples
385+#### Examples
207
386
208```
387```
209−> !?(264 (add 2 2))
388+> !? [142 140] (add 2 2)
2104
3894
211
390
212−> !?(164 (add 2 2))
391+> !? 142 (add 2 2)
2134
3924
214
393
215−> !?(64 (add 2 2))
394+> !? 64 (add 2 2)
216! exit
395! exit
217```
396```
218
397
219−### `!!` "zapzap"
398+---
399+
400+## `!@` "zappat"
401+
402+Branch on whether a wing exists.
403+
404+#### Syntax
405+
406+Three arguments, fixed.
407+
408+<table>
409+<tr><th>Form</th><th>Syntax</th></tr>
410+<tr>
411+<td>Tall</td>
412+<td>
413+<pre>
414+!@ p
415+ q
416+r
417+</pre>
418+</td>
419+</tr>
420+<tr>
421+<td>Wide</td>
422+<td>
423+<pre>
424+!@(p q r)
425+</pre>
426+</td>
427+</tr>
428+<tr>
429+<td>Irregular</td>
430+<td>None.</td>
431+</tr>
432+</table>
433+
434+#### AST
220
435
221−`[%zpzp ~]`: crash.
436+```hoon
437+[%zppt p=(list wing) q=hoon r=hoon]
438+```
222
439
223−##### Produces
440+#### Discussion
224
441
225−Nothing. Always crashes, with type `%void`.
442+`p` is a wing reference like `foo`, `bar.foo`, etc. If `p` exists, `q`. If `p`
443+does not exist, `r`. Essentially, this is like `?:` for wing existence.
226
444
227−##### Syntax
445+#### Examples
228
446
229−`!!`
447+```
448+> =foo 42
449+
450+> !@(foo 'exists' 'does not exist')
451+'exists'
452+
453+> !@(baz 'exists' 'does not exist')
454+'does not exist'
455+```
230
456
457+---
458+
459+## `!!` "zapzap"
460+
461+Crash.
462+
463+#### Syntax
464+
465+No arguments.
466+
467+<table>
468+<tr><th>Form</th><th>Syntax</th></tr>
469+<tr>
470+<td>Tall</td>
471+<td>
472+<pre>
473+!!
474+</pre>
475+</td>
476+</tr>
477+<tr>
478+<td>Wide</td>
479+<td>
480+<pre>
481+!!
482+</pre>
483+</td>
484+</tr>
485+<tr>
486+<td>Irregular</td>
487+<td>None.</td>
488+</tr>
489+</table>
490+
491+#### AST
492+
493+```hoon
494+[%zpzp ~]
495+```
496+
497+#### Produces
498+
499+Nothing. Always crashes, with type `%void`.
500+
231−##### Discussion
501+#### Discussion
232
502
233`%void` nests in every other type, so you can stub out anything with `!!`.
503`%void` nests in every other type, so you can stub out anything with `!!`.
234
504
235−##### Examples
505+#### Examples
236
506
237```
507```
238> !!
508> !!
239−ford: build failed
509+dojo: hoon expression failed
510+```
511+
512+---
513+
514+## `!:` "zapcol"
515+
516+Turn on stack trace.
517+
518+#### Syntax
519+
520+One argument, fixed
521+
522+<table>
523+<tr><th>Form</th><th>Syntax</th></tr>
524+<tr>
525+<td>Tall</td>
526+<td>
527+<pre>
528+!: p
529+</pre>
530+</td>
531+</tr>
532+<tr>
533+<td>Wide</td>
534+<td>
535+<pre>
536+!:(p)
537+</pre>
538+</td>
539+</tr>
540+<tr>
541+<td>Irregular</td>
542+<td>None.</td>
543+</tr>
544+</table>
545+
546+#### Produces
547+
548+The product of `p` unless `p` crashes, in which case a stack trace is given.
549+
550+#### Discussion
551+
552+`!:` is used to turn on a debugging stack trace option for any code you have in
553+`p`.
554+
555+#### Examples
556+
240```
557```
558+> ?:(=(0 1) 123 !!)
559+dojo: hoon expression failed
560+
561+> !: ?:(=(0 1) 123 !!)
562+/~zod/base/~2022.4.2..08.54.53..07d7:<[1 5].[1 22]>
563+/~zod/base/~2022.4.2..08.54.53..07d7:<[1 19].[1 21]>
564+dojo: hoon expression failed
565+```
566+
567+---
568+
569+## `!.` "zapdot"
570+
571+Turn off stack trace for a subexpression `p`
572+
573+#### Syntax
574+
575+One argument, fixed.
576+
577+<table>
578+<tr><th>Form</th><th>Syntax</th></tr>
579+<tr>
580+<td>Tall</td>
581+<td>
582+<pre>
583+!. p
584+</pre>
585+</td>
586+</tr>
587+<tr>
588+<td>Wide</td>
589+<td>
590+<pre>
591+!.(p)
592+</pre>
593+</td>
594+</tr>
595+<tr>
596+<td>Irregular</td>
597+<td>None.</td>
598+</tr>
599+</table>
600+
601+#### Produces
602+
603+The product of `p`. If `p` crashes, no stack trace entries are given for that code.
604+
605+#### Discussion
606+
607+`!.` is used to turn off a debugging stack trace option for any code you have in
608+`p`. This rune can be embedded under a `!:` rune for inner loops of your code
609+that you don't want or need to trace. This is especially useful if a trace
610+overflows the stack.
611+
612+#### Examples
613+
614+```
615+> %.(1 |=(a=@ ^-(@ ?:(=(a 10) !! $(a +(a))))))
616+dojo: hoon expression failed
617+
618+> !: %.(1 |=(a=@ ^-(@ ?:(=(a 10) !! $(a +(a))))))
619+/~zod/base/~2022.4.2..08.56.45..5ecc:<[1 5].[1 49]>
620+/~zod/base/~2022.4.2..08.56.45..5ecc:<[1 17].[1 47]>
621+/~zod/base/~2022.4.2..08.56.45..5ecc:<[1 22].[1 46]>
622+...skipping some lines...
623+/~zod/base/~2022.4.2..08.56.45..5ecc:<[1 22].[1 46]>
624+/~zod/base/~2022.4.2..08.56.45..5ecc:<[1 33].[1 35]>
625+dojo: hoon expression failed
626+
627+> !: %.(1 !.(|=(a=@ ^-(@ ?:(=(a 10) !! $(a +(a)))))))
628+/~zod/base/~2022.4.2..08.57.07..d40b:<[1 5].[1 53]>
629+dojo: hoon expression failed
630+```
631+
632+---
lib/glossary.js+7
@@ -91,6 +91,13 @@ export const glossary = [
91 slug: "/docs/hoon/reference/rune/zap/#-zapwut",
91 slug: "/docs/hoon/reference/rune/zap/#-zapwut",
92 desc: "<code>[%zpwt p=@ q=hoon]</code>: restrict Hoon version.",
92 desc: "<code>[%zpwt p=@ q=hoon]</code>: restrict Hoon version.",
93 },
93 },
94+ {
95+ name: "zappat",
96+ symbol: "!@",
97+ usage: "wild",
98+ slug: "/docs/hoon/reference/rune/zap/#-zappat",
99+ desc: "<code>[%zppt p=(list wing) q=hoon r=hoon]</code>: branch on wing existence.",
100+ },
94 {
101 {
95 name: "zapzap",
102 name: "zapzap",
96 symbol: "!!",
103 symbol: "!!",