@@ -4,64 +4,89 @@ weight = 7
4template = "doc.html"
4template = "doc.html"
5aliases = ["docs/reference/hoon-expressions/rune/bar/"]
5aliases = ["docs/reference/hoon-expressions/rune/bar/"]
7Core expressions produce cores. A core is a cell of `[battery payload]`.
8Core expressions produce cores. A core is a cell of `[battery payload]`.
8−The `battery` is code, a battery of Nock formulas. The `payload` is the data
9+The `battery` is code, a battery of Nock formulas. The `payload` is the data
9needed to run those formulas correctly.
10needed to run those formulas correctly.
11−Five core runes (`|=`, `|.`, `|-`, `|*`, and `|$`) produce a
12+Five core runes (`|=`, `|.`, `|-`, `|*`, and `|$`) produce a core with a single
12−core with a single arm, named `$`. As with all arms, we can recompute `$``
13+arm, named `$`. As with all arms, we can recompute `$` with changes, which is
13−with changes, which is useful for recursion among other things.
14+useful for recursion among other things.
15−## Runes
16+## `|$` "barbuc"
17−### |$ "barbuc"
18+Declares a mold builder wet gate with one or more molds as its sample.
19−Declares a mold builder wet gate with one or more molds as its
20+#### Syntax
22−##### Syntax
22+Two arguments, fixed.
25−```hoon
25+<tr><th>Form</th><th>Syntax</th></tr>
26−|$ a=(lest term) b=spec
26+<tr>
31−[%brbs sample=(lest term) body=spec]
52+[%brbc sample=(lest term) body=spec]
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`.
41−##### Expands to
55+#### Expands to
49|* [a=$~(* $-(* *)) b=$~(* $-(* *))]
65|* [a=$~(* $-(* *)) b=$~(* $-(* *))]
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`.
54−##### Discussion
77+#### Discussion
56A mold builder is a wet gate from one or more molds to a mold. A mold is a
79A mold builder is a wet gate from one or more molds to a mold. A mold is a
57function from nouns to nouns with types that may be partial, is always
80function from nouns to nouns with types that may be partial, is always
58idempotent, and usually the identity function on the noun itself.
81idempotent, and usually the identity function on the noun itself.
60−`|$` is a restricted form of `|*`. The use of `|$` over `|*` is one of style, as either could
83+`|$` is a restricted form of `|*`. The use of `|$` over `|*` is one of style, as
61−be used to make wet gates that are mold builders. The buc in `|$` is a hint that
84+either could be used to make wet gates that are mold builders. The buc in `|$`
85+is a hint that `|$` is closely related to buc runes, and thus `|$` should be
62−`|$` is closely related to buc runes, and thus `|$` should be used to make mold builders, while `|*` should be used for any other sort of
86+used to make mold builders, while `|*` should be used for any other sort of wet
87+gate. Unlike `|*`, the body of `|$` is parsed in pattern mode to a `$spec`.
63−wet gate. Thus, the second argument of `|$` is frequently a buc
88+Thus, the second argument of `|$` is frequently a buc rune. For further
64−rune. For further discussion of wet gates, see the entry for [`|*`](#bartar).
89+discussion of wet gates, see the entry for [`|*`](#-bartar).
66Like other single-arm cores, the arm for `|$` is named `$` and this can be used to
91Like other single-arm cores, the arm for `|$` is named `$` and this can be used to
67define recursive structures. Note however that Hoon is evaluated eagerly, and so
92define recursive structures. Note however that Hoon is evaluated eagerly, and so
@@ -69,53 +94,58 @@ infinite structures are not permitted.
70Proper style for `|$` is to enclose the first argument with brackets, even if it
95Proper style for `|$` is to enclose the first argument with brackets, even if it
71is only a single term. The interpeter will accept a single term without brackets
96is only a single term. The interpeter will accept a single term without brackets
72−just fine, but this style is for consistency with the fact that the first argument is a `lest`.
97+just fine, but this style is for consistency with the fact that the first
74−##### Examples
100+#### Examples
77−~zod:dojo> =foo |$([a b] [b a])
103+> =foo |$([a b] [b a])
79−~zod:dojo> =bar (foo [@ @tas])
105+> =bar (foo [@ @tas])
81−~zod:dojo> (bar %cat 3)
107+> (bar %cat 3)
85−### `|_` "barcab"
113+## `|_` "barcab"
87Produce a **door** (a core with a sample).
115Produce a **door** (a core with a sample).
89−##### Syntax
117+#### Syntax
91−Regular:
119+One fixed argument, then a variable number of `+`-family expressions.
122+<tr><th>Form</th><th>Syntax</th></tr>
95++ b=term c=hoon
128++ b=term c=hoon
96++ d=term e=hoon
129++ d=term e=hoon
98++ f=term g=hoon
131++ f=term g=hoon
136+<tr><td>Wide</td><td>None.</td></tr>
137+<tr><td>Irregular</td><td>None.</td></tr>
102Note: The `++` rune may be replaced with any other rune in the `+` family.
140Note: The `++` rune may be replaced with any other rune in the `+` family.
107[%brcb p=spec q=alas r=(map term tome)]
145[%brcb p=spec q=alas r=(map term tome)]
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.
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.
116−The context of the door is the subject of the `|_` expression.
118−##### Expands to
148+#### Expands to
@@ -127,29 +157,49 @@ The context of the door is the subject of the `|_` expression.
130−##### Discussion
160+#### Semantics
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.
132−A door is the general case of a gate (function). A gate is a
165+`a` defines the door sample type and usually includes a name assignment (e.g.,
133−door with only one arm, which has the name `$`.
166+`n=@`). `a` is followed by a series of arm definitions, each of which begins
167+with a rune in the `+` family (most of `++`). There must be at least one arm,
168+but there may be arbitrarily many. Each arm must include a name (`b`, `d`, and
169+`f` above), which is followed by the expression (`c`, `e`, and `g` above) that
170+defines the arm product.
172+The context of the door is the subject of the `|_` expression.
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 `$`.
135−Calling a door is like calling a gate except the caller also needs
179+Calling a door is like calling a gate except the caller also needs to specify
180+the arm to be computed. So, for example, if you have some door `door` which
136−to specify the arm to be computed. So, for example, if you have some door `door` which contains some arm `arm`, and you want to pass some argument (i.e., input value `arg`), you would call it with `~(arm door arg)`.
181+contains some arm `arm`, and you want to pass some argument (i.e., input value
182+`arg`), you would call it with `~(arm door arg)`.
138−Because gates are also doors, you can call them the same way. To call the gate `foo` as a door, instead of `(foo baz)` we would write `~($ foo baz)`. This
184+Because gates are also doors, you can call them the same way. To call the gate
185+`foo` as a door, instead of `(foo baz)` we would write `~($ foo baz)`. This is
186+an irregular form for `%~($ foo baz)`,
139−is an irregular form for `%~($ foo baz)`, [%~](/docs/hoon/reference/rune/cen#censig).
187+[%~](/docs/hoon/reference/rune/cen#censig).
141−##### Examples
189+#### Examples
143A trivial door:
191A trivial door:
146−/~zod:dojo> =mol |_ a=@ud
194+> =mol |_ a=@ud
147− ++ succ +(a)
195+ ++ succ +(a)
148− ++ prev (dec a)
196+ ++ prev (dec a)
150−/~zod:dojo> ~(succ mol 1)
199+> ~(succ mol 1)
152−/~zod:dojo> ~(succ mol ~(succ mol ~(prev mol 5)))
202+> ~(succ mol ~(succ mol ~(prev mol 5)))
@@ -172,174 +222,246 @@ The `ne` door prints a digit in base 10, 16, 32 or 64:
175−### `|%` "barcen"
225+---
177−Produce a core, `[battery payload]`.
227+## `|:` "barcol"
179−##### Syntax
229+Produce a gate with a custom sample.
181−Regular:
231+#### Syntax
233+Two arguments, fixed.
236+<tr><th>Form</th><th>Syntax</th></tr>
184−|%
263+[%brcl p=hoon q=hoon]
192−Note: The `++` rune may be replaced with any other rune in the `+` family.
266+#### Semantics
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.
197−[%brcn p=(unit term) q=(map term tome)]
273+=+ a
200−##### Semantics
277+#### Discussion
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.
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.
206−The core payload is the subject of the `|%` expression.
284+#### Examples
208−##### Discussion
286+```
287+> =add-ten |:(n=`@`2 (add n 10))
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)
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)
214−A core is like an "object" in a conventional language, but its
296+---
215−attributes (_arms_) are functions on the core, not the core and
216−an argument. A "method" on a core is an arm that produces a gate.
218−##### Examples
298+## `|%` "barcen"
220−A trivial core:
300+Produce a core, `[battery payload]`.
223−~zod:dojo> =foo =+ x=58
235−### `|:` "barcol"
304+Argument: a variable number of `+`-family expressions.
237−Produce a gate with a custom sample.
306+<table>
307+<tr><th>Form</th><th>Syntax</th></tr>
321+<tr><td>Wide</td><td>None.</td></tr>
322+<tr><td>Irregular</td><td>None.</td></tr>
239−##### Syntax
325+Note: The `++` rune may be replaced with any other rune in the `+` family.
244−|: a=hoon b=hoon
330+[%brcn p=(unit term) q=(map term tome)]
247−AST:
333+#### Semantics
249−```
335+The product of a `|%` expression is a dry core with one or more arms in the
250−[%brcl p=hoon q=hoon]
336+battery.
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.
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.
257−##### Expands to
346+#### Discussion
259−```hoon
348+A core is a cell of `[battery payload]`, where the `battery` is code and the
260−=> ^~ a
349+`payload` is data. The `battery` is one or more arms. An arm is a computation
261− |. b
350+that takes the core itself as its subject.
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`.
266−Pick your own default value for the sample. Note that `a` is an ordinary expression, not a type; `|:` doesn't bunt a sample as
357+A core is like an "object" in a conventional language, but its attributes
267−[`|=`](#bartis) does.
358+(_arms_) are functions on the core, not the core and an argument. A "method" on
359+a core is an arm that produces a gate.
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
271−##### Examples
363+A trivial core:
274−> =add-ten |:(n=`@`2 (add n 10))
366+> =foo =+ x=58
276−> (add-ten 10)
373+> n.foo
279−> (add-ten)
376+> (g.foo 1)
283−### `|.` "bardot"
380+---
285−Produce a trap (a core with one arm `$`).
382+## `|.` "bardot"
287−##### Syntax
384+Produce a trap (a core with one arm `$`).
289−Regular:
386+#### Syntax
391+<tr><th>Form</th><th>Syntax</th></tr>
298[%brdt p=hoon]
417[%brdt p=hoon]
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.
305−The payload of the core is the subject of the `|.` expression.
307−##### Expands to
420+#### Expands to
310|% ++ $ a=hoon
423|% ++ $ a=hoon
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
433+The payload of the core is the subject of the `|.` expression.
314−##### Discussion
435+#### Discussion
316A trap is generally used to defer a computation.
437A trap is generally used to defer a computation.
318−##### Examples
439+#### Examples
320A trivial trap:
441A trivial trap:
323−~zod:dojo> =foo |.(42)
444+> =foo |.(42)
325−~zod:dojo> $:foo
446+> $:foo
328−~zod:dojo> (foo)
449+> (foo)
332A more interesting trap:
453A more interesting trap:
335−~zod:dojo> =foo =/ reps 10
456+> =foo =/ reps 10
336− =/ step 0
457+ =/ step 0
337− =/ outp 0
458+ =/ outp 0
339− ?: =(step reps)
460+ ?: =(step reps)
341− $(outp (add outp 2), step +(step))
462+ $(outp (add outp 2), step +(step))
342−~zod:dojo> (foo)
464+> (foo)
@@ -348,92 +470,43 @@ trap, since it's a core with an `$` arm.
349> `$(...)` expands to `%=($ ...)` (["centis"](/docs/hoon/reference/rune/cen#centis)).
471> `$(...)` expands to `%=($ ...)` (["centis"](/docs/hoon/reference/rune/cen#centis)).
351−### `|-` "barhep"
473+---
353−Produce a trap (a core with one arm `$`) and evaluate it.
371−A `|-` expression produces a core with one arm named `$` and immediately evaluates `$`. `a` is a Hoon expression that determines what `$` evaluates to.
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 `$()`.
383−> `$(...)` expands to `%=($ ...)` (["centis"](/docs/hoon/reference/rune/cen#centis)).
387−A trivial computation doesn't recurse:
394−The classic loop is a decrement:
397−~zod:dojo> =foo =/ a 42
407−### `|^` "barket"
475+## `|^` "barket"
409Produce a core whose battery includes a `$` arm and compute the latter.
477Produce a core whose battery includes a `$` arm and compute the latter.
411−##### Syntax
479+#### Syntax
413−Regular:
481+One fixed argument, then a variable number of `+`-family expressions.
484+<tr><th>Form</th><th>Syntax</th></tr>
417++ b=term c=hoon
490++ b=term c=hoon
418++ d=term e=hoon
491++ d=term e=hoon
420++ f=term g=hoon
493++ f=term g=hoon
499+<td>Wide</td><td>None.</td></tr>
500+<tr><td>Irregular</td><td>None.</td></tr>
424−Note: The `++` rune may be replaced with any other rune in the `+` family.
429[%brkt p=hoon q=(map term tome)]
506[%brkt p=hoon q=(map term tome)]
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.
436−##### Expands to
509+#### Expands to
@@ -446,86 +519,218 @@ A `|^` expression produces a multi-arm core whose battery includes a `$` arm, wh
449−##### Discussion
522+#### Semantics
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 `$`
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
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.
453−##### Examples
535+#### Examples
455A trivial example:
537A trivial example:
458−~zod:dojo> |^
540+> |^
459− (add n g)
541+ (add n g)
466−### `|~` "barsig"
548+---
468−Produce an iron gate.
550+## `|-` "barhep"
470−##### Syntax
552+Produce a trap (a core with one arm `$`) and evaluate it.
472−Regular:
554+#### Syntax
559+<tr><th>Form</th><th>Syntax</th></tr>
475−|~ a=spec b=hoon
585+[%brhp p=hoon]
478−AST:
588+#### Expands to
481−[%brsg p=spec q=hoon]
593+
596+A `|-` expression produces a core with one arm named `$` and immediately
597+evaluates `$`. `a` is a Hoon expression that determines what `$` evaluates to.
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 `$()`.
605+> `$(...)` expands to `%=($ ...)` (["centis"](/docs/hoon/reference/rune/cen#centis)).
609+A trivial computation doesn't recurse:
616+The classic loop is a decrement:
484−##### Semantics
630+---
634+Produce an iron gate.
638+Two arguments, fixed.
641+<tr><th>Form</th><th>Syntax</th></tr>
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]
488−##### Expands to
671+#### Expands to
491^| |=(a b)
674^| |=(a b)
679+A `|~` expression produces an iron gate. `a` defines the sample, and `b` defines
680+the output value of the gate.
494−##### Discussion
682+#### Discussion
496See [this discussion of core variance models](/docs/hoon/reference/advanced)
684See [this discussion of core variance models](/docs/hoon/reference/advanced)
498−##### Examples
686+#### Examples
501−~zod:dojo> => ~ ^+(|~(a=@ *@) |=(a=* *@))
689+> => ~ ^+(|~(a=@ *@) |=(a=* *@))
502<1|usl {a/@ $~}>
690<1|usl {a/@ $~}>
505−### `|*` "bartar"
693+---
507−Produce a wet gate (one-armed core with sample).
695+## `|*` "bartar"
509−##### Syntax
697+Produce a wet gate (one-armed core with sample).
511−Regular:
699+#### Syntax
701+Two arguments, fixed.
704+<tr><th>Form</th><th>Syntax</th></tr>
520[%brtr p=spec q=hoon]
730[%brtr p=spec q=hoon]
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.
528−##### Expands to
733+#### Expands to
@@ -535,14 +740,19 @@ is a Hoon expression that determines the output value of the gate.
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.
538−##### Discussion
748+#### Discussion
540In a normal (dry) gate, your argument is converted into the
750In a normal (dry) gate, your argument is converted into the
541−sample type. In a generic (wet) gate, your argument type
751+sample type. In a generic (wet) gate, your argument type
542passes through the function, rather as if it were a macro (there
752passes through the function, rather as if it were a macro (there
543is still only one copy of the code, however).
753is still only one copy of the code, however).
545−Genericity is a powerful and dangerous tool. Use wet gates only if
755+Genericity is a powerful and dangerous tool. Use wet gates only if
546you know what you're doing.
756you know what you're doing.
548Just as with a [gate](#bartis), we can recurse back into a wet gate
758Just as with a [gate](#bartis), we can recurse back into a wet gate
@@ -553,58 +763,83 @@ with `$()`.
553`|*` can be used to make wet gates that produce structures, but this usage is
763`|*` can be used to make wet gates that produce structures, but this usage is
554discouraged in favor of `|$`.
764discouraged in favor of `|$`.
556−##### Examples
766+#### Examples
558Wet and dry gates in a nutshell:
768Wet and dry gates in a nutshell:
561−~zod:dojo> =foo |=([a=* b=*] [b a])
771+> =foo |=([a=* b=*] [b a])
563−~zod:dojo> =bar |*([a=* b=*] [b a])
773+> =bar |*([a=* b=*] [b a])
565−~zod:dojo> (foo %cat %dog)
775+> (foo %cat %dog)
566[6.778.724 7.627.107]
776[6.778.724 7.627.107]
568−~zod:dojo> (bar %cat %dog)
778+> (bar %cat %dog)
569[%dog %cat]
779[%dog %cat]
572The dry gate does not preserve the type of `a` and `b`; the wet
782The dry gate does not preserve the type of `a` and `b`; the wet
573gate does.
783gate does.
575−### `|=` "bartis"
785+---
577−Produce a gate (a one-armed core with a sample).
787+## `|=` "bartis"
579−##### Syntax
789+Produce a gate (a one-armed core with a sample).
581−Regular:
791+#### Syntax
793+Two arguments, fixed.
796+<tr><th>Form</th><th>Syntax</th></tr>
590[%brts p=spec q=hoon]
823[%brts p=spec q=hoon]
595−The product of a `|=` expression is a dry **gate**, i.e., a Hoon function.
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.
599−##### Expands to
826+#### Expands to
602−=| a=spec
829+=+ ^~(*a=spec)
603|% ++ $ b=hoon
830|% ++ $ b=hoon
836+The product of a `|=` expression is a dry **gate**, i.e., a Hoon function.
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.
607−##### Discussion
842+#### Discussion
609Dry gates are used for the vast majority of ordinary functions in Hoon.
844Dry gates are used for the vast majority of ordinary functions in Hoon.
@@ -612,97 +847,138 @@ A gate is a core with one arm named `$`, so we can recurse back into it with `$(
613> `$(...)` expands to `%=($ ...)` (["centis"](/docs/hoon/reference/rune/cen#centis)).
848> `$(...)` expands to `%=($ ...)` (["centis"](/docs/hoon/reference/rune/cen#centis)).
615−##### Examples
850+#### Examples
617A trivial gate:
852A trivial gate:
620−~zod:dojo> =foo |=(a=@ +(a))
855+> =foo |=(a=@ +(a))
622−~zod:dojo> (foo 20)
857+> (foo 20)
626A slightly less trivial gate:
861A slightly less trivial gate:
629−~zod:dojo> =foo |= [a=@ b=@]
864+> =foo |= [a=@ b=@]
630− (add a b)
865+ (add a b)
631−~zod:dojo> (foo 30 400)
867+> (foo 30 400)
635−### `|@` "barpat"
873+## `|@` "barpat"
637Produce a 'wet' core `[battery payload]`.
875Produce a 'wet' core `[battery payload]`.
639−##### Syntax
877+#### Syntax
641−Regular:
879+Arguments: a variable number of `+`-family expressions.
882+<tr><th>Form</th><th>Syntax</th></tr>
645++ a=term b=hoon
888++ a=term b=hoon
646++ c=term d=hoon
889++ c=term d=hoon
648++ e=term f=hoon
891++ e=term f=hoon
896+<tr><td>Wide</td><td>None.</td></tr>
897+<tr><td>Irregular</td><td>None.</td></tr>
652Note: The `++` rune may be replaced with any other rune in the `+` family.
900Note: The `++` rune may be replaced with any other rune in the `+` family.
657[%brpt p=(unit term) q=(map term tome)]
905[%brpt p=(unit term) q=(map term tome)]
660−##### Semantics
908+#### Semantics
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`
664−##### Discussion
915+#### Discussion
917+The `|@` rune is just like the `|%` rune except that instead of producing a
918+'dry' core, it produces a 'wet' one. This allows for type polymorphism of its
666−The `|@` rune is just like the `|%` rune except that instead of producing a 'dry' core, it produces a 'wet' one. This allows for type polymorphism of its arms, using 'genericity'. See [Advanced types](/docs/hoon/reference/advanced).
919+arms, using 'genericity'. See [Advanced types](/docs/hoon/reference/advanced).
668−### `|?` "barwut"
921+---
670−Produce a lead trap.
923+## `|?` "barwut"
672−##### Syntax
925+Produce a lead trap.
674−Regular:
927+#### Syntax
932+<tr><th>Form</th><th>Syntax</th></tr>
683[%brwt p=hoon]
958[%brwt p=hoon]
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.
690−##### Expands to
961+#### Expands to
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.
696−##### Discussion
972+#### Discussion
698See this [discussion of the core variance model](/docs/hoon/reference/advanced).
974See this [discussion of the core variance model](/docs/hoon/reference/advanced).
700−##### Examples
976+#### Examples
703−~zod:dojo> => ~ ^+ |?(%a) |.(%a)
979+> => ~ ^+ |?(%a) |.(%a)
704<1?pqz $~>
980<1?pqz $~>
706−~zod:dojo> => ~ ^+ |?(%a) |.(%b)
982+> => ~ ^+ |?(%a) |.(%b)