on master help sign in
Merge branch 'master' into mp/pass-href
commit5e8115aab59b3bb62ad310f639bf4aa4a769b340 authorMatilde Park <matilde.park@urbit.org> dateThu 5 May 2022, 13:32 (4 years ago) parent2211d569a94572
45 files changed+6392−2172
components/ContentArea.js+3−3 components/Search.js+3−1 components/TableOfContents.js+2−2 content/docs/hoon/reference/auras.md+10−1 content/docs/hoon/reference/rune/_index.md+6−1 content/docs/hoon/reference/rune/bar.md+603−327 content/docs/hoon/reference/rune/buc.md+624−215 content/docs/hoon/reference/rune/cen.md+468−187 content/docs/hoon/reference/rune/col.md+364−143 content/docs/hoon/reference/rune/constants.md+101−82 content/docs/hoon/reference/rune/dot.md+243−74 content/docs/hoon/reference/rune/fas.md+257 content/docs/hoon/reference/rune/ket.md+436−128 content/docs/hoon/reference/rune/lus.md+107−41 content/docs/hoon/reference/rune/mic.md+384−143 content/docs/hoon/reference/rune/sig.md+582−167 content/docs/hoon/reference/rune/terminators.md+25−14 content/docs/hoon/reference/rune/tis.md+749−202 content/docs/hoon/reference/rune/wut.md+756−254 content/docs/hoon/reference/rune/zap.md+514−122 content/docs/hoon/reference/stdlib/2n.md+21−13 content/docs/userspace/threads/examples/child-thread.md+3−3 content/docs/userspace/threads/gall/poke-thread.md+1−1 content/docs/userspace/threads/gall/start-thread.md+2−2 content/docs/userspace/threads/gall/stop-thread.md+1−1 content/docs/userspace/threads/gall/take-facts.md+1−1 content/docs/userspace/threads/gall/take-result.md+1−1 content/docs/userspace/threads/reference.md+1−1 content/grants/app-openbsd.md+5−1 content/grants/astrolabe.md+7−7 content/grants/filesharer.md+3−3 content/groups/~fabled-faster/structure.md+1−1 content/groups/~fabled-faster/wind.md+1−1 content/groups/~hatryx-lastud/other-life.md+1−1 content/groups/~rondev/group-discovery.md+9 content/groups/~todset-partug/urmetica.md+9 content/groups/~wacrep-lossul/encyclosphere.md+9 content/groups/~winder-dapsym/urchan.md+9 content/ids/sogrum-savluc.md+11 content/ids/tiplec-lacnyx.md+6 lib/glossary.js+8−1 pages/docs/[[...slug]].js+10 pages/ids/submit.js+4−4 pages/index.js+27−23 styles/markdown.css+4
components/ContentArea.js+3−3
@@ -44,7 +44,7 @@ export default function ContentArea(props) {
4444 <div className="w-full min-w-0 flex flex-col items-center">
4545 <div
4646 ref={scrollBox}
47− className="px-4 md:px-12 lg:px-24 pb-24 pt-8 md:pt-10 lg:pt-16 flex flex-col w-full max-w-screen-xl max-h-screen h-screen overflow-y-scroll"
47+ className="px-4 md:px-12 lg:px-24 pt-8 md:pt-10 lg:pt-16 flex flex-col w-full max-w-screen-xl max-h-screen h-screen overflow-y-scroll"
4848 >
4949 <div className="flex justify-between w-full items-center shrink-0">
5050 <div className="type-ui text-wall-500">{props.breadcrumbs}</div>
@@ -65,13 +65,13 @@ export default function ContentArea(props) {
6565 <Section narrow className={""}>
6666 <h2 className="mb-16 mt-24">{props.title}</h2>
6767 {props.children}
68− <div className="pb-32" />
68+ <div className="pb-24" />
6969 </Section>
7070 ) : (
7171 <div className="min-w-0">
7272 <h2 className="mb-16 mt-24">{props.title}</h2>
7373 {props.children}
74− <div className="pb-32" />
74+ <div className="pb-24" />
7575 </div>
7676 )}
7777 <TableOfContents
components/Search.js+3−1
@@ -25,7 +25,9 @@ class Search extends Component {
2525
2626 glossarySearch(query) {
2727 return glossary.filter((entry) => {
28− return query.toLowerCase() === entry.name || entry.symbol === query;
28+ return (
29+ entry.name.includes(query.toLowerCase()) || entry.symbol.includes(query)
30+ );
2931 });
3032 }
3133
components/TableOfContents.js+2−2
@@ -55,13 +55,13 @@ const Headings = ({ headings, activeId }) => (
5555 {headings.map((heading, index) => (
5656 <li key={heading.id}>
5757 <a
58− className={index === 0 ? "font-bold" : "font-medium"}
58+ className={index === 0 ? "font-bold" : "font-medium text-sm"}
5959 href={`#${heading.id}`}
6060 >
6161 {heading.title}
6262 </a>
6363 {heading.items.length > 0 && (
64− <ul className="pl-2">
64+ <ul className="pl-2 text-xs">
6565 {heading.items.map((child) => (
6666 <li
6767 key={child.id}
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
1616Aura Meaning Example Literal Syntax
1717-------------------------------------------------------------------------
1818@ empty aura
19−@c Unicode codepoint ~-~45fed
19+@c UTF-32 ~-~45fed
2020@d date
2121 @da absolute date ~2018.5.14..22.31.46..1435
2222 @dr relative date (ie, timespan) ~h5.m30.s12
@@ -66,23 +66,30 @@ two, starting from A.
6666
6767A given aura nests under any aura whose name is a substring or extension of the
6868given aura:
69+
6970```
7071> :- (~(nest ut [%atom %ud ~]) | [%atom %u ~])
7172 (~(nest ut [%atom %ud ~]) | [%atom %udx ~])
7273[%.y %.y]
7374```
75+
7476but does not nest "sideways":
77+
7578```
7679> (~(nest ut [%atom %ud ~]) | [%atom %ux ~])
7780%.n
7881```
82+
7983We call auras "soft types" since this nesting behavior can be ignored. Auras are
8084non-coercive, but conversions may have to go via the empty aura, e.g.
85+
8186```
8287> ^-(@ud ^-(@ 'foo'))
83887.303.014
8489```
90+
8591This is implicitly done by the irregular form of `^-`.
92+
8693```
8794> `@ud`'foo'
88957.303.014
@@ -91,8 +98,10 @@ This is implicitly done by the irregular form of `^-`.
9198### Bunting
9299
93100The bunt value for all auras is 0 except for `@da`.
101+
94102```
95103> *@da
96104~2000.1.1
97105```
106+
98107A 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"
66aliases = ["docs/reference/hoon-expressions/rune/"]
77insert_anchor_links = "right"
88+++
9+
910Runes are a way to form expressions in Hoon.
1011
1112## Non-Rune Expressions
1213
1314### [Constants](/docs/hoon/reference/rune/constants)
1415
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).
1617
1718### [Limbs and Wings](/docs/hoon/reference/limbs/)
1819
@@ -68,6 +69,10 @@ Miscellaneous useful macros.
6869
6970Runes that use Nock `11` to pass non-semantic info to the interpreter.
7071
72+### [`/ fas` (Imports)](/docs/hoon/reference/rune/fas)
73+
74+Ford runes which import files.
75+
7176### [`--`, `==` (Terminators)](/docs/hoon/reference/rune/terminators)
7277
7378Runes used to terminate expressions.
content/docs/hoon/reference/rune/bar.md+603−327
@@ -4,64 +4,89 @@ weight = 7
44template = "doc.html"
55aliases = ["docs/reference/hoon-expressions/rune/bar/"]
66+++
7+
78Core 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
910needed to run those formulas correctly.
1011
11−Five core runes (`|=`, `|.`, `|-`, `|*`, and `|$`) produce a
12−core with a single arm, named `$`. As with all arms, we can recompute `$``
13−with changes, which is useful for recursion among other things.
12+Five core runes (`|=`, `|.`, `|-`, `|*`, and `|$`) produce a core with a single
13+arm, named `$`. As with all arms, we can recompute `$` with changes, which is
14+useful for recursion among other things.
1415
15−## Runes
16+## `|$` "barbuc"
1617
17−### |$ "barbuc"
18+Declares a mold builder wet gate with one or more molds as its sample.
1819
19−Declares a mold builder wet gate with one or more molds as its
20−sample.
20+#### Syntax
2121
22−##### Syntax
22+Two arguments, fixed.
2323
24−Regular:
25−```hoon
26−|$ a=(lest term) b=spec
27−```
24+<table>
25+<tr><th>Form</th><th>Syntax</th></tr>
26+<tr>
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
2850
29−AST:
3051```hoon
31−[%brbs sample=(lest term) body=spec]
52+[%brbc sample=(lest term) body=spec]
3253```
3354
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
4256
4357```hoon
4458|$ [a b]
4559body
4660```
61+
4762becomes
63+
4864```hoon
4965|* [a=$~(* $-(* *)) b=$~(* $-(* *))]
5066^:
5167body
5268```
5369
54−##### Discussion
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+
77+#### Discussion
5578
5679A mold builder is a wet gate from one or more molds to a mold. A mold is a
5780function from nouns to nouns with types that may be partial, is always
5881idempotent, and usually the identity function on the noun itself.
5982
60−`|$` is a restricted form of `|*`. The use of `|$` over `|*` is one of style, as either could
61−be used to make wet gates that are mold builders. The buc in `|$` is a hint that
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
63−wet gate. Thus, the second argument of `|$` is frequently a buc
64−rune. For further discussion of wet gates, see the entry for [`|*`](#bartar).
83+`|$` is a restricted form of `|*`. The use of `|$` over `|*` is one of style, as
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
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`.
88+Thus, the second argument of `|$` is frequently a buc rune. For further
89+discussion of wet gates, see the entry for [`|*`](#-bartar).
6590
6691Like other single-arm cores, the arm for `|$` is named `$` and this can be used to
6792define recursive structures. Note however that Hoon is evaluated eagerly, and so
@@ -69,53 +94,58 @@ infinite structures are not permitted.
6994
7095Proper style for `|$` is to enclose the first argument with brackets, even if it
7196is 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`.
7399
74−##### Examples
100+#### Examples
75101
76102```
77−~zod:dojo> =foo |$([a b] [b a])
103+> =foo |$([a b] [b a])
78104
79−~zod:dojo> =bar (foo [@ @tas])
105+> =bar (foo [@ @tas])
80106
81−~zod:dojo> (bar %cat 3)
107+> (bar %cat 3)
82108[%cat 3]
83109```
84110
85−### `|_` "barcab"
111+---
112+
113+## `|_` "barcab"
86114
87115Produce a **door** (a core with a sample).
88116
89−##### Syntax
117+#### Syntax
90118
91−Regular:
119+One fixed argument, then a variable number of `+`-family expressions.
92120
93−```hoon
121+<table>
122+<tr><th>Form</th><th>Syntax</th></tr>
123+<tr>
124+<td>Tall</td>
125+<td>
126+<pre>
94127|_ a=spec
95128++ b=term c=hoon
96129++ d=term e=hoon
97130 ...
98131++ f=term g=hoon
99132--
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>
101139
102140Note: The `++` rune may be replaced with any other rune in the `+` family.
103141
104−AST:
142+#### AST
105143
106−```
144+```hoon
107145[%brcb p=spec q=alas r=(map term tome)]
108146```
109147
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
119149
120150```hoon
121151=| a=spec
@@ -127,29 +157,49 @@ The context of the door is the subject of the `|_` expression.
127157--
128158```
129159
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.
131164
132−A door is the general case of a gate (function). A gate is a
133−door with only one arm, which has the name `$`.
165+`a` defines the door sample type and usually includes a name assignment (e.g.,
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.
134171
135−Calling a door is like calling a gate except the caller also needs
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)`.
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+
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
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)`.
137183
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
139−is an irregular form for `%~($ foo baz)`, [%~](/docs/hoon/reference/rune/cen#censig).
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)`,
187+[%~](/docs/hoon/reference/rune/cen#censig).
140188
141−##### Examples
189+#### Examples
142190
143191A trivial door:
144192
145193```
146−/~zod:dojo> =mol |_ a=@ud
147− ++ succ +(a)
148− ++ prev (dec a)
149− --
150−/~zod:dojo> ~(succ mol 1)
194+> =mol |_ a=@ud
195+ ++ succ +(a)
196+ ++ prev (dec a)
197+ --
198+
199+> ~(succ mol 1)
1512002
152−/~zod:dojo> ~(succ mol ~(succ mol ~(prev mol 5)))
201+
202+> ~(succ mol ~(succ mol ~(prev mol 5)))
1532036
154204```
155205
@@ -172,174 +222,246 @@ The `ne` door prints a digit in base 10, 16, 32 or 64:
172222'c'
173223```
174224
175−### `|%` "barcen"
225+---
176226
177−Produce a core, `[battery payload]`.
227+## `|:` "barcol"
178228
179−##### Syntax
229+Produce a gate with a custom sample.
180230
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
182261
183262```hoon
184−|%
185−++ a=term b=hoon
186−++ c=term d=hoon
187− ...
188−++ e=term f=hoon
189−--
263+[%brcl p=hoon q=hoon]
190264```
191265
192−Note: The `++` rune may be replaced with any other rune in the `+` family.
266+#### Semantics
193267
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.
195269
196−```
197−[%brcn p=(unit term) q=(map term tome)]
270+#### Expands to
271+
272+```hoon
273+=+ a
274+|. b
198275```
199276
200−##### Semantics
277+#### Discussion
201278
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.
203281
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.
205283
206−The core payload is the subject of the `|%` expression.
284+#### Examples
207285
208−##### Discussion
286+```
287+> =add-ten |:(n=`@`2 (add n 10))
209288
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
211291
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+```
213295
214−A core is like an "object" in a conventional language, but its
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.
296+---
217297
218−##### Examples
298+## `|%` "barcen"
219299
220−A trivial core:
300+Produce a core, `[battery payload]`.
221301
222−```
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−```
302+#### Syntax
234303
235−### `|:` "barcol"
304+Argument: a variable number of `+`-family expressions.
236305
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>
238324
239−##### Syntax
325+Note: The `++` rune may be replaced with any other rune in the `+` family.
240326
241−Regular:
327+#### AST
242328
243329```hoon
244−|: a=hoon b=hoon
330+[%brcn p=(unit term) q=(map term tome)]
245331```
246332
247−AST:
333+#### Semantics
248334
249−```
250−[%brcl p=hoon q=hoon]
251−```
335+The product of a `|%` expression is a dry core with one or more arms in the
336+battery.
252337
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.
254343
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.
256345
257−##### Expands to
346+#### Discussion
258347
259−```hoon
260−=> ^~ a
261− |. b
262−```
348+A core is a cell of `[battery payload]`, where the `battery` is code and the
349+`payload` is data. The `battery` is one or more arms. An arm is a computation
350+that takes the core itself as its subject.
263351
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`.
265356
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
267−[`|=`](#bartis) does.
357+A core is like an "object" in a conventional language, but its attributes
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.
268360
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
270362
271−##### Examples
363+A trivial core:
272364
273365```
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+ --
275372
276−> (add-ten 10)
277−20
373+> n.foo
374+100
278375
279−> (add-ten)
280−12
376+> (g.foo 1)
377+101
281378```
282379
283−### `|.` "bardot"
380+---
284381
285−Produce a trap (a core with one arm `$`).
382+## `|.` "bardot"
286383
287−##### Syntax
384+Produce a trap (a core with one arm `$`).
288385
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
290415
291416```hoon
292−|. a=hoon
293−```
294−
295−AST:
296−
297−```
298417[%brdt p=hoon]
299418```
300419
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
308421
309422```hoon
310423|% ++ $ a=hoon
311424--
312425```
313426
314−##### Discussion
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+
435+#### Discussion
315436
316437A trap is generally used to defer a computation.
317438
318−##### Examples
439+#### Examples
319440
320441A trivial trap:
321442
322443```
323−~zod:dojo> =foo |.(42)
444+> =foo |.(42)
324445
325−~zod:dojo> $:foo
446+> $:foo
32644742
327448
328−~zod:dojo> (foo)
449+> (foo)
32945042
330451```
331452
332453A more interesting trap:
333454
334455```
335−~zod:dojo> =foo =/ reps 10
336− =/ step 0
337− =/ outp 0
338− |.
339− ?: =(step reps)
340− outp
341− $(outp (add outp 2), step +(step))
342−~zod:dojo> (foo)
456+> =foo =/ reps 10
457+ =/ step 0
458+ =/ outp 0
459+ |.
460+ ?: =(step reps)
461+ outp
462+ $(outp (add outp 2), step +(step))
463+
464+> (foo)
34346520
344466```
345467
@@ -348,92 +470,43 @@ trap, since it's a core with an `$` arm.
348470
349471> `$(...)` expands to `%=($ ...)` (["centis"](/docs/hoon/reference/rune/cen#centis)).
350472
351−### `|-` "barhep"
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.
473+---
372474
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"
408476
409477Produce a core whose battery includes a `$` arm and compute the latter.
410478
411−##### Syntax
479+#### Syntax
412480
413−Regular:
481+One fixed argument, then a variable number of `+`-family expressions.
414482
415−```hoon
483+<table>
484+<tr><th>Form</th><th>Syntax</th></tr>
485+<tr>
486+<td>Tall</td>
487+<td>
488+<pre>
416489|^ a=hoon
417490++ b=term c=hoon
418491++ d=term e=hoon
419492 ...
420493++ f=term g=hoon
421494--
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>
423502
424−Note: The `++` rune may be replaced with any other rune in the `+` family.
425−
426−AST:
503+#### AST
427504
428−```
505+```hoon
429506[%brkt p=hoon q=(map term tome)]
430507```
431508
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
437510
438511```hoon
439512=> |%
@@ -446,86 +519,218 @@ A `|^` expression produces a multi-arm core whose battery includes a `$` arm, wh
446519$
447520```
448521
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.
450529
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
452531
453−##### Examples
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+
535+#### Examples
454536
455537A trivial example:
456538
457539```
458−~zod:dojo> |^
459− (add n g)
460− ++ n 42
461− ++ g 58
462− --
540+> |^
541+ (add n g)
542+ ++ n 42
543+ ++ g 58
544+ --
463545100
464546```
465547
466−### `|~` "barsig"
548+---
467549
468−Produce an iron gate.
550+## `|-` "barhep"
469551
470−##### Syntax
552+Produce a trap (a core with one arm `$`) and evaluate it.
471553
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
473583
474584```hoon
475−|~ a=spec b=hoon
585+[%brhp p=hoon]
476586```
477587
478−AST:
588+#### Expands to
479589
590+```hoon
591+=<($ |.(a=hoon))
480592```
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
482628```
483629
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
485666
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+```
487670
488−##### Expands to
671+#### Expands to
489672
490673```hoon
491674^| |=(a b)
492675```
493676
494−##### Discussion
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+
682+#### Discussion
495683
496684See [this discussion of core variance models](/docs/hoon/reference/advanced)
497685
498−##### Examples
686+#### Examples
499687
500688```
501−~zod:dojo> => ~ ^+(|~(a=@ *@) |=(a=* *@))
689+> => ~ ^+(|~(a=@ *@) |=(a=* *@))
502690<1|usl {a/@ $~}>
503691```
504692
505−### `|*` "bartar"
693+---
506694
507−Produce a wet gate (one-armed core with sample).
695+## `|*` "bartar"
508696
509−##### Syntax
697+Produce a wet gate (one-armed core with sample).
510698
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
512728
513729```hoon
514−|* a=spec b=hoon
515−```
516−
517−AST:
518−
519−```
520730[%brtr p=spec q=hoon]
521731```
522732
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
529734
530735```hoon
531736=| a
@@ -535,14 +740,19 @@ is a Hoon expression that determines the output value of the gate.
535740--
536741```
537742
538−##### Discussion
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+
748+#### Discussion
539749
540750In 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
542752passes through the function, rather as if it were a macro (there
543753is still only one copy of the code, however).
544754
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
546756you know what you're doing.
547757
548758Just as with a [gate](#bartis), we can recurse back into a wet gate
@@ -553,58 +763,83 @@ with `$()`.
553763`|*` can be used to make wet gates that produce structures, but this usage is
554764discouraged in favor of `|$`.
555765
556−##### Examples
766+#### Examples
557767
558768Wet and dry gates in a nutshell:
559769
560770```
561−~zod:dojo> =foo |=([a=* b=*] [b a])
771+> =foo |=([a=* b=*] [b a])
562772
563−~zod:dojo> =bar |*([a=* b=*] [b a])
773+> =bar |*([a=* b=*] [b a])
564774
565−~zod:dojo> (foo %cat %dog)
775+> (foo %cat %dog)
566776[6.778.724 7.627.107]
567777
568−~zod:dojo> (bar %cat %dog)
778+> (bar %cat %dog)
569779[%dog %cat]
570780```
571781
572782The dry gate does not preserve the type of `a` and `b`; the wet
573783gate does.
574784
575−### `|=` "bartis"
785+---
576786
577−Produce a gate (a one-armed core with a sample).
787+## `|=` "bartis"
578788
579−##### Syntax
789+Produce a gate (a one-armed core with a sample).
580790
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
582821
583822```hoon
584−|= a=spec b=hoon
585−```
586−
587−AST:
588−
589−```
590823[%brts p=spec q=hoon]
591824```
592825
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
600827
601828```hoon
602−=| a=spec
829+=+ ^~(*a=spec)
603830|% ++ $ b=hoon
604831--
605832```
606833
607−##### Discussion
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+
842+#### Discussion
608843
609844Dry gates are used for the vast majority of ordinary functions in Hoon.
610845
@@ -612,97 +847,138 @@ A gate is a core with one arm named `$`, so we can recurse back into it with `$(
612847
613848> `$(...)` expands to `%=($ ...)` (["centis"](/docs/hoon/reference/rune/cen#centis)).
614849
615−##### Examples
850+#### Examples
616851
617852A trivial gate:
618853
619854```
620−~zod:dojo> =foo |=(a=@ +(a))
855+> =foo |=(a=@ +(a))
621856
622−~zod:dojo> (foo 20)
857+> (foo 20)
62385821
624859```
625860
626861A slightly less trivial gate:
627862
628863```
629−~zod:dojo> =foo |= [a=@ b=@]
630− (add a b)
631−~zod:dojo> (foo 30 400)
864+> =foo |= [a=@ b=@]
865+ (add a b)
866+
867+> (foo 30 400)
632868430
633869```
634870
635−### `|@` "barpat"
871+---
872+
873+## `|@` "barpat"
636874
637875Produce a 'wet' core `[battery payload]`.
638876
639−##### Syntax
877+#### Syntax
640878
641−Regular:
879+Arguments: a variable number of `+`-family expressions.
642880
643−```hoon
881+<table>
882+<tr><th>Form</th><th>Syntax</th></tr>
883+<tr>
884+<td>Tall</td>
885+<td>
886+<pre>
644887|@
645888++ a=term b=hoon
646889++ c=term d=hoon
647890 ...
648891++ e=term f=hoon
649892--
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>
651899
652900Note: The `++` rune may be replaced with any other rune in the `+` family.
653901
654−AST:
902+#### AST
655903
656−```
904+```hoon
657905[%brpt p=(unit term) q=(map term tome)]
658906```
659907
660−##### Semantics
908+#### Semantics
661909
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).
663914
664−##### Discussion
915+#### Discussion
665916
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).
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
919+arms, using 'genericity'. See [Advanced types](/docs/hoon/reference/advanced).
667920
668−### `|?` "barwut"
921+---
669922
670−Produce a lead trap.
923+## `|?` "barwut"
671924
672−##### Syntax
925+Produce a lead trap.
673926
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
675956
676957```hoon
677−|? a=hoon
678−```
679−
680−AST:
681−
682−```
683958[%brwt p=hoon]
684959```
685960
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
691962
692963```hoon
693964^? |. a
694965```
695966
696−##### Discussion
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+
972+#### Discussion
697973
698974See this [discussion of the core variance model](/docs/hoon/reference/advanced).
699975
700−##### Examples
976+#### Examples
701977
702978```
703−~zod:dojo> => ~ ^+ |?(%a) |.(%a)
979+> => ~ ^+ |?(%a) |.(%a)
704980<1?pqz $~>
705981
706−~zod:dojo> => ~ ^+ |?(%a) |.(%b)
982+> => ~ ^+ |?(%a) |.(%b)
707983nest-fail
708984```
content/docs/hoon/reference/rune/buc.md+624−215
@@ -5,7 +5,7 @@ template = "doc.html"
55aliases = ["docs/reference/hoon-expressions/rune/buc/"]
66+++
77
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,
99these runes are used to produce `spec`s, which we call 'structures'.
1010
1111## Overview
@@ -46,35 +46,45 @@ it's generally a faux pas to validate structure at runtime -- or even in userspa
4646Nonetheless they are sometimes utilized for types that will be more performant
4747if they satisfy some validating gate.
4848
49−## Base Structures
49+---
5050
51−`[%base p=$@(?(%noun %cell %flag %null %void) [%atom p=aura])]`: trivial structures (types).
51+## `$|` "bucbar"
5252
53−##### Produces
53+Structure that satisfies a validator.
5454
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
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.
55+#### Syntax
7256
73−##### Syntax
57+Two arguments, fixed.
58+
59+<table>
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
7482
75−Regular: **2-fixed**
83+```hoon
84+[%bcbr p=spec q=hoon]
85+```
7686
77−##### Discussion
87+#### Discussion
7888
7989`$|` is used for validation of values at a finer level than that of types.
8090Recall 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
106116a type to have a more specific set of values than its mold would suggest. This
107117rune should rarely be used, but it is extremely important when it is.
108118
109−##### Examples
119+#### Examples
110120
111121```
112−~zod:dojo> =foo $| (list @)
113− |=(a=(list) (lth (lent a) 4))
122+> =foo $| (list @)
123+ |=(a=(list) (lth (lent a) 4))
114124```
125+
115126This creates a structure `foo` whose values are `list`s with length less than 4.
127+
116128```
117129> (foo ~[1 2 3])
118130~[1 2 3]
131+
119132> (foo ~[1 2 3 4])
120133ford: %ride failed to execute:
121134```
122135
123−
124136The definition of `+set` in `hoon.hoon` is the following:
137+
125138```hoon
126139++ set
127− |$ [item] :: set
140+ |$ [item]
128141 $| (tree item)
129− |=(a=(tree) ~(apt in a))
142+ |=(a=(tree) ?:(=(~ a) & ~(apt in a)))
130143```
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'.
138144
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+---
139154
140−### `$_` "buccab"
155+## `$_` "buccab"
141156
142−`[%bscb p=hoon]`: structure that normalizes to an example.
157+Structure that normalizes to an example.
158+
159+#### Syntax
143160
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
145192
146193```hoon
147−|=(* p)
194+[%bccb p=hoon]
148195```
149196
150−##### Syntax
151−
152−Regular: **1-fixed**.
197+#### Expands to
153198
154−Irregular: `_foo` is `$_(foo)`.
199+```hoon
200+|=(* p)
201+```
155202
156−##### Discussion
203+#### Discussion
157204
158−`$_` discards the sample it's supposedly normalizing
159−and produces its **example** instead.
205+`$_` discards the sample it's supposedly normalizing and produces its
206+**example** instead.
160207
161−##### Examples
208+#### Examples
162209
163210```
164−~zod:dojo> =foo $_([%foobaz %moobaz])
211+> =foo $_([%foobaz %moobaz])
165212
166−~zod:dojo> (foo %foo %baz)
213+> (foo %foo %baz)
167214[%foobaz %moobaz]
168215
169−~zod:dojo> `foo`[%foobaz %moobaz]
216+> `foo`[%foobaz %moobaz]
170217[%foobaz %moobaz]
171218
172−~zod:dojo $:foo
219+> $:foo
173220[%foobaz %moobaz]
174221```
175222
176−### `$%` "buccen"
223+---
177224
178−`[%bscn p=(list spec)]`: structure which recognizes a union tagged by head atom.
225+## `$%` "buccen"
179226
180−##### Defaults to
227+Structure which recognizes a union tagged by head atom.
181228
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+```
183266
184−##### Syntax
267+#### Defaults to
185268
186−Regular form: **2-running**.
269+The default of the last item `i` in `p`. Crashes if `p` is empty.
187270
188−##### Discussion
271+#### Discussion
189272
190273A `$%` is a tagged union, a common data model.
191274
192275Make 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
194277type default value.
195278
196−##### Examples
279+#### Examples
197280
198281```
199−~zod:dojo> =foo $%([%foo p=@ud q=@ud] [%baz p=@ud])
282+> =foo $%([%foo p=@ud q=@ud] [%baz p=@ud])
200283
201−~zod:dojo> (foo [%foo 4 2])
284+> (foo [%foo 4 2])
202285[%foo p=4 q=2]
203286
204−~zod:dojo> (foo [%baz 37])
287+> (foo [%baz 37])
205288[%baz p=37]
206289
207−~zod:dojo> $:foo
290+> $:foo
208291[%baz p=0]
209292```
210293
211−### `$:` "buccol"
294+---
212295
213−`[%bscl p=(list spec)]`: form a cell type.
296+## `$:` "buccol"
214297
215−##### Normalizes to
298+Form a cell type.
216299
217−The tuple the length of `p`, normalizing each item.
300+#### Syntax
218301
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
220345
221−The tuple the length of `p`.
346+```hoon
347+[%bccl p=(list spec)]
348+```
349+
350+#### Normalizes to
222351
223−##### Syntax
352+The tuple the length of `p`, normalizing each item.
224353
225−Regular: **running**.
354+#### Defaults to
226355
227−Irregular (noun mode): `,[a b c]` is `$:(a b c)`.
228−Irregular (structure mode): `[a b c]` is `$:(a b c)`.
356+The tuple the length of `p`.
229357
230−##### Examples
358+#### Examples
231359
232360```
233−~zod:dojo> =foo $:(p=@ud q=@tas)
361+> =foo $:(p=@ud q=@tas)
234362
235−~zod:dojo> (foo 33 %foo)
363+> (foo 33 %foo)
236364[p=33 q=%foo]
237365
238−~zod:dojo> `foo`[33 %foo]
366+> `foo`[33 %foo]
239367[p=33 q=%foo]
240368
241−~zod:dojo> $:foo
369+> $:foo
242370[p=0 q=%$]
243371```
244372
373+---
245374
246−### `$<` "bucgal"
375+## `$<` "bucgal"
247376
248−`[%bsld p=spec q=spec]`: Filters a pre-existing mold to obtain a mold
249−that excludes a particular structure.
377+Filters a pre-existing mold to obtain a mold that excludes a particular
378+structure.
250379
251−##### Syntax
380+#### Syntax
252381
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
254407
255−##### Discussion
408+```hoon
409+[%bcgl p=spec q=spec]
410+```
411+
412+#### Discussion
256413
257414This can be used to obtain type(s) from a list of types `q` that do not satisfy a
258415requirement given by `p`.
259416
260−##### Examples
417+#### Examples
261418
262419```
263−~zod:dojo> =foo $%([%bar p=@ud q=@ud] [%baz p=@ud])
420+> =foo $%([%bar p=@ud q=@ud] [%baz p=@ud])
264421
265−~zod:dojo> =m $<(%bar foo)
422+> =m $<(%bar foo)
266423
267−~zod:dojo> (m [%bar 2 4])
424+> (m [%bar 2 4])
268425ford: %ride failed to execute:
269426
270−~zod:dojo> (m [%baz 2])
427+> (m [%baz 2])
271428[%baz p=2]
272429
273−~zod:dojo> ;;($<(%foo [@tas *]) [%foo 1])
430+> ;;($<(%foo [@tas *]) [%foo 1])
274431ford: %ride failed to execute:
275432
276−~zod:dojo> ;;($<(%foo [@tas *]) [%bar 1])
433+> ;;($<(%foo [@tas *]) [%bar 1])
277434[%bar 1]
278− ```
435+```
279436
437+---
280438
281−### `$>` "bucgar"
439+## `$>` "bucgar"
282440
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.
285442
286−##### Syntax
443+#### Syntax
287444
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
289470
290−##### Discussion
471+```hoon
472+[%bcgr p=spec q=spec]
473+```
474+
475+#### Discussion
291476
292477This can be used to obtain type(s) from a list of types `q` that satisfy a
293478requirement given by `p`.
294479
295−##### Examples
480+#### Examples
296481
297482Examples with `$%`:
483+
298484```
299−~zod:dojo> =foo $%([%bar p=@ud q=@ud] [%baz p=@ud])
485+> =foo $%([%bar p=@ud q=@ud] [%baz p=@ud])
300486
301−~zod:dojo> =m $>(%bar foo)
487+> =m $>(%bar foo)
302488
303−~zod:dojo> (m [%bar 2 4])
489+> (m [%bar 2 4])
304490[%bar p=2 q=4]
305491
306−>~zod:dojo> (m [%baz 2])
492+> (m [%baz 2])
307493ford: %ride failed to execute:
308494```
309495
310496Examples with `;;`:
497+
311498```
312−~zod:dojo> ;;([@tas *] [%foo 1])
499+> ;;([@tas *] [%foo 1])
313500[%foo 1]
314501
315−~zod:dojo> ;;([@tas *] [%bar 1])
502+> ;;([@tas *] [%bar 1])
316503[%bar 1]
317504
318−~zod:dojo> ;;($>(%foo [@tas *]) [%foo 1])
505+> ;;($>(%foo [@tas *]) [%foo 1])
319506[%foo 1]
320507
321−~zod:dojo> ;;($>(%foo [@tas *]) [%bar 1])
508+> ;;($>(%foo [@tas *]) [%bar 1])
322509ford: %ride failed to execute:
323− ```
510+```
511+
512+---
324513
514+## `$-` "buchep"
325515
326−### `$-` "buchep"
516+Structure that normalizes to an example gate.
327517
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+```
329523
330−##### Expands to
524+#### Expands to
331525
332526```hoon
333527$_ ^|
334528|=(p $:q)
335529```
336530
337−##### Syntax
531+#### Syntax
532+
533+Two arguments, fixed.
338534
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>
340556
341−##### Discussion
557+`p` is the type the gate takes and `q` is the type the gate produces.
342558
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
344560
345−##### Examples
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+
563+#### Examples
346564
347565```
348−~zod:dojo> =foo $-(%foo %baz)
566+> =foo $-(%foo %baz)
349567
350−~zod:dojo> ($:foo %foo)
568+> ($:foo %foo)
351569%baz
352570```
353571
572+---
573+
574+## `$^` "bucket"
575+
576+Structure which normalizes a union tagged by head depth (cell).
577+
578+#### Syntax
354579
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
356605
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+```
358609
359−##### Normalizes to
610+#### Normalizes to
360611
361612Default, if the sample is an atom; `p`, if the head of the sample
362613is an atom; `q` otherwise.
363614
364−##### Defaults to
615+#### Defaults to
365616
366617The default of `p`.
367618
368−##### Syntax
369−
370−Regular: **2-fixed**.
371−
372−##### Examples
619+#### Examples
373620
374621```
375−~zod:dojo> =a $%([%foo p=@ud q=@ud] [%baz p=@ud])
622+> =a $%([%foo p=@ud q=@ud] [%baz p=@ud])
376623
377−~zod:dojo> =b $^([a a] a)
624+> =b $^([a a] a)
378625
379−~zod:dojo> (b [[%baz 33] [%foo 19 22]])
626+> (b [[%baz 33] [%foo 19 22]])
380627[[%baz p=33] [%foo p=19 q=22]]
381628
382−~zod:dojo> (b [%foo 19 22])
629+> (b [%foo 19 22])
383630[%foo p=19 q=22]
384631
385−~zod:dojo> $:b
632+> $:b
386633[%baz p=0]
387634```
388635
389−### $& "bucpam"
636+---
390637
391−`[%bspd p=spec q=hoon]`: repair a value of a tagged union type
638+## `$&` "bucpam"
392639
393−##### Syntax
640+Repair a value of a tagged union type.
394641
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>
396667
397668```hoon
398669$&(combined-mold=spec normalizing-gate=hoon)
399670```
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`.
403671
404−##### Normalizes to
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+
682+#### Normalizes to
405683
406684The product of the normalizing gate and sample.
407685
408−##### Defaults to
686+#### Defaults to
409687
410688The default of the last type listed in `p`, normalized with the normalizing gate.
411689
412−##### Discussion
690+#### Discussion
413691
414692This 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
416−updating an app.
693+an old version to a new version. For example, this may happen when migrating
694+state after updating an app.
417695
418−##### Examples
696+#### Examples
419697
420698```hoon
421699+$ old [%0 @]
@@ -423,39 +701,69 @@ updating an app.
423701+$ combined $%(old new)
424702+$ adapting $&(combined |=(?-(-.a %0 [%1 1 +.a], %1 a)))
425703```
704+
426705Here `adapting` is a structure that bunts to `[%1 ^]` but also normalizes from
427706`[%0 @]` if called on such a noun.
428707
708+---
429709
430−### `$~` "bucsig"
431−
432−`[%bssg p=hoon q=spec]`: define a custom type default value
710+## `$~` "bucsig"
433711
434−##### Product
712+Define a custom type default value.
435713
436−Creates a structure (custom type) just like `q`, except its default value is `p`.
714+#### Syntax
437715
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
439744
440−The product of `p`.
745+```hoon
746+[%bcsg p=hoon q=spec]
747+```
441748
442−##### Syntax
749+#### Product
443750
444−Regular: **2-fixed**.
751+Creates a structure (custom type) just like `q`, except its default value is `p`.
445752
446−```hoon
447−$~ p=hoon q=spec
448−```
753+#### Defaults to
449754
450−`p` defines the default value, and `q` defines everything else about the structure.
755+The product of `p`.
451756
452−##### Discussion
757+#### Discussion
453758
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).)
455762
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 `%~`.)
763+Do not confuse the `$~` rune with the constant type for null, `$~`. (The latter
764+uses older Hoon syntax that is still accepted. Preferably it would be `%~`.)
457765
458−##### Examples
766+#### Examples
459767
460768First, let's define a type without using `$~`:
461769
@@ -491,116 +799,217 @@ Using `$~`:
491799%default-value
492800```
493801
494−### `$@` "bucpat"
802+---
495803
496−`[%bsvt p=spec q=spec]`: structure which normalizes a union tagged by head depth (atom).
804+## `$@` "bucpat"
497805
498−##### Normalizes to
806+Structure which normalizes a union tagged by head depth (atom).
499807
500−`p`, if the sample is an atom; `q`, if the sample is a cell.
808+#### Syntax
501809
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
503835
504−The default of `p`.
836+```hoon
837+[%bcpt p=spec q=spec]
838+```
505839
506−#### Syntax
840+#### Normalizes to
841+
842+`p`, if the sample is an atom; `q`, if the sample is a cell.
507843
508−Regular: **2-fixed**.
844+#### Defaults to
509845
510−Product: a structure which applies `p` if its sample is an atom,
511−`q` if its sample is a cell.
846+The default of `p`.
512847
513−Regular form: **2-fixed**.
848+#### Produces
514849
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
516854
517855```
518−~zod:dojo> =a $@(%foo $:(p=%baz q=@ud))
856+> =a $@(%foo $:(p=%baz q=@ud))
519857
520−~zod:dojo> (a %foo)
858+> (a %foo)
521859%foo
522860
523−~zod:dojo> `a`[%baz 99]
861+> `a`[%baz 99]
524862[p=%baz q=99]
525863
526−~zod:dojo> $:a
864+> $:a
527865%foo
528866```
529867
868+---
869+
870+## `$=` "buctis"
530871
531−### `$=` "buctis"
872+Structure which wraps a face around another structure.
532873
533−`[%bsts p=skin q=spec]`: structure which wraps a face around another structure.
874+#### Syntax
534875
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
536908
537909```hoon
538−|= *
539−^=(p %-(q +6))
910+[%bcts p=skin q=spec]
540911```
541912
542−##### Syntax
913+#### Expands to
543914
544−Regular: **2-fixed**.
545−
546−Irregular (structure mode): `foo=baz` is `$=(foo baz)`.
915+```hoon
916+|= *
917+^=(p %-(q +6))
918+```
547919
548−##### Discussion
920+#### Discussion
549921
550922Note that the Hoon compiler is at least slightly clever about
551923compiling structures, and almost never has to actually put in a gate
552924layer (as seen in the expansion above) to apply a `$=`.
553925
554−##### Examples
926+#### Examples
555927
556928```
557−~zod:dojo> =a $=(p %foo)
929+> =a $=(p %foo)
558930
559−~zod:dojo> (a %foo)
931+> (a %foo)
560932p=%foo
561933
562−~zod:dojo> (a %baz)
934+> (a %baz)
563935ford: %ride failed to execute:
564936```
565937
566−### `$?` "bucwut"
938+---
567939
568−`[%bswt p=(list spec)]`: form a type from a union of other types.
940+## `$?` "bucwut"
569941
570−##### Normalizes to
942+Form a type from a union of other types.
571943
572−The first item in `p` which normalizes the sample to itself.
944+#### Syntax
573945
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+```
575985
576−##### Defaults to
986+#### Normalizes to
577987
578−The first item in `p`.
988+The last item in `p` which normalizes the sample to itself.
579989
580−##### Syntax
990+Void, if `p` is empty.
581991
582−Regular: **running**.
992+#### Defaults to
583993
584−Irregular: `?(%foo %baz)` is `$?(%foo %baz)`.
994+The last item in `p`.
585995
586−##### Discussion
996+#### Discussion
587997
588−For a union of atoms, a `$?` is fine. For more complex nouns,
589−always try to use a [`$%`](#buccen), [`$@`](#bucpat) or
590−[`$^`](#bucket), at least if you expect your structure to be used as a
591−normalizer.
998+For a union of atoms, a `$?` is fine. For more complex nouns, always try to use
999+a [`$%`](#buccen), [`$@`](#bucpat) or [`$^`](#bucket), at least if you expect
1000+your structure to be used as a normalizer.
5921001
593−##### Examples
1002+#### Examples
5941003
5951004```
596−~zod:dojo> =a ?(%foo %baz %baz)
1005+> =a ?(%foo %baz %baz)
5971006
598−~zod:dojo> (a %baz)
1007+> (a %baz)
5991008%baz
6001009
601−~zod:dojo> (a [37 45])
1010+> (a [37 45])
6021011ford: %ride failed to execute:
6031012
604−~zod:dojo> $:a
1013+> $:a
6051014%baz
6061015```
content/docs/hoon/reference/rune/cen.md+468−187
@@ -4,109 +4,175 @@ weight = 10
44template = "doc.html"
55aliases = ["docs/reference/hoon-expressions/rune/cen/"]
66+++
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.)
87
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.)
1012
11−## Runes
13+These runes reduce to the `%=` rune.
1214
13−### `%_` "cencab"
15+## `%_` "cencab"
1416
1517Resolve a wing with changes, preserving type.
1618
17−##### Syntax
19+#### Syntax
1820
19−Regular, tall:
21+One fixed argument, then a variable number of pairs.
2022
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>
2229%_ a=wing
2330 b=wing c=hoon
2431 d=wing e=hoon
25− ...
2632 f=wing g=hoon
2733==
28−```
29−
30−Regular, flat:
31−
32−```hoon
34+</pre>
35+</td>
36+</tr>
37+<tr>
38+<td>Tall style #2</td>
39+<td>
40+<pre>
41+%_ a=wing
42+ b=wing
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>
3358%_(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>
3567
36−AST:
68+#### AST
3769
38−```
70+```hoon
3971[%cncb p=wing q=(list (pair wing hoon))]
4072```
4173
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
4775
4876```hoon
4977^+(a %=(a b c, d e, ...))
5078```
5179
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`.
5386
54−`%_` is different from `%=` because `%=` can change the type of a wing with mutations. `%_` preserves the wing type.
87+#### Discussion
88+
89+`%_` is different from `%=` because `%=` can change the type of a wing with
90+mutations. `%_` preserves the wing type.
5591
5692See [how wings are resolved](/docs/hoon/reference/limbs/).
5793
58−##### Examples
94+#### Examples
5995
6096```
61−~zod:dojo> =foo [p=42 q=6]
97+> =foo [p=42 q=6]
6298
63−~zod:dojo> foo(p %baz)
99+> foo(p %baz)
64100[p=%baz q=6]
65101
66−~zod:dojo> foo(p [55 99])
102+> foo(p [55 99])
67103[p=[55 99] q=6]
68104
69−~zod:dojo> %_(foo p %baz)
105+> %_(foo p %baz)
70106[p=7.496.034 99]
71107
72−~zod:dojo> %_(foo p [55 99])
108+> %_(foo p [55 99])
73109! nest-fail
74110```
75111
76−### `%:` "cencol"
112+---
113+
114+## `%:` "cencol"
77115
78116Call a gate with many arguments.
79117
80−##### Syntax
118+#### Syntax
81119
82−Regular:
120+One fixed argument, then a variable number of arguments.
83121
84−```hoon
122+<table>
123+<tr><th>Form</th><th>Syntax</th></tr>
124+<tr>
125+<td>Tall</td>
126+<td>
127+<pre>
85128%: a=hoon
86129 b=hoon
87130 c=hoon
88131 ...
89132 d=hoon
90133==
91−```
92−
93−AST:
134+</pre>
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+
155+#### AST
94156
95−```
157+```hoon
96158[%cncl p=hoon q=(list hoon)]
97159```
98160
99−##### Semantics
161+#### Semantics
100162
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]`.
102168
103−##### Discussion
169+#### Discussion
104170
105171When `%:` is used in tall-form syntax, the series of expressions after `p` must be terminated with `==`.
106172
107−##### Examples
173+#### Examples
108174
109−```hoon
175+```
110176> %: add 22 33 ==
11117755
112178
@@ -123,211 +189,342 @@ When `%:` is used in tall-form syntax, the series of expressions after `p` must
123189> %: adder 22 33 44 55 ==
124190154
125191
126−> %:(adder 22 33 44 ~)
192+> %:(adder 22 33 44)
193+99
194+
195+> (adder 22 33 44)
12719699
128197```
129198
130−### `%.` "cendot"
199+---
131200
132−Call a gate (function), inverted.
201+## `%.` "cendot"
133202
134−##### Syntax
203+Call a gate (function), inverted.
135204
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
137234
138235```hoon
139−%. a=hoon b=hoon
140−```
141−
142−AST:
143−
144−```
145236[%cndt p=hoon q=hoon]
146237```
147238
148−##### Semantics
239+#### Semantics
149240
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.
151243
152−##### Expands to
244+#### Expands to
153245
154246```hoon
155247%-(b=hoon a=hoon)
156248```
157249
158−##### Discussion
250+#### Discussion
159251
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.
161254
162−##### Examples
255+#### Examples
163256
164257```
165−~zod:dojo> =add-triple |=([a=@ b=@ c=@] :(add a b c))
258+> =add-triple |=([a=@ b=@ c=@] :(add a b c))
166259
167−~zod:dojo> %.([1 2 3] add-triple)
260+> %.([1 2 3] add-triple)
1682616
169262```
170263
171−### `%-` "cenhep" {#cenhep}
172−
173−Call a gate (function).
174−
175−##### Syntax
264+---
176265
177−Regular:
266+## `%-` "cenhep" {#cenhep}
178267
179−```hoon
180−%- a=hoon b=hoon
181−```
268+Call a gate (function).
182269
183−Irregular:
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>
292+<td>Irregular</td>
293+<td>
294+<pre>
295+(a b)
296+</pre>
297+</td>
298+</tr>
299+</table>
300+
301+#### AST
184302
185303```hoon
186−(a=hoon b=hoon)
187−```
188−
189−AST:
190−
191−```
192304[%cnhp p=hoon q=hoon]
193305```
194306
195−##### Semantics
307+#### Semantics
196308
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.
198312
199−##### Expands to
313+#### Expands to
200314
201315```hoon
202316%~($ a b)
203317```
204318
205−##### Discussion
319+#### Discussion
206320
207−`%-` is used to call a function; `a` is the function ([`gate`](/docs/hoon/reference/rune/bar#bartis),
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).
321+`%-` is used to call a function; `a` is the function
322+([`gate`](/docs/hoon/reference/rune/bar#bartis), `q` the argument. `%-` is a
323+special case of [`%~` ("censig")](#censig), and a gate is a special case of a
324+[door](/docs/hoon/reference/rune/bar#barcab).
209325
210−##### Examples
326+#### Examples
211327
212328```
213−~zod:dojo> =add-triple |=([a=@ b=@ c=@] :(add a b c))
214−~zod:dojo> (add-triple 1 2 3)
329+> =add-triple |=([a=@ b=@ c=@] :(add a b c))
330+
331+> (add-triple 1 2 3)
2153326
216−~zod:dojo> %-(add-triple [1 2 3])
333+
334+> %-(add-triple [1 2 3])
2173356
218336```
219337
220−### `%^` "cenket"
338+---
221339
222−Call gate with triple sample.
340+## `%^` "cenket"
223341
224−##### Syntax
342+Call gate with triple sample.
225343
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
227380
228381```hoon
229−%^ a=hoon b=hoon c=hoon d=hoon
230−```
231−
232−AST:
233−
234−```
235382[%cnkt p=hoon q=hoon r=hoon s=hoon]
236383```
237384
238−
239−##### Expands to
385+#### Expands to
240386
241387```hoon
242388%-(a=hoon [b=hoon c=hoon d=hoon])
243389```
244390
245−##### Examples
391+#### Examples
246392
247393```
248−~zod:dojo> =add-triple |=([a=@ b=@ c=@] :(add a b c))
394+> =add-triple |=([a=@ b=@ c=@] :(add a b c))
249395
250−~zod:dojo> %^(add-triple 1 2 3)
396+> %^(add-triple 1 2 3)
2513976
252398```
253399
254−### `%+` "cenlus"
400+---
255401
256−Call gate with a cell sample.
402+## `%+` "cenlus"
257403
258−##### Syntax
404+Call gate with a cell sample.
259405
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
261441
262442```hoon
263−%+ a=hoon b=hoon c=hoon
264−```
265−
266−AST:
267−
268−```
269443[%cnls p=hoon q=hoon r=hoon]
270444```
271445
272−##### Semantics
446+#### Semantics
273447
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.
275450
276−##### Expands to
451+#### Expands to
277452
278453```hoon
279454%-(a=hoon [b=hoon c=hoon])
280455```
281456
282−##### Examples
457+#### Examples
283458
284459```
285−~zod:dojo> =add-triple |=([a=@ b=@ c=@] :(add a b c))
460+> =add-triple |=([a=@ b=@ c=@] :(add a b c))
286461
287−~zod:dojo> %+(add-triple 1 [2 3])
462+> %+(add-triple 1 [2 3])
2884636
289464```
290465
291−### `%~` "censig"
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
466+---
315467
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"
317469
318−##### Discussion
470+Evaluate an arm in a door.
319471
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)`.
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+
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)`.
321517
322518See also [`|_`](/docs/hoon/reference/rune/bar#barcab).
323519
324−##### Examples
520+#### Examples
325521
326−```hoon
522+```
327523> =mycore |_ a=@
328524 ++ plus-two (add 2 a)
329525 ++ double (mul 2 a)
330526 --
527+
331528> ~(plus-two mycore 10)
33252912
333530
@@ -335,34 +532,72 @@ See also [`|_`](/docs/hoon/reference/rune/bar#barcab).
33553220
336533```
337534
338−### `%*` "centar"
535+---
536+
537+## `%*` "centar"
339538
340539Evaluate an expression, then resolve a wing with changes.
341540
342−##### Syntax
541+#### Syntax
343542
344−Regular:
543+Two fixed arguments, then a variable number of pairs.
345544
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>
347551%* a=wing b=hoon
348552 c=wing d=hoon
349553 e=wing f=hoon
350554 ...
351555 g=wing h=hoon
352556==
353−```
354−
355−AST:
557+</pre>
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+
588+#### AST
356589
357−```
590+```hoon
358591[%cntr p=wing q=hoon r=(list (pair wing hoon))]
359592```
360593
361−##### Semantics
594+#### Semantics
362595
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`.
596+A `%*` expression evaluates some arbitrary Hoon expression, `b`, and then
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`.
364599
365−##### Expands to
600+#### Expands to
366601
367602```hoon
368603=+ b=hoon
@@ -374,7 +609,7 @@ A `%*` expression evaluates some arbitrary Hoon expression, `b`, and then resolv
374609==
375610```
376611
377−##### Examples
612+#### Examples
378613
379614```
380615> %*($ add a 2, b 3)
@@ -398,52 +633,96 @@ A `%*` expression evaluates some arbitrary Hoon expression, `b`, and then resolv
398633[a=1 b=7 c=10]
399634```
400635
401−### `%=` "centis"
636+---
637+
638+## `%=` "centis"
402639
403640Resolve a wing with changes.
404641
405−##### Syntax
642+#### Syntax
406643
407−Regular:
644+One fixed argument, then a variable number of pairs.
408645
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>
410652%= a=wing
411653 b=wing c=hoon
412654 d=wing e=hoon
413655 ...
414656 f=wing g=hoon
415657==
416−```
417−
418−Irregular:
419−
420−`foo(x 1, y 2, z 3)` is `%=(foo x 1, y 2, z 3)`.
421−
422−AST:
658+</pre>
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>
687+<td>Irregular</td>
688+<td>
689+<pre>
690+a(b c, d e, f g)
691+</pre>
692+</td>
693+</tr>
694+</table>
695+
696+#### AST
423697
424−```
698+```hoon
425699[%cnts p=wing q=(list (pair wing hoon))]
426700```
427701
428−##### Semantics
702+#### Semantics
429703
430704A `%=` expression resolves a wing of the subject, but with changes made.
431705
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.
433709
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.
435714
436−##### Discussion
715+#### Discussion
437716
438−Note that `a` is a wing, not just any expression. Knowing that a function
439−call `(foo baz)` involves evaluating `foo`, replacing its sample
440−at slot `+6` with `baz`, and then resolving to the `$` limb, you might think
441−`(foo baz)` would mean `%=(foo +6 baz)`.
717+Note that `a` is a wing, not just any expression. Knowing that a function call
718+`(foo baz)` involves evaluating `foo`, replacing its sample at slot `+6` with
719+`baz`, and then resolving to the `$` limb, you might think `(foo baz)` would
720+mean `%=(foo +6 baz)`.
442721
443−But it's actually `=+(foo =>(%=(+2 +6 baz) $))`. Even if `foo` is
444−a wing, we would just be mutating `+6` within the core that defines the
445−`foo` arm. Instead we want to modify the **product** of `foo` -- the gate
446−-- so we have to pin it into the subject.
722+But it's actually `=+(foo =>(%=(+2 +6 baz) $))`. Even if `foo` is a wing, we
723+would just be mutating `+6` within the core that defines the `foo` arm. Instead
724+we want to modify the **product** of `foo` -- the gate -- so we have to pin it
725+into the subject.
447726
448727Here's that again in tall form:
449728
@@ -455,12 +734,14 @@ Here's that again in tall form:
455734 $
456735```
457736
458−##### Examples
737+#### Examples
459738
460739```
461−~zod:dojo> =foo [p=5 q=6]
462−~zod:dojo> foo(p 42)
740+> =foo [p=5 q=6]
741+
742+> foo(p 42)
463743[p=42 q=6]
464−~zod:dojo> foo(+3 99)
744+
745+> foo(+3 99)
465746[p=5 99]
466747```
content/docs/hoon/reference/rune/col.md+364−143
@@ -4,157 +4,404 @@ weight = 9
44template = "doc.html"
55aliases = ["docs/reference/hoon-expressions/rune/col/"]
66+++
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 `:-`.
87
9−## Runes
10−
11−### `:_` "colcab"
12−
13−`[%clcb p=hoon q=hoon]`; construct a cell, inverted.
14−
15−##### Expands to
8+The `:` ("col") expressions are used to produce cells, which are pairs of
9+values. E.g., `:-(p q)` produces the cell `[p q]`. All `:` runes reduce to `:-`.
10+
11+## `:-` "colhep"
12+
13+Construct a cell (2-tuple).
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
1657
1758```hoon
18−:-(q p)
59+[%clhp p=hoon q=hoon]
1960```
2061
21−##### Syntax
62+#### Produces
2263
23−Regular: **2-fixed**.
64+The cell of `p` and `q`.
2465
25−##### Examples
66+#### Discussion
2667
27−```
28−~zod:dojo> :_(1 2)
29−[2 1]
30−```
31−
32−### `::` "colcol"
68+Hoon expressions actually use the same "autocons" pattern as Nock
69+formulas. If you're assembling expressions (which usually only the
70+compiler does), `[a b]` is the same as `:-(a b)`.
3371
34−Code comment
72+#### Examples
3573
36−##### Syntax
74+```
75+> :-(1 2)
76+[1 2]
3777
38−:: any text you like!
78+~zod:dojo> 1^2
79+[1 2]
80+```
3981
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
41118
42119```hoon
43−::
44−:: this is commented code
45−::
46−|= a=@ :: a gate
47−(add 2 a) :: that adds 2
48− :: to the input
120+[%clcb p=hoon q=hoon]
49121```
50122
51−### `:-` "colhep"
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]`.
123+#### Expands to
70124
71−Irregular: `` `a `` is `[~ a]`.
125+```hoon
126+:-(q p)
127+```
72128
73−Irregular: `~[a b]` is `[a b ~]`.
129+#### Examples
74130
75−Irregular: `[a b c]~` is `[[a b c] ~]`.
131+```
132+> :_(1 2)
133+[2 1]
134+```
76135
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
78177
79−Hoon expressions actually use the same "autocons" pattern as Nock
80−formulas. If you're assembling expressions (which usually only the
81−compiler does), `[a b]` is the same as `:-(a b)`.
178+```hoon
179+[%clls p=hoon q=hoon r=hoon]
180+```
82181
83−##### Examples
182+#### Expands to:
84183
184+```hoon
185+:-(p :-(q r))
85186```
86−~zod:dojo> :-(1 2)
87−[1 2]
88187
89−~zod:dojo> 1^2
90−[1 2]
188+#### Examples
91189
92−~zod:dojo> 1/2
93−[%1 2]
190+```
191+> :+ 1
192+ 2
193+ 3
194+[1 2 3]
94195
95−~zod:dojo> `1
96−[~ 1]
196+> :+(%a ~ 'b')
197+[%a ~ 'b']
97198```
98199
99−### `:^` "colket"
200+---
201+
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
100242
101−`[%clkt p=hoon q=hoon r=hoon s=hoon]`: construct a quadruple (4-tuple).
243+```hoon
244+[%clkt p=hoon q=hoon r=hoon s=hoon]
245+```
102246
103−##### Expands to
247+#### Expands to
104248
105249```hoon
106250:-(p :-(q :-(r s)))
107251```
108252
109−##### Syntax
110−
111−Regular: **4-fixed**.
112−
113−##### Examples
253+#### Examples
114254
115255```
116−~zod:dojo> :^(1 2 3 4)
256+> :^(1 2 3 4)
117257[1 2 3 4]
118258
119−~zod:dojo> :^ 5
120− 6
121− 7
122− 8
259+> :^ 5
260+ 6
261+ 7
262+ 8
123263[5 6 7 8]
124264```
125265
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
127309
310+```hoon
311+[%cltr p=(list hoon)]
312+```
128313
129−`[%clls p=hoon q=hoon r=hoon]`: construct a triple (3-tuple).
314+#### Expands to
130315
131−##### Expands to:
316+**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
132317
133318```hoon
134−:-(p :-(q r))
319+:-(a :-(b :-(c :-(... z)))))
135320```
136321
137−##### Syntax
322+#### Desugaring
138323
139−Regular: **3-fixed**.
324+```hoon
325+|-
326+?~ p
327+ !!
328+?~ t.p
329+ i.p
330+:- i.p
331+$(p t.p)
332+```
140333
141−##### Examples
334+#### Examples
142335
143336```
144−/~zod:dojo> :+ 1
145− 2
146− 3
147−[1 2 3]
337+> :*(5 3 4 1 4 9 0 ~ 'a')
338+[5 3 4 1 4 9 0 ~ 'a']
148339
149−~zod:dojo> :+(%a ~ 'b')
150−[%a ~ 'b']
340+> [5 3 4 1 4 9 0 ~ 'a']
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']
151354```
152355
153−### `:~` "colsig"
356+---
357+
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
154399
155−`[%clsg p=(list hoon)]`: construct a null-terminated list.
400+```hoon
401+[%clsg p=(list hoon)]
402+```
156403
157−##### Expands to
404+#### Expands to
158405
159406**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
160407
@@ -162,7 +409,7 @@ Regular: **3-fixed**.
162409:-(a :-(b :-(c :-(... :-(z ~)))))
163410```
164411
165−##### Desugaring
412+#### Desugaring
166413
167414```hoon
168415|-
@@ -172,74 +419,48 @@ Regular: **3-fixed**.
172419$(p t.p)
173420```
174421
175−##### Syntax
422+#### Discussion
176423
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.
178426
179−##### Examples
427+#### Examples
180428
181429```
182−~zod:dojo> :~(5 3 4 2 1)
430+> :~(5 3 4 2 1)
183431[5 3 4 2 1 ~]
184432
185−~zod:dojo> ~[5 3 4 2 1]
433+> ~[5 3 4 2 1]
186434[5 3 4 2 1 ~]
187435
188−~zod:dojo> :~ 5
189− 3
190− 4
191− 2
192− 1
193− ==
436+> :~ 5
437+ 3
438+ 4
439+ 2
440+ 1
441+ ==
194442[5 3 4 2 1 ~]
195443```
196444
197−### `:*` "coltar"
445+---
198446
199−`[%cltr p=(list hoon)]`: construct an n-tuple.
447+## `::` "colcol"
200448
201−##### Expands to
449+Code comment.
202450
203−**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
451+#### Syntax
204452
205453```hoon
206−:-(a :-(b :-(c :-(... z)))))
454+:: any text you like!
207455```
208456
209−##### Desugaring
457+#### Examples
210458
211459```hoon
212−|-
213−?~ p
214− !!
215−?~ t.p
216− i.p
217−:- i.p
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']
460+::
461+:: this is commented code
462+::
463+|= a=@ :: a gate
464+(add 2 a) :: that adds 2
465+ :: to the input
245466```
content/docs/hoon/reference/rune/constants.md+101−82
@@ -4,35 +4,33 @@ weight = 1
44template = "doc.html"
55aliases = ["docs/reference/hoon-expressions/rune/constants/"]
66+++
7+
78The 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
910se, because they have interpolations.)
1011
11−## Expressions
12−
13−### `:_ "Cold Atom"`
12+## "Cold Atom"
1413
15−`[%rock p=term q=@]`; a constant, cold atom.
16−
17−A cold atom is one whose type is inferred to be of a single atom constant.
14+A constant, cold atom.
1815
19−##### Produces
16+#### Syntax
2017
21−A cold (fixed) atom `q` with aura `p`.
18+Any [warm atom](#warm) form, prefixed with `%`.
2219
23−##### Syntax
20+#### AST
2421
25−Irregular: any [warm atom](#warm) form, prefixed with `%`.
22+```hoon
23+[%rock p=term q=*]
24+```
2625
27−Irregular: e.g., `%hi`. Character constraints: `a-z`
28−lowercase to start, `a-z` or `0-9` thereafter, with infix
29−hyphens (`hep`), "kebab-case."
26+#### Discussion
3027
31−Irregular: `~`.
28+A cold atom is one whose type is inferred to be of a single atom constant.
3229
33−##### Examples
30+#### Examples
3431
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`:
3634
3735```
3836> (ream '%hi')
@@ -45,20 +43,22 @@ We can see the contrast with warm atoms by using the compiler parser function, `
4543[%rock p=%ud q=12]
4644```
4745
48−### `:_` "Paths"
46+---
47+
48+## "Paths"
4949
50−`[%path p=(list (each @ta hoon))]`: path with interpolation.
50+Path with interpolation.
5151
52−##### Produces
52+#### Syntax
5353
54−A null-terminated list of the items in `p`, which are either constant
55−`@ta` atoms (`knots`), or expressions producing a `knot`.
54+`/this/is/a/path`
5655
57−##### Syntax
56+#### Produces
5857
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`.
6060
61−##### Examples
61+#### Examples
6262
6363```
6464> `path`/this/is/a/path
@@ -74,19 +74,19 @@ Irregular: `/this/is/a/path`.
7474~
7575```
7676
77−### `:_` "Strings with Interpolation"
77+---
7878
79−`[%knit p=(list (each @t hoon))]`: text string with interpolation.
79+## "Strings with Interpolation"
8080
81−##### Produces
81+Text string with interpolation.
8282
83−A tape.
83+#### Syntax
8484
85−##### Syntax
85+A [$tape](/docs/hoon/reference/stdlib/2q#tape)
8686
87−Irregular: `"abcdefg"`.
87+`"abcdefg"`
8888
89−Irregular: `"abc{(weld "lmnop" "xyz")}defg"`.
89+`"abc{(weld "lmnop" "xyz")}defg"`
9090
9191```
9292> "abcdefg"
@@ -99,7 +99,17 @@ Irregular: `"abc{(weld "lmnop" "xyz")}defg"`.
9999[%knit p=~[97 98 99 100 101 102 103]]
100100```
101101
102−##### Examples
102+#### AST
103+
104+```hoon
105+[%knit p=(list woof)]
106+```
107+
108+#### Produces
109+
110+A tape.
111+
112+#### Examples
103113
104114String:
105115
@@ -122,11 +132,63 @@ String with interpolated prettyprinting:
122132"hello, %world."
123133```
124134
125−### `:_` "Warm Atoms" {#warm}
135+---
136+
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
126183
127−`[%sand p=term q=@]`; a constant, warm atom.
184+```hoon
185+[%sand p=term q=*]
186+```
187+
188+#### Discussion
128189
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.
130192
131193```
132194> `@`12
@@ -136,9 +198,10 @@ A 'warm' atom is one whose type is inferred to be general, i.e., not just a sing
136198nest-fail
137199```
138200
139−##### Produces
201+#### Produces
140202
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:
142205
143206```
144207> (ream '12')
@@ -147,47 +210,3 @@ A warm (variable) atom `q` with aura `p`. Use the Hoon compiler parser function
147210> (ream '\'Hello!\'')
148211[%sand p=%t q=36.762.444.129.608]
149212```
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/"]
77
88Anything Nock can do, Hoon can do also. These runes are used for carrying out Nock operations in Hoon.
99
10−## Runes
11−
12−### `.^` "dotket"
13−
14−`[%dtkt p=spec q=hoon]`: load from the Arvo namespace with a fake Nock instruction: 'Nock `12`''.
10+## `.^` "dotket"
11+
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+```
1559
16−##### Produces
60+#### Produces
1761
1862The noun `q`, cast to the type `p`.
1963
20−##### Discussion
64+#### Discussion
2165
2266Nock has no `12` instruction! But the virtual Nock
2367used 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
2973
3074In 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.
3175
32−##### Examples
76+#### Examples
3377
3478In the dojo we can ask Clay -- the Arvo filesystem -- for a listing of the files at our current path, `%`:
3579
@@ -37,17 +81,14 @@ In the dojo we can ask Clay -- the Arvo filesystem -- for a listing of the files
3781> .^(arch %cy %)
3882[ fil=~
3983 dir
40− { [p=~.web q=~]
41− [p=~.LICENSE q=~]
42− [p=~.app q=~]
43− [p=~.lib q=~]
44− [p=~.sec q=~]
45− [p=~.sys q=~]
46− [p=~.ren q=~]
84+ { [p=~.app q=~]
4785 [p=~.sur q=~]
48− [p=~.tests q=~]
49− [p=~.mar q=~]
5086 [p=~.gen q=~]
87+ [p=~.lib q=~]
88+ [p=~.mar q=~]
89+ [p=~.ted q=~]
90+ [p=~.desk q=~]
91+ [p=~.sys q=~]
5192 }
5293]
5394```
@@ -67,38 +108,69 @@ You can modify the time of the file listing quite simply and ask for a listing f
67108> .^(arch %cy /(scot %p our)/base/(scot %da (sub now ~h5)))
68109[ fil=~
69110 dir
70− { [p=~.web q=~]
71− [p=~.LICENSE q=~]
72− [p=~.app q=~]
73− [p=~.lib q=~]
74− [p=~.sec q=~]
75− [p=~.sys q=~]
76− [p=~.ren q=~]
111+ { [p=~.app q=~]
77112 [p=~.sur q=~]
78− [p=~.tests q=~]
79− [p=~.mar q=~]
80113 [p=~.gen q=~]
114+ [p=~.lib q=~]
115+ [p=~.mar q=~]
116+ [p=~.ted q=~]
117+ [p=~.desk q=~]
118+ [p=~.sys q=~]
81119 }
82120]
83121```
84122
85123`our` is the value for your ship's name.
86124
87−### `.+` "dotlus"
88−
89−`[%dtls p=hoon]`: increment an atom with Nock `4`.
125+---
126+
127+## `.+` "dotlus"
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
166+[%dtls p=hoon]
167+```
90168
91−##### Produces
169+#### Produces
92170
93171`p` plus `1` if `p` is an atom; otherwise, crashes. The product atom has no aura.
94172
95−##### Syntax
96−
97−Regular: **1-fixed**.
98−
99−Irregular: `+(6)` is `.+(6)`.
100−
101−##### Examples
173+#### Examples
102174
103175```
104176> .+(6)
@@ -114,19 +186,52 @@ Irregular: `+(6)` is `.+(6)`.
114186nest-fail
115187```
116188
117−### `.*` "dottar"
189+---
118190
119−`[%dttr p=hoon q=hoon]`: evaluate with Nock `2`.
191+## `.*` "dottar"
120192
121−##### Produces
193+Evaluate with Nock `2`.
122194
123−Nock of formula `q` and subject `p`, with type `%noun`.
195+#### Produces
124196
125−##### Syntax
197+Nock of formula `q` and subject `p`, with type `%noun`.
126198
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+```
128233
129−##### Discussion
234+#### Discussion
130235
131236`.*(p q)` is used to run Nock formula `q` on the subject `p` from within Hoon.
132237
@@ -135,7 +240,7 @@ Keep in mind that `p` and `q` can be arbitrary Hoon expressions, as long as they
135240Note also that `.*` ("dottar") can be used to bypass the type system. It's
136241therefore possible to use Hoon as a typeless language.
137242
138−##### Examples
243+#### Examples
139244
140245```
141246> .*([20 30] [0 2])
@@ -157,32 +262,64 @@ therefore possible to use Hoon as a typeless language.
1572621
158263```
159264
160−### `.=` "dottis" {#dottis}
161−
162−`[%dtts p=hoon q=hoon]`: test for equality with Nock `5`.
265+---
266+
267+## `.=` "dottis" {#dottis}
268+
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+```
163309
164−##### Produces
310+#### Produces
165311
166312`%.y` if `p` equals `q`; otherwise `%.n`.
167313
168−##### Syntax
169−
170−Regular: **2-fixed**.
171−
172−Irregular: `=(a b)` is `.=(a b)`.
173−
174−##### 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.
314+#### Discussion
177315
178316Like Nock equality, `.=` ("dottis") tests whether two nouns are the same,
179−ignoring invisible pointer structure. Because in a conventional
180−noun implementation each noun has a lazy short hash, comparisons
181−are fast unless the hash needs to be computed, or we are comparing
182−separate copies of identical nouns. (Comparing large duplicates
183−is a common cause of performance bugs.)
317+ignoring invisible pointer structure. Because in a conventional noun
318+implementation each noun has a lazy short hash, comparisons are fast unless the
319+hash needs to be computed, or we are comparing separate copies of identical
320+nouns. (Comparing large duplicates is a common cause of performance bugs.)
184321
185−##### Examples
322+#### Examples
186323
187324```
188325> .=(0 0)
@@ -198,22 +335,54 @@ is a common cause of performance bugs.)
198335%.n
199336
200337> =(12 [12 14])
201−nest-fail
338+%.n
202339```
203340
204−### `.?` "dotwut"
205−
206−`[%dtwt p=hoon]`: test for cell or atom with Nock `3`.
341+---
342+
343+## `.?` "dotwut"
344+
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+```
207380
208−##### Produces
381+#### Produces
209382
210383`%.y` if `p` is a cell; otherwise `%.n`.
211384
212−##### Syntax
213−
214−Regular: **1-fixed**.
215−
216−##### Examples
385+#### Examples
217386
218387```
219388> .?(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
44template = "doc.html"
55aliases = ["docs/reference/hoon-expressions/rune/ket/"]
66+++
7−[`^-` ("kethep")](#kethep), [`^+` ("ketlus")](#ketlus), and
8−[`^=` ("kettis")](#kettis) let us adjust types without violating type
9−constraints.
107
11−The `nest` algorithm which tests subtyping is conservative;
12−it never allows invalid nests, it sometimes rejects valid nests.
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; it never allows
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
1347
14−## Runes
15−
16−### `^|` "ketbar"
17−
18−`[%ktbr p=hoon]`: convert a gold core to an iron core (contravariant).
48+```hoon
49+[%ktbr p=hoon]
50+```
1951
20−##### Produces
52+#### Produces
2153
2254`p` as an iron core; crash if not a gold core.
2355
24−##### Syntax
25−
26−Regular: **1-fixed**.
27−
28−##### Discussion
56+#### Discussion
2957
3058An iron core is an opaque function (gate or door).
3159
@@ -37,7 +65,7 @@ Informally, a function fits an interface if the function has a
3765more specific result and/or a less specific argument than the
3866interface.
3967
40−##### Examples
68+#### Examples
4169
4270The prettyprinter shows the core metal (`.` gold, `|` iron):
4371
@@ -49,34 +77,68 @@ The prettyprinter shows the core metal (`.` gold, `|` iron):
4977<1|gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
5078```
5179
52−### `^:` "ketcol"
80+---
81+
82+## `^:` "ketcol"
83+
84+Mold gate for type `p`.
85+
86+**Note this rune is now redundant.**
5387
54−`[%ktcl p=spec]`: mold gate for type `p`.
88+#### Syntax
5589
56−##### Produces
90+One argument, fixed.
5791
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>
59115
60−##### Syntax
116+#### AST
61117
62−Regular: **1-fixed**.
118+```hoon
119+[%ktcl p=spec]
120+```
121+
122+#### Produces
63123
64−##### Discussion
124+A gate that returns the sample value if it's of the correct type, but crashes
125+otherwise.
65126
66−A mold is an idempotent gate that is guaranteed to produce a noun of that type.
67−If an input value isn't of the correct type, the bunt value of that type is
68−returned. (See `^*`.)
127+#### Discussion
69128
70−`^:` is used to produce a gate that is much like a mold, except that instead of
71−producing a bunt value when the input value is of the wrong type, it crashes.
129+`^:` is used to produce a mold that crashes if its sample is of the wrong type.
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**.
72134
73135One 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
75137`:` is the irregular syntax for `=<` this is is parsed as "get `^` (i.e. the
76138mold for cells) from a subject of `(path /foo)`", with `:` being the irregular
77139syntax for `=<`.
78140
79−##### Examples
141+#### Examples
80142
81143```
82144> ^: @
@@ -94,31 +156,60 @@ syntax for `=<`.
94156ford: %ride failed to execute:
95157```
96158
97−### `^.` "ketdot"
98−
99−`[%ktdt p=hoon q=hoon]`: typecast on value produced by passing `q` to `p`.
100−
101−##### Expands to
159+---
160+
161+## `^.` "ketdot"
162+
163+Typecast on value produced by passing `q` to `p`.
164+
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
102195
103196```hoon
104−^+(%:(p q) q)
197+[%ktdt p=hoon q=hoon]
105198```
106199
107−##### Syntax
108−
109−Regular: **2-fixed**.
200+#### Expands to
110201
111202```hoon
112−^. p=hoon q=hoon
203+^+(%:(p q) q)
113204```
114205
115−##### Discussion
206+#### Discussion
116207
117208`p` produces a gate and q is any Hoon expression.
118209
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.
120211
121−##### Examples
212+#### Examples
122213
123214```
124215> =mylist [11 22 33 ~]
@@ -135,31 +226,66 @@ mint-vain
135226~[22 33]
136227```
137228
138−### `^-` "kethep"
229+---
230+
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
139269
140−`[%kthp p=spec q=hoon]`: typecast by explicit type label.
270+```hoon
271+[%kthp p=spec q=hoon]
272+```
141273
142−##### Expands to
274+#### Expands to
143275
144276```hoon
145277^+(^*(p) q)
146278```
147279
148−##### Syntax
149−
150−Regular: **2-fixed**.
151−
152−Irregular: `` `foo`baz`` is `^-(foo ^-(@ baz))`.
153−
154−##### Discussion
280+#### Discussion
155281
156282It'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
158284only in the presence of head recursion (otherwise you'll get a
159285`rest-loop` error, or if you really screw up spectacularly an
160286infinite loop in the compiler).
161287
162−##### Examples
288+#### Examples
163289
164290```
165291~zod:dojo> (add 90 7)
@@ -179,44 +305,103 @@ infinite loop in the compiler).
179305[~ ~.a]
180306```
181307
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
183339
184−`[%ktls p=hoon q=hoon]`: typecast by inferred type.
185−
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`.
340+```hoon
341+[%ktls p=hoon q=hoon]
342+```
189343
190−##### Syntax
344+#### Produces
191345
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`.
193348
194−##### Examples
349+#### Examples
195350
196351```
197352~zod:dojo> ^+('text' %a)
198353'a'
199354```
200355
201−### `^&` "ketpam"
356+---
202357
203−`[%ktpm p=hoon]`: convert a core to a zinc core (covariant).
358+## `^&` "ketpam"
204359
205−##### Produces
360+Convert a core to a zinc core (covariant).
206361
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
208388
209−##### Syntax
389+```hoon
390+[%ktpm p=hoon]
391+```
210392
211−Regular: **1-fixed**.
393+#### Produces
394+
395+`p` as a zinc core; crash if `p` isn't a gold or zinc core.
212396
213−##### Discussion
397+#### Discussion
214398
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).
216400
217−##### Examples
401+#### Examples
218402
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):
220405
221406```
222407> |=(@ 1)
@@ -251,53 +436,112 @@ ford: %slim failed:
251436ford: %ride failed to compute type:
252437```
253438
254−### `^~` "ketsig"
439+---
255440
256−`[%ktsg p=hoon]`: fold constant at compile time.
441+## `^~` "ketsig"
257442
258−##### Produces
443+Fold constant at compile time.
259444
260−`p`, folded as a constant if possible.
445+#### Syntax
261446
262−##### Syntax
447+One argument, fixed.
263448
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>
265469
266−##### Examples
470+#### AST
267471
472+```hoon
473+[%ktsg p=hoon]
268474```
269−~zod:dojo> (make '|-(42)')
270−[%8 p=[%1 p=[1 42]] q=[%9 p=2 q=[%0 p=1]]]
271475
272−~zod:dojo> (make '^~(|-(42))')
273−[%1 p=42]
274−```
476+#### Produces
275477
276−### `^*` "kettar"
478+`p`, folded as a constant if possible.
277479
278−`[%kttr p=spec]`: Produce example type value.
480+#### Examples
279481
280−##### Produces
482+```
483+> (make '|-(42)')
484+[%8 p=[%1 p=[1 42]] q=[%9 p=2 q=[%0 p=1]]]
281485
282−A default value (i.e., 'bunt value') of the type `p`.
486+> (make '^~(|-(42))')
487+[%1 p=42]
488+```
283489
284−##### Syntax
490+---
491+
492+## `^*` "kettar"
493+
494+Produce example type value.
495+
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.
285529
286−Regular: **1-fixed**.
530+#### AST
287531
288532```hoon
289−^* p=spec
533+[%kttr p=spec]
290534```
291535
292−Irregular: `*p`.
536+#### Produces
293537
294−`p` is any structure expression.
538+A default value (i.e., 'bunt value') of the type `p`.
295539
296−##### Examples
540+#### Examples
297541
298542Regular:
299543
300−```hoon
544+```
301545> ^* @
3025460
303547
@@ -313,7 +557,7 @@ Regular:
313557
314558Irregular:
315559
316−```hoon
560+```
317561> *@
3185620
319563
@@ -324,55 +568,119 @@ Irregular:
324568""
325569```
326570
327−### `^=` "kettis"
328−
329−`[%ktts p=skin q=hoon]`: Bind name to a value.
330−
331−##### Produces
332−
333−If `p` is a term, the product `q` with type `[%face p q]`. `p`
334−may also be a tuple of terms, or a term-skin pair; the type of
335−`q` must divide evenly into cells to match it.
571+---
572+
573+## `^=` "kettis"
574+
575+Bind name to a value.
576+
577+#### Syntax
578+
579+Two arguments, fixed.
580+
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
336611
337−##### Syntax
612+```hoon
613+[%ktts p=skin q=hoon]
614+```
338615
339−Regular: **2-fixed**.
616+#### Produces
340617
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.
342621
343−##### Examples
622+#### Examples
344623
345624```
346−~zod:dojo> a=1
625+> a=1
347626a=1
348627
349−~zod:dojo> ^= a
350− 1
628+> ^= a
629+ 1
351630a=1
352631
353−~zod:dojo> ^=(a 1)
632+> ^=(a 1)
354633a=1
355634
356−~zod:dojo> [b c d]=[1 2 3 4]
635+> [b c d]=[1 2 3 4]
357636[b=1 c=2 d=[3 4]]
358637
359−~zod:dojo> [b c d=[x y]]=[1 2 3 4]
638+> [b c d=[x y]]=[1 2 3 4]
360639[b=1 c=2 d=[x=3 y=4]]
361640```
362641
363−### `^?` "ketwut"
642+---
364643
365−`[%ktwt p=hoon]`: convert any core to a lead core (bivariant).
644+## `^?` "ketwut"
366645
367−##### Produces
646+Convert any core to a lead core (bivariant).
368647
369−`p` as a lead core; crash if not a core.
648+#### Syntax
370649
371−##### Syntax
650+One argument, fixed.
372651
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>
374672
375−##### Discussion
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+
683+#### Discussion
376684
377685A lead core is an opaque generator; the payload can't be read or
378686written.
@@ -383,14 +691,14 @@ Theorem: if type `x` nests within type `a`, a lead core producing
383691Informally, a more specific generator can be used as a less
384692specific generator.
385693
386−##### Examples
694+#### Examples
387695
388696The prettyprinter shows the core metal (`.` gold, `?` lead):
389697
390698```
391−~zod:dojo> |=(@ 1)
699+> |=(@ 1)
392700<1.gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
393701
394−~zod:dojo> ^?(|=(@ 1))
702+> ^?(|=(@ 1))
395703<1?gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
396704```
content/docs/hoon/reference/rune/lus.md+107−41
@@ -4,33 +4,53 @@ weight = 8
44template = "doc.html"
55+++
66
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.
89
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.
10+Arm runes are used to define arms in a core, and thus can only be used from
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.
1014
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 `+*`.
1218
13−## Runes
19+## `+|` "lusbar"
1420
15−### `+|` "lusbar"
21+Chapter label (not useful)
1622
17−Chapter label.
23+#### Syntax
1824
19−##### Syntax
25+One argument, fixed.
2026
21−Regular: **1-fixed**.
22−
23−```hoon
27+<table>
28+<tr><th>Form</th><th>Syntax</th></tr>
29+<tr>
30+<td>Tall</td>
31+<td>
32+<pre>
2433+| %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>
2640
27−##### Discussion
41+#### Discussion
2842
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.
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
45+'organization'. Chapter labels aren't part of the underlying noun of the core;
46+they're stored as type system metadata only.
3047
31−See `tome` in the Hoon standard library.
48+See [`tome`](/docs/hoon/reference/stdlib/4o#tome) in the Hoon standard library.
3249
33−##### Examples
50+**Note:** The `+|` rune has little practical utility. Chapter labels cannot be
51+referenced short of manually processing the `$type` of a core.
52+
53+#### Examples
3454
3555Let's look at what the Hoon compiler's parser, `ream`, does with the `+|` rune:
3656
@@ -46,7 +66,7 @@ Let's look at what the Hoon compiler's parser, `ream`, does with the `+|` rune:
4666]
4767```
4868
49−Notice that `p.q` has the label `%numbers`. Contrast with:
69+Notice that `p.q` has the label `%numbers`. Contrast with:
5070
5171```
5272> (ream '|% ++ two 2 ++ three 3 --')
@@ -60,27 +80,42 @@ Notice that `p.q` has the label `%numbers`. Contrast with:
6080]
6181```
6282
63−### `+$` "lusbuc"
83+---
84+
85+## `+$` "lusbuc"
6486
6587Produce a structure arm (type definition).
6688
67−##### Syntax
89+#### Syntax
6890
69−Regular: **2-fixed**.
91+Two arguments, fixed.
7092
71−```hoon
93+<table>
94+<tr><th>Form</th><th>Syntax</th></tr>
95+<tr>
96+<td>Tall</td>
97+<td>
98+<pre>
7299+$ 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>
74106
75107`p` is an arm name, and `q` is any structure expression.
76108
77−##### Discussion
109+#### Discussion
78110
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.
80112
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`).
82117
83−##### Examples
118+#### Examples
84119
85120```
86121> =c |%
@@ -98,27 +133,41 @@ nest-fail
98133[%.y 22]
99134```
100135
101−### `++` "luslus"
136+---
137+
138+## `++` "luslus"
102139
103140Produce a normal arm.
104141
105−##### Syntax
142+#### Syntax
106143
107−Regular: **2-fixed**.
144+Two arguments, fixed.
108145
109−```hoon
146+<table>
147+<tr><th>Form</th><th>Syntax</th></tr>
148+<tr>
149+<td>Tall</td>
150+<td>
151+<pre>
110152++ 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>
112159
113160`p` is the arm name, and `q` is any Hoon expression.
114161
115−##### Discussion
162+#### Discussion
116163
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.
118167
119168Any Hoon expression, `q`, may be used to define the arm computation.
120169
121−##### Examples
170+#### Examples
122171
123172```
124173> =c |%
@@ -133,20 +182,32 @@ Any Hoon expression, `q`, may be used to define the arm computation.
13318212
134183```
135184
136−### `+*` "lustar"
185+---
186+
187+## `+*` "lustar"
137188
138189Defines deferred expressions within doors.
139190
140−##### Syntax
191+#### Syntax
141192
142−Regular: **variadic**.
193+Arguments: A variable number of pairs.
143194
144−```hoon
195+<table>
196+<tr><th>Form</th><th>Syntax</th></tr>
197+<tr>
198+<td>Tall</td>
199+<td>
200+<pre>
145201+* a=term b=hoon
146202 c=term d=hoon
147203 ...
148204 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>
150211
151212`a`, `c`, `e` are arm names and `b`, `d`, `f` are any Hoon expression. Note that
152213unlike all other runes with a variable number of arguments, the list of
@@ -155,7 +216,7 @@ arguments of `+*` does not end with a terminator.
155216`+*` arms must always come at the beginning of the battery, before any other
156217type of lus arm.
157218
158−##### Discussion
219+#### Discussion
159220
160221The primary use of `+*` is to create deferred expressions within doors (see
161222Examples below). This is a name for an expressions that will be evaluated in
@@ -178,7 +239,9 @@ compiled from this Hoon expression
178239++ y (sub z n)
179240--
180241```
242+
181243as being identical the Nock compiled from this one:
244+
182245```hoon
183246=| z=@ud
184247|%
@@ -191,13 +254,15 @@ as being identical the Nock compiled from this one:
191254--
192255```
193256
194−##### Examples
257+#### Examples
195258
196259To assign an alias to a door, we often write the following.
260+
197261```hoon
198262|_ foo
199263+* this .
200264```
265+
201266This is the idomatic way to assign the alias `this` to the door.
202267
203268Sometimes 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.
211276 samp +<
212277 cont +>
213278```
279+
214280This assigns the door the alias `this`, the sample of the door `samp`, and the
215281context of the door `cont`.
216282
@@ -218,7 +284,7 @@ You may also call functions with `+*` by making use of e.g. the `%~` rune.
218284
219285```hoon
220286=<
221− |_ a=@
287+ |_ a=@
222288 +* do ~(. +> a)
223289 ++ stuff foo:do
224290::etc
content/docs/hoon/reference/rune/mic.md+384−143
@@ -7,13 +7,53 @@ aliases = ["docs/reference/hoon-expressions/rune/mic/"]
77
88Miscellaneous useful macros.
99
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
1151
12−### `;:` "miccol"
13−
14−`[%mccl p=hoon q=(list hoon)]`: call a binary function as an n-ary function.
52+```hoon
53+[%mccl p=hoon q=(list hoon)]
54+```
1555
16−##### Expands to
56+#### Expands to
1757
1858**Pseudocode**: `a`, `b`, `c`, ... as elements of `q`:
1959
@@ -29,7 +69,7 @@ Irregular form:
2969(p a (p b (p c ...)))
3070```
3171
32−##### Desugaring
72+#### Desugaring
3373
3474```hoon
3575|-
@@ -40,35 +80,57 @@ Irregular form:
4080(p i.q $(q t.q))
4181```
4282
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
5084
5185```
52−~zod:dojo> (add 3 (add 4 5))
86+> (add 3 (add 4 5))
538712
5488
55−~zod:dojo> ;:(add 3 4 5)
89+> ;:(add 3 4 5)
569012
5791
58−~zod:dojo> :(add 3 4 5)
92+> :(add 3 4 5)
599312
94+
95+> `@t`:((cury cat 3) 'a' 'b' 'c' 'd')
96+'abcd'
6097```
6198
62−### `;<` "micgal"
99+---
100+
101+## `;<` "micgal"
102+
103+Monadic do notation.
104+
105+#### Syntax
63106
64−`[%mcgl p=spec q=hoon r=hoon s=hoon]`: monadic do notation.
107+Four arguments, fixed.
65108
66−##### Syntax
109+<table>
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>
67129
68−Regular: **4-fixed**
130+#### AST
69131
70132```hoon
71−;< mold=mold bind=hoon expr1=hoon expr2=hoon
133+[%mcgl p=spec q=hoon r=hoon s=hoon]
72134```
73135
74136#### Semantics
@@ -77,7 +139,7 @@ A `;<` is for sequencing two computations, `expr1` and `expr2`, using a provided
77139implementation of monadic bind. This rune takes a gate `bind` which takes a mold
78140`mold` and produces an implementation of monadic bind.
79141
80−##### Desugaring
142+#### Desugaring
81143
82144```hoon
83145%+ (bind mold)
@@ -86,7 +148,7 @@ implementation of monadic bind. This rune takes a gate `bind` which takes a mold
86148expr2
87149```
88150
89−##### Discussion
151+#### Discussion
90152
91153`;<` is much like Haskell `do` notation. You have a sequence of events you'd
92154like to run such that each past the first depends on the output of the previous
@@ -103,72 +165,102 @@ external data.
103165
104166We remark that you can switch binds in the middle of a sequence of `;<`.
105167
106−##### Examples
168+#### Examples
107169
108170[`+biff`](/docs/hoon/reference/stdlib/2a/#biff) is the unit monad's
109171implementation of monadic bind. That is to say, it takes a unit `a` and a gate
110172`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`.
112174
113175We illustrate the usage of `;<` with `+biff` with a `map` of atoms:
176+
114177```
115−~zod:dojo> =m (my ~[[1 3] [2 2] [3 1]])
116− > (~(get by m) 1)
117− [~ 3]
178+> =m (my ~[[1 3] [2 2] [3 1]])
179+> (~(get by m) 1)
180+[~ 3]
118181```
182+
119183A single usage of `;<` only serves to apply the binding function to the output
120184of `expr1`:
185+
121186```
122−~zod:dojo> ;< a=@ _biff (~(get by m) 1)
123− a
124− 3
187+> ;< a=@ _biff (~(get by m) 1)
188+ a
189+3
125190```
191+
126192Here we see the result of chaining them together:
193+
127194```
128−~zod:dojo> ;< a=@ _biff (~(get by m) 1)
129− ;< b=@ _biff (~(get by m) a)
130− b
131− 1
195+> ;< a=@ _biff (~(get by m) 1)
196+ ;< b=@ _biff (~(get by m) a)
197+ b
198+1
132199```
133200
201+---
134202
135−
136−### `;+` "miclus"
203+## `;+` "miclus"
137204
138205make a single XML node (Sail)
139206
140−##### Produces
141−
142−A `marl`, i.e., a list of `manx`. A `manx` is a noun that represents a single XML node.
207+#### Syntax
208+
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>
143231
144−##### Syntax
145−
146−**1-fixed**
232+`p` is a Hoon expression that produces a `manx`.
147233
148−```hoon
149−;+ p=hoon
150−```
234+#### Produces
151235
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.
153239
154−##### Discussion
240+#### Discussion
155241
156242tl;dr -- `;+` converts a `manx` to a `marl`.
157243
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.
244+`;+` is a Sail rune. Sail is a part of Hoon used for creating and operating on
245+nouns that represent XML nodes. With the appropriate rendering pipeline, a Sail
246+document can be used to generate a static website.
159247
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:
248+In Sail a single XML node is represented by a `manx`. A single
249+<code>&lt;p&gt;</code> node `manx` can be produced in the following way:
161250
162251```
163252> ;p: This will be rendered as an XML node.
164253[[%p ~] [[%$ [%$ "This will be rendered as an XML node."] ~] ~] ~]
165254```
166255
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.
168258
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.
170262
171−##### Examples
263+#### Examples
172264
173265```
174266> ^- marl
@@ -192,11 +284,45 @@ One interesting thing about Sail is that it allows you to use complex Hoon expre
192284]
193285```
194286
195−### `;;` "micmic"
287+---
288+
289+## `;;` "micmic"
290+
291+Normalize with a mold, asserting fixpoint.
196292
197−`[%mcmc p=spec q=hoon]`: normalize with a mold, asserting fixpoint.
293+#### Syntax
198294
199−##### Expands to
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+
325+#### Expands to
200326
201327```hoon
202328=+ a=(p q)
@@ -206,68 +332,130 @@ a
206332
207333> Note: the expansion implementation is hygienic -- it doesn't actually add the `a` face to the subject.
208334
209−##### Syntax
210−
211−Regular: **2-fixed**.
212−
213−##### Examples
335+#### Examples
214336
215337Fails because of auras:
216338
217339```
218−~zod:dojo> ^-(tape ~[97 98 99])
340+> ^-(tape ~[97 98 99])
219341mint-nice
342+-need.?(%~ [i=@tD t=""])
343+-have.[@ud @ud @ud %~]
220344nest-fail
221−ford: %slim failed:
222−ford: %ride failed to compute type:
345+dojo: hoon expression failed
223346```
224347
225348Succeeds because molds don't care about auras:
226349
227350```
228−~zod:dojo> ;;(tape ~[97 98 99])
351+> ;;(tape ~[97 98 99])
229352"abc"
230353```
231354
232355Fails because not a fixpoint:
233356
234357```
235−~zod:dojo> ;;(tape [50 51 52])
236−ford: %ride failed to execute:
358+> ;;(tape [50 51 52])
359+dojo: hoon expression failed
237360```
238361
239−### `;/` "micfas"
362+---
363+
364+## `;/` "micfas"
365+
366+Tape as XML element.
240367
241−`[%mcnt p=hoon]`: tape as XML element.
368+#### Syntax
242369
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
244394
245395```hoon
246−~[%$ ~[%$ 'p']]
396+[%mcnt p=hoon]
247397```
248398
249−##### Examples
399+#### Expands to
250400
401+```hoon
402+~[%$ ~[%$ 'p']]
251403```
252−~zod/try=> ;/ "foo"
253−[[%~. [%~. "foo] ~] ~]
254−```
404+
405+#### Examples
255406
256407```
257−~zod/try=> :/"foo"
258−[[%~. [%~. "foo] ~] ~]
408+> ;/ "foo"
409+[[%~. [%~. "foo"] ~] ~]
259410```
260411
261−### `;~` "micsig"
412+---
413+
414+## `;~` "micsig"
415+
416+Glue a pipeline together with a product-sample adapter.
262417
263−`[%mcsg p=hoon q=(list hoon)]`: glue a pipeline together with a
264−product-sample adapter.
418+#### Syntax
265419
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+```
267452
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
269454
270−##### Expands to
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+
458+#### Expands to
271459
272460**Note: these are structurally correct, but elide some type-system complexity.**
273461
@@ -289,7 +477,7 @@ The gates in `q` are composed together using the gate `p` as an intermediate fun
289477|. (a (c arg) d(+6 arg))
290478```
291479
292−##### Desugaring
480+#### Desugaring
293481
294482```hoon
295483?~ q !!
@@ -301,12 +489,11 @@ The gates in `q` are composed together using the gate `p` as an intermediate fun
301489|. (p (b c) a(,.+6 c))
302490```
303491
304−##### Discussion
492+#### Discussion
305493
306−Apparently `;~` is a "Kleisli arrow." It's also
307−a close cousin of the infamous "monad." Don't let that bother
308−you. Hoon doesn't know anything about category theory,
309−so you don't need to either.
494+Apparently `;~` is a "Kleisli arrow." It's also a close cousin of the infamous
495+"monad." Don't let that bother you. Hoon doesn't know anything about category
496+theory, so you don't need to either.
310497
311498`;~` is often used in parsers, but is not only for parsers.
312499
@@ -315,80 +502,105 @@ nesting the gates in `q`, each is passed individually to `p` with the product
315502of the previous gate, allowing arbitrary filtering, transformation, or
316503conditional application.
317504
318−##### Syntax
319−
320−Regular: **1-fixed**, then **running**.
321−
322−##### Examples
505+#### Examples
323506
324−A simple "parser." `trip` converts a `cord` (atomic string) to
507+A simple "parser." `trip` converts a `cord` (atomic string) to
325508a `tape` (linked string).
326509
327510```
328−~zod:dojo> =cmp |=([a=tape b=$-(char tape)] `tape`?~(a ~ (weld (b i.a) t.a)))
329−~zod:dojo> ;~(cmp trip)
511+> =cmp |=([a=tape b=$-(char tape)] `tape`?~(a ~ (weld (b i.a) t.a)))
512+> ;~(cmp trip)
330513<1.zje {a/@ <409.yxa 110.lxv 1.ztu $151>}>
331−
332514```
333515
334516With just one gate in the pipeline `q`, the glue `p` is unused:
335517
336518```
337−~zod:dojo> (;~(cmp trip) 'a')
519+> (;~(cmp trip) 'a')
338520"a"
339521```
340522
341523But for multiple gates, we need it to connect the pipeline:
342524
343525```
344−~zod:dojo> (;~(cmp trip |=(a=@ ~[a a])) 'a')
526+> (;~(cmp trip |=(a=@ ~[a a])) 'a')
345527"aa"
346−~zod:dojo> (;~(cmp trip |=(a=@ ~[a a])) '')
528+
529+> (;~(cmp trip |=(a=@ ~[a a])) '')
347530""
348531```
349532
350533A more complicated example:
351534
352535```
353−~zod:dojo> (;~(cmp trip ;~(cmp |=(a=@ ~[a a]) |=(a=@ <(dec a)>))) 'b')
536+> (;~(cmp trip ;~(cmp |=(a=@ ~[a a]) |=(a=@ <(dec a)>))) 'b')
354537"97b"
355−~zod:dojo> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'b')
538+
539+> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'b')
356540"97b"
357−~zod:dojo> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) '')
541+
542+> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) '')
358543""
359−~zod:dojo> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'a')
544+
545+> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'a')
360546"96a"
361−~zod:dojo> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'acd')
547+
548+> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'acd')
362549"96acd"
363550```
364551
365−### `;*` "mictar"
552+---
553+
554+## `;*` "mictar"
366555
367556make a list of XML nodes from complex Hoon expression (Sail)
368557
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>
370582
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`.
372584
373−##### Syntax
585+#### Produces
374586
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.
376590
377−```hoon
378−;* p=hoon
379−```
591+#### Discussion
380592
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.
382596
383−##### Discussion
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.
597+If you need a complex Hoon expression to produce a `marl`, use the `;*` rune.
598+Often this rune is used with an expression, `p`, that includes one or more `;=`
599+subexpressions.
388600
389601(See also [`;=`](#mictis).)
390602
391−##### Examples
603+#### Examples
392604
393605```
394606> ;* ?: (gth 3 2)
@@ -414,40 +626,69 @@ If you need a complex Hoon expression to produce a `marl`, use the `;*` rune. O
414626]
415627```
416628
417−### `;=` "mictis"
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`.
629+---
434630
435−##### Discussion
631+## `;=` "mictis"
436632
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)
438634
439−In Sail a single XML node is represented by a `manx`. A single `<p>` node `manx` can be produced in the following way:
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+
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:
440680
441681```
442682> ;p: This will be rendered as an XML node.
443683[[%p ~] [[%$ [%$ "This will be rendered as an XML node."] ~] ~] ~]
444684```
445685
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.
447688
448689(See also [`;*`](#mictar).)
449690
450−##### Examples
691+#### Examples
451692
452693```
453694> ;= ;p: This is the first node.
content/docs/hoon/reference/rune/sig.md+582−167
@@ -3,35 +3,69 @@ title = "Hints ~ ('sig')"
33weight = 14
44template = "doc.html"
55+++
6+
67Runes that use Nock `11` to pass non-semantic info to the interpreter. A
78mnemonic to remember what sig runes are for is "we're *sig*naling some
89information to the interpreter".
910
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
1045
11−## Runes
12−
13−### `~>` "siggar"
14−
15−`[%sggr p=$@(term [p=term q=hoon]) q=hoon]`: raw hint, applied
16−to computation.
46+```hoon
47+[%sggr p=$@(term [p=term q=hoon]) q=hoon]
48+```
1749
18−##### Expands to
50+#### Expands to
1951
2052`q`.
2153
22−##### Syntax
54+#### Semantics
2355
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.
2559
26−##### Discussion
60+#### Discussion
2761
2862Hoon has no way of telling what hints are used and what aren't.
2963Hints are all conventions at the interpreter level.
3064
31−##### Examples
65+#### Examples
3266
3367```
34−~zod:dojo> ~>(%a 42)
68+> ~>(%a 42)
356942
3670```
3771
@@ -45,24 +79,56 @@ Running the compiler:
4579[%11 p=[p=97 q=[%4 p=[%1 p=2]]] q=[%1 p=42]]
4680```
4781
48−### `~|` "sigbar"
49−
82+---
83+
84+## `~|` "sigbar"
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
50118
51−`[%sgbr p=hoon q=hoon]`: tracing printf.
119+```hoon
120+[%sgbr p=hoon q=hoon]
121+```
52122
53−##### Expands to
123+#### Expands to
54124
55125`q`.
56126
57−##### Convention
127+#### Convention
58128
59129Prettyprints `p` in stack trace if `q` crashes.
60130
61−##### Syntax
62−
63−Regular: **2-fixed**.
64−
65−##### Examples
131+#### Examples
66132
67133```
68134> ~|('sample error message' !!)
@@ -75,46 +141,138 @@ dojo: hoon expression failed
75141dojo: hoon expression failed
76142```
77143
78−### `~$` "sigbuc"
144+---
145+
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
79180
80−`[%sgbc p=term q=hoon]`: profiling hit counter.
181+```hoon
182+[%sgbc p=term q=hoon]
183+```
81184
82−##### Expands to
185+#### Expands to
83186
84187`q`.
85188
86−##### Convention
189+#### Discussion
87190
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`.
89194
90−##### Syntax
195+#### Examples
91196
92−Regular: **2-fixed**.
197+```
198+> ~$(%foo 3)
199+3
200+```
93201
94−##### Examples
202+Assuming we have the binary running with the `-P` flag, if we do this:
95203
96204```
97−~zod:dojo> ~$(%foo 3)
98−3
205+> =z |= a=@
206+ ?: =(a 0)
207+ a
208+ ~$ %my-hit-counter
209+ $(a (dec a))
210+
211+> (z 42)
212+0
99213```
100214
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:
102217
103−`[%sgcb p=hoon q=hoon]`: user-formatted tracing printf.
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
260+[%sgcb p=hoon q=hoon]
261+```
104262
105−##### Expands to
263+#### Expands to
106264
107265`q`.
108266
109−##### Convention
267+#### Convention
110268
111269Shows `p` in stacktrace if `q` crashes.
112270
113−##### Discussion
271+#### Discussion
114272
115−`p` must produce a `tank` (prettyprint source).
273+`p` must produce a `tank` (pretty-print source).
116274
117−##### Examples
275+#### Examples
118276
119277```
120278> ~_([%leaf "sample error message"] !!)
@@ -127,52 +285,81 @@ sample error message
127285dojo: hoon expression failed
128286```
129287
130−### `~%` "sigcen"
288+---
289+
290+## `~%` "sigcen"
291+
292+Jet registration.
131293
132−`[%sgcn p=term q=wing r=(list [term hoon]) s=hoon]`: jet registration.
294+#### Syntax
133295
134−##### Expands to
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+
326+#### Expands to
135327
136328`s`.
137329
138−##### Convention
330+#### Convention
139331
140332Register a core with name `p`, with parent at leg `q`, exporting
141333the named formulas `r`, constructed by `s`.
142334
143−##### Syntax
144−
145−Regular: **4-fixed**. For `r`, use `~` if empty. Otherwise, **jogging**
146−between opening and closing `==`.
147−
148−##### Discussion
335+#### Discussion
149336
150−`~%` is for registering cores. A registered core declares its
337+`~%` is for registering cores. A registered core declares its
151338formal identity to the interpreter, which may or may not be able
152339to recognize and/or accelerate it.
153340
154341Registered 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
156343register 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
158345must be, if (a) we registered it on creation, (b) the child was
159346created by an arm defined on the parent.
160347
161−(Cores are actually managed by their formula/battery. Any
348+(Cores are actually managed by their formula/battery. Any
162349function 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
164351battery -- matching the semantics constrains the payload as well,
165352since the semantics of a battery may depend on any parent core
166353and/or payload constant.)
167354
168−The purpose of registration is always performance-related. It
355+The purpose of registration is always performance-related. It
169356may involve (a) a special-purpose optimizer or "jet", written
170357for a specific core and checked with a Merkle hash; (b) a
171358general-purpose hotspot optimizer or "JIT"; or (c) merely a
172359hotspot declaration for profiling.
173360
174361As 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 `~%`
176363indiscriminately on all hotspots, bottlenecks, etc, real or
177364suspected.
178365
@@ -181,7 +368,7 @@ implementors with named Nock formulas that act on the core.
181368In complex systems, jet implementations are often partial and
182369want to call back into userspace.
183370
184−The child core contains the parent, of course. When we register
371+The child core contains the parent, of course. When we register
185372a core, we state the leg to its parent, in the form of wing `q`.
186373We assume that the parent -- any core within the payload -- is
187374already registered.
@@ -190,55 +377,80 @@ already registered.
190377
191378Registers a jet in core `s` so that it can be called when that code is run.
192379
193−Regular form: **4-fixed**
380+#### Examples
194381
195−##### Examples
196−
197−Here's the AES
382+Here's the beginning of the AES core in `zuse.hoon`:
198383
199384```hoon
200− ++ aesc :: AES-256
201− ~% %aesc + ~
202− |%
203− ++ en :: ECB enc
204− ~/ %en
205− |= [a=@I b=@H] ^- @uxH
206− =+ ahem
207− (be & (ex a) b)
208− ++ de :: ECB dec
209− ~/ %de
210− |= [a=@I b=@H] ^- @uxH
211− =+ ahem
212− (be | (ix (ex a)) b)
213− --
385+++ aes !.
386+ ~% %aes ..part ~
387+ |%
388+ ++ ahem
389+ |= [nnk=@ nnb=@ nnr=@]
390+ =>
391+ =+ => [gr=(ga 8 0x11b 3) few==>(fe .(a 5))]
392+ [pro=pro.gr dif=dif.gr pow=pow.gr ror=ror.few]
393+ => |%
394+ ..........
214395```
215396
216−Here we label the entire `++aesc` core for optimization. You can see the
217−jet in `jets/e/aesc.c`.
397+Here we label the entire `++aes` core for optimization.
218398
399+---
219400
220−### `~<` "siggal"
401+## `~<` "siggal"
221402
403+Raw hint, applied to product.
222404
223−`[%sggl p=$@(term [p=term q=hoon]) q=hoon]`: raw hint, applied to
224−product.
405+#### Syntax
225406
226−##### Expands to
407+Two arguments, fixed.
227408
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
229438
230−##### Syntax
439+```hoon
440+[%sggl p=$@(term [p=term q=hoon]) q=hoon]
441+```
231442
232−Regular: **2-fixed**. For the dynamic form, write `%term.hoon`.
443+#### Expands to
444+
445+`q`.
233446
234−##### Discussion
447+#### Discussion
235448
236−`~<` is only used for jet hints ([`~/`](#sigfas)
237−and [`~%`](#sigcen)) at the moment; we are not telling the
238−interpreter something about the computation we're about to perform, but
239−rather about its product.
449+`~<` is only used for jet hints ([`~/`](#sigfas) and [`~%`](#sigcen)) at the
450+moment; we are not telling the interpreter something about the computation we're
451+about to perform, but rather about its product.
240452
241−##### Examples
453+#### Examples
242454
243455```
244456> (make '~<(%a 42)')
@@ -247,64 +459,129 @@ rather about its product.
247459[%7 p=[%1 p=42] q=[%11 p=[p=97 q=[%4 p=[%0 p=1]]] q=[%0 p=1]]]
248460```
249461
250−### `~+` "siglus"
462+---
463+
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
251497
252−`[%sgls p=hoon]`: cache a computation.
498+```hoon
499+[%sgls p=hoon]
500+```
253501
254−##### Expands to
502+#### Expands to
255503
256504`p`.
257505
258−##### Convention
506+#### Convention
259507
260508Caches the formula and subject of `p` in a local cache (generally
261509transient in the current event).
262510
263−##### Syntax
264−
265−Regular: **1-fixed**.
266−
267−##### Examples
511+#### Examples
268512
269513This may pause for a second:
270514
271515```
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))))))
273517121.393
274518```
275519
276520This may make you want to press `ctrl-c`:
277521
278522```
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))))))
2805241.346.269
281525```
282526
283527This should work fine:
284528
285529```
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)))))))
287531573.147.844.013.817.084.101
288532```
289533
290−### `~/` "sigfas"
534+---
535+
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
291570
292−`[%sgfs p=term q=hoon]`: jet registration for gate with
293−registered context.
571+```hoon
572+[%sgfs p=term q=hoon]
573+```
294574
295−##### Expands to
575+#### Expands to
296576
297577```hoon
298578~%(p +7 ~ q)
299579```
300580
301−##### Syntax
302−
303−Regular: **2-fixed**.
304−
305−##### Examples
581+#### Examples
306582
307583From the kernel:
584+
308585```hoon
309586++ add
310587 ~/ %add
@@ -314,139 +591,277 @@ From the kernel:
314591 $(a (dec a), b +(b))
315592```
316593
317−### `~&` "sigpam"
594+---
595+
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
318630
319−`[%sgpm p=hoon q=hoon]`: debugging printf.
631+```hoon
632+[%sgpm p=hoon q=hoon]
633+```
320634
321−##### Expands to
635+#### Expands to
322636
323637`q`.
324638
325−##### Product
639+#### Product
326640
327641Pretty-prints `p` on the console before computing `q`.
328642
329−##### Discussion
643+#### Discussion
330644
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.
332647
333648It's most useful for debugging programs.
334649
335−##### Syntax
336−
337−Regular: **2-fixed**.
338−
339−##### Examples
650+#### Examples
340651
341652```
342−~zod:dojo> ~&('halp' ~)
653+> ~&('halp' ~)
343654'halp'
344655~
345656
346−~zod:dojo> ~& 'halp'
347− ~
657+> ~& 'halp'
658+ ~
348659'halp'
349660~
350661```
351662
352−### `~=` "sigtis"
663+---
664+
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
353699
354−`[%sgts p=hoon q=hoon]`: detect duplicate.
700+```hoon
701+[%sgts p=hoon q=hoon]
702+```
355703
356−##### Expands to
704+#### Expands to
357705
358706`q`.
359707
360−##### Convention
708+#### Convention
361709
362710If `p` equals `q`, produce `p` instead of `q`.
363711
364−##### Discussion
712+#### Discussion
365713
366714Duplicate 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.
368716
369−##### Examples
717+#### Examples
370718
371719This code traverses a tree and replaces all instances of `32` with
372720`320`:
373721
374722```
375−~zod:dojo> =foo |= a=(tree)
376− ?~(a ~ ~=(a [?:(=(n.a 32) 320 n.a) $(a l.a) $(a r.a)]))
723+> =foo |= a=(tree)
724+ ?~(a ~ ~=(a [?:(=(n.a 32) 320 n.a) $(a l.a) $(a r.a)]))
377725
378−~zod:dojo> (foo 32 ~ ~)
726+> (foo 32 ~ ~)
379727[320 ~ ~]
380728```
381729
382−Without `~=`, it would build a copy of a completely unchanged tree. Sad!
383−
384−### `~?` "sigwut"
730+Without `~=`, it would build a copy of a completely unchanged tree. Sad!
731+
732+---
733+
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
385769
386−`[%sgwt p=hoon q=hoon r=hoon]`: conditional debug printf.
770+```hoon
771+[%sgwt p=hoon q=hoon r=hoon]
772+```
387773
388−##### Expands to
774+#### Expands to
389775
390776`r`.
391777
392−##### Convention
778+#### Convention
393779
394780If `p` is true, prettyprints `q` on the console before computing `r`.
395781
396−##### Syntax
397−
398−Regular: **3-fixed**.
399−
400−##### Examples
782+#### Examples
401783
402784```
403−~zod:dojo> ~?((gth 1 2) 'oops' ~)
785+> ~?((gth 1 2) 'oops' ~)
404786~
405787
406−~zod:dojo> ~?((gth 1 0) 'oops' ~)
788+> ~?((gth 1 0) 'oops' ~)
407789'oops'
408790~
409791
410−~zod:dojo> ~? (gth 1 2)
411− 'oops'
412− ~
792+> ~? (gth 1 2)
793+ 'oops'
794+ ~
413795~
414796
415−~zod:dojo> ~? (gth 1 0)
416− 'oops'
417− ~
797+> ~? (gth 1 0)
798+ 'oops'
799+ ~
418800'oops'
419801~
420802```
421803
422−### `~!` "sigzap"
804+---
805+
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
423840
424−`[%sgzp p=hoon q=hoon]`: print type on compilation fail.
841+```hoon
842+[%sgzp p=hoon q=hoon]
843+```
425844
426−##### Expands to
845+#### Expands to
427846
428847`q`.
429848
430−##### Convention
849+#### Convention
431850
432851If compilation of `q` fails, prints the type of `p` in the trace.
433852
434−##### Syntax
435−
436−Regular: **2-fixed**.
437−
438−##### Examples
853+#### Examples
439854
440855```
441−~zod:dojo> a
856+> a
442857! -find.a
443858
444−~zod:dojo> ~!('foo' a)
859+> ~!('foo' a)
445860! @t
446861! find.a
447862
448−~zod:dojo> ~! 'foo'
449− a
863+> ~! 'foo'
864+ a
450865! @t
451866! find.a
452867```
content/docs/hoon/reference/rune/terminators.md+25−14
@@ -1,23 +1,26 @@
11+++
22title = "Terminators -- and =="
3−weight = 15
3+weight = 16
44template = "doc.html"
55+++
6−The `--` and `==` are used as terminators: `--` for core expressions, and `==` for terminating a 'running' or 'jogging' series of Hoon expressions.
76
8−## Runes
7+The `--` and `==` are used as terminators: `--` for core expressions, and `==`
8+for terminating a 'running' or 'jogging' series of Hoon expressions.
99
10−### `--` "hephep"
10+## `--` "hephep"
1111
12−##### Syntax
12+#### Syntax
1313
1414The `--` rune is used to indicate the end of a core expression.
1515
16−##### Discussion
16+#### Discussion
1717
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.
18+The `|%`, `|_`, and `|^` runes are used to create cores that can have
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.
1922
20−##### Examples
23+#### Examples
2124
2225```
2326> =num |%
@@ -36,17 +39,25 @@ The `|%`, `|_`, and `|^` runes are used to create cores that can have arbitraril
363924
3740```
3841
39−### `==` "tistis"
42+---
4043
41−##### Syntax
44+## `==` "tistis"
4245
43−The `==` rune is used to indicate the end of a 'jogging' or 'running' series of Hoon expressions.
46+#### Syntax
4447
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).
4650
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
4852
49−##### Examples
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+
60+#### Examples
5061
5162```
5263> :* 2
content/docs/hoon/reference/rune/tis.md+749−202
@@ -4,127 +4,287 @@ weight = 5
44template = "doc.html"
55+++
66
7−These runes modify the subject. (Or more precisely, they
7+These runes modify the subject. (Or more precisely, they
88evaluate at least one of their subexpressions with a modified subject.)
99
1010## Overview
1111
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
1313to 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 `=`
1515family of runes.
1616
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
19−the cell is the new value. So to pin `12` with the face `a` the new subject
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
19+the cell is the new value. So to pin `12` with the face `a` the new subject
2020would be: `[a=12 p]`.
2121
2222Of 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
2461
25−## Runes
26−
27−### `=>` "tisgar"
28−
29−`[%tsgr p=hoon q=hoon]`: compose two expressions.
62+```hoon
63+[%tsgr p=hoon q=hoon]
64+```
3065
31−##### Produces
66+#### Produces
3267
3368the product of `q`, with the product of `p` taken as the subject.
3469
35−##### Syntax
36−
37−Regular: **2-fixed**.
38−
39−##### Examples
70+#### Examples
4071
4172```
4273> =>([a=1 b=2 c=3] b)
43742
4475
76+> => 9 .
77+9
78+
4579> =>((add 2 4) [. .])
4680[6 6]
47−```
4881
49−### `=|` "tisbar"
82+> =>
83+ |%
84+ ++ foo
85+ |= [a=@ b=@]
86+ [b a]
87+ --
88+ (foo 42 27)
89+[27 42]
90+```
5091
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
51129
52−`[%tsbr p=spec q=hoon]`: combine a default type value with the subject.
130+```hoon
131+[%tsbr p=spec q=hoon]
132+```
53133
54−##### Expands to
134+#### Expands to
55135
56136```hoon
57137=+(*p q)
58138```
59139
60−##### Syntax
61−
62−Regular: **2-fixed**.
140+#### Discussion
63141
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.
65144
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.
67147
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
71149
72150```
73−~zod:dojo> =foo |= a=@
74− =| b=@
75− =- :(add a b c)
76− c=2
77−~zod:dojo> (foo 5)
78−7
151+> =| a=@ud a
152+0
153+
154+> =| a=[@t @t @t] a
155+['' '' '']
79156```
80157
81−### `=:` "tiscol"
158+---
159+
160+## `=:` "tiscol"
82161
83−`[%tscl p=(list (pair wing hoon)) q=hoon]`: change multiple legs in the subject.
162+Change multiple legs in the subject.
84163
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
86197
87198```hoon
88−=>(%_(. p) q)
199+[%tscl p=(list (pair wing hoon)) q=hoon]
89200```
90201
91−##### Syntax
202+#### Expands to
92203
93−Regular: **jogging**, then **1-fixed**.
204+```hoon
205+=>(%_(. p) q)
206+```
94207
95−##### Discussion
208+#### Discussion
96209
97210This rune is like `=.`, but for modifying the values of multiple legs of the subject.
98211
99−##### Examples
212+#### Examples
100213
101214```
102−~zod:dojo> =+ a=[b=1 c=2]
103− =: c.a 4
104− b.a 3
105− ==
106− a
215+> =+ a=[b=1 c=2]
216+ =: c.a 4
217+ b.a 3
218+ ==
219+ a
107220[b=3 c=4]
108221```
109222
110−### `=,` "tiscom"
223+---
224+
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
111259
112−`[%tscm p=hoon q=hoon]`: expose namespace
260+```hoon
261+[%tscm p=hoon q=hoon]
262+```
113263
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
115265
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`).
117268
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+```
119279
120−##### Examples
280+#### Examples
121281
122282With an imported core:
123283
124284```
125285> (sum -7 --7)
126286-find.sum
127−[crash message]
287+dojo: hoon expression failed
128288
129289> (sum:si -7 --7)
130290--0
@@ -142,26 +302,61 @@ With a dojo-defined face:
142302[2 4]
143303```
144304
145−### `=.` "tisdot"
305+---
306+
307+## `=.` "tisdot"
308+
309+Change one leg in the subject.
310+
311+#### Syntax
146312
147−`[%tsdt p=wing q=hoon r=hoon]`: change one leg in the subject.
313+Three arguments, fixed.
148314
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
150341
151342```hoon
152−=>(%_(. p q) r)
343+[%tsdt p=wing q=hoon r=hoon]
153344```
154345
155−##### Syntax
346+#### Expands to
156347
157−Regular: **3-fixed**.
348+```hoon
349+=>(%_(. p q) r)
350+```
158351
159−##### Discussion
352+#### Discussion
160353
161−Technically the `=.` rune doesn't change the subject. It creates
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`.
354+Technically the `=.` rune doesn't change the subject. It creates a new subject
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`.
163358
164−##### Examples
359+#### Examples
165360
166361```
167362> =+ 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
178373nest-fail
179374```
180375
181−### `=-` "tishep"
376+---
377+
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
182412
183−`[%tshp p=hoon q=hoon]`: combine a new noun with the subject, inverted.
413+```hoon
414+[%tshp p=hoon q=hoon]
415+```
184416
185−##### Expands to
417+#### Expands to
186418
187419```hoon
188420=>([q .] p)
189421```
190422
191−##### Syntax
192−
193−Regular: **2-fixed**.
423+#### Discussion
194424
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.
196428
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
200430
201431```
202−~zod:dojo> =foo |= a=@
203− =+ b=1
204− =- (add a b c)
205− c=2
206−~zod:dojo> (foo 5)
432+> =foo |= a=@
433+ =+ b=1
434+ =- (add a b c)
435+ c=2
436+> (foo 5)
2074378
208438```
209439
210−### `=^` "tisket"
440+---
441+
442+## `=^` "tisket"
443+
444+Pin the head of a pair; change a leg with the tail.
211445
212−`[%tskt p=skin q=wing r=hoon s=hoon]`: pin the head of a pair; change
213−a leg with the tail.
446+#### Syntax
214447
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
216477
217478```hoon
218−=/(p -.r =.(q +.r s))
479+[%tskt p=skin q=wing r=hoon s=hoon]
219480```
220481
221−##### Syntax
482+#### Expands to
483+
484+```hoon
485+=/(p -.r =.(q +.r s))
486+```
222487
223−Regular: **4-fixed**.
488+#### Discussion
224489
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.
226494
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:
228498
229−We generally use `=^` when we have a state machine with a function, `r`, that
230−produces a cell, whose head is a result and whose tail is a new
231−state. The head value is given a new name `p`, and the
232−tail is stuffed back into wherever we stored the old state, `q`.
499+```hoon
500+=^ cards state
501+ (handle-poke !<(action vase))
502+[cards this]
503+```
233504
234505This may also remind you of Haskell's State monad.
235506
236−##### Examples
507+#### Examples
237508
238509The `og` core is a stateful pseudo-random number generator.
239510We have to change the core state every time we generate a
@@ -247,114 +518,269 @@ random number, so we use `=^`:
247518[99 46]
248519```
249520
250−### `=<` "tisgal"
521+---
522+
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
251561
252−`[%tsgl p=hoon q=hoon]`: compose two expressions, inverted.
562+```hoon
563+[%tsgl p=hoon q=hoon]
564+```
253565
254−##### Expands to
566+#### Expands to
255567
256568```hoon
257569=>(q p)
258570```
259571
260−##### Syntax
261−
262−Regular: **2-fixed**.
263−
264−Irregular: `foo:baz` is `=<(foo baz)`.
265−
266−##### Discussion
572+#### Discussion
267573
268574`=<` is just `=>` backwards.
269575
270−##### Examples
576+#### Examples
271577
272578```
273−~zod:dojo> =<(b [a=1 b=2 c=3])
579+> =<(b [a=1 b=2 c=3])
2745802
275581
276−~zod:dojo> =< b
277− [a=1 b=2 c=3]
582+> =< b
583+ [a=1 b=2 c=3]
2785842
279585
280−~zod:dojo> b:[a=1 b=2 c=3]
586+> b:[a=1 b=2 c=3]
2815872
282588
283−~zod:dojo> [. .]:(add 2 4)
589+> [. .]:(add 2 4)
284590[6 6]
285591```
286592
287−### `=+` "tislus"
288−
593+---
594+
595+## `=+` "tislus"
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
289629
290−`[%tsls p=hoon q=hoon]`: combine a new noun with the subject.
630+```hoon
631+[%tsls p=hoon q=hoon]
632+```
291633
292−##### Expands to
634+#### Expands to
293635
294636```hoon
295637=>([p .] q)
296638```
297639
298−##### Syntax
640+#### Discussion
299641
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.
301645
302−##### Discussion
646+Loosely speaking, `=+` is the simplest way of "declaring a variable."
303647
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
305649
306−Loosely speaking, `=+` is the simplest way of "declaring a variable."
650+```
651+> =+ 42 -
652+42
307653
308−##### Examples
654+> =+ x=42 x
655+42
309656
310−### `=;` "tismic"
657+> =+ [a='foo' b='bar'] a
658+'foo'
659+```
311660
312−`[%tsmc p=skin q=hoon r=hoon]`: combine a named noun with the subject, possibly with type annotation; inverted order.
661+---
313662
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
315699
316700```hoon
317−=/(p r q)
701+[%tsmc p=skin q=hoon r=hoon]
318702```
319703
320−##### Syntax
704+#### Expands to
321705
322−Regular: **3-fixed**.
706+```hoon
707+=/(p r q)
708+```
323709
324−##### Discussion
710+#### Discussion
325711
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.
327714
328−##### Examples
715+#### Examples
329716
330717```
331−~zod:dojo> =foo |= a=@
332− =/ b 1
333− =; c=@ :(add a b c)
334− 2
335−~zod:dojo> (foo 5)
718+> =foo |= a=@
719+ =/ b 1
720+ =; c=@
721+ :(add a b c)
722+ 2
723+> (foo 5)
3367248
337725```
338726
339−### `=/` "tisfas"
727+---
728+
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
340764
341−`[%tsfs p=skin q=hoon r=hoon]`: combine a named noun with the subject, possibly with type annotation.
765+```hoon
766+[%tsfs p=skin q=hoon r=hoon]
767+```
342768
343−##### Expands to
769+#### Expands to
344770
345−**if `p` is a name**, (e.g. `a`):
771+if `p` is a name, (e.g. `a`):
346772
347773```hoon
348774=+(^=(p q) r)
349775```
350776
351−**if `p` is a name with a type** (e.g., `a=@`):
777+if `p` is a name with a type (e.g., `a=@`):
352778
353779```hoon
354780=+(^-(p q) r)
355781```
356782
357−##### Desugaring
783+#### Desugaring
358784
359785```hoon
360786?@ p
@@ -364,76 +790,155 @@ Regular: **3-fixed**.
364790r
365791```
366792
367−##### Syntax
793+#### Discussion
368794
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."
370798
371−##### Discussion
799+#### Examples
372800
373−`p` can be either a name or a name=type. If it's just a name,
374−`=/` ("tisfas") "declares a type-inferred variable." If it has a type, `=/`
375−"declares a type-checked variable."
801+```
802+> =/ a=@t 'hello' a
803+'hello'
376804
377−##### Examples
805+> =/ x [1 2 3] x
806+[1 2 3]
378807
379−```
380−~zod:dojo> =foo |= a=@
381− =/ b 1
382− =/ c=@ 2
383− :(add a b c)
384−~zod:dojo> (foo 5)
808+> =foo |= a=@
809+ =/ b 1
810+ =/ c=@ 2
811+ :(add a b c)
812+> (foo 5)
3858138
386814```
387815
388−### `=~` "tissig"
389−
816+---
817+
818+## `=~` "tissig"
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
390855
391−`[%tssg p=(list hoon)]`: compose many expressions.
856+```hoon
857+[%tssg p=(list hoon)]
858+```
392859
393−##### Produces
860+#### Produces
394861
395862The product of the chain composition.
396863
397−##### Syntax
398−
399−Regular: **running**.
400−
401−##### Examples
864+#### Examples
402865
403866```
404−~zod:dojo> =~ [sub (mul 3 20) (add 10 20)]
867+> =~ 10
868+ [20 .]
869+ [30 .]
870+ [40 .]
871+ .
872+ ==
873+[40 30 20 10]
874+
875+> =~ [sub (mul 3 20) (add 10 20)]
405876 (sub +)
406877 +(.)
407878 ==
40887931
409880
410−~zod:dojo> =foo =| n=@
411− =< =~ increment
412− increment
413− increment
414− n
415− ==
416− |%
417− ++ increment
418− ..increment(n +(n))
419− --
420−~zod:dojo> foo
881+> =foo =| n=@
882+ =< =~ increment
883+ increment
884+ increment
885+ n
886+ ==
887+ |%
888+ ++ increment
889+ ..increment(n +(n))
890+ --
891+> foo
4218923
422893```
423894
424−### `=*` "tistar" {#tistar}
895+---
425896
426−`[%tstr p=term q=hoon r=hoon]`: define a deferred expression.
897+## `=*` "tistar" {#tistar}
427898
428−##### Produces
899+Define a deferred expression.
429900
430−`r`, compiled with a subject in which `p` is a deferred expression for `q`.
901+#### Syntax
431902
432−##### Syntax
903+Three arguments, fixed.
433904
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
435932
436−##### Discussion
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+
941+#### Discussion
437942
438943`=*` assigns a name to an expression that will be evaluated in each place the
439944name is dereferenced. This allows you to "write" through it to the original
@@ -443,47 +948,89 @@ calculated every time you use `p`.
443948This rune has some similarities with macros, and some similarities with aliases,
444949but it is not really either.
445950
446−##### Examples
951+This rune is commonly used to give a Gall agent's state the name `state` like:
447952
953+```hoon
954+=* state -
448955```
449−~zod:dojo>
450− =+ a=1
451− =* b a
452− [a b]
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+```
964+> =+ a=1
965+ =* b a
966+ [a b]
453967[1 1]
454968
455−~zod:dojo>
456− =+ a=1
457− =* b a
458− =. a 2
459− [a b]
969+> =+ a=1
970+ =* b a
971+ =. a 2
972+ [a b]
460973[2 2]
461974```
462975
463−### `=?` "tiswut"
976+---
464977
465−`[$tswt p=wing q=hoon r=hoon s=hoon]`: conditionally change one leg in the subject.
978+## `=?` "tiswut"
466979
467−##### Expands to
980+Conditionally change one leg in the subject.
468981
469−```hoon
470−=. p ?:(q r p)
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>
992+=? p q
993+ r
471994s
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]
4721016```
4731017
474−##### Syntax
1018+#### Expands to
4751019
476−Regular: **4-fixed**.
1020+```hoon
1021+=. p ?:(q r p)
1022+s
1023+```
4771024
478−##### Discussion
1025+#### Discussion
4791026
4801027Use `=?` to replace the value of leg `p` with `r` on condition `q`. As
4811028usual, 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
4831030type check against the old subject; the type of `r` must nest under
4841031the type of `p`.
4851032
486−##### Examples
1033+#### Examples
4871034
4881035```
4891036> =a 12
content/docs/hoon/reference/rune/wut.md+756−254
@@ -4,9 +4,10 @@ weight = 6
44template = "doc.html"
55aliases = ["docs/reference/hoon-expressions/rune/wut/"]
66+++
7−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−whether a value matches a given type. In the course of type inference, Hoon
7+
8+Hoon has the usual program control branches. It also has the usual logical
9+operators: AND `?&`, OR `?|`, and NOT `?!`. It also has a `?=` rune that tests
10+whether a value matches a given type. In the course of type inference, Hoon
1011learns from `?=` tests in the test condition of [`?:` ("wutcol")](#wutcol)
1112expressions.
1213
@@ -16,321 +17,634 @@ All `?` runes reduce to `?:` and/or `?=`.
1617
1718If the condition of an `?:` is a `?=`, **and** the `?=` is
1819testing 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
2021for expressions which expand to `?:`.
2122
2223The test does not have to be a single `?=`; the compiler can
2324analyze arbitrary boolean logic ([`?&` ("wutpam")](#wutpam),
2425[`?|` ("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**
2627analyzed.
2728
2829If the compiler detects that the branch is degenerate (only one
2930side is taken), it fails with an error.
3031
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
3275
33−### `?>` "wutgar"
76+```hoon
77+[%wtbr p=(list hoon)]
78+```
3479
35−`[%wtgr p=hoon q=hoon]`: positive assertion.
80+#### Expands to
3681
37−##### Expands to
82+**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
3883
3984```hoon
40−?.(p !! q)
85+?:(a & ?:(b & ?:(c & ?:(... ?:(z & |)))))
4186```
4287
43−##### Syntax
44−
45−Regular: **2-fixed**.
88+#### Desugaring
4689
47−##### Discussion
90+```hoon
91+|-
92+?~ p
93+ |
94+?: i.p
95+ &
96+$(p t.p)
97+```
4898
49−`?>` is used to force a crash when some condition `p` doesn't yield 'yes', `%.y`.
99+#### Produces
50100
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.
52103
53−##### Examples
104+#### Examples
54105
55106```
56−> ?>(=(3 3) %foo)
57−%foo
58−
59−> ?>(=(3 4) %foo)
60−ford: build failed
61−
62−> =a `*`123
63−
64−> `@`a
65−nest-fail
107+> |(=(6 42) =(42 42))
108+%.y
66109
67−> ?>(?=(@ a) `@`a)
68−123
110+> |(=(6 42) =(42 43))
111+%.n
69112```
70113
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
72170
73−`[%wtbr p=(list hoon)]`: logical OR.
171+```hoon
172+[%wthp p=wing q=(list (pair spec value))]
173+```
74174
75−##### Expands to
175+#### Expands to
76176
77−**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
177+**Pseudocode**: `a`, `b`, `c`, ... as elements of `q`:
78178
79179```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 !!)
81185```
82186
83−##### Desugaring
187+#### Desugaring
84188
85189```hoon
86190|-
87−?~ p
88− |
89−?: i.p
90− &
91−$(p t.p)
191+?. q
192+ ~|(%mint-lost !!)
193+?: ?=(p.i.q p)
194+ q.i.q
195+$(q t.q)
92196```
93197
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.
95203
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.
97207
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`.
99210
100−##### Examples
211+#### Examples
101212
102213```
103−~zod:dojo> |(=(6 42) =(42 42))
104−%.y
214+> =cor |= vat=?(%a %b)
215+ ?- vat
216+ %a 20
217+ %b 42
218+ ==
105219
106−~zod:dojo> |(=(6 42) =(42 43))
107−%.n
220+> (cor %a)
221+20
222+
223+> (cor %b)
224+42
225+
226+> (cor %c)
227+! nest-fail
108228```
109229
110−### `?:` "wutcol" {#wutcol}
230+---
111231
112−`[%wtcl p=hoon q=hoon r=hoon]`: branch on a boolean test.
232+## `?:` "wutcol" {#wutcol}
113233
114−##### Produces
234+Branch on a boolean test.
115235
116−If `p` produces yes, `%.y`, then `q`. If `p` produces no, `%.n`, then `r`.
117−If `p` is not a boolean, compiler yells at you.
236+#### Syntax
118237
119−##### Type inference
238+Three arguments, fixed.
120239
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
122267
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+```
124271
125−##### Syntax
272+#### Produces
126273
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.
128276
129−##### Discussion
277+#### Discussion
130278
131−Short-circuiting in boolean tests works as you'd expect
132−and includes the expected inference. For instance,
133−if you write `?&(a b)`, `b` is only executed if `a` is
134−positive, and compiled with that assumption.
279+If test analysis reveals that either branch is never taken, or if `p` is not a
280+boolean, compilation fails. An untaken branch is indicated with `mint-lost`.
135281
136282Note also that all other branching expressions reduce to `?:`.
137283
138−##### Examples
284+#### Examples
139285
140286```
141−~zod:dojo> ?:((gth 1 0) 3 4)
287+> ?:((gth 1 0) 3 4)
1422883
143289
144−~zod:dojo> ?: (gth 1 0)
145− 3
146− 4
290+> ?: (gth 1 0)
291+ 3
292+ 4
1472933
148294
149−~zod:dojo> ?:((gth 1 2) 3 4)
295+> ?:((gth 1 2) 3 4)
1502964
151297
152−~zod:dojo> ?: (gth 1 2)
153− 3
154− 4
298+> ?: (gth 1 2)
299+ 3
300+ 4
1553014
156302```
157303
158−### `?.` "wutdot"
304+---
159305
160−`[%wtdt p=hoon q=hoon r=hoon]`: branch on a boolean test, inverted.
306+## `?.` "wutdot"
161307
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
163341
164342```hoon
165−?:(p r q)
343+[%wtdt p=hoon q=hoon r=hoon]
166344```
167345
168−##### Syntax
346+#### Expands to
169347
170−Regular: **3-fixed**.
348+```hoon
349+?:(p r q)
350+```
171351
172−##### Discussion
352+#### Discussion
173353
174354`?.` is just like `?:`, but with its last two subexpressions reversed.
175355
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.
177358
178−##### Examples
359+#### Examples
179360
180361```
181−~zod:dojo> ?.((gth 1 2) 3 4)
362+> ?.((gth 1 2) 3 4)
1823633
183364
184−~zod:dojo> ?.(?=(%a 'a') %not-a %yup)
365+> ?.(?=(%a 'a') %not-a %yup)
185366%yup
186367
187−~zod:dojo> ?. %.y
188− 'this false case is less heavy than the true case'
189− ?: =(2 3)
190− 'two not equal to 3'
191− 'but see how \'r is much heavier than \'q?'
368+> ?. %.y
369+ 'this false case is less heavy than the true case'
370+ ?: =(2 3)
371+ 'two not equal to 3'
372+ 'but see how \'r is much heavier than \'q?'
192373'but see how \'r is much heavier than \'q?'
193374```
194375
195−### `?-` "wuthep"
376+---
196377
197−`[%wthp p=wing q=(list (pair spec value))]`: switch against a union, with no default.
378+## `?^` "wutket"
198379
199−##### Expands to
380+Branch on whether a wing of the subject is a cell.
200381
201−**Pseudocode**: `a`, `b`, `c`, ... as elements of `q`:
382+#### Syntax
202383
203−```hoon
204−?: ?=(p.a p) q.a
205−?: ?=(p.b p) q.b
206−?: ?=(p.c p) q.c
207−...
208−~|(%mint-lost !!)
209−```
384+Three arguments, fixed.
210385
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
212413
213414```hoon
214−|-
215−?. q
216− ~|(%mint-lost !!)
217−?: ?=(p.i.q p)
218− q.i.q
219−$(q t.q)
415+[%wtkt p=wing q=hoon r=hoon]
220416```
221417
222−##### Syntax
418+#### Expands to
223419
224−Regular: **1-fixed**, then **jogging**.
420+```hoon
421+?:(?=(^ p) q r)
422+```
225423
226−##### Discussion
424+#### Discussion
227425
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.
229429
230−The compiler makes sure that your code neither misses a case of
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.
430+#### Examples
234431
235−A missing case will throw the `mint-lost` error. An extra case
236−will throw `mint-vain`.
432+```
433+> ?^(0 1 2)
434+! mint-vain
435+! exit
237436
238−##### Examples
437+> ?^(`*`0 1 2)
438+2
239439
440+> ?^(`*`[1 2] 3 4)
441+3
240442```
241−~zod:dojo> =cor |= vat=?(%a %b)
242− ?- vat
243− %a 20
244− %b 42
245− ==
246443
247−~zod:dojo> (cor %a)
248−20
444+---
249445
250−~zod:dojo> (cor %b)
251−42
446+## `?<` "wutgal"
252447
253−~zod:dojo> (cor %c)
254−! nest-fail
255−```
448+Negative assertion.
256449
257−### `?^` "wutket"
450+#### Syntax
258451
259−`[%wtkt p=wing q=hoon r=hoon]`: branch on whether a wing
260−of the subject is a cell.
452+Two arguments, fixed.
261453
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
263480
264481```hoon
265−?:(?=(^ p) q r)
482+[%wtgl p=hoon q=hoon]
266483```
267484
268−##### Syntax
485+#### Expands to
269486
270−Regular: **3-fixed**.
487+```hoon
488+?:(p !! q)
489+```
271490
272−##### Discussion
491+#### Discussion
273492
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.
275496
276−##### Examples
497+#### Examples
277498
278499```
279−~zod:dojo> ?^(0 1 2)
280−! mint-vain
281−! exit
500+> ?<(=(3 4) %foo)
501+%foo
282502
283−~zod:dojo> ?^(`*`0 1 2)
284−2
503+> ?<(=(3 3) %foo)
504+dojo: hoon expression failed
285505
286−~zod:dojo> ?^(`*`[1 2] 3 4)
287−3
506+> =a `*`[12 14]
507+
508+> `^`a
509+nest-fail
510+
511+> ?<(?=(@ a) `^`a)
512+[12 14]
288513```
289514
290−### `?<` "wutgal"
515+---
516+
517+## `?>` "wutgar"
291518
292−`[%wtgl p=hoon q=hoon]`: negative assertion.
519+Positive assertion.
293520
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
295551
296552```hoon
297−?:(p !! q)
553+[%wtgr p=hoon q=hoon]
298554```
299555
300−##### Syntax
301−
302−Regular: **2-fixed**.
556+#### Expands to
303557
304−##### Discussion
558+```hoon
559+?.(p !! q)
560+```
305561
306−`?<` is used to force a crash when some condition `p` doesn't yield 'no', `%.n`.
562+#### Discussion
307563
308−It can be used for type inference with the `?=` rune, much like the `?>` rune.
564+`?>` is used to force a crash when some condition `p` doesn't yield true
565+(`%.y`). It can be used for type inference, with the `?=` rune, to specify the
566+type of a value.
309567
310−##### Examples
568+#### Examples
311569
312570```
313−> ?<(=(3 4) %foo)
571+> ?>(=(3 3) %foo)
314572%foo
315573
316−> ?<(=(3 3) %foo)
317−ford: build failed
574+> ?>(=(3 4) %foo)
575+dojo: hoon expression failed
318576
319−> =a `*`[12 14]
577+> =a `*`123
320578
321−> `^`a
579+> `@`a
322580nest-fail
323581
324−> ?<(?=(@ a) `^`a)
325−[12 14]
582+> ?>(?=(@ a) `@`a)
583+123
326584```
327585
328−### `?+` "wutlus"
586+---
587+
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
329642
330−`[%wtls p=wing q=hoon r=(list (pair spec hoon))]`: switch against
331−a union, with a default.
643+```hoon
644+[%wtls p=wing q=hoon r=(list (pair spec hoon))]
645+```
332646
333−##### Expands to
647+#### Expands to
334648
335649**Pseudocode**: `a`, `b`, `c`, ... as elements of `r`:
336650
@@ -342,7 +656,7 @@ a union, with a default.
342656q
343657```
344658
345−##### Desugaring
659+#### Desugaring
346660
347661```hoon
348662|-
@@ -353,40 +667,82 @@ q
353667$(r t.r)
354668```
355669
356−##### Syntax
357−
358−Regular: **2-fixed**, then **jogging**.
359−
360−##### Discussion
670+#### Discussion
361671
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.
672+The `?+` rune is for a conditional expression in which the type of `p`
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.
363676
364677If there is a case that is never taken you'll get a `mint-vain` error.
365678
366−##### Examples
679+#### Examples
367680
368681```
369−~zod:dojo> =cor |= vat=@tas
370− ?+ vat 240
371− %a 20
372− %b 42
373− ==
682+> =cor |= vat=@tas
683+ ?+ vat 240
684+ %a 20
685+ %b 42
686+ ==
374687
375−~zod:dojo> (cor %a)
688+> (cor %a)
37668920
377690
378−~zod:dojo> (cor %b)
691+> (cor %b)
37969242
380693
381−~zod:dojo> (cor %c)
694+> (cor %c)
382695240
383696```
384697
385−### `?&` "wutpam"
698+---
699+
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
386740
387−`[%wtpm p=(list hoon)]`: logical AND.
741+```hoon
742+[%wtpm p=(list hoon)]
743+```
388744
389−##### Expands to
745+#### Expands to
390746
391747**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
392748
@@ -394,7 +750,7 @@ If there is a case that is never taken you'll get a `mint-vain` error.
394750?.(a | ?.(b | ?.(c | ?.(... ?.(z | &)))))
395751```
396752
397−##### Desugaring
753+#### Desugaring
398754
399755```hoon
400756|-
@@ -405,136 +761,282 @@ If there is a case that is never taken you'll get a `mint-vain` error.
405761$(p t.p)
406762```
407763
408−##### Syntax
409−
410−Regular: **running**.
764+#### Produces
411765
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`).
413768
414−##### Examples
769+#### Examples
415770
416771```
417−~zod:dojo> &(=(6 6) =(42 42))
772+> &(=(6 6) =(42 42))
418773%.y
419774
420−~zod:dojo> &(=(6 7) =(42 43))
775+> &(=(6 7) =(42 42))
421776%.n
422777```
423778
424−### `?~` "wutsig"
779+---
425780
426−`[%wtsg p=wing q=hoon r=hoon]`: branch on whether a wing of the subject is null.
781+## `?@` "wutpat"
427782
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
429816
430817```hoon
431−?:(?=($~ p) q r)
818+[%wtpt p=wing q=hoon r=hoon]
819+```
820+
821+#### Expands to
822+
823+```hoon
824+?:(?=(@ p) q r)
432825```
433826
434−##### Syntax
827+#### Produces
435828
436−Regular: **3-fixed**.
829+If `p` is an atom, `q`. If `p` is a cell, `r`.
437830
438−##### Discussion
831+#### Discussion
439832
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.
441836
442−##### Examples
837+#### Examples
443838
444839```
445−~zod:dojo> =foo ""
840+> ?@(0 1 2)
841+! mint-vain
842+! exit
446843
447−~zod:dojo> ?~(foo 1 2)
844+> ?@(`*`0 1 2)
4488451
846+
847+> ?@(`*`[1 2] 3 4)
848+4
449849```
450850
451−### `?=` "wuttis"
851+---
852+
853+## `?~` "wutsig"
452854
453−`[%wtts p=spec q=wing]`: test pattern match.
855+Branch on whether a wing of the subject is null.
454856
455−##### Produces
857+#### Syntax
456858
457−`%.y` (yes) if the noun at `q` is in the type of `p`; `%.n` (no) otherwise.
859+Three arguments, fixed.
458860
459−##### Syntax
861+<table>
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
460888
461−Regular: **2-fixed**.
889+```hoon
890+[%wtsg p=wing q=hoon r=hoon]
891+```
462892
463−##### Discussion
893+#### Expands to
464894
465−`?=` is not as powerful as it might seem. For instance, it
466−can't generate a loop -- you cannot (and should not) use it to
467−test whether a `*` is a `(list @)`. Nor can it validate atomic
468−auras.
895+```hoon
896+?:(?=($~ p) q r)
897+```
469898
470−Patterns should be as weak as possible. Unpack one layer of
471−union at a time. Don't confirm things the type system knows.
899+#### Produces
472900
473−For example, when matching from a tagged union for the type `[%foo p=@
474−q=[@ @]]`, the appropriate pattern is `[%foo *]`. You have one
475−question, which is whether the head of the noun is `%foo`.
901+If `p` is null (`~`), `q`. If `p` is non-null, `r`.
476902
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, `~`.
478907
479−##### Examples
908+#### Examples
480909
481910```
482−~zod:dojo> =bar [%foo %bar %baz]
483−~zod:dojo> ?=([%foo *] bar)
484−%.y
911+> =foo ""
912+
913+> ?~(foo 1 2)
914+1
485915```
486916
487−### `?@` "wutpat"
917+---
918+
919+## `?=` "wuttis"
920+
921+Test pattern match.
922+
923+#### Syntax
488924
489−`[%wtpt p=wing q=hoon r=hoon]`: branch on whether a wing of the subject is an atom.
925+Two arguments, fixed.
490926
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
492953
493954```hoon
494−?:(?=(@ p) q r)
955+[%wtts p=spec q=wing]
495956```
496957
497−##### Syntax
958+#### Produces
498959
499−Regular: **3-fixed**.
960+`%.y` (true) if the noun at `q` is in the type of `p`; `%.n` (false) otherwise.
500961
501−##### Discussion
962+#### Discussion
502963
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.
504968
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.
506971
507−```
508−~zod:dojo> ?@(0 1 2)
509−! mint-vain
510−! exit
972+For example, when matching from a tagged union for the type `[%foo p=@ q=[@ @]]`, the appropriate pattern is `[%foo *]`. You have one
973+question, which is whether the head of the noun is `%foo`.
511974
512−~zod:dojo> ?@(`*`0 1 2)
513−1
975+A common error is `find.$`, meaning `p` is not a type.
976+
977+#### Examples
514978
515−~zod:dojo> ?@(`*`[1 2] 3 4)
516−4
979+```
980+> =bar [%foo %bar %baz]
981+> ?=([%foo *] bar)
982+%.y
517983```
518984
519−### `?!` "wutzap"
985+---
986+
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
5201024
521−`[%wtzp p=hoon]`: logical NOT.
1025+```hoon
1026+[%wtzp p=hoon]
1027+```
5221028
523−##### Expands to
1029+#### Expands to
5241030
5251031```hoon
5261032.=(| p)
5271033```
5281034
529−Produces the logical NOT of `p`.
530−
531−##### Syntax
532−
533−Regular: **1-fixed**.
1035+#### Produces
5341036
535−Irregular: `!foo` is `?!(foo)`.
1037+The logical NOT of `p`, which must evaluate to either `%.y` or `%.n`.
5361038
537−##### Examples
1039+#### Examples
5381040
5391041```
5401042~zod:dojo> ?!(.=(1 2))
content/docs/hoon/reference/rune/zap.md+514−122
@@ -5,60 +5,179 @@ template = "doc.html"
55aliases = ["docs/reference/hoon-expressions/rune/zap/"]
66+++
77
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
942
10−### `!>` "zapgar"
43+```hoon
44+[%zpcm p=hoon q=hoon]
45+```
1146
12−`[%zpgr p=hoon]`: wrap a noun in its type.
47+#### Discussion
1348
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.
1553
16−A cell whose tail is the product of `p`, and whose head is the static type of `p`.
54+#### Examples
1755
18−##### Syntax
56+```
57+> !, *hoon [1 1]
58+[%cltr p=~[[%sand p=%ud q=1] [%sand p=%ud q=1]]]
1959
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+```
2163
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
2399
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+```
25103
26−##### Examples
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+
113+#### Examples
27114
28115```
29116> !>(1)
30117[#t/@ud q=1]
31118```
32119
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 `!>`:
34122
35123```
36124> -:!>(1)
37125#t/@ud
38126```
39127
40−### `!<` "zapgal"
41−
42−`[%zpld p=spec q=hoon]`
128+---
129+
130+## `!<` "zapgal"
131+
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
43165
44−Takes a mold and a `vase` and dynamically checks that the type in the `vase`
45−matches the mold.
166+```hoon
167+[%zpgl p=spec q=hoon]
168+```
46169
47−##### Produces
170+#### Produces
48171
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
50173`nest-fail`.
51174
52−##### Syntax
53−
54−Regular: **2-fixed**
175+#### Discussion
55176
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`.
57179
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
62181
63182```
64183> !< @ !> ~zod
@@ -67,105 +186,124 @@ a typed value from a `vase`.
67186> !< @p !> 0
68187nest-fail
69188
70−> =m !> 0
71−> =n !> 1
72−> !< [@ @] (slop m n)
73−[0 1]
189+> !< tape !>("foobar")
190+"foobar"
74191```
75192
76−### `!:` "zapcol"
77−
78−`[%dbug p=hoon]`: turn on stack trace
79−
80−##### Produces
81−
82−The product of `p` unless `p` crashes, in which case a stack trace is given.
83−
84−##### Syntax
85−
86−Regular: **1-fixed**.
193+---
194+
195+## `!;` "zapmic"
196+
197+Wrap a noun in its type (raw).
198+
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
87229
88230```hoon
89−!: p=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−
231+[%zpmc p=hoon q=hoon]
98232```
99−> ?:(=(0 1) 123 !!)
100−ford: %ride failed to execute:
101233
102−> !: ?:(=(0 1) 123 !!)
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−```
234+#### Discussion
107235
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.
109239
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.
111244
112−##### Produces
245+It's unlikely you'd use this rune directly; [`!>`](#-zapgar) is much more
246+typical.
113247
114−The product of `p`. If `p` crashes, no stack trace entries are given for that code.
115−
116−##### Syntax
117−
118−Regular: **1-fixed**.
248+#### Examples
119249
120−```hoon
121−!. p=hoon
122250```
251+> !; *type [1 1]
252+[#t/[@ud @ud] 1 1]
123253
124−`p` is any Hoon expression.
125−
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−
254+> !; *type 'foo'
255+[#t/@t 'foo']
132256```
133−> %.(1 |=(a=@ ^-(@ ?:(=(a 10) !! $(a +(a))))))
134−ford: %ride failed to execute:
135257
136−> !: %.(1 |=(a=@ ^-(@ ?:(=(a 10) !! $(a +(a))))))
137−/~zod/base/~2018.10.15..20.01.21..6b0c:<[1 5].[1 49]>
138−/~zod/base/~2018.10.15..20.01.21..6b0c:<[1 17].[1 47]>
139−/~zod/base/~2018.10.15..20.01.21..6b0c:<[1 22].[1 46]>
140−/~zod/base/~2018.10.15..20.01.21..6b0c:<[1 36].[1 45]>
141−...skipping some lines...
142−/~zod/base/~2018.10.15..20.01.21..6b0c:<[1 17].[1 47]>
143−/~zod/base/~2018.10.15..20.01.21..6b0c:<[1 22].[1 46]>
144−/~zod/base/~2018.10.15..20.01.21..6b0c:<[1 33].[1 35]>
145−ford: %ride failed to execute:
258+---
259+
260+## `!=` "zaptis"
261+
262+Make the Nock formula for a Hoon expression.
263+
264+#### Syntax
265+
266+One argument, fixed.
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
146293
147−> !: %.(1 !.(|=(a=@ ^-(@ ?:(=(a 10) !! $(a +(a)))))))
148−/~zod/base/~2018.10.15..20.01.35..0529:<[1 5].[1 53]>
149−ford: %ride failed to execute:
294+```hoon
295+[%zpts p=hoon]
150296```
151297
152−### `!=` "zaptis"
153−
154−`[%zpts p=hoon]`: make the Nock formula for a Hoon expression.
155−
156−##### Produces
298+#### Produces
157299
158300The Nock generated by `p`.
159301
160−##### Syntax
161−
162−Regular: **1-fixed**.
163−
164−##### Discussion
302+#### Discussion
165303
166304Don't confuse `!=` with a negation, `!`, followed by a test for equality, `=(10 11)`.
167305
168−##### Examples
306+#### Examples
169307
170308```
171309> !=(20)
@@ -188,53 +326,307 @@ Don't confuse the `!=` rune with:
188326%.n
189327```
190328
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+```
192372
193−### `!?` "zapwut"
373+#### Produces
194374
195−`[%zpwt p=@ q=hoon]`: restrict Hoon version.
375+When `p` is an atom:
196376
197−##### Produces
377+- `q` if `p` ≥ Hoon kelvin version, otherwise crash.
198378
199−`q`, if `p` is greater than or equal to the Hoon kelvin version.
200−(Versions count down; the current version is 140.)
379+When `p` is a cell:
201380
202−##### Syntax
381+- `q`, if `p.p` ≥ Hoon kelvin version ≥ `q.p`, otherwise crash.
203382
204−Regular: **2-fixed**.
383+(Versions count down; the current version is 140.)
205384
206−##### Examples
385+#### Examples
207386
208387```
209−> !?(264 (add 2 2))
388+> !? [142 140] (add 2 2)
2103894
211390
212−> !?(164 (add 2 2))
391+> !? 142 (add 2 2)
2133924
214393
215−> !?(64 (add 2 2))
394+> !? 64 (add 2 2)
216395! exit
217396```
218397
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
220435
221−`[%zpzp ~]`: crash.
436+```hoon
437+[%zppt p=(list wing) q=hoon r=hoon]
438+```
222439
223−##### Produces
440+#### Discussion
224441
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.
226444
227−##### Syntax
445+#### Examples
228446
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+```
230456
231−##### Discussion
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+
501+#### Discussion
232502
233503`%void` nests in every other type, so you can stub out anything with `!!`.
234504
235−##### Examples
505+#### Examples
236506
237507```
238508> !!
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+
240557```
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+---
content/docs/hoon/reference/stdlib/2n.md+21−13
@@ -40,11 +40,15 @@ Pair after
4040
4141Compose forward
4242
43−Build `f` such that `(f x) .= (b (a x))`.
43+Call gate `a`, then call gate `b` with its product.
44+
45+This is a wet gate that takes two gates and produces a new gate.
46+
47+This is the inverse of [`++corl`](#corl).
4448
4549#### Accepts
4650
47−`a` is a noun.
51+`a` is a gate.
4852
4953`b` is a gate.
5054
@@ -57,14 +61,11 @@ Build `f` such that `(f x) .= (b (a x))`.
5761#### Examples
5862
5963```
60− > (:(cork dec dec dec) 20)
61− 17
62−
63− > `@ub`(bex (met 0 23))
64− 0b10.0000
64+> ((cork dec |=(a=@ [a a])) 20)
65+[19 19]
6566
66− > `@ub`((cork (cury met 0) bex) 23)
67− 0b10.0000
67+> ((cork dec some) 20)
68+[~ u=19]
6869```
6970
7071---
@@ -73,13 +74,17 @@ Build `f` such that `(f x) .= (b (a x))`.
7374
7475Compose backward
7576
76−Build `f` such that
77+Call gate `b`, then call gate `a` with its product.
78+
79+This is a wet gate that takes two gates and produces a new gate.
80+
81+This is the inverse of [`++cork`](#cork).
7782
7883#### Accepts
7984
8085`a` is a gate.
8186
82−`b` is a noun.
87+`b` is a gate.
8388
8489#### Source
8590
@@ -95,8 +100,11 @@ Build `f` such that
95100#### Examples
96101
97102```
98− > ((corl (lift bex) (slat %ud)) '2')
99− [~ 4]
103+> ((corl |=(a=@ [a a]) dec) 20)
104+[19 19]
105+
106+> ((corl some dec) 20)
107+[~ u=19]
100108```
101109
102110---
content/docs/userspace/threads/examples/child-thread.md+3−3
@@ -75,7 +75,7 @@ We note that this is mostly the same as `await-thread:strandio`.
7575;< ~ bind:m %- poke-our
7676 :* %spider
7777 %spider-start
78− !>([`tid.bowl `tid byk.bowl(q da+now.bowl) %child !>(~)])
78+ !>([`tid.bowl `tid byk.bowl(r da+now.bowl) %child !>(~)])
7979 ==
8080;< =cage bind:m (take-fact /awaiting/[tid])
8181;< ~ bind:m (take-kick /awaiting/[tid])
@@ -131,7 +131,7 @@ We pre-emptively subscribe for the result. Spider sends the result at `/thread-r
131131;< ~ bind:m %- poke-our
132132 :* %spider
133133 %spider-start
134− !>([`tid.bowl `tid byk.bowl(q da+now.bowl) %child !>(~)])
134+ !>([`tid.bowl `tid byk.bowl(r da+now.bowl) %child !>(~)])
135135 ==
136136```
137137
@@ -184,7 +184,7 @@ Finally we test whether the thread produced a `%thread-done` or a `%thread-fail`
184184;< ~ bind:m %- poke-our
185185 :* %spider
186186 %spider-start
187− !>([`tid.bowl byk.bowl(q da+now.bowl) `tid %child !>(~)])
187+ !>([`tid.bowl byk.bowl(r da+now.bowl) `tid %child !>(~)])
188188 ==
189189;< ~ bind:m (sleep ~s5)
190190%- (slog leaf+"Stopping child thread..." ~)
content/docs/userspace/threads/gall/poke-thread.md+1−1
@@ -29,7 +29,7 @@ Here's a modified agent that pokes our thread. I've replaced some off the previo
2929 (pair term term)
3030 =/ tid `@ta`(cat 3 'thread_' (scot %uv (sham eny.bowl)))
3131 =/ ta-now `@ta`(scot %da now.bowl)
32− =/ start-args [~ `tid byk.bowl(q da+now.bowl) p.q.vase !>(q.q.vase)]
32+ =/ start-args [~ `tid byk.bowl(r da+now.bowl) p.q.vase !>(q.q.vase)]
3333 :_ this
3434 :~
3535 [%pass /thread/[ta-now] %agent [our.bowl %spider] %watch /thread-result/[tid]]
content/docs/userspace/threads/gall/start-thread.md+2−2
@@ -29,7 +29,7 @@ Here's an example of a barebones gall agent that just starts a thread:
2929 (pair term term)
3030 =/ tid `@ta`(cat 3 'thread_' (scot %uv (sham eny.bowl)))
3131 =/ ta-now `@ta`(scot %da now.bowl)
32− =/ start-args [~ `tid byk.bowl(q da+now.bowl) p.q.vase !>(q.q.vase)]
32+ =/ start-args [~ `tid byk.bowl(r da+now.bowl) p.q.vase !>(q.q.vase)]
3333 :_ this
3434 :~
3535 [%pass /thread/[ta-now] %agent [our.bowl %spider] %poke %spider-start !>(start-args)]
@@ -116,7 +116,7 @@ We can ignore the input logic, here's the important part:
116116```hoon
117117=/ tid `@ta`(cat 3 'thread_' (scot %uv (sham eny.bowl)))
118118=/ ta-now `@ta`(scot %da now.bowl)
119−=/ start-args [~ `tid byk.bowl(q da+now.bowl) p.q.vase !>(q.q.vase)]
119+=/ start-args [~ `tid byk.bowl(r da+now.bowl) p.q.vase !>(q.q.vase)]
120120:_ this
121121:~
122122 [%pass /thread/[ta-now] %agent [our.bowl %spider] %poke %spider-start !>(start-args)]
content/docs/userspace/threads/gall/stop-thread.md+1−1
@@ -29,7 +29,7 @@ Here we've added one last card to `on-poke` to stop the thread and a little extr
2929 (pair term term)
3030 =/ tid `@ta`(cat 3 'thread_' (scot %uv (sham eny.bowl)))
3131 =/ ta-now `@ta`(scot %da now.bowl)
32− =/ start-args [~ `tid byk.bowl(q da+now.bowl) p.q.vase !>(q.q.vase)]
32+ =/ start-args [~ `tid byk.bowl(r da+now.bowl) p.q.vase !>(q.q.vase)]
3333 :_ this
3434 :~
3535 [%pass /thread/[ta-now] %agent [our.bowl %spider] %watch /thread-result/[tid]]
content/docs/userspace/threads/gall/take-facts.md+1−1
@@ -31,7 +31,7 @@ Here we've added another card to subscribe for any facts sent by the thread and
3131 (pair term term)
3232 =/ tid `@ta`(cat 3 'thread_' (scot %uv (sham eny.bowl)))
3333 =/ ta-now `@ta`(scot %da now.bowl)
34− =/ start-args [~ `tid byk.bowl(q da+now.bowl) p.q.vase !>(q.q.vase)]
34+ =/ start-args [~ `tid byk.bowl(r da+now.bowl) p.q.vase !>(q.q.vase)]
3535 :_ this
3636 :~
3737 [%pass /thread/[ta-now] %agent [our.bowl %spider] %watch /thread-result/[tid]]
content/docs/userspace/threads/gall/take-result.md+1−1
@@ -29,7 +29,7 @@ Here we've added an extra card to subscribe for the result and a couple of lines
2929 (pair term term)
3030 =/ tid `@ta`(cat 3 'thread_' (scot %uv (sham eny.bowl)))
3131 =/ ta-now `@ta`(scot %da now.bowl)
32− =/ start-args [~ `tid byk.bowl(q da+now.bowl) p.q.vase !>(q.q.vase)]
32+ =/ start-args [~ `tid byk.bowl(r da+now.bowl) p.q.vase !>(q.q.vase)]
3333 :_ this
3434 :~
3535 [%pass /thread/[ta-now] %agent [our.bowl %spider] %watch /thread-result/[tid]]
content/docs/userspace/threads/reference.md+1−1
@@ -25,7 +25,7 @@ Where:
2525 [%ud p=@ud] :: number
2626 ==
2727 ```
28− You'll almost always just want the current revision, so you can specify the `case` as `da+now.bowl`. If the thread is on the same desk as the agent, you can also just use `byk.bowl` for the `beak`.
28+ You'll almost always just want the current revision, so you can specify the `case` as `da+now.bowl`. If the thread is on the same desk as the agent you can also just use `byk.bowl(r da+now)` for the `beak`.
2929- `file` - name of the thread file in `/ted`. For example, if the thread you want to start is `/ted/foo/hoon` you'd specify `%foo`.
3030- `vase` - `vase` to be given to the thread when it's started. Can be whatever or just `!>(~)` if it doesn't need any args.
3131
content/grants/app-openbsd.md+5−1
@@ -9,7 +9,7 @@ grant_category = [ "Runtime" ]
99[extra]
1010image = ""
1111description = "Get the project to the point where it works on OpenBSD"
12−reward = "$8,000 in WSTR"
12+reward = "1 star"
1313mentor = "~silsyn-wathep"
1414assignee = "~tidsut-radryd"
1515completed = false
@@ -46,3 +46,7 @@ Get the project to the point where it works on OpenBSD as a first class citizen.
4646- Self-directedness, ability to debug and troubleshoot creatively
4747- Some familiarity with Nock
4848- Optional: nix, hoon
49+
50+## Compensation
51+
52+The apprentice will be rewarded 1 star upon the successful completion of the project.
content/grants/astrolabe.md+7−7
@@ -10,7 +10,7 @@ grant_category = ["App Dev: Other"]
1010[extra]
1111image = ""
1212description = "Urbit address space explorer"
13−reward = "$45000 in WSTR"
13+reward = "5 stars"
1414assignee = "~midlev-mindyr"
1515champion = "~norsyr-torryn"
1616grant_id = "P0120"
@@ -89,7 +89,7 @@ The rewards are based on $100 per estimated hour.
8989
9090Time to Complete: ~80 hours over ~1 month
9191
92−Desired Reward: $8.000
92+Desired Reward: 1 star
9393
9494- Make a cool frontend for @p entry (alert user of mistakes)
9595
@@ -106,7 +106,7 @@ Desired Reward: $8.000
106106
107107Time to Complete: ~100 hours over ~1 1⁄3 months
108108
109−Desired Reward: $10.000
109+Desired Reward: 1 star
110110
111111- write hoon for searching urbit ids
112112
@@ -118,7 +118,7 @@ Desired Reward: $10.000
118118
119119Time to Complete: ~100 hours over ~1 1⁄3 months
120120
121−Desired Reward: $10.000
121+Desired Reward: 1 star
122122
123123- PKI graph with performance optimizations
124124
@@ -132,7 +132,7 @@ Desired Reward: $10.000
132132
133133Time to Complete: ~100 hours over ~1 1⁄3 months
134134
135−Desired Reward: $10.000
135+Desired Reward: 1 star
136136
137137- design and make a cool ui for inputting sigils
138138
@@ -144,7 +144,7 @@ Desired Reward: $10.000
144144
145145Time to Complete: ~70 hours over ~1 month (very rough estimate)
146146
147−Desired Reward: $7.000
147+Desired Reward: 1 star
148148
149149- Integrations:
150150
@@ -161,4 +161,4 @@ Desired Reward: $7.000
161161
162162Time to Complete: ~450 hours over ~6 months
163163
164−Desired Reward: $45.000
164+Desired Reward: 5 stars
content/grants/filesharer.md+3−3
@@ -9,7 +9,7 @@ grant_category = ["App Dev"]
99[extra]
1010image = ""
1111description = "Simple file sharing on Urbit"
12−reward = "$15,000 in WSTR"
12+reward = "2 stars"
1313assignee = "~tinden-pontev"
1414id = ""
1515completed = false
@@ -73,7 +73,7 @@ The following areas need to be added:
7373
7474Expected completion: 8 weeks
7575
76−Payment: $7500 in WSTR
76+Payment: 1 star
7777
7878- Rework state and clean up code for implementation of planned features and
7979 improving readability.
@@ -88,7 +88,7 @@ Payment: $7500 in WSTR
8888
8989Expected completion: 8 weeks
9090
91−Payment: $7500 in WSTR
91+Payment: 1 star
9292
9393- Add ability to restrict whitelist by tag.
9494
content/groups/~fabled-faster/structure.md+1−1
@@ -1,6 +1,6 @@
11+++
22title = "structure"
3−shortcode = "~fabled-faster-/wind"
3+shortcode = "~fabled-faster/structure"
44description = "Urbit Structural Design and Engineering Group. Always Thinking About Mechanics."
55type = "Public"
66tile = "https://fabled-faster.nyc3.digitaloceanspaces.com/fabled-faster/2022.1.27..17.59.43-image.png"
content/groups/~fabled-faster/wind.md+1−1
@@ -1,6 +1,6 @@
11+++
22title = "Wind"
3−shortcode = "~fabled-faster-/wind"
3+shortcode = "~fabled-faster/wind"
44description = "Wind was the first music. Let's chat, discuss, scheme, and learn everything about new music on Urbit."
55type = "Public"
66tile = "https://fabled-faster.nyc3.digitaloceanspaces.com/fabled-faster/2021.4.15..03.52.47-original_001012c5d98277b0f0061b3da18e4f1a.jpg"
content/groups/~hatryx-lastud/other-life.md+1−1
@@ -4,7 +4,7 @@ shortcode = "~hatryx-lastud/other-life"
44description = "The Imperceptible City"
55type = "Public"
66tile = "https://dl.airtable.com/.attachmentThumbnails/85973e6c8ac12bef0ce4fbc046a2fb7c/8c21d303"
7−participant_range = "5000+"
7+participant_range = "1000+"
88+++
99
1010The Imperceptible City
content/groups/~rondev/group-discovery.mdnew file+9
@@ -0,0 +1,9 @@
1++++
2+title = "Group Discovery"
3+shortcode = "~rondev/group-discovery"
4+type = "Public"
5+tile = "https://urbit.me/images/icons/icon-512x512.png"
6+participant_range = "1000+"
7++++
8+
9+A group for finding other groups
content/groups/~todset-partug/urmetica.mdnew file+9
@@ -0,0 +1,9 @@
1++++
2+title = "Urmetica"
3+shortcode = "~todset-partug/urmetica"
4+type = "Public"
5+tile = "https://poldec-tonteg-content.sfo2.digitaloceanspaces.com/poldec-tonteg/2022.4.12..15.18.26-image.png"
6+participant_range = "150+"
7++++
8+
9+Quod est superius est sicut quod inferius, et quod inferius est sicut quod est superius
content/groups/~wacrep-lossul/encyclosphere.mdnew file+9
@@ -0,0 +1,9 @@
1++++
2+title = "Encyclosphere"
3+shortcode = "~wacrep-lossul/encyclosphere"
4+type = "Public"
5+tile = "https://encyclosphere.org/wp-content/uploads/2021/07/go.png"
6+participant_range = "1"
7++++
8+
9+Imagine all the encyclopedias in the world, connected into one decentralized network, the way all the blogs are loosely connected. You've heard of the blogosphere; now, we’re building an encyclosphere.
content/groups/~winder-dapsym/urchan.mdnew file+9
@@ -0,0 +1,9 @@
1++++
2+title = "urChan"
3+shortcode = "~winder-dapsym/urchan"
4+type = "Public"
5+tile = "https://winder-dapsym.sfo3.digitaloceanspaces.com/Images/urChan/urChanlogo_dark.png"
6+participant_range = "1131"
7++++
8+
9+a comfy place to discuss with frens, this is the newest chan. this is ur chan. decentralized: urChan2.0
content/ids/sogrum-savluc.mdnew file+11
@@ -0,0 +1,11 @@
1++++
2+ship = "~sogrum-savluc"
3+nickname = "Vinney"
4+bgColor = "#876930"
5+image = ""
6++++
7+
8+I'm a software developer with over a decade of experience building custom, novel web and mobile applications for small and medium (and the occasional Fortune 500) businesses. I left the Earth web behind for Mars and have never been happier.
9+I'm one of the full-time engineers at Quartus and a proud member of the Dalten Collective, where we're pioneering increasingly-proven methods of Sovereignty and Sustainability under the guiding light of Fellowship.
10+
11+The future is bright.
content/ids/tiplec-lacnyx.mdnew file+6
@@ -0,0 +1,6 @@
1++++
2+ship = "~tiplec-lacnyx"
3+nickname = "Sol"
4+bgColor = "#000000"
5+image = ""
6++++
lib/glossary.js+8−1
@@ -91,6 +91,13 @@ export const glossary = [
9191 slug: "/docs/hoon/reference/rune/zap/#-zapwut",
9292 desc: "<code>[%zpwt p=@ q=hoon]</code>: restrict Hoon version.",
9393 },
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+ },
94101 {
95102 name: "zapzap",
96103 symbol: "!!",
@@ -884,7 +891,7 @@ export const glossary = [
884891 },
885892 {
886893 name: "terminators",
887− symbol: "--,",
894+ symbol: "--",
888895 usage: "Terminators",
889896 slug: "/docs/hoon/reference/rune/terminators/",
890897 desc: "Runes used to terminate expressions.",
pages/docs/[[...slug]].js+10
@@ -121,6 +121,7 @@ export default function DocsLayout({
121121 "text-wall-600": !isSelected,
122122 });
123123 const rootClasses = "pl-0 text-base hover:text-green-400";
124+
124125 return (
125126 <>
126127 <Head>
@@ -176,6 +177,15 @@ export default function DocsLayout({
176177 />
177178 )}
178179 </div>
180+ <a
181+ className="font-semibold rounded-xl block p-2 text-wall-400 hover:text-green-400 mt-16"
182+ target="_blank"
183+ href={`https://github.com/urbit/urbit.org/blob/master/content/docs/${
184+ params.slug?.join("/") || "_index"
185+ }.md`}
186+ >
187+ Edit this page on GitHub
188+ </a>
179189 </ContentArea>
180190 </div>
181191 </>
pages/ids/submit.js+4−4
@@ -53,13 +53,13 @@ ${form?.description || ""}`
5353 “Create pull request” on the following page.
5454 </p>
5555 <p>
56− Then, to validate that you operate this group, send a DM to{" "}
56+ Then, to validate that you own that ID, send a DM to{" "}
5757 <Link href="/ids/~haddef-sigwen" passHref>
5858 <a>~haddef-sigwen</a>
5959 </Link>{" "}
60− from your group host <code>@p</code> with a link to the pull
61− request on GitHub. We’ll approve the pull request and your page
62− will be online shortly.
60+ from your <code>@p</code> with a link to the pull request on
61+ GitHub. We’ll approve the pull request and your page will be
62+ online shortly.
6363 </p>
6464 </div>
6565 <div className="flex flex-col space-y-4">
pages/index.js+27−23
@@ -1,6 +1,6 @@
11import Head from "next/head";
22import Link from "next/link";
3−import React, { useState, useEffect } from "react";
3+import React from "react";
44import { DateTime } from "luxon";
55
66import Container from "../components/Container";
@@ -8,22 +8,14 @@ import Section from "../components/Section";
88import SingleColumn from "../components/SingleColumn";
99import Header from "../components/Header";
1010import Footer from "../components/Footer";
11−import BackgroundImage from "../components/BackgroundImage";
1211import Contact from "../components/Contact";
1312import PostPreview from "../components/PostPreview";
1413import EventPreview from "../components/EventPreview";
1514import Cross from "../components/icons/Cross";
1615import TwoUp from "../components/TwoUp";
1716import BubbleLink from "../components/BubbleLink";
18−import {
19− getAllPosts,
20− getAllEvents,
21− formatDate,
22− getOpenGrantsCount,
23− generateRealtimeDate,
24−} from "../lib/lib";
25−import { contact, eventKeys } from "../lib/constants";
26−import { useLocalStorage } from "../lib/hooks";
17+import { getAllPosts, getAllEvents, generateRealtimeDate } from "../lib/lib";
18+import { eventKeys } from "../lib/constants";
2719
2820const Banner = ({ children, isOpen, href, dismiss }) => {
2921 return (
@@ -50,7 +42,7 @@ const Banner = ({ children, isOpen, href, dismiss }) => {
5042 );
5143};
5244
53−export default function Home({ posts, events, openGrantsCount, search }) {
45+export default function Home({ posts, events, grantNumbers, search }) {
5446 return (
5547 <Container>
5648 <Head>
@@ -135,29 +127,24 @@ export default function Home({ posts, events, openGrantsCount, search }) {
135127 <Section narrow>
136128 <div className="flex items-center pb-12">
137129 <h2 className="m-0 p-0 mr-4">Grants</h2>
138− {/* <Link href="/grants/proposals"> */}
139− {/* <a className="bg-green-400 text-white badge-lg"> */}
140− {/* {openGrantsCount} Open */}
141− {/* </a> */}
142− {/* </Link> */}
143130 </div>
144131 <div className="flex flex-col md:flex-row w-full items-center md:items-start bg-green-100 px-8 py-8 rounded-xl">
145132 <div className="flex items-center flex-col p-4 w-full">
146− <h2 className="text-green-400">200+</h2>
133+ <h2 className="text-green-400">{grantNumbers?.starsAwarded}</h2>
147134 <h4 className="text-green-400 text-center pt-2">
148135 Urbit stars awarded
149136 </h4>
150137 </div>
151138 <div className="h-0 w-0 md:h-24 md:w-4 bg-green-200 self-center" />
152139 <div className="flex items-center flex-col p-4 w-full">
153− <h2 className="text-green-400">400+</h2>
140+ <h2 className="text-green-400">{grantNumbers?.contributors}</h2>
154141 <h4 className="text-green-400 text-center pt-2">
155142 Different Contributors
156143 </h4>
157144 </div>
158145 <div className="h-0 w-0 md:h-24 md:w-4 bg-green-200 self-center" />
159146 <div className="flex items-center flex-col p-4 w-full">
160− <h2 className="text-green-400">45+</h2>
147+ <h2 className="text-green-400">{grantNumbers?.active}</h2>
161148 <h4 className="text-green-400 text-center pt-2">
162149 Active Projects
163150 </h4>
@@ -283,8 +270,6 @@ export default function Home({ posts, events, openGrantsCount, search }) {
283270}
284271
285272export async function getStaticProps() {
286− const openGrantsCount = getOpenGrantsCount();
287−
288273 const posts = getAllPosts(
289274 ["title", "slug", "date", "description", "extra"],
290275 "blog",
@@ -293,6 +278,25 @@ export async function getStaticProps() {
293278
294279 const events = getAllEvents(eventKeys, "events");
295280
281+ const grants = getAllPosts(["extra", "taxonomies"], "grants", "date");
282+
283+ const grantNumbers = {
284+ starsAwarded: grants.reduce(
285+ (total, a) =>
286+ total + (Number(a?.extra?.reward.replace(/ star[s]?/, "")) || 0),
287+ 0
288+ ),
289+ contributors: [...new Set(grants.map((e) => e.extra.assignee))].length,
290+ active: grants.filter(
291+ (e) =>
292+ !e.extra.canceled &&
293+ !e.extra.completed &&
294+ e.extra.assignee &&
295+ e.extra.assignee.length > 0
296+ ).length,
297+ };
298+
299+ console.log(grantNumbers.active);
296300 const now = DateTime.now();
297301
298302 const pastEvents = events.filter((event) => {
@@ -325,7 +329,7 @@ export async function getStaticProps() {
325329 return {
326330 props: {
327331 posts,
328− openGrantsCount,
332+ grantNumbers,
329333 events: happeningNow.concat(futureEvents).concat(pastEvents),
330334 },
331335 };
styles/markdown.css+4
@@ -73,6 +73,10 @@
7373 @apply text-base leading-relaxed;
7474}
7575
76+.markdown.technical p code {
77+ white-space: pre-wrap;
78+}
79+
7680.markdown.technical li {
7781 @apply py-2 ml-6 text-base;
7882}