on master help sign in
content of barbuc and some typos
93a7d17syzygyzer
reference/hoon-expressions/rune/bar.md+66−5
@@ -10,15 +10,72 @@ needed to run those formulas correctly.
10
10
11Four core runes (`|=`, `|.`, `|-`, and `|*`) produce a
11Four core runes (`|=`, `|.`, `|-`, and `|*`) produce a
12core with a single arm, named `$`. We can recompute this arm
12core with a single arm, named `$`. We can recompute this arm
13−with changes, which useful for recursion among other things:
13+with changes, which is useful for recursion among other things.
14
14
15## Runes
15## Runes
16
16
17### |$ "barbuc"
17### |$ "barbuc"
18
18
19−`{$brbs sample=(lest term) body=spec} `
19+Produces a wet gate that creates a structure parameterized by molds.
20
20
21−Produces a wet gate with a single arm named `$` (I think).
21+##### Syntax
22+
23+Regular:
24+```hoon
25+|$ a=(lest term) b=spec
26+```
27+
28+AST:
29+```hoon
30+[%brbs sample=(lest term) body=spec]
31+```
32+
33+##### Semantics
34+
35+`|$` is used to create a wet gate that is polymorphic in its input types and
36+produces a structure. `a` is a `lest` of `term` used as identifiers for the
37+input types. `b` is a structure built from elements of `a`. The output of `|$`
38+is a `spec` obtained by substituting the input types parameterized by `a` into
39+the `b`.
40+
41+##### Expands to
42+
43+I'm having some trouble deciphering this, would appreciate help. From `hoon.hoon`:
44+```hoon
45+ {$brbs *} =- ?~ - !!
46+ [%brtr [%bscl -] [%ktcl body.gen]]
47+ %+ turn `(list term)`sample.gen
48+ |= =term
49+ ^- spec
50+ =/ tar [%base %noun]
51+ [%bsts term [%bssg tar [%bshp tar tar]]]
52+```
53+
54+##### Discussion
55+
56+`|$` is a restricted form of `|*`. The use of `|$` over `|*` is one of style, as either could
57+be used to make wet gates that produce structures. The buc in `|$` is a hint that
58+`|$` is closely related to buc runes, and thus `|$` should be used to make wet
59+gates that produce structures, while `|*` should be used for any other sort of
60+wet gate. Thus, the second argument of `|$` is frequently a buc
61+rune. For further discussion of wet gates, see the entry for [`|*`](#bartar).
62+
63+Unlike other single-armed cores, `|$` does not have an arm named `$` that can be recursed upon.
64+
65+Proper style for `|$` is to enclose the first argument with brackets, even if it
66+is only a single term. The interpeter will accept a single term without brackets
67+just fine, but this style is for consistency with the fact that the first argument is a `lest`.
68+
69+##### Examples
70+
71+```
72+~zod:dojo> =foo |$([a b] [b a])
73+
74+~zod:dojo> =bar (foo [@ @tas])
75+
76+~zod:dojo> (bar %cat 3)
77+[%cat 3]
78+```
22
79
23### |_ "barcab"
80### |_ "barcab"
24
81
@@ -236,7 +293,7 @@ AST:
236[%brdt p=hoon]
293[%brdt p=hoon]
237```
294```
238
295
239−Semantics:
296+##### Semantics
240
297
241A `|.` 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.
298A `|.` 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.
242
299
@@ -460,7 +517,8 @@ AST:
460
517
461##### Semantics
518##### Semantics
462
519
520+A `|*` expression produces a wet gate. `a` defines the gate's sample, and `b`
463−A `|*` expression produces a wet gate. `a` defines the gate's sample, and `b` is a Hoon expression that determines the output value of the gate.
521+is a Hoon expression that determines the output value of the gate.
464
522
465##### Expands to
523##### Expands to
466
524
@@ -487,6 +545,9 @@ with `$()`.
487
545
488> `$(...)` expands to `%=($ ...)` (["centis"](@/docs/reference/hoon-expressions/rune/cen.md#centis)).
546> `$(...)` expands to `%=($ ...)` (["centis"](@/docs/reference/hoon-expressions/rune/cen.md#centis)).
489
547
548+`|*` can be used to make wet gates that produce structures, but this usage is
549+discouraged in favor of `|$`.
550+
490##### Examples
551##### Examples
491
552
492Wet and dry gates in a nutshell:
553Wet and dry gates in a nutshell: