on master help sign in
Update most of the docs to Hoon 143, renaming /docs/hoon/twig/cen-call/tis-make/ to /docs/rune/cen/tis/; move atom and limb docs out into /docs/hoon/; move /docs/byte/ to /docs/urbyte/; various formatting and additions
9bc0b51Keaton Dunsford
docs.md+2−2
@@ -7,7 +7,7 @@ sort: 4
7
7
8<div class="lead">
8<div class="lead">
9 <div class="logo inverse"></div>
9 <div class="logo inverse"></div>
10− <h1 class="blue i-b">Urbit docs</h1>
10+ <h1 class="i-b">Urbit docs</h1>
11</div>
11</div>
12
12
13<div class="col-md-12 head">
13<div class="col-md-12 head">
@@ -19,7 +19,7 @@ sort: 4
19Check out the [technical overview](about/overview) for a high-level
19Check out the [technical overview](about/overview) for a high-level
20architecture description. To install and run Urbit, head to the Using section, starting with the [installation guide](using/install) and continuing forward.
20architecture description. To install and run Urbit, head to the Using section, starting with the [installation guide](using/install) and continuing forward.
21
21
22−To begin developing for Urbit, start by walking through [Urbytes](byte/0). After that, delve into Hoon [syntax](hoon/syntax) directly, then walk through the [Arvo tutorials](arvo). The examples and exercises in Arvo will teach you to build high-level programs and interact with the network.
22+To begin developing for Urbit, start by walking through [Urbytes](urbyte/0). After that, delve into Hoon [syntax](hoon/syntax) directly, then walk through the [Arvo tutorials](arvo). The examples and exercises in Arvo will teach you to build high-level programs and interact with the network.
23
23
24Dig into the mechanics of Urbit with [Core Hoon](hoon). Refer back
24Dig into the mechanics of Urbit with [Core Hoon](hoon). Refer back
25there for pure-code exercises and functions in the [standard library](hoon/library).
25there for pure-code exercises and functions in the [standard library](hoon/library).
docs/about/glossary.md+10−10
@@ -140,7 +140,7 @@ Some common auras and their aliases:
140- <h6 id="-aura-char">char:</h6> (`@tD`): a character, a single unicode byte (for multi-byte
140- <h6 id="-aura-char">char:</h6> (`@tD`): a character, a single unicode byte (for multi-byte
141 characters and codepoints, see `@c`)
141 characters and codepoints, see `@c`)
142
142
143−You can find the list of all auras [here](../../hoon/twig/atom/sand/).
143+You can find the list of all auras [here](../../hoon/atom/sand/).
144
144
145*See [basic types](../../hoon/basic/#-atom-p-term-q-unit-atom)*.
145*See [basic types](../../hoon/basic/#-atom-p-term-q-unit-atom)*.
146
146
@@ -173,7 +173,7 @@ A face is a type that wraps a named symbol (of [aura](#-aura)
173
173
174A _gate_ is a [core](#-core) with one [arm](#-arm) -- Hoon's closest
174A _gate_ is a [core](#-core) with one [arm](#-arm) -- Hoon's closest
175analog to a function/lambda/closure. To call a gate on an argument,
175analog to a function/lambda/closure. To call a gate on an argument,
176−replace the sample (at [tree address](../../hoon/twig/limb/limb/) `+6`
176+replace the sample (at [tree address](../../hoon/limb/limb/) `+6`
177in the core) with the argument, and then compute the arm.
177in the core) with the argument, and then compute the arm.
178
178
179The payload of a gate has a shape of `[sample context]`.
179The payload of a gate has a shape of `[sample context]`.
@@ -181,8 +181,8 @@ The payload of a gate has a shape of `[sample context]`.
181- <h6 id="-gate-sample">sample:</h6> the argument tuple
181- <h6 id="-gate-sample">sample:</h6> the argument tuple
182- <h6 id="-gate-context">context:</h6> the subject in which the gate was defined
182- <h6 id="-gate-context">context:</h6> the subject in which the gate was defined
183
183
184−*See [basic types](../../hoon/basic/#-core-p-span-q-map-term-span),
184+*See [basic types](../../hoon/basic/#-core-p-type-q-map-term-type),
185−[`%-` ("cenhep")](../../hoon/twig/cen-call/hep-call/) (the
185+[`%-` ("cenhep")](../../hoon/rune/cen-call/hep-call/) (the
186[rune](#-rune) for calling a `gate`).*
186[rune](#-rune) for calling a `gate`).*
187
187
188#### <h4 id="-a-hoon">hoon</h4>
188#### <h4 id="-a-hoon">hoon</h4>
@@ -234,7 +234,7 @@ found, the result is the product of the arm.
234- <h6 id="-limb-wing">wing:</h6> a list of limbs, searched from right to left (`a.b` means
234- <h6 id="-limb-wing">wing:</h6> a list of limbs, searched from right to left (`a.b` means
235 `b` within `a`).
235 `b` within `a`).
236
236
237−*See [Limbs and wings](../../hoon/twig/limb/)*
237+*See [Limbs and wings](../../hoon/limb/)*
238
238
239#### loobean
239#### loobean
240
240
@@ -284,7 +284,7 @@ Here's some common mold terminology:
284 sample
284 sample
285- <h6 id="-mold-icon">icon:</h6> the type of the mold's range
285- <h6 id="-mold-icon">icon:</h6> the type of the mold's range
286
286
287−*See [mold hoons](../../hoon/twig/buc-mold/).*
287+*See [mold hoons](../../hoon/rune/buc-mold/).*
288
288
289#### nest
289#### nest
290
290
@@ -302,10 +302,10 @@ error. This is one of the most commons errors in Hoon programming.
302A Hoon _rune_ is a pair of ASCII symbols used to begin a
302A Hoon _rune_ is a pair of ASCII symbols used to begin a
303[Hoon expression](#-a-hoon).
303[Hoon expression](#-a-hoon).
304
304
305−For example, the rune [`?:`](../../hoon/twig/wut-test/col-if/) is
305+For example, the rune [`?:`](../../hoon/rune/wut-test/col-if/) is
306Hoon's most common conditional, a branch on a boolean test. The first
306Hoon's most common conditional, a branch on a boolean test. The first
307symbol in a rune represents a family of related runes. For example, the
307symbol in a rune represents a family of related runes. For example, the
308−[`?` family](../../hoon/twig/wut-test/) are all conditionals.
308+[`?` family](../../hoon/rune/wut-test/) are all conditionals.
309
309
310The result of parsing a Hoon source expression&mdash;the rune, followed
310The result of parsing a Hoon source expression&mdash;the rune, followed
311by its respective children&mdash;into an AST node is simply called
311by its respective children&mdash;into an AST node is simply called
@@ -338,7 +338,7 @@ Tall hoons can contain flat hoons, but not vice versa. All irregular
338forms are flat.
338forms are flat.
339
339
340*See [hoon concept](../../hoon/concepts/#-hoon),
340*See [hoon concept](../../hoon/concepts/#-hoon),
341−[expressions](../../hoon/twig/), and [syntax](../../hoon/syntax/)*.
341+[expressions](../../hoon/rune/), and [syntax](../../hoon/syntax/)*.
342
342
343#### slot
343#### slot
344
344
@@ -361,5 +361,5 @@ All types are assembled out of base types defined in `++type`.
361does type-inference on a program, it assembles complex types out
361does type-inference on a program, it assembles complex types out
362of the simpler built-in types.
362of the simpler built-in types.
363
363
364−*See [basic types](../../hoon/basic/#-type-span-and-mold).*
364+*See [basic types](../../hoon/basic/).*
365
365
docs/arvo/generators.md+2−2
@@ -1,6 +1,6 @@
1---
1---
2−navhome: '/docs'
2+navhome: /docs/
3−next: True
3+next: true
4sort: 18
4sort: 18
5title: Using generators with apps
5title: Using generators with apps
6---
6---
docs/hoon/advanced.md+47−47
@@ -1,13 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3−sort: 16
4next: true
3next: true
4+sort: 20
5title: Advanced types
5title: Advanced types
6---
6---
7
7
8# Advanced types
8# Advanced types
9
9
10−As we noted, the definition of `span` in the last chapter is a
10+As we noted, the definition of `type` in the last chapter is a
11subset. The Hoon type system is simple, but not *that* simple.
11subset. The Hoon type system is simple, but not *that* simple.
12
12
13The good news is that you can *skip this section*, at least when
13The good news is that you can *skip this section*, at least when
@@ -15,73 +15,73 @@ you're first learning Hoon. Polymorphism and aliasing are mainly
15for advanced programmers writing complex infrastructure and/or
15for advanced programmers writing complex infrastructure and/or
16large functions. Don't worry about them for a little while.
16large functions. Don't worry about them for a little while.
17
17
18−## The complete, uncensored `span`
18+## The complete, uncensored `type`
19
19
20```
20```
21−++ span $@ $? $noun
21+++ type $@ $? %noun
22− $void
22+ %void
23− == $% {$atom p/term q/(unit atom)}
23+ == $% [%atom p=term q=(unit atom)]
24− {$cell p/span q/span}
24+ [%cell p=type q=type]
25− {$core p/span q/coil}
25+ [%core p=type q=coil]
26− {$face p/$@(term tune) q/span}
26+ [%face p=$@(term tune) q=type]
27− {$fork p/(set span)}
27+ [%fork p=(set type)]
28− {$hold p/span q/twig}
28+ [%hold p=type q=hoon]
29 ==
29 ==
30::
30::
31−++ coil $: p/?($gold $iron $lead $zinc)
31+++ coil $: p=?(%gold %iron %lead %zinc)
32− q/span
32+ q=type
33− r/{p/?($~ ^) q/(map term foot)}
33+ r=[p=?(~ ^) q=(map term foot)]
34 ==
34 ==
35−++ foot $% {$dry p/twig}
35+++ foot $% [%dry p=hoon]
36− {$wet p/twig}
36+ [%wet p=hoon]
37 ==
37 ==
38++ tune
38++ tune
39− $: p/(map term (unit twig))
39+ $: p=(map term (unit hoon))
40− q/(list twig)
40+ q=(list hoon)
41 ==
41 ==
42```
42```
43
43
44−If you compare this to the basic `span`, you'll see that we've
44+If you compare this to the basic `type`, you'll see that we've
45−changed two stems: `$core` and `$face`. We added polymorphism to
45+changed two stems: `%core` and `%face`. We added polymorphism to
46−`$core`, aliases and bridges to `$face`.
46+`%core`, aliases and bridges to `%face`.
47
47
48−## `$core`: advanced polymorphism
48+## `%core`: advanced polymorphism
49
49
50If cores never changed, we wouldn't need polymorphism. Of
50If cores never changed, we wouldn't need polymorphism. Of
51course, nouns are immutable and never change, but we use them as
51course, nouns are immutable and never change, but we use them as
52templates to construct new nouns around.
52templates to construct new nouns around.
53
53
54−Suppose we take a core, a cell `{battery payload}`, and replace
54+Suppose we take a core, a cell `[battery payload]`, and replace
55the payload with a different noun. Then, we invoke an arm from
55the payload with a different noun. Then, we invoke an arm from
56the battery.
56the battery.
57
57
58Is this legal? Does it make sense? Every function call in Hoon
58Is this legal? Does it make sense? Every function call in Hoon
59does this, so we'd better make it work well.
59does this, so we'd better make it work well.
60
60
61−The full core stores both payload spans. The span that describes
61+The full core stores both payload types. The type that describes
62−the payload currently in the core is `p`. The span that describes
62+the payload currently in the core is `p`. The type that describes
63the payload the core was compiled with is `q.q`.
63the payload the core was compiled with is `q.q`.
64
64
65In the Bertrand Meyer tradition of type theory, there are two
65In the Bertrand Meyer tradition of type theory, there are two
66forms of polymorphism: variance and genericity. In Hoon this
66forms of polymorphism: variance and genericity. In Hoon this
67choice is per arm, which is why our battery went from `(map term
67choice is per arm, which is why our battery went from `(map term
68−twig)` to `(map term foot)` when it went into the coil. A `foot`
68+hoon)` to `(map term foot)` when it went into the coil. A `foot`
69−is `$dry` or `$wet`. Dry polymorphism relies on variance; wet
69+is `%dry` or `%wet`. Dry polymorphism relies on variance; wet
70polymorphism relies on genericity.
70polymorphism relies on genericity.
71
71
72### Dry arms
72### Dry arms
73
73
74For a dry arm, we apply the Liskov substitution principle: we
74For a dry arm, we apply the Liskov substitution principle: we
75ask, "can we use any `p` as if it was a `q.q`?" This is the same
75ask, "can we use any `p` as if it was a `q.q`?" This is the same
76−test as in `:cast` or any type comparison (`nest`). Intuitively,
76+test as in `^-` ("kethep") or any type comparison (`nest`). Intuitively,
77we ask: "is the new payload compatible with the old payload?"
77we ask: "is the new payload compatible with the old payload?"
78
78
79For a core `a`, if `p.a` fits in `q.q.a`, we can use arms on the
79For a core `a`, if `p.a` fits in `q.q.a`, we can use arms on the
80−core. The product of a dry arm whose twig is `b` is always
80+core. The product of a dry arm whose hoon is `b` is always
81−defined as `{$hold a(p q.q.a, p.q %gold) b}`.
81+defined as `[%hold a(p q.q.a, p.q %gold) b]`.
82
82
83In other words, the subject of the arm computation is the
83In other words, the subject of the arm computation is the
84−original core span. The span of the modified payload, `p`, is
84+original core type. The type of the modified payload, `p`, is
85thrown away. This is of course the normal behavior of a function
85thrown away. This is of course the normal behavior of a function
86call in most languages.
86call in most languages.
87
87
@@ -94,7 +94,7 @@ replaces it with another core which does something useful.
94For core `b` to nest within core `a`, the batteries of `a` and
94For core `b` to nest within core `a`, the batteries of `a` and
95`b` must have the same tree shape, and the product of each `b`
95`b` must have the same tree shape, and the product of each `b`
96arm must nest within the product of the `a` arm. Wet arms (see
96arm must nest within the product of the `a` arm. Wet arms (see
97−below) are not compatible unless the twig is exactly the same.
97+below) are not compatible unless the hoon is exactly the same.
98
98
99But we also apply a payload test that depends on the rules of
99But we also apply a payload test that depends on the rules of
100variance. Again, this is traditional Meyer type theory; don't
100variance. Again, this is traditional Meyer type theory; don't
@@ -102,8 +102,8 @@ worry if you don't know it. These rules should make sense if you
102just think about them intuitively.
102just think about them intuitively.
103
103
104Each core has a "metal" `p.q` which defines its variance model.
104Each core has a "metal" `p.q` which defines its variance model.
105−A core can be *invariant* (`$gold`), *bivariant* (`$lead`),
105+A core can be *invariant* (`%gold`), *bivariant* (`%lead`),
106−*covariant* (`$zinc`), or *contravariant* (`$iron`). The default
106+*covariant* (`%zinc`), or *contravariant* (`%iron`). The default
107is gold; a gold core can be cast or converted to any metal, and
107is gold; a gold core can be cast or converted to any metal, and
108any metal can be cast or converted to lead.
108any metal can be cast or converted to lead.
109
109
@@ -132,29 +132,29 @@ For a wet arm, we ask: "suppose this core was actually compiled
132using `p` instead of `q.q`?" Would the Nock formula we generated
132using `p` instead of `q.q`?" Would the Nock formula we generated
133for `q.q` actually work for a `p` payload?
133for `q.q` actually work for a `p` payload?
134
134
135−A wet arm with twig `b` in core `a` produces the span `{$hold a
135+A wet arm with hoon `b` in core `a` produces the type `[%hold a
136−b}`. Assuming `a` has a modified payload, this will (lazily)
136+b]`. Assuming `a` has a modified payload, this will (lazily)
137analyze the arm with the caller's modified payload, `p`.
137analyze the arm with the caller's modified payload, `p`.
138
138
139But of course, we don't actually recompile the arm at runtime.
139But of course, we don't actually recompile the arm at runtime.
140We actually run the formula generated for the original payload,
140We actually run the formula generated for the original payload,
141`q.q`.
141`q.q`.
142
142
143−When we call a wet arm, we're essentially using the twig as a
143+When we call a wet arm, we're essentially using the hoon as a
144macro. We are not generating new code for every call site; we
144macro. We are not generating new code for every call site; we
145are creating a new type analysis path, which works as if we
145are creating a new type analysis path, which works as if we
146expanded the callee with the caller's context.
146expanded the callee with the caller's context.
147
147
148Consider a function like `turn` (Haskell `map`) which transforms
148Consider a function like `turn` (Haskell `map`) which transforms
149each element of a list. To use `turn`, we install a list and a
149each element of a list. To use `turn`, we install a list and a
150−transformation function in a generic core. The span of the list
150+transformation function in a generic core. The type of the list
151−we produce depends on the span of the list and the span of the
151+we produce depends on the type of the list and the type of the
152transformation function. But the Nock formulas for transforming
152transformation function. But the Nock formulas for transforming
153each element of the list will work on any function and any list,
153each element of the list will work on any function and any list,
154so long as the function's argument is the list item.
154so long as the function's argument is the list item.
155
155
156Again, will this work? A simple (and not quite right) way to ask
156Again, will this work? A simple (and not quite right) way to ask
157−this question is to compile all the twigs in the battery for both
157+this question is to compile all the hoons in the battery for both
158a payload of `p` and a payload of `q.q`, and see if they generate
158a payload of `p` and a payload of `q.q`, and see if they generate
159exactly the same Nock. The actual algorithm is a little more
159exactly the same Nock. The actual algorithm is a little more
160interesting, but not much.
160interesting, but not much.
@@ -171,22 +171,22 @@ use them unless you know what you're doing.
171
171
172There's only one field of the `coil` we haven't explained yet:
172There's only one field of the `coil` we haven't explained yet:
173`p.r.q`. This is simply the compiled battery, if available. (Of
173`p.r.q`. This is simply the compiled battery, if available. (Of
174−course, we compile the twigs in a core against the core itself,
174+course, we compile the hoons in a core against the core itself,
175and the formulas can't be available while we're compiling them.)
175and the formulas can't be available while we're compiling them.)
176External users of the core want this battery constant, though: it
176External users of the core want this battery constant, though: it
177lets us fold constants by executing arms at compile time.
177lets us fold constants by executing arms at compile time.
178
178
179−## `$face`: aliases and bridges
179+## `%face`: aliases and bridges
180
180
181−In the advanced `tune` form, the `$face` span also has a couple
181+In the advanced `tune` form, the `%face` type also has a couple
182of secret superpowers for hacking the namespace. Remember that
182of secret superpowers for hacking the namespace. Remember that
183Hoon doesn't have anything like a symbol table; to resolve a
183Hoon doesn't have anything like a symbol table; to resolve a
184−limb, we just search the span depth-first.
184+limb, we just search the type depth-first.
185
185
186If a name is in the `p.p` map, it's an alias. The map contains a
186If a name is in the `p.p` map, it's an alias. The map contains a
187−`(unit twig)`; if the unit is full, the name resolves to that
187+`(unit hoon)`; if the unit is full, the name resolves to that
188−twig (compiled against the `q` span). If the unit is empty,
188+hoon (compiled against the `q` type). If the unit is empty,
189−the name is blocked / skipped (see [limb](../twig/limb) for what
189+the name is blocked / skipped (see [limb](../limb/) for what
190this means).
190this means).
191
191
192If a name is in the `q.p` map, it's a bridge. When we search for
192If a name is in the `q.p` map, it's a bridge. When we search for
docs/hoon/twig/atom.md → docs/hoon/atom.mdrenamed+3−2
@@ -1,7 +1,8 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 1
4+sort: 15
4−
5+title: Atoms and strings
5---
6---
6
7
7# Atoms and strings
8# Atoms and strings
docs/hoon/twig/atom/knit.md → docs/hoon/atom/knit.mdrenamed+4−4
@@ -1,17 +1,17 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3sort: 3
3sort: 3
4−
4+title: Knit
5---
5---
6
6
7−# `:knit`
7+# Knit
8
8
9−`{$knit p/(list (each @t seed))}`: text string with interpolation.
9+`[%knit p=(list (each @t hoon))]`: text string with interpolation.
10
10
11### Produces
11### Produces
12
12
13A list-shaped string (`tape`) of the items in `p`, which are
13A list-shaped string (`tape`) of the items in `p`, which are
14−either constant `@t` multibyte UTF-8 strings (`cord`) or twigs
14+either constant `@t` multibyte UTF-8 strings (`cord`) or hoons
15producing a `tape`.
15producing a `tape`.
16
16
17### Syntax
17### Syntax
docs/hoon/twig/atom/path.md → docs/hoon/atom/path.mdrenamed+7−6
@@ -1,30 +1,31 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3sort: 4
3sort: 4
4+title: Path
4---
5---
5
6
6−# `:path`
7+# Path
7
8
8−`{$path p/(list (each @ta seed))}`: path with interpolation.
9+`[%path p=(list (each @ta hoon))]`: path with interpolation.
9
10
10### Produces
11### Produces
11
12
12A null-terminated list if of the items in `p`, which are either constant
13A null-terminated list if of the items in `p`, which are either constant
13−`@ta` atoms (`knot`), or twigs producing a `knot`.
14+`@ta` atoms (`knot`), or hoons producing a `knot`.
14
15
15### Syntax
16### Syntax
16
17
17Irregular: `/foo/bar/baz`.
18Irregular: `/foo/bar/baz`.
18
19
19−Irregular: `"foo{(weld "moo" "baz")}bar"`.
20−
21### Examples
20### Examples
22
21
23```
22```
24~zod/dojo> /foo/bar/baz
23~zod/dojo> /foo/bar/baz
25/foo/bar/baz
24/foo/bar/baz
25+
26−~zod/dojo> /foo/[`@ta`(cat 3 %moo %bar)]/baz
26+~zod/dojo> `path`/foo/[`@ta`(cat 3 %moo %bar)]/baz
27/foo/moobar/baz/
27/foo/moobar/baz/
28+
28~zod:dojo> /
29~zod:dojo> /
29~
30~
30```
31```
docs/hoon/twig/atom/rock.md → docs/hoon/atom/rock.mdrenamed+4−4
@@ -1,12 +1,12 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3sort: 2
3sort: 2
4−
4+title: Rock
5---
5---
6
6
7−# `:rock`
7+# Rock
8
8
9−`{$rock p/term q/@}`; a constant, cold atom.
9+`[%rock p=term q=@]`; a constant, cold atom.
10
10
11### Produces
11### Produces
12
12
@@ -14,7 +14,7 @@ A cold (fixed) atom `q` with aura `a`.
14
14
15### Syntax
15### Syntax
16
16
17−Irregular: any warm atom (`:sand`) form, prefixed with `%`.
17+Irregular: any warm atom [(`%sand`)](../sand/) form, prefixed with `%`.
18
18
19Irregular: `%foo`, `@tas`, symbol. Character constraints: `a-z`
19Irregular: `%foo`, `@tas`, symbol. Character constraints: `a-z`
20lowercase to start, `a-z` or `0-9` thereafter, with infix
20lowercase to start, `a-z` or `0-9` thereafter, with infix
docs/hoon/twig/atom/sand.md → docs/hoon/atom/sand.mdrenamed+3−3
@@ -1,12 +1,12 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3sort: 1
3sort: 1
4−
4+title: Sand
5---
5---
6
6
7−# `:sand`
7+# Sand
8
8
9−`{$sand p/term q/@}`; a constant, warm atom.
9+`[%sand p=term q=@]`; a constant, warm atom.
10
10
11### Produces
11### Produces
12
12
docs/hoon/basic.md+23−23
@@ -1,6 +1,6 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3−sort: 15
3+sort: 19
4next: true
4next: true
5title: Basic types
5title: Basic types
6---
6---
@@ -68,9 +68,9 @@ the type `atom`. On the other hand,
68...this should result in a `nest-fail`, because `[17 18]` is a cell,
68...this should result in a `nest-fail`, because `[17 18]` is a cell,
69not an atom.
69not an atom.
70
70
71−See the documentation on the [`^` family](../twig/ket-cast/) of runes
71+See the documentation on the [`^` family](../rune/ket/) of runes
72for more information on casts. See the documentation on the
72for more information on casts. See the documentation on the
73−[`$` family](../twig/buc-mold/) of runes for building molds.
73+[`$` family](../rune/buc/) of runes for building molds.
74(Also check out the irregular `,` operator.)
74(Also check out the irregular `,` operator.)
75
75
76## `type`: a set of types
76## `type`: a set of types
@@ -94,14 +94,14 @@ section.
94```
94```
95++ term @tas
95++ term @tas
96++ type
96++ type
97− $@ $? $noun
97+ $@ $? %noun
98− $void
98+ %void
99− == $% {$atom p/term q/(unit atom)}
99+ == $% [%atom p=term q=(unit atom)]
100− {$cell p/type q/type}
100+ [%cell p=type q=type]
101− {$core p/type q/(map term hoon)}
101+ [%core p=type q=(map term hoon)]
102− {$face p/term q/type}
102+ [%face p=term q=type]
103− {$fork p/(set type)}
103+ [%fork p=(set type)]
104− {$hold p/type q/hoon}
104+ [%hold p=type q=hoon]
105 ==
105 ==
106```
106```
107
107
@@ -110,23 +110,23 @@ the `type`-tree is a cell, it's a tuple with one of the heads `%atom`,
110`%cell`, `%core`, etc. We'll go through each of these cases below.
110`%cell`, `%core`, etc. We'll go through each of these cases below.
111these cases below.
111these cases below.
112
112
113−### `?($noun $void)`
113+### `?(%noun %void)`
114
114
115`%noun` is the label for the set of all nouns. `%void` is the label
115`%noun` is the label for the set of all nouns. `%void` is the label
116for the empty set.
116for the empty set.
117
117
118(For now, don't worry too much about the switch from `$` to `%`.)
118(For now, don't worry too much about the switch from `$` to `%`.)
119
119
120−### `{$cell p/type q/type}`
120+### `[%cell p=type q=type]`
121
121
122`[%cell p=type q=type]` is for the set of all cells with head `p` and
122`[%cell p=type q=type]` is for the set of all cells with head `p` and
123tail `q`.
123tail `q`.
124
124
125−### `{$fork p/(set type)}`
125+### `[%fork p=(set type)]`
126
126
127`[%fork p=(set type)]` is for the union of all types in the set `p`.
127`[%fork p=(set type)]` is for the union of all types in the set `p`.
128
128
129−### `{$hold p/type q/hoon}`
129+### `[%hold p=type q=hoon]`
130
130
131A `%hold` type, with type `p` and hoon `q`, is a lazy reference
131A `%hold` type, with type `p` and hoon `q`, is a lazy reference
132to the type of `(mint p q)`. In English, it means: "the type of
132to the type of `(mint p q)`. In English, it means: "the type of
@@ -135,17 +135,17 @@ the product when we compile `q` against subject `p`."
135Note that this means we can have parsed Hoon AST data in the
135Note that this means we can have parsed Hoon AST data in the
136`type`-tree.
136`type`-tree.
137
137
138−### `{$face p/term q/type}`
138+### `[%face p=term q=type]`
139
139
140A `[%face p=term q=type]` wraps the label `p` around the type
140A `[%face p=term q=type]` wraps the label `p` around the type
141`q`. `p` is a `term` or `@tas`, an atomic ASCII string which
141`q`. `p` is a `term` or `@tas`, an atomic ASCII string which
142obeys symbol rules: lowercase and digit only, infix hyphen,
142obeys symbol rules: lowercase and digit only, infix hyphen,
143first character must be lowercase.
143first character must be lowercase.
144
144
145−See [`%limb`](../twig/limb/limb) for how labels are resolved. It's
145+See [`%limb`](../limb/limb/) for how labels are resolved. It's
146nontrivial.
146nontrivial.
147
147
148−### `{%atom p/term q/(unit atom))}`
148+### `[%atom p=term q=(unit atom))]`
149
149
150`%atom` is for an atom, with two twists. `q` is a `unit`, Hoon's
150`%atom` is for an atom, with two twists. `q` is a `unit`, Hoon's
151equivalent of a nullable pointer or a Haskell `Maybe`. If `q`
151equivalent of a nullable pointer or a Haskell `Maybe`. If `q`
@@ -191,8 +191,8 @@ here are some conventions bound to constant syntax:
191 @sw signed base64
191 @sw signed base64
192 @sx signed hexadecimal
192 @sx signed hexadecimal
193@t UTF-8 text (cord)
193@t UTF-8 text (cord)
194− @ta ASCII text (span)
194+ @ta ASCII text (knot)
195− @tas ASCII symbol (term)
195+ @tas ASCII text symbol (term)
196@u unsigned integer
196@u unsigned integer
197 @ub unsigned binary
197 @ub unsigned binary
198 @ud unsigned decimal
198 @ud unsigned decimal
@@ -206,7 +206,7 @@ statically, by casting through the empty aura `@`. Hoon is not
206dependently typed and can't statically enforce data constraints
206dependently typed and can't statically enforce data constraints
207(for example, it can't enforce that a `@tas` is really a symbol).
207(for example, it can't enforce that a `@tas` is really a symbol).
208
208
209−### `{$core p/type q/(map term type)}`
209+### `[%core p=type q=(map term type)]`
210
210
211`%core` is for a code-data cell. The data (or *payload*) is the
211`%core` is for a code-data cell. The data (or *payload*) is the
212tail; the code (or *battery*) is the head. `p`, a type, is the
212tail; the code (or *battery*) is the head. `p`, a type, is the
@@ -225,8 +225,8 @@ sense. An arm is a computed attribute. A method is an arm whose
225product is a Hoon function (or *gate*).
225product is a Hoon function (or *gate*).
226
226
227A gate (function, lambda, etc) is a core with one arm, whose name
227A gate (function, lambda, etc) is a core with one arm, whose name
228−is the empty symbol `$`, and a payload whose shape is `{sample
228+is the empty symbol `$`, and a payload whose shape is `[sample
229−context}`. The *context* is the subject in which the gate was
229+context]`. The *context* is the subject in which the gate was
230defined; the *sample* is the argument.
230defined; the *sample* is the argument.
231
231
232To call this function on an argument `x`, replace the sample (at
232To call this function on an argument `x`, replace the sample (at
docs/hoon/cheat-sheet.mdnew file+38
@@ -0,0 +1,38 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 26
5+title: Cheat sheet
6+---
7+
8+# Hoon cheat sheet
9+##### `~rovnys-ricfer`
10+
11+_Original Fora post_ [*here*](https://urbit.org/fora/posts/~2017.9.18..22.31.06..24d5~).
12+
13+<br />
14+
15+[Download .pdf](https://storage.googleapis.com/media.urbit.org/docs/hoon-cheat-sheet--2017-12-12.pdf)
16+
17+<br />
18+
19+We've found it's useful to have a quick reference of Hoon's syntax always at
20+hand. So above is a download link to a Hoon cheatsheet .pdf. It's missing a
21+few of the literal syntaxes, but it covers the most common ones.
22+
23+This doesn't list any of the Ford runes, although there is now at least
24+some documentation for those [here](/docs/arvo/internals/ford/runes).
25+
26+The following runes also exist, but are currently undocumented and not listed in the cheat sheet:
27+
28+```
29+!: :: turn on debugging printfs
30+!. :: turn off debugging printfs
31+!; :: using the "type of type", emit the type for an expression
32+!, :: emit AST of expression
33+$* :: bunt (irregular form is *)
34+^. :: use gate to transform type
35+^& :: zinc (covariant) -- see the docs on advanced types
36+```
37+
38+Hope this helps!
docs/hoon/concepts.md+2−2
@@ -220,7 +220,7 @@ of type `foo:atom`.
220
220
221### <a name="-limb">`limb`</a> (attribute or variable reference)
221### <a name="-limb">`limb`</a> (attribute or variable reference)
222
222
223−A [`limb`](../twig/limb/limb/), like `foo`, is Hoon's equivalent of a variable
223+A [`limb`](../limb/limb/), like `foo`, is Hoon's equivalent of a variable
224reference. A limb is a [`hoon`](#-hoon); given a subject [`type`](#-type),
224reference. A limb is a [`hoon`](#-hoon); given a subject [`type`](#-type),
225[`mint`](#-mint) resolves it to a Nock formula and a product [`type`](#-type).
225[`mint`](#-mint) resolves it to a Nock formula and a product [`type`](#-type).
226
226
@@ -239,7 +239,7 @@ regardless of the kind of limb.
239
239
240### <a name="-wing">`wing`</a> ([`limb`](#-limb) path)
240### <a name="-wing">`wing`</a> ([`limb`](#-limb) path)
241
241
242−A [wing](../twig/limb/wing/) is a list of limbs. Like attribute
242+A [wing](../limb/wing/) is a list of limbs. Like attribute
243references in a conventional language, it uses the syntax `a.b.c`,
243references in a conventional language, it uses the syntax `a.b.c`,
244but inside out: Hoon `a.b.c` means "a within b within c", the equivalent
244but inside out: Hoon `a.b.c` means "a within b within c", the equivalent
245of `c.b.a` in any other language. All limbs but the last, here `a`,
245of `c.b.a` in any other language. All limbs but the last, here `a`,
docs/hoon/examples.md+146−147
@@ -1,8 +1,8 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3−sort: 17
4−title: Examples
5next: true
3next: true
4+sort: 21
5+title: Examples
6---
6---
7
7
8# Examples
8# Examples
@@ -18,29 +18,30 @@ side of simple manual construction over high-octane FP.)
18
18
19A function that produces the list of primes less than or equal to
19A function that produces the list of primes less than or equal to
20its argument, an atom:
20its argument, an atom:
21+
21```
22```
22−:gate thru/atom :: 1
23+|= thru/@ :: 1
23−:cast (list atom) :: 2
24+^- (list @) :: 2
24−:var field/(set atom) (silt (gulf 2 thru)) :: 3
25+=/ field/(set @) (silt (gulf 2 thru)) :: 3
25−:rap abet:main :: 4
26+=< abet:main :: 4
26−:core :: 5
27+|% :: 5
27++ abet :: 6
28++ abet :: 6
28 (sort (~(tap in field) ~) lth) :: 7
29 (sort (~(tap in field) ~) lth) :: 7
29:: :: 8
30:: :: 8
30++ main :: 9
31++ main :: 9
31− :var factor/atom 2 :: 10
32+ =/ factor/@ 2 :: 10
32− :loop :like ..main :: 11
33+ |- ^+ ..main :: 11
33− :if (gth (mul factor factor) thru) :: 12
34+ ?: (gth (mul factor factor) thru) :: 12
34 ..main :: 13
35 ..main :: 13
35− :moar(factor +(factor), ..main (reap factor)) :: 14
36+ $(factor +(factor), ..main (reap factor)) :: 14
36:: :: 15
37:: :: 15
37++ reap :: 16
38++ reap :: 16
38− :gate factor/atom :: 17
39+ |= factor/@ :: 17
39− :var count/atom (mul 2 factor) :: 18
40+ =/ count/@ (mul 2 factor) :: 18
40− :loop :like ..reap :: 19
41+ |- ^+ ..reap :: 19
41− :if (gth count thru) :: 20
42+ ?: (gth count thru) :: 20
42 ..reap :: 21
43 ..reap :: 21
43− :moar :: 22
44+ %= $ :: 22
44 count (add count factor) :: 23
45 count (add count factor) :: 23
45 field (~(del in field) count) :: 24
46 field (~(del in field) count) :: 24
46 == :: 25
47 == :: 25
@@ -50,9 +51,9 @@ its argument, an atom:
50## `sieve`: explanation
51## `sieve`: explanation
51
52
52```
53```
53−:gate thru/atom :: 1
54+|= thru/@ :: 1
54−:cast (list atom) :: 2
55+^- (list @) :: 2
55−:var field/(set atom) (silt (gulf 2 thru)) :: 3
56+=/ field/(set @) (silt (gulf 2 thru)) :: 3
56```
57```
57
58
58Line `1`: we are building a gate (function) whose sample
59Line `1`: we are building a gate (function) whose sample
@@ -67,13 +68,13 @@ list of atoms.
67
68
68Line `4`: below, we introduce a core which does our work. With
69Line `4`: below, we introduce a core which does our work. With
69reverse flow, we compute `main` on this core, then `abet` on the
70reverse flow, we compute `main` on this core, then `abet` on the
70−product of `main`. (`abet:main` means `:rap(abet main)`.)
71+product of `main`. (`abet:main` means `=<(abet main)`.)
71
72
72The core is a state machine; `main` produces the core itself,
73The core is a state machine; `main` produces the core itself,
73with the computation completed. `abet` then extracts the result.
74with the computation completed. `abet` then extracts the result.
74
75
75```
76```
76−:core :: 5
77+|% :: 5
77++ abet :: 6
78++ abet :: 6
78 (sort (~(tap in field) ~) lth) :: 7
79 (sort (~(tap in field) ~) lth) :: 7
79```
80```
@@ -90,8 +91,8 @@ list in ascending order with `lth` (less-than).
90
91
91```
92```
92++ main :: 9
93++ main :: 9
93− :var factor/atom 2 :: 10
94+ =/ factor/@ 2 :: 10
94− :loop :like ..main :: 11
95+ |- ^+ ..main :: 11
95```
96```
96
97
97Line `9`: the `main` arm, which performs the main calculation.
98Line `9`: the `main` arm, which performs the main calculation.
@@ -103,9 +104,9 @@ Line `11`: we start a loop. The product of the loop is cast to
103`..main`, which is the core we're in (`+1.main`).
104`..main`, which is the core we're in (`+1.main`).
104
105
105```
106```
106− :if (gth (mul factor factor) thru) :: 12
107+ ?: (gth (mul factor factor) thru) :: 12
107 ..main :: 13
108 ..main :: 13
108− :moar(factor +(factor), ..main (reap factor)) :: 14
109+ $(factor +(factor), ..main (reap factor)) :: 14
109```
110```
110
111
111Lines `12` and `13`: we terminate the loop, returning `..main`,
112Lines `12` and `13`: we terminate the loop, returning `..main`,
@@ -116,8 +117,8 @@ replacing the core with a version sieved by `reap`.
116
117
117```
118```
118++ reap :: 16
119++ reap :: 16
119− :gate factor/atom :: 17
120+ |= factor/@ :: 17
120− :var count/atom (mul 2 factor) :: 18
121+ =/ count/@ (mul 2 factor) :: 18
121```
122```
122
123
123Lines `16` and `17`: the `reap` arm, which produces a gate that
124Lines `16` and `17`: the `reap` arm, which produces a gate that
@@ -128,10 +129,10 @@ Line `18`: we declare a variable `count`, an atom, with the
128initial value `(mul 2 factor)`.
129initial value `(mul 2 factor)`.
129
130
130```
131```
131− :loop :like ..reap :: 19
132+ |- ^+ ..reap :: 19
132− :if (gth count thru) :: 20
133+ ?: (gth count thru) :: 20
133 ..reap :: 21
134 ..reap :: 21
134− :moar :: 22
135+ %= $ :: 22
135 count (add count factor) :: 23
136 count (add count factor) :: 23
136 field (~(del in field) count) :: 24
137 field (~(del in field) count) :: 24
137 == :: 25
138 == :: 25
@@ -147,9 +148,7 @@ multiple of `factor`, and deleting it from `field`.
147
148
148## `sieve`: code in kernel style
149## `sieve`: code in kernel style
149
150
150−Finally, the same code transliterated into runes (and in a more
151−concise "kernel" style).
151+Finally, the same code in a more concise "kernel" style.
152−
153```
152```
154|= top/@
153|= top/@
155^- (list @)
154^- (list @)
@@ -165,7 +164,7 @@ concise "kernel" style).
165 $(fac +(fac), ..main (reap fac))
164 $(fac +(fac), ..main (reap fac))
166::
165::
167++ reap
166++ reap
168− |= fac/atom
167+ |= fac/@
169 =+ cot=(mul 2 fac)
168 =+ cot=(mul 2 fac)
170 |- ^+ ..reap
169 |- ^+ ..reap
171 ?: (gth cot top)
170 ?: (gth cot top)
@@ -181,65 +180,65 @@ state, producing a list of game actions. Events are tic-tac-toe
181moves (`move)`; actions are tic-tac-toe results (`fact`).
180moves (`move)`; actions are tic-tac-toe results (`fact`).
182
181
183```
182```
184−:rap :gate feed/(list move) :: 1
183+=< |= feed/(list move) :: 1
185− :new game/game :: 2
184+ =| game/game :: 2
186− :loop :cast (list fact) :: 3
185+ |- ^- (list fact) :: 3
187− :ifno feed ~ :: 4
186+ ?~ feed ~ :: 4
188− :sip this/(unit fact) :: 5
187+ =^ this/(unit fact) :: 5
189− game :: 6
188+ game :: 6
190− (~(do go game) i.feed) :: 7
189+ (~(do go game) i.feed) :: 7
191− :var rest/(list fact) :moar(feed t.feed) :: 8
190+ =/ rest/(list fact) $(feed t.feed) :: 8
192− :ifno(this rest [u.this rest]) :: 9
191+ ?~(this rest [u.this rest]) :: 9
193:: :: 10
192:: :: 10
194−:per :core :: 11
193+=> |% :: 11
195− ++ side atom :: 12
194+ ++ side @ :: 12
196− ++ spot {x/atom y/atom} :: 13
195+ ++ spot {x/@ y/@} :: 13
197− ++ fact :book {$tie $~} :: 14
196+ ++ fact $% {$tie $~} :: 14
198− {$win p/cord} :: 15
197+ {$win p/cord} :: 15
199− == :: 16
198+ == :: 16
200− ++ move :book {$x p/spot} :: 17
199+ ++ move $% {$x p/spot} :: 17
201− {$o p/spot} :: 18
200+ {$o p/spot} :: 18
202− {$z $~} :: 19
201+ {$z $~} :: 19
203− == :: 20
202+ == :: 20
204− ++ game :bank w/? :: 21
203+ ++ game $: w/? :: 21
205− a/side :: 22
204+ a/side :: 22
206− z/side :: 23
205+ z/side :: 23
207− == :: 24
206+ == :: 24
208− -- :: 25
207+ -- :: 25
209−:core :: 26
208+|% :: 26
210++ bo :: 27
209++ bo :: 27
211− :door half/side :: 28
210+ |_ half/side :: 28
212− ++ bit :gate(a/atom =(1 (cut 0 [a 1] half))) :: 29
211+ ++ bit |=(a/@ =(1 (cut 0 [a 1] half))) :: 29
213− ++ off :gate(a/spot (add x.a (mul 3 y.a))) :: 30
212+ ++ off |=(a/spot (add x.a (mul 3 y.a))) :: 30
214− ++ get :gate(a/spot (bit (off a))) :: 31
213+ ++ get |=(a/spot (bit (off a))) :: 31
215− ++ set :gate(a/spot (con half (bex (off a)))) :: 32
214+ ++ set |=(a/spot (con half (bex (off a)))) :: 32
216− ++ win :calt lien :: 33
215+ ++ win %+ lien :: 33
217 (rip 4 0wl04h0.4A0Aw.4A00s.0e070) :: 34
216 (rip 4 0wl04h0.4A0Aw.4A00s.0e070) :: 34
218− :gate(a/atom =(a (dis a half))) :: 35
217+ |=(a/@ =(a (dis a half))) :: 35
219 -- :: 36
218 -- :: 36
220++ go :: 37
219++ go :: 37
221− :door game/game :: 38
220+ |_ game/game :: 38
222 ++ do :: 39
221 ++ do :: 39
223− :gate act/move :: 40
222+ |= act/move :: 40
224− :cast {(unit fact) ^game} :: 41
223+ ^- {(unit fact) ^game} :: 41
225− :case act :: 42
224+ ?- act :: 42
226− {$x *} :sure(w.game ~(mo on p.act)) :: 43
225+ {$x *} ?>(w.game ~(mo on p.act)) :: 43
227− {$o *} :deny(w.game ~(mo on p.act)) :: 44
226+ {$o *} ?<(w.game ~(mo on p.act)) :: 44
228 {$z *} [~ nu] :: 45
227 {$z *} [~ nu] :: 45
229 == :: 46
228 == :: 46
230 :: :: 47
229 :: :: 47
231− ++ nu :like(game [& 0 0]) :: 48
230+ ++ nu ^+(game [& 0 0]) :: 48
232 ++ on :: 49
231 ++ on :: 49
233− :door here/spot :: 50
232+ |_ here/spot :: 50
234− ++ is :or (~(get bo a.game) here) :: 51
233+ ++ is ?| (~(get bo a.game) here) :: 51
235− (~(get bo z.game) here) :: 52
234+ (~(get bo z.game) here) :: 52
236− == :: 53
235+ == :: 53
237− ++ mo :cast {(unit fact) ^game} :: 54
236+ ++ mo ^- {(unit fact) ^game} :: 54
238− :deny is :: 55
237+ ?< is :: 55
239− :var next/side (~(set bo a.game) here) :: 56
238+ =/ next/side (~(set bo a.game) here) :: 56
240− :if ~(win bo next) :: 57
239+ ?: ~(win bo next) :: 57
241− [[~ %win ?:(w.game %x %o)] nu] :: 58
240+ [[~ %win ?:(w.game %x %o)] nu] :: 58
242− [~ game(w !w.game, a z.game, z next)] :: 59
241+ [~ game(w !w.game, a z.game, z next)] :: 59
243 -- :: 60
242 -- :: 60
244 -- :: 62
243 -- :: 62
245-- :: 63
244-- :: 63
@@ -248,10 +247,10 @@ moves (`move)`; actions are tic-tac-toe results (`fact`).
248### `toe`: explanation
247### `toe`: explanation
249
248
250```
249```
251−:rap :gate feed/(list move) :: 1
250+=< |= feed/(list move) :: 1
252− :new game/game :: 2
251+ =| game/game :: 2
253− :loop :cast (list fact) :: 3
252+ |- ^- (list fact) :: 3
254− :ifno feed ~ :: 4
253+ ?~ feed ~ :: 4
255```
254```
256
255
257Line `1` wraps a conclusion around a stack of cores. The cores
256Line `1` wraps a conclusion around a stack of cores. The cores
@@ -268,7 +267,7 @@ Line `3` enters a loop producing a list of game events, `fact`.
268Line `4` produces nil, `~`, if `feed` is empty.
267Line `4` produces nil, `~`, if `feed` is empty.
269
268
270```
269```
271− :sip this/(unit fact) :: 5
270+ =^ this/(unit fact) :: 5
272 game :: 6
271 game :: 6
273 (~(do go game) i.feed) :: 7
272 (~(do go game) i.feed) :: 7
274```
273```
@@ -277,12 +276,12 @@ Lines `5` through `7` apply the move. We open a `go` core on the
277current game state, produce a `do` gate, and call that gate on
276current game state, produce a `do` gate, and call that gate on
278the move. The product of the `do` gate is a pair; the head is
277the move. The product of the `do` gate is a pair; the head is
279`(unit fact)`, either `~` or `[~ fact]`; the tail is a new
278`(unit fact)`, either `~` or `[~ fact]`; the tail is a new
280−`game`. The `:sip` twig declares the head as a new variable,
279+`game`. The `=^` hoon declares the head as a new variable,
281`this`; it modifies the subject by setting `game` to the tail.
280`this`; it modifies the subject by setting `game` to the tail.
282
281
283```
282```
284− :var rest/(list fact) :moar(feed t.feed) :: 8
283+ =/ rest/(list fact) $(feed t.feed) :: 8
285− :ifno(this rest [u.this rest]) :: 9
284+ ?~(this rest [u.this rest]) :: 9
286```
285```
287
286
288Line `8` declares a new variable, `rest`, which is all the facts
287Line `8` declares a new variable, `rest`, which is all the facts
@@ -292,9 +291,9 @@ generated by the moves in `t.feed`, the tail of the move list.
292prepends the new fact to `rest`.
291prepends the new fact to `rest`.
293
292
294```
293```
295−:per :core :: 11
294+=> |% :: 11
296− ++ side atom :: 12
295+ ++ side @ :: 12
297− ++ spot {x/atom y/atom} :: 13
296+ ++ spot {x/@ y/@} :: 13
298```
297```
299
298
300Line `11` wraps a library core around a data structure core, a
299Line `11` wraps a library core around a data structure core, a
@@ -308,9 +307,9 @@ A side is a half of the board, as a marked/unmarked bitfield.
308Line `13` defines the `spot` mold, a 2D coordinate.
307Line `13` defines the `spot` mold, a 2D coordinate.
309
308
310```
309```
311− ++ fact :book {$tie $~} :: 14
310+ ++ fact $% {$tie $~} :: 14
312− {$win p/cord} :: 15
311+ {$win p/cord} :: 15
313− == :: 16
312+ == :: 16
314```
313```
315
314
316Lines `14` to `16` define the `fact` mold, a game event (i.e.,
315Lines `14` to `16` define the `fact` mold, a game event (i.e.,
@@ -319,21 +318,21 @@ output action), as a book (tagged union). There are two forms of
319(reporting that `'X'` or `'O'` won a game.
318(reporting that `'X'` or `'O'` won a game.
320
319
321```
320```
322− ++ move :book {$x p/spot} :: 17
321+ ++ move $% {$x p/spot} :: 17
323− {$o p/spot} :: 18
322+ {$o p/spot} :: 18
324− {$z $~} :: 19
323+ {$z $~} :: 19
325− == :: 20
324+ == :: 20
326```
325```
327
326
328Lines `17` to `20` define the `move` mold, a game move. This is
327Lines `17` to `20` define the `move` mold, a game move. This is
329either `[%x spot]`, `[%o spot]`, or `[%z ~]` to reset the board.
328either `[%x spot]`, `[%o spot]`, or `[%z ~]` to reset the board.
330
329
331```
330```
332− ++ game :bank w/? :: 21
331+ ++ game $: w/? :: 21
333− a/side :: 22
332+ a/side :: 22
334− z/side :: 23
333+ z/side :: 23
335− == :: 24
334+ == :: 24
336− -- :: 25
335+ -- :: 25
337```
336```
338
337
339Lines `21` to `23` define the `game` mold, the game state. This
338Lines `21` to `23` define the `game` mold, the game state. This
@@ -342,13 +341,13 @@ side; and `w`, which is `&` (yes) if `a` is X and `b` is O; `|`
342otherwise. (Obviously, we swap `a` and `z` on every move.)
341otherwise. (Obviously, we swap `a` and `z` on every move.)
343
342
344```
343```
345−:core :: 26
344+|% :: 26
346++ bo :: 27
345++ bo :: 27
347− :door half/side :: 28
346+ |_ half/side :: 28
348− ++ bit :gate(a/atom =(1 (cut 0 [a 1] half))) :: 29
347+ ++ bit |=(a/@ =(1 (cut 0 [a 1] half))) :: 29
349− ++ off :gate(a/spot (add x.a (mul 3 y.a))) :: 30
348+ ++ off |=(a/spot (add x.a (mul 3 y.a))) :: 30
350− ++ get :gate(a/spot (bit (off a))) :: 31
349+ ++ get |=(a/spot (bit (off a))) :: 31
351− ++ set :gate(a/spot (con half (bex (off a)))) :: 32
350+ ++ set |=(a/spot (con half (bex (off a)))) :: 32
352```
351```
353
352
354Line `26` introduces the library core, which contains the doors
353Line `26` introduces the library core, which contains the doors
@@ -369,9 +368,9 @@ bit at a `spot` set. It works by ORing (`con`) `half` with the
369binary exponent (`bex`) of the offset (`off`) of the spot.
368binary exponent (`bex`) of the offset (`off`) of the spot.
370
369
371```
370```
372− ++ win :calt lien :: 33
371+ ++ win %+ lien :: 33
373 (rip 4 0wl04h0.4A0Aw.4A00s.0e070) :: 34
372 (rip 4 0wl04h0.4A0Aw.4A00s.0e070) :: 34
374− :gate(a/atom =(a (dis a half))) :: 35
373+ |=(a/@ =(a (dis a half))) :: 35
375 -- :: 36
374 -- :: 36
376```
375```
377
376
@@ -383,10 +382,10 @@ of which must equal itself when ANDed (`dis`) with `half`.
383
382
384```
383```
385++ go :: 37
384++ go :: 37
386− :door game/game :: 38
385+ |_ game/game :: 38
387 ++ do :: 39
386 ++ do :: 39
388− :gate act/move :: 40
387+ |= act/move :: 40
389− :cast {(unit fact) ^game} :: 41
388+ ^- {(unit fact) ^game} :: 41
390```
389```
391
390
392Lines `37` to `38` begin the `go` core, a door around a `game`.
391Lines `37` to `38` begin the `go` core, a door around a `game`.
@@ -398,9 +397,9 @@ move. The product is cast to a pair of `(unit fact)` and a new
398game state, written `^game` to skip to the second binding.
397game state, written `^game` to skip to the second binding.
399
398
400```
399```
401− :case act :: 42
400+ ?- act :: 42
402− {$x *} :sure(w.game ~(mo on p.act)) :: 43
401+ {$x *} ?>(w.game ~(mo on p.act)) :: 43
403− {$o *} :deny(w.game ~(mo on p.act)) :: 44
402+ {$o *} ?<(w.game ~(mo on p.act)) :: 44
404 {$z *} [~ nu] :: 45
403 {$z *} [~ nu] :: 45
405 == :: 46
404 == :: 46
406 :: :: 47
405 :: :: 47
@@ -412,12 +411,12 @@ the `mo` door to apply the move. If it's a `%z` move, we clear
412the board.
411the board.
413
412
414```
413```
415− ++ nu :like(game [& 0 0]) :: 48
414+ ++ nu ^+(game [& 0 0]) :: 48
416 ++ on :: 49
415 ++ on :: 49
417− :door here/spot :: 50
416+ |_ here/spot :: 50
418− ++ is :or (~(get bo a.game) here) :: 51
417+ ++ is ?| (~(get bo a.game) here) :: 51
419− (~(get bo z.game) here) :: 52
418+ (~(get bo z.game) here) :: 52
420− == :: 53
419+ == :: 53
421```
420```
422
421
423Line `48` is the `nu` arm, which produces a blank game state.
422Line `48` is the `nu` arm, which produces a blank game state.
@@ -427,16 +426,16 @@ Lines `49` to `50` begin the `on` door, a door around `here`, a
427game state, we have multiple computed attributes (`is` and `mo`)
426game state, we have multiple computed attributes (`is` and `mo`)
428against the combination of game state and coordinate.
427against the combination of game state and coordinate.
429
428
430−Lines `51` to `53` define the `is` arm, which is `&` (yes) iff
429+Lines `51` to `53` define the `is` arm, which is `&` (yes) if
431either `a` or `z` has played `here`.
430either `a` or `z` has played `here`.
432
431
433```
432```
434− ++ mo :cast {(unit fact) ^game} :: 54
433+ ++ mo ^- {(unit fact) ^game} :: 54
435− :deny is :: 55
434+ ?< is :: 55
436− :var next/side (~(set bo a.game) here) :: 56
435+ =/ next/side (~(set bo a.game) here) :: 56
437− :if ~(win bo next) :: 57
436+ ?: ~(win bo next) :: 57
438− [[~ %win ?:(w.game %x %o)] nu] :: 58
437+ [[~ %win ?:(w.game %x %o)] nu] :: 58
439− [~ game(w !w.game, a z.game, z next)] :: 59
438+ [~ game(w !w.game, a z.game, z next)] :: 59
440 -- :: 60
439 -- :: 60
441 -- :: 62
440 -- :: 62
442-- :: 63
441-- :: 63
@@ -487,13 +486,13 @@ side `z`, and replaces `z` with `next`.
487|%
486|%
488++ bo
487++ bo
489 |_ haf/side
488 |_ haf/side
490− ++ bit |=(a/atom =(1 (cut 0 [a 1] haf)))
489+ ++ bit |=(a/@ =(1 (cut 0 [a 1] haf)))
491 ++ get |=(a/spot (bit (off a)))
490 ++ get |=(a/spot (bit (off a)))
492 ++ off |=(a/spot (add x.a (mul 3 y.a)))
491 ++ off |=(a/spot (add x.a (mul 3 y.a)))
493 ++ set |=(a/spot (con haf (bex (off a))))
492 ++ set |=(a/spot (con haf (bex (off a))))
494 ++ win %+ lien
493 ++ win %+ lien
495 (rip 4 0wl04h0.4A0Aw.4A00s.0e070)
494 (rip 4 0wl04h0.4A0Aw.4A00s.0e070)
496− |=(a/atom =(a (dis a haf)))
495+ |=(a/@ =(a (dis a haf)))
497 --
496 --
498++ go
497++ go
499 |_ mag/game
498 |_ mag/game
@@ -510,9 +509,9 @@ side `z`, and replaces `z` with `next`.
510 ++ on
509 ++ on
511 =| her/spot
510 =| her/spot
512 |%
511 |%
513− ++ is ?| (~(get bo a.mag) her)
512+ ++ is ?| (~(get bo a.mag) her)
514− (~(get bo z.mag) her)
513+ (~(get bo z.mag) her)
515− ==
514+ ==
516 ++ mo ^- {(unit fact) game}
515 ++ mo ^- {(unit fact) game}
517 ?< is
516 ?< is
518 =+ next=(~(set bo a.mag) her)
517 =+ next=(~(set bo a.mag) her)
@@ -563,28 +562,28 @@ side `z`, and replaces `z` with `next`.
563::::
562::::
564::::
563::::
565
564
566−++ tree |* a/gate :: binary tree
565+++ tree |* a/gate :: binary tree
567 $@($~ {n/a l/(tree a) r/(tree a)}) ::
566 $@($~ {n/a l/(tree a) r/(tree a)}) ::
568++ trap |*(a/_* _|?(*a)) :: makes perfect sense
567++ trap |*(a/_* _|?(*a)) :: makes perfect sense
569−++ trel |* {a/gate b/gate c/gate} :: just a triple
568+++ trel |* {a/gate b/gate c/gate} :: just a triple
570 {p/a q/b r/c} ::
569 {p/a q/b r/c} ::
571++ each |* {a/gate b/gate} :: either a or b
570++ each |* {a/gate b/gate} :: either a or b
572 $%({$& p/a} {$| p/b}) :: a default
571 $%({$& p/a} {$| p/b}) :: a default
573
572
574−++ qual |* {a/gate b/gate c/gate d/gate} :: just a quadruple
573+++ qual |* {a/gate b/gate c/gate d/gate} :: just a quadruple
575 {p/a q/b r/c s/d} ::
574 {p/a q/b r/c s/d} ::
576−++ pair |*({a/gate b/gate} {p/a q/b}) :: just a pair
575+++ pair |*({a/gate b/gate} {p/a q/b}) :: just a pair
577−++ quid |*({a/gate b/*} {a _b}) :: for =^
576+++ quid |*({a/gate b/*} {a _b}) :: for =^
578−++ quip |*({a/gate b/*} {(list a) _b}) :: for =^
577+++ quip |*({a/gate b/*} {(list a) _b}) :: for =^
579−++ unit |* a/gate :: maybe
578+++ unit |* a/gate :: maybe
580 $@($~ {$~ u/a}) ::
579 $@($~ {$~ u/a}) ::
581−++ list |* a/gate :: null-term list
580+++ list |* a/gate :: null-term list
582 $@($~ {i/a t/(list a)}) ::
581 $@($~ {i/a t/(list a)}) ::
583−++ lone |*(a/gate p/a) :: just one thing
582+++ lone |*(a/gate p/a) :: just one thing
584
583
585::::
584::::
586::::
585::::
587−++ map |* {a/gate b/gate} :: associative tree
586+++ map |* {a/gate b/gate} :: associative tree
588 $@($~ {n/{p/a q/b} l/(map a b) r/(map a b)}) ::
587 $@($~ {n/{p/a q/b} l/(map a b) r/(map a b)}) ::
589++ qeu |* a/gate :: queue
588++ qeu |* a/gate :: queue
590 $@($~ {n/a l/(qeu a) r/(qeu a)}) ::
589 $@($~ {n/a l/(qeu a) r/(qeu a)}) ::
docs/hoon/exercises.md+2−1
@@ -1,6 +1,7 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 18
4+sort: 22
4title: Exercises
5title: Exercises
5---
6---
6
7
docs/hoon/irregular.md+74−90
@@ -1,6 +1,6 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3−sort: 22
3+sort: 25
4title: Irregular forms
4title: Irregular forms
5comments: true
5comments: true
6---
6---
@@ -10,29 +10,29 @@ comments: true
10
10
11<br />
11<br />
12
12
13−*Original `fora` post* [*here*](http://urbit.org/fora/posts/~2016.12.29..19.37.08..89d5~/).
13+*Original Fora post* [*here*](https://urbit.org/fora/posts/~2016.12.29..19.37.08..89d5~/).
14
14
15##### Reading guide
15##### Reading guide
16Headings contain runes, phonetics and tokens. Description contains a link to the docs and a short description of the rune. Both regular (R) and irregular (I) forms are given.
16Headings contain runes, phonetics and tokens. Description contains a link to the docs and a short description of the rune. Both regular (R) and irregular (I) forms are given.
17
17
18−Want to `ctrl-f` to find out the meaning of something weird you saw? Search for `\symbol`. ie `\?` or `\=`. It'll show you to the irregular forms that uses that symbol.
18+Want to `Ctrl-f` to find out the meaning of something weird you saw? Search for `\symbol`. ie `\?` or `\=`. It'll show you to the irregular forms that uses that symbol.
19
19
20## . dot (nock)
20## . dot (nock)
21
21
22Anything Nock can do, Hoon can do also.
22Anything Nock can do, Hoon can do also.
23
23
24−### .+ dotlus :bump
24+### .+ dotlus
25
25
26−[docs](https://urbit.org/docs/hoon/twig/dot-nock/lus-bump/) \\+
26+[docs](../rune/dot/lus/) \\+
27−`{$bump p/atom}`: increment an atom with Nock 4.
27+`[%dtls p=atom]`: increment an atom with Nock 4.
28
28
29R: `.+(p)`
29R: `.+(p)`
30I: `+(p)`
30I: `+(p)`
31
31
32−### .= dottis :same
32+### .= dottis
33
33
34−[docs](https://urbit.org/docs/hoon/twig/dot-nock/tis-same/) \\=
34+[docs](../rune/dot/tis/) \\=
35−`{$same p/seed q/seed}`: test for equality with Nock 5.
35+`[%dtls p=hoon q=hoon]`: test for equality with Nock 5.
36
36
37R: `.=(p q)`
37R: `.=(p q)`
38I: `=(p q)`
38I: `=(p q)`
@@ -41,22 +41,22 @@ I: `=(p q)`
41
41
42Miscellaneous useful macros.
42Miscellaneous useful macros.
43
43
44−### ;: semcol :wad
44+### ;: semcol
45
45
46−[docs](https://urbit.org/docs/hoon/twig/sem-make/col-wad/) \\:
46+[docs](../rune/sem/col/) \\:
47−`{$wad p/seed q/(list seed)}`: call a binary function as an n-ary function.
47+`[%smcl p=hoon q=(list hoon)]`: call a binary function as an n-ary function.
48
48
49R: `;:(p q)`
49R: `;:(p q)`
50I: `:(p q)`
50I: `:(p q)`
51
51
52## : col (cells)
52## : col (cells)
53
53
54−The cell twigs.
54+The cell runes.
55
55
56−### :- colhep :cons
56+### :- colhep
57
57
58−[docs](https://urbit.org/docs/hoon/twig/col-cell/hep-cons/) \\[\\]\\^\\+\\\`\\~
58+[docs](../rune/col/hep/) \\[\\]\\^\\+\\\`\\~
59−`{$cons p/seed q/seed}`: construct a cell (2-tuple).
59+`[%clhp p=hoon q=hoon]`: construct a cell (2-tuple).
60
60
61R: `:-(p q)`
61R: `:-(p q)`
62I:
62I:
@@ -65,7 +65,7 @@ I:
65 [a b] ==> :-(a b)
65 [a b] ==> :-(a b)
66[a b c] ==> [a [b c]]
66[a b c] ==> [a [b c]]
67 a^b^c ==> [a b c]
67 a^b^c ==> [a b c]
68− a+b ==> [%a b]
68+ a/b ==> [%a b]
69 `a ==> [~ a]
69 `a ==> [~ a]
70 ~[a b] ==> [a b ~]
70 ~[a b] ==> [a b ~]
71 [a b]~ ==> [[a b] ~]
71 [a b]~ ==> [[a b] ~]
@@ -73,54 +73,54 @@ I:
73
73
74## = tis (flow)
74## = tis (flow)
75
75
76−Flow twigs change the subject. All non-flow twigs (except cores) pass the subject down unchanged.
76+Flow hoons change the subject. All non-flow hoons (except cores) pass the subject down unchanged.
77
77
78−### =< tisgal :rap
78+### =< tisgar
79
79
80−[docs](https://urbit.org/docs/hoon/twig/tis-flow/gal-rap/) \\:
80+[docs](../rune/tis/gal/) \\:
81−`{$rap p/seed q/seed}`: compose two twigs, inverted.
81+`[%tsgl p=hoon q=hoon]`: compose two hoons, inverted.
82
82
83R: `=<(p q)`
83R: `=<(p q)`
84I: `p:q`
84I: `p:q`
85
85
86## | bar (core)
86## | bar (core)
87
87
88−[docs](https://urbit.org/docs/hoon/twig/bar-core/) \\$
88+[docs](../rune/bar/) \\$
89−Core twigs are flow twigs.
89+Core hoons are flow hoon.
90
90
91Technically not irregular syntax, but worth mentioning.
91Technically not irregular syntax, but worth mentioning.
92
92
93−* `|= bartis :gate`
93+* `|= bartis` (gate)
94−* `|. bardot :trap`
94+* `|. bardot` (trap)
95−* `|- barhep :loop`
95+* `|- barhep` (loop)
96−* `|* bartar :gill`
96+* `|* bartar` (gill)
97
97
98−The above runes produce a core with a single arm, named `$` (or `:moar`). We can recompute this arm with changes, useful for recursion among other things. Commonly used with the irregular syntax for `%=`, `:make`, like so: `$()`.
98+The above runes produce a core with a single arm, named `$` ("buc"). We can recompute this arm with changes, useful for recursion among other things. Commonly used with the irregular syntax for `%=`, `:make`, like so: `$()`.
99
99
100## % cen (call)
100## % cen (call)
101
101
102−The invocation family of twigs.
102+The invocation family of runes.
103
103
104−### %= centis :make
104+### %= centis
105
105
106−[docs](https://urbit.org/docs/hoon/twig/cen-call/tis-make/) \\(\\)
106+[docs](../rune/cen/tis/) \\(\\)
107−`{$make p/wing q/(list (pair wing seed))}`: take a wing with changes.
107+`[%cnts p=wing q=(list (pair wing hoon))]`: take a wing with changes.
108
108
109R: `%=(p a 1)`
109R: `%=(p a 1)`
110I: `p(a 1)`
110I: `p(a 1)`
111
111
112−### %~ censig :open
112+### %~ censig
113
113
114−[docs](https://urbit.org/docs/hoon/twig/cen-call/sig-open/) \\~
114+[docs](../rune/cen/sig/) \\~
115−`{$cnsg p/wing q/seed r/seed}`: call with multi-armed door.
115+`[%cnsg p=wing q=hoon r=hoon]`: call with multi-armed door.
116
116
117R: `%~(p q r)`
117R: `%~(p q r)`
118I: `~(p q r)`
118I: `~(p q r)`
119
119
120−### %- cenhep :call
120+### %- cenhep
121
121
122−[docs](https://urbit.org/~~/docs/hoon/twig/cen-call/hep-call/) \\(\\)
122+[docs](../rune/cen/hep/) \\(\\)
123−`{$call p/seed q/seed}`: call a gate (function).
123+`[%cnhp p=hoon q=hoon]`: call a gate (function).
124
124
125R: `%-(p q)`
125R: `%-(p q)`
126I: `(p q)`
126I: `(p q)`
@@ -131,34 +131,18 @@ Note: `(p)` becomes `$:p` (`=<($ p)`), which behaves as you would expect (func c
131
131
132A mold is a gate (function) that helps us build simple and rigorous data structures.
132A mold is a gate (function) that helps us build simple and rigorous data structures.
133
133
134−### $: buccol :bank
134+### $? bucwut
135
135
136−[docs](https://urbit.org/docs/hoon/twig/buc-mold/col-bank/) \\{\\}
136+[docs](../rune/buc/wut/) \\?
137−`{$bank p/(list moss)}`: form a mold which recognizes a tuple.
138−
139−R: `$:(p q)`
140−I: `{p q}`
141−
142−### $= buctis :coat
143−
144−[docs](https://urbit.org/docs/hoon/twig/buc-mold/tis-coat/) \\/
145−`{$coat p/@tas q/moss}`: mold which wraps a face around another mold.
146−
147−R: `$=(p q)`
148−I: `p/q`
149−
150−### $? bucwut :pick
151−
152−[docs](https://urbit.org/docs/hoon/twig/buc-mold/wut-pick/) \\?
153−`{$pick p/(list moss)}`: mold which normalizes a general union.
137+`[%bcwt p=(list model)]`: mold which normalizes a general union.
154
138
155R: `$?(p)`
139R: `$?(p)`
156I: `?(p)`
140I: `?(p)`
157
141
158−### $_ buccab :shoe
142+### $_ buccab
159
143
160−[docs](https://urbit.org/docs/hoon/twig/buc-mold/cab-shoe/) \\_
144+[docs](../rune/buc/cab/) \\_
161−`{$shoe p/seed}`: mold which normalizes to an example.
145+`[%bccb p=value]`: mold which normalizes to an example.
162
146
163R: `$_(p)`
147R: `$_(p)`
164I: `_p`
148I: `_p`
@@ -167,46 +151,46 @@ I: `_p`
167
151
168Hoon has the usual branches and logical tests.
152Hoon has the usual branches and logical tests.
169
153
170−### ?! wutzap :not
154+### ?! wutzap
171
155
172−[docs](https://urbit.org/docs/hoon/twig/wut-test/zap-not/) \\!
156+[docs](../rune/wut/zap/) \\!
173−`{$not p/seed}`: logical not.
157+`[%wtzp p=hoon]`: logical not.
174
158
175R: `?!(p)`
159R: `?!(p)`
176I: `!(p)`
160I: `!(p)`
177
161
178−### ?& wutpam :and
162+### ?& wutpam
179
163
180−[docs](https://urbit.org/docs/hoon/twig/wut-test/pam-and/) \\&
164+[docs](../rune/wut/pam/) \\&
181−`{$and p/(list seed)}`: logical and.
165+`[%wtpm p=(list hoon)]`: logical and.
182
166
183R: `?&(p)`
167R: `?&(p)`
184I: `&(p)`
168I: `&(p)`
185
169
186−### ?& wutbar :or
170+### ?| wutbar
187
171
188−[docs](https://urbit.org/docs/hoon/twig/wut-test/bar-or/) \\|
172+[docs](../rune/wut/bar/) \\|
189−`{$or p/(list seed)}`: logical or.
173+`[%wtbr p=(list hoon)]`: logical or.
190
174
191R: `?|(p)`
175R: `?|(p)`
192I: `|(p)`
176I: `|(p)`
193
177
194## ^ ket (cast)
178## ^ ket (cast)
195
179
196−Lets us adjust spans without violating type constraints.
180+Lets us adjust types without violating type constraints.
197
181
198−### ^- kethep :cast
182+### ^- kethep
199
183
200−[docs](https://urbit.org/docs/hoon/twig/ket-cast/hep-cast/) \\\`
184+[docs](../rune/ket/hep/) \\\`
201−`{$cast p/moss q/seed}`: typecast by mold.
185+`[%kthp p=model q=value]`: typecast by mold.
202
186
203R: `^-(p q)`
187R: `^-(p q)`
204−I: ```p`q``
188+I: `` `p`q ``
205
189
206−### ^= kettis :name
190+### ^= kettis
207
191
208−[docs](https://urbit.org/docs/hoon/twig/ket-cast/tis-name/) \\=
192+[docs](../rune/ket/tis/) \\=
209−`{$name p/toga q/seed}`: name a value.
193+`[%ktts p=toga q=value]`: name a value.
210
194
211R: `^=(p q)`
195R: `^=(p q)`
212I: `p=q`
196I: `p=q`
@@ -220,27 +204,27 @@ I: `p=q`
220* `*` noun.
204* `*` noun.
221* `^` cell.
205* `^` cell.
222* `?` loobean.
206* `?` loobean.
223−* `$~` null.
207+* `~` null.
224
208
225### Values
209### Values
226
210
227\\~\\-\\.\\&\\|
211\\~\\-\\.\\&\\|
228−
212+}
229* `~` null.
213* `~` null.
230* `&` loobean true.
214* `&` loobean true.
231* `|` loobean false.
215* `|` loobean false.
232* `%a` constant `a`, where `a` can be an ((ir)regularly defined) atom or a symbol.
216* `%a` constant `a`, where `a` can be an ((ir)regularly defined) atom or a symbol.
233
217
234−See [:sand](https://urbit.org/docs/hoon/twig/atom/sand/) for other irregular definitions of atoms.
218+See [%sand](../atom/sand/) for other irregular definitions of atoms.
235
219
236−### List addressing
220+### List addressing}
237* `&n` nth element of a list.
221* `&n` nth element of a list.
238* `|n` tail of list after nth element (i.e. n is the head).
222* `|n` tail of list after nth element (i.e. n is the head).
239
223
240−### Limbs :limb
224+### Limbs
241
225
242−[docs](https://urbit.org/docs/hoon/twig/limb/limb/) \\+\\.\\^
226+[docs](../limb/limb/) \\+\\.\\^
243−`{$limb p/(each @ud {p/@ud q/@tas})}`: attribute of subject.
227+`[%limb p=(each @ud [p=@ud q=@tas])]`: attribute of subject.
244
228
245* `+15` is slot 15
229* `+15` is slot 15
246* `.` is the whole subject (slot 1)
230* `.` is the whole subject (slot 1)
@@ -260,17 +244,17 @@ See [:sand](https://urbit.org/docs/hoon/twig/atom/sand/) for other irregular def
260```
244```
261
245
262
246
263−### Wings :wing
247+### Wings
264−
265−[docs](https://urbit.org/~~/docs/hoon/twig/limb/wing/) \\.
266−`{$wing p/(list limb)`; a limb search path.
267
248
249+[docs](../limb/wing/) \\.
250+`[%wing p=(list limb)]`; a limb search path.
251+}
268`a.b` finds limb `a` within limb `b` ("var" `a` within "var" `b`).
252`a.b` finds limb `a` within limb `b` ("var" `a` within "var" `b`).
269
253
270### Printing stuff
254### Printing stuff
271
255
272−* `<a b c>` prints a [tape](https://urbit.org/docs/hoon/library/2q/#-tape).
256+* `<a b c>` prints a [tape](../library/2q/#-tape).
273−* `>a b c<` prints a [tank](https://urbit.org/docs/hoon/library/2q/#-tank).
257+* `>a b c<` prints a [tank](../library/2q/#-tank).
274
258
275## Commentary
259## Commentary
276
260
docs/hoon/library.md+1−1
@@ -1,6 +1,6 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3−sort: 20
3+sort: 18
4title: Standard library
4title: Standard library
5---
5---
6
6
docs/hoon/twig/limb.md → docs/hoon/limb.mdrenamed+5−3
@@ -1,12 +1,14 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 2
4+sort: 16
5+title: Limbs and wings
4---
6---
5
7
6# Limbs and wings
8# Limbs and wings
7
9
8One feature Hoon lacks: a context that isn't a first-class value.
10One feature Hoon lacks: a context that isn't a first-class value.
9−Hoon has no concept of scope, environment, etc. A twig has one
11+Hoon has no concept of scope, environment, etc. A hoon has one
10data source, the *subject*, a noun like any other.
12data source, the *subject*, a noun like any other.
11
13
12In most languages "variable" and "attribute" are different
14In most languages "variable" and "attribute" are different
@@ -14,7 +16,7 @@ things. They are both symbols, but a variable is in "the
14environment" and a attribute is on "an object." In Hoon, "the
16environment" and a attribute is on "an object." In Hoon, "the
15environment" is "an object" -- the subject.
17environment" is "an object" -- the subject.
16
18
17−`$limb` and `$wing` are two basic twig stems that extract
19+`%limb` and `%wing` are two basic hoon stems that extract
18information from the subject. A `limb` is an attribute; a `wing`
20information from the subject. A `limb` is an attribute; a `wing`
19is an attribute path, ie, a list of limbs.
21is an attribute path, ie, a list of limbs.
20
22
docs/hoon/twig/limb/limb.md → docs/hoon/limb/limb.mdrenamed+13−12
@@ -1,18 +1,19 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 1
4sort: 1
4−
5+title: Limb
5---
6---
6
7
7−# `:limb`
8+# Limb
8
9
9−`{$limb p/(each @ud {p/@ud q/@tas})}`: attribute of subject.
10+`[%limb p=(each @ud [p=@ud q=@tas])]`: attribute of subject.
10
11
11### Produces
12### Produces
12
13
13−If `p` matches `{$& p/@ud}`, slot `p.p` of the subject.
14+If `p` matches `[%& p=@ud]`, slot `p.p` of the subject.
14
15
15−If `p` matches `{$| p/@ud q/@tas}`, the `p`th match for `q`,
16+If `p` matches `[%| p=@ud q=@tas]`, the `p`th match for `q`,
16using the search traverse below.
17using the search traverse below.
17
18
18### Syntax
19### Syntax
@@ -45,13 +46,13 @@ subject leg to compute the result. Logically, a limb is an
45attribute -- computation or subtree, "synthesized" or "natural"
46attribute -- computation or subtree, "synthesized" or "natural"
46-- of the subject.
47-- of the subject.
47
48
48−We search the subject span headfirst, depth-first, and pre-order.
49+We search the subject type headfirst, depth-first, and pre-order.
49−If we descend to a `$face` span whose label matches the limb
50+If we descend to a `%face` type whose label matches the limb
50−symbol, the descent address is a leg. The span is the span
51+symbol, the descent address is a leg. The type is the type
51−beneath the label. But if the `$face` label differs, the search
52+beneath the label. But if the `%face` label differs, the search
52skips this whole subtree.
53skips this whole subtree.
53
54
54−If we descend into a `$core` span in which the limb symbol is an
55+If we descend into a `%core` type in which the limb symbol is an
55arm, we produce that arm. If the limb symbol is not bound, we
56arm, we produce that arm. If the limb symbol is not bound, we
56descend into the payload (data) of the core.
57descend into the payload (data) of the core.
57
58
@@ -61,7 +62,7 @@ through" an overriding label. No label anywhere is inaccessible.
61
62
62### Examples
63### Examples
63
64
64−The `:dojo` prompt gives you a subject with a decent namespace.
65+The Dojo prompt gives you a subject with a decent namespace.
65Try
66Try
66
67
67```
68```
@@ -70,7 +71,7 @@ Try
70```
71```
71
72
72You can also add variables to the subject, then use them. (Note
73You can also add variables to the subject, then use them. (Note
73−that `=variable value` is not Hoon (language) syntax; it's `:dojo`
74+that `=variable value` is not Hoon (language) syntax; it's Dojo
74(shell) syntax.)
75(shell) syntax.)
75
76
76```
77```
docs/hoon/twig/limb/wing.md → docs/hoon/limb/wing.mdrenamed+4−3
@@ -1,16 +1,17 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3sort: 2
3sort: 2
4+title: Wing
4---
5---
5
6
6−# `:wing`
7+# Wing
7
8
8−`{$wing p/(list limb)`; a limb search path.
9+`[%wing p=(list limb)]`; a limb search path.
9
10
10### Produces
11### Produces
11
12
12If `p` is null, the subject at leg `1`. Otherwise, let `x` be
13If `p` is null, the subject at leg `1`. Otherwise, let `x` be
13−the `$wing` of `t.p`. `x` is either an arm or a leg. We compute
14+the `%wing` of `t.p`. `x` is either an arm or a leg. We compute
14limb `i.p` on some subject leg `s`, where:
15limb `i.p` on some subject leg `s`, where:
15
16
16If `x` is a leg/slot number, `s` is `x`.
17If `x` is a leg/slot number, `s` is `x`.
docs/hoon/mission.md+1−1
@@ -1,6 +1,6 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3−sort: 10
3+sort: 11
4next: true
4next: true
5title: Mission
5title: Mission
6---
6---
docs/hoon/reference.md+27−25
@@ -1,6 +1,7 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 21
4+sort: 24
4title: Expression reference
5title: Expression reference
5---
6---
6
7
@@ -10,72 +11,73 @@ title: Expression reference
10
11
11<div class="book">
12<div class="book">
12
13
13−### [Atoms and strings](../twig/atom)
14+### [Atoms and strings](../atom/)
14
15
15−### [Limbs and wings](../twig/limb)
16+### [Limbs and wings](../limb/)
16
17
17−## `$ buc` (mold)
18+## `. dot` (nock)
18
19
19−<list src="../twig/buc-mold" dataPreview="true" className="runes" childIsFragment="true"></list>
20+<list src="../rune/dot" dataPreview="true" className="runes" childIsFragment="true"></list>
20
21
21---
22---
22
23
23−## `| bar` (core)
24+## `! zap` (wild)
24
25
25−<list src="../twig/bar-core" dataPreview="true" className="runes" childIsFragment="true"></list>
26+<list src="../rune/zap" dataPreview="true" className="runes" childIsFragment="true"></list>
26
27
27---
28---
28
29
29−## `: col` (cell)
30+## `= tis` (flow)
30
31
31−<list src="../twig/col-cell" dataPreview="true" className="runes" childIsFragment="true"></list>
32+<list src="../rune/tis" dataPreview="true" className="runes" childIsFragment="true"></list>
32
33
33---
34---
34
35
35−## `% cen` (call)
36+## `? wut` (test)
36
37
37−<list src="../twig/cen-call" dataPreview="true" className="runes" childIsFragment="true"></list>
38+<list src="../rune/wut" dataPreview="true" className="runes" childIsFragment="true"></list>
38
39
39---
40---
40
41
41−## `. dot` (nock)
42+## `| bar` (core)
42
43
43−<list src="../twig/dot-nock" dataPreview="true" className="runes" childIsFragment="true"></list>
44+<list src="../rune/bar" dataPreview="true" className="runes" childIsFragment="true"></list>
44
45
45---
46---
46
47
47−## `^ ket` (cast)
48+## `~ sig` (hint)
48
49
49−<list src="../twig/ket-cast" dataPreview="true" className="runes" childIsFragment="true"></list>
50+<list src="../rune/sig" dataPreview="true" className="runes" childIsFragment="true"></list>
50
51
51---
52---
52
53
53−## `~ sig` (hint)
54+## `: col` (cell)
54
55
55−<list src="../twig/sig-hint" dataPreview="true" className="runes" childIsFragment="true"></list>
56+<list src="../rune/col" dataPreview="true" className="runes" childIsFragment="true"></list>
56
57
57---
58---
58
59
59−## `; sem` (make)
60+## `% cen` (call)
60
61
61−<list src="../twig/sem-make" dataPreview="true" className="runes" childIsFragment="true"></list>
62+<list src="../rune/cen" dataPreview="true" className="runes" childIsFragment="true"></list>
62
63
63---
64---
64
65
65−## `= tis` (flow)
66+## `^ ket` (cast)
66
67
67−<list src="../twig/tis-flow" dataPreview="true" className="runes" childIsFragment="true"></list>
68+<list src="../rune/ket" dataPreview="true" className="runes" childIsFragment="true"></list>
68
69
69---
70---
70
71
71−## `? wut` (test)
72+## `$ buc` (mold)
72
73
73−<list src="../twig/wut-test" dataPreview="true" className="runes" childIsFragment="true"></list>
74+<list src="../rune/buc" dataPreview="true" className="runes" childIsFragment="true"></list>
74
75
75---
76---
76
77
77−## `! zap` (wild)
78+## `; sem` (make)
78
79
79−<list src="../twig/zap-wild" dataPreview="true" className="runes" childIsFragment="true"></list>
80+<list src="../rune/sem" dataPreview="true" className="runes" childIsFragment="true"></list>
80
81
81</div>
82</div>
83+
docs/hoon/rune.mdnew file+77
@@ -0,0 +1,77 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 17
5+title: Runes
6+---
7+
8+# Runes
9+
10+<div class="book">
11+
12+## `. dot` (nock)
13+
14+<list src="./dot" dataPreview="true" className="runes" childIsFragment="true"></list>
15+
16+---
17+
18+## `! zap` (wild)
19+
20+<list src="./zap" dataPreview="true" className="runes" childIsFragment="true"></list>
21+
22+---
23+
24+## `= tis` (flow)
25+
26+<list src="./tis" dataPreview="true" className="runes" childIsFragment="true"></list>
27+
28+---
29+
30+## `? wut` (test)
31+
32+<list src="./wut" dataPreview="true" className="runes" childIsFragment="true"></list>
33+
34+---
35+
36+## `| bar` (core)
37+
38+<list src="./bar" dataPreview="true" className="runes" childIsFragment="true"></list>
39+
40+---
41+
42+## `~ sig` (hint)
43+
44+<list src="./sig" dataPreview="true" className="runes" childIsFragment="true"></list>
45+
46+---
47+
48+## `: col` (cell)
49+
50+<list src="./col" dataPreview="true" className="runes" childIsFragment="true"></list>
51+
52+---
53+
54+## `% cen` (call)
55+
56+<list src="./cen" dataPreview="true" className="runes" childIsFragment="true"></list>
57+
58+---
59+
60+## `^ ket` (cast)
61+
62+<list src="./ket" dataPreview="true" className="runes" childIsFragment="true"></list>
63+
64+---
65+
66+## `$ buc` (mold)
67+
68+<list src="./buc" dataPreview="true" className="runes" childIsFragment="true"></list>
69+
70+---
71+
72+## `; sem` (make)
73+
74+<list src="./sem" dataPreview="true" className="runes" childIsFragment="true"></list>
75+
76+</div>
77+
docs/hoon/rune/bar.mdnew file+27
@@ -0,0 +1,27 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 15
5+title: Core | "bar"
6+---
7+
8+# Core `|` "bar"
9+
10+Core hoons are flow hoons. The compiler essentially pins a Nock
11+formula, or battery of formulas, to the subject.
12+
13+All `|` hoons are macros around `%core`. (See the `%core`
14+section in [`type`](../../basic#-core-p-type-q-map-term-type) above.)
15+`%core` uses the subject as the payload of a battery, whose arms are
16+compiled with the core itself as the subject.
17+
18+Four of these hoons (`|=`, `|.`, `|-`, and `|*`) produce a
19+core with a single arm, named `$`. We can recompute this arm
20+with changes, useful for recursion among other things:
21+
22+> `$()` expands to `%=($)` (["cenhep"](../cen/hep)), accepting
23+> a *jogging* body containing a list of changes to the subject.
24+
25+## Stems
26+
27+<list dataPreview="true" className="runes"></list>
docs/hoon/twig/bar-core/cab-door.md → docs/hoon/rune/bar/cab.mdrenamed+7−24
@@ -1,23 +1,17 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 5
4+sort: 3
4−
5+title: |_ "barcab"
5---
6---
6
7
7−# `:door |_ "barcab"`
8+# `|_ "barcab"`
8
9
9−`{$door p/moss q/(map term foot)}`: form a door, a many-armed core
10+`[%brcb p=model q=(map term foot)]`: form a door, a many-armed core
10with a sample.
11with a sample.
11
12
12## Expands to
13## Expands to
13
14
14−```
15−:new p
16−:core
17− q
18−==
19−```
20−
21```
15```
22=| p
16=| p
23|% q
17|% q
@@ -41,25 +35,14 @@ structure becomes a door.
41Calling a door is just like calling a gate, but the caller needs
35Calling a door is just like calling a gate, but the caller needs
42to specify the arm. For instance, to call the gate `foo` as a
36to specify the arm. For instance, to call the gate `foo` as a
43door, instead of `(foo bar)` we would write `~($ foo bar)`. This
37door, instead of `(foo bar)` we would write `~($ foo bar)`. This
44−is an irregular form for `:open($ foo bar)`, `%~`, "censig".
38+is an irregular form for `%~($ foo bar)`, ["censig"](../../cen/sig).
45
39
46## Examples
40## Examples
47
41
48A trivial door:
42A trivial door:
49
43
50```
44```
51−/~zod:dojo> =mol :door a/@ud
45+/~zod:dojo> =mol |_ a=@ud
52− ++ succ +(a)
53− ++ prev (dec a)
54− --
55−/~zod:dojo> :call(succ mol 1)
56−2
57−/~zod:dojo> :call(succ mol :call(succ mol :call(prev mol 5)))
58−6
59−```
60−
61−```
62−/~zod:dojo> =mol |_ a/@ud
63 ++ succ +(a)
46 ++ succ +(a)
64 ++ prev (dec a)
47 ++ prev (dec a)
65 --
48 --
docs/hoon/twig/bar-core/cen-core.md → docs/hoon/rune/bar/cen.mdrenamed+6−18
@@ -1,12 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 1
4sort: 1
4−
5+title: |% "barcen"
5---
6---
6
7
7−# `:core |% "barcen"`
8+# `|% "barcen"`
8
9
9−Form a core `{battery payload}` with subject as the payload.
10+Form a core `[battery payload]` with subject as the payload.
10
11
11## Produces
12## Produces
12
13
@@ -19,31 +20,18 @@ Regular: *battery*.
19## Discussion
20## Discussion
20
21
21A core is like an "object" in a conventional language, but its
22A core is like an "object" in a conventional language, but its
22−attributes (*arms*) are functions on the core, not the core and
23+attributes (_arms_) are functions on the core, not the core and
23an argument. A "method" on a core is an arm producing a gate.
24an argument. A "method" on a core is an arm producing a gate.
24
25
25## Examples
26## Examples
26
27
27A trivial core:
28A trivial core:
28
29
29−```
30−~zod:dojo> =foo :pin :name(x 58)
31− :core
32− ++ n (add 42 x)
33− ++ g :gate b/@
34− (add b n)
35− --
36−~zod:dojo> n.foo
37−100
38−~zod:dojo> (g.foo 1)
39−101
40−```
41−
42```
30```
43~zod:dojo> =foo =+ x=58
31~zod:dojo> =foo =+ x=58
44 |%
32 |%
45 ++ n (add 42 x)
33 ++ n (add 42 x)
46− ++ g |= b/@
34+ ++ g |= b=@
47 (add b n)
35 (add b n)
48 --
36 --
49~zod:dojo> n.foo
37~zod:dojo> n.foo
docs/hoon/rune/bar/col.mdnew file+26
@@ -0,0 +1,26 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 8
5+title: |: "barcol"
6+---
7+
8+# `|: "barcol"`
9+
10+`[%brcl p=hoon q=hoon]`: form a gate with burnt sample.
11+
12+## Expands to
13+
14+```
15+=> ^~ p
16+ |. q
17+```
18+
19+## Discussion
20+
21+Note that `p` is a hoon, not a model; `|:` doesn't bunt your sample as
22+[`|=`](../tis) does.
23+
24+## Syntax
25+
26+Regular: *2-fixed*.
docs/hoon/rune/bar/dot.mdnew file+58
@@ -0,0 +1,58 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 4
5+title: |. "bardot"
6+---
7+
8+# `|. "bardot"`
9+
10+`[%brdt p=hoon]`: form a trap, a core with one arm `$`.
11+
12+## Expands to
13+
14+```
15+|% ++ $ p
16+--
17+```
18+
19+## Syntax
20+
21+Regular: *1-fixed*.
22+
23+## Discussion
24+
25+A trap is a deferred computation.
26+
27+## Examples
28+
29+A trivial trap:
30+
31+```
32+~zod:dojo> =foo |.(42)
33+~zod:dojo> $:foo
34+42
35+~zod:dojo> (foo)
36+42
37+```
38+
39+A more interesting trap:
40+
41+```
42+~zod:dojo> =foo =/ reps 10
43+ =/ step 0
44+ =/ outp 0
45+ |.
46+ ?: =(step reps)
47+ outp
48+ $(outp (add outp 2), step +(step))
49+~zod:dojo> (foo)
50+20
51+```
52+
53+Note that we can use `$()` to recurse back into the
54+trap, since it's a core with an `$` arm.
55+
56+> `$()` expands to `%=($)` (["centis"](../../cen/tis)),
57+> accepting a *jogging* body containing a list of changes
58+> to the subject.
docs/hoon/rune/bar/hep.mdnew file+52
@@ -0,0 +1,52 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 5
5+title: |- "barhep"
6+---
7+
8+# `|- "barhep"`
9+
10+`[%brhp p=hoon]`: form a trap and kick ("*call*") it.
11+
12+## Expands to
13+
14+```
15+=<($ |.(p))
16+```
17+
18+## Syntax
19+
20+Regular: *1-fixed*.
21+
22+## Discussion
23+
24+The `|-` ("barhep") rune can be thought of as a "recursion
25+point". Since `|-` makes a `|.` (["bardot"](../dot), a core
26+with one arm named `$`, we can recurse back into it with `$()`.
27+
28+> `$()` expands to `%=($)` (["centis"](../../cen/tis)),
29+> accepting a *jogging* body containing a list of changes to
30+> the subject.
31+
32+## Examples
33+
34+A trivial loop doesn't even recurse:
35+
36+```
37+~zod:dojo> |-(42)
38+42
39+```
40+
41+The classic loop is a decrement:
42+
43+```
44+~zod:dojo> =foo =/ a 42
45+ =/ b 0
46+ |-
47+ ?: =(a +(b))
48+ b
49+ $(b +(b))
50+~zod:dojo> foo
51+41
52+```
docs/hoon/twig/bar-core/ket-cork.md → docs/hoon/rune/bar/ket.mdrenamed+6−21
@@ -1,24 +1,17 @@
1---
1---
2−navhome: /docs
2+navhome: /docs/
3+next: true
3−sort: 7
4+sort: 6
4−
5+title: |^ "barket"
5---
6---
6
7
7−# `:cork |^ "barket"`
8+# `|^ "barket"`
8
9
9−`{$cork p/twig q/(map term foot)}`: form a core with battery and
10+`[%brkt p=hoon q=(map term foot)]`: form a core with battery and
10anonymous arm `$` and kick it.
11anonymous arm `$` and kick it.
11
12
12## Expands to
13## Expands to
13
14
14−```
15−:per :core
16− ++ $ p
17− q
18− --
19−$
20−```
21−
22```
15```
23=> |%
16=> |%
24 ++ $ p
17 ++ $ p
@@ -35,14 +28,6 @@ Regular: *1-fixed*, then *battery*.
35
28
36A trivial cork:
29A trivial cork:
37
30
38−```
39−~zod:dojo> :cork
40− (add n g)
41− ++ n 42
42− ++ g 58
43− --
44−```
45−
46```
31```
47~zod:dojo> |^
32~zod:dojo> |^
48 (add n g)
33 (add n g)
docs/hoon/rune/bar/sig.mdnew file+31
@@ -0,0 +1,31 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 10
5+title: |~ "barsig"
6+---
7+
8+# `|~ "barsig"`
9+
10+`[%brsg p=model q=hoon]`: form an iron gate.
11+
12+## Expands to
13+
14+```
15+^| |=(p q)
16+```
17+
18+## Syntax
19+
20+Regular: *2-fixed*.
21+
22+## Discussion
23+
24+See [this discussion of core variance models](../../../advanced)
25+
26+## Examples
27+
28+```
29+~zod:dojo> => ~ ^+(|~(a=@ *@) |=(a=* *@))
30+<1|usl {a/@ $~}>
31+```
docs/hoon/rune/bar/tar.mdnew file+57
@@ -0,0 +1,57 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 9
5+title: |* "bartar"
6+---
7+
8+# `|* "bartar"`
9+
10+`[%brtr p=model q=hoon]`: form a gill, a wet one-armed
11+core with sample.
12+
13+## Expands to
14+
15+```
16+=| p
17+|%
18++- $
19+ q
20+--
21+```
22+
23+## Syntax
24+
25+Regular: *2-fixed*.
26+
27+## Discussion
28+
29+In a normal (dry) gate, your argument is converted into the
30+sample type. In a generic (wet) gate or gill, your argument type
31+passes through the function, rather as if it was a macro (there
32+is still only one copy of the code, however).
33+
34+Genericity is a powerful and dangerous tool. Use gills only if
35+you think you know what you're doing.
36+
37+Just as with a [gate](../tis), we can recurse back into a gill
38+with `$()`.
39+
40+> `$()` expands to `%=($)` (["centis"](../../cen/tis)), accepting
41+> a *jogging* body containing a list of changes to the subject.
42+
43+## Examples
44+
45+Wet and dry gates in a nutshell:
46+
47+```
48+~zod:dojo> =foo |=([a=* b=*] [b a])
49+~zod:dojo> =bar |*([a=* b=*] [b a])
50+~zod:dojo> (foo %cat %dog)
51+[6.778.724 7.627.107]
52+~zod:dojo> (bar %cat %dog)
53+[%dog %cat]
54+```
55+
56+The dry gate does not preserve the type of `a` and `b`; the wet
57+gate does.
docs/hoon/rune/bar/tis.mdnew file+49
@@ -0,0 +1,49 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 2
5+title: |= "bartis"
6+---
7+
8+# `|= "bartis"`
9+
10+`[%brts p=model q=hoon]`: form a gate, a dry one-armed core with sample.
11+
12+## Expands to
13+
14+```
15+=| p
16+|% ++ $ q
17+--
18+```
19+
20+## Syntax
21+
22+Regular: *2-fixed*.
23+
24+## Discussion
25+
26+A gate is a core with one arm named `$`, so, just as with
27+[`|-` ("barhep")](../hep), we can recurse back into it with `$()`.
28+
29+> `$()` expands to `%=($)` (["centis"](../../cen/tis)), accepting
30+> a *jogging* body containing a list of changes to the subject.
31+
32+## Examples
33+
34+A trivial gate:
35+
36+```
37+~zod:dojo> =foo |=(a=@ +(a))
38+~zod:dojo> (foo 20)
39+21
40+```
41+
42+A slightly less trivial gate:
43+
44+```
45+~zod:dojo> =foo |= [a=@ b=@]
46+ (add a b)
47+~zod:dojo> (foo 20 400)
48+420
49+```
docs/hoon/twig/bar-core/wut-tray.md → docs/hoon/rune/bar/wut.mdrenamed+5−15
@@ -1,19 +1,15 @@
1---
1---
2−navhome: /docs
2+navhome: /docs/
3−sort: 9
3+sort: 11
4−
4+title: |? "barwut"
5---
5---
6
6
7−# `:tray |? "barwut"`
7+# `|? "barwut"`
8
8
9−`{$tray p/seed}`: form a lead trap.
9+`[%brwt p=hoon]`: form a lead trap.
10
10
11## Expands to
11## Expands to
12
12
13−```
14−:lead :trap p
15−```
16−
17```
13```
18^? |. p
14^? |. p
19```
15```
@@ -28,12 +24,6 @@ See this [discussion of the core variance model](../../../advanced).
28
24
29## Examples
25## Examples
30
26
31−```
32−~zod:dojo> :per ~ :like :tray(%a) :trap(%a)
33−<1?pqz $~>
34−~zod:dojo> :per ~ :like :tray(%a) :trap(%b)
35−nest-fail
36−```
37```
27```
38~zod:dojo> => ~ ^+ |?(%a) |.(%a)
28~zod:dojo> => ~ ^+ |?(%a) |.(%a)
39<1?pqz $~>
29<1?pqz $~>
docs/hoon/twig/buc-mold.md → docs/hoon/rune/buc.mdrenamed+9−8
@@ -1,10 +1,11 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 7
4+sort: 20
4−
5+title: Mold $ "buc"
5---
6---
6
7
7−# Mold, `$` ("buc")
8+# Mold `$` "buc"
8
9
9A *mold* is a `gate` (function) that helps us build simple and
10A *mold* is a `gate` (function) that helps us build simple and
10rigorous data structures. (In fact, since "mold" sounds nasty,
11rigorous data structures. (In fact, since "mold" sounds nasty,
@@ -13,7 +14,7 @@ we often call molds and mold builders "structures.")
13## Overview
14## Overview
14
15
15A correct mold is a *normalizer*: an idempotent function across
16A correct mold is a *normalizer*: an idempotent function across
16−all nouns. If the sample of a gate has span `%noun`, and its
17+all nouns. If the sample of a gate has type `%noun`, and its
17body obeys the constraint that for any x, `=((mold x) (mold (mold
18body obeys the constraint that for any x, `=((mold x) (mold (mold
18x)))`, it's a normalizer and can be used as a mold.
19x)))`, it's a normalizer and can be used as a mold.
19
20
@@ -22,12 +23,12 @@ statically, so we can't actually tell if a mold matches this
22definition perfectly. This is not actually a problem.)
23definition perfectly. This is not actually a problem.)
23
24
24Twigs in the `$` family are macros designed for making molds.
25Twigs in the `$` family are macros designed for making molds.
25−But any Hoon twig may produce a mold. (This is why `moss` is a
26+But any hoon may produce a mold. (This is why `model` is a
26−synonym for `twig`).
27+synonym for `hoon`).
27
28
28−Many macros *bunt* a mold, producing `:burn(:per(mold $))`. This
29+Many macros *bunt* a mold, producing `^~(=>(mold $))`. This
29produces a constant default value. The formal range of a mold
30produces a constant default value. The formal range of a mold
30−(the span of its bunt) is called its *icon*.
31+(the type of its bunt) is called its *icon*.
31
32
32Molds have two uses: defining simple and rigorous structures, and
33Molds have two uses: defining simple and rigorous structures, and
33validating untrusted input data. Validation, though very
34validating untrusted input data. Validation, though very
docs/hoon/rune/buc/base.mdnew file+34
@@ -0,0 +1,34 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 1
5+title: Base molds
6+---
7+
8+# Base molds
9+
10+`[%base p=$@(?(%noun %cell %bean %null) [%atom p=aura])]`: trivial molds.
11+
12+## Produces
13+
14+A mold for the base in `p`. `%noun` is any noun; `%atom` is any
15+atom; `%cell` is a cell of nouns; `%bean` is a loobean, ``?(`@f`0
16+`@f`1)``. `%null` is zero with aura `@n`.
17+
18+## Syntax
19+
20+Irregular: `*` makes `,%noun`, `^` makes `,%cell`, `?` makes
21+`,%bean`, `,~` makes `,%null`, `@aura` makes atom `aura`.
22+
23+## Examples
24+
25+```
26+~zod:dojo> (* %foo)
27+7.303.014
28+~zod:dojo> (,~ 0)
29+~
30+~zod:dojo> (^ 0)
31+^
32+~zod:dojo> (@ux [1 1])
33+0x0
34+```
docs/hoon/rune/buc/cab.mdnew file+42
@@ -0,0 +1,42 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 9
5+title: $_ "buccab"
6+---
7+
8+# `$_ "buccab"`
9+
10+`[%bccb p=hoon]`: mold which normalizes to an example.
11+
12+## Expands to
13+
14+```
15+|=(* p)
16+```
17+
18+## Syntax
19+
20+Regular: *1-fixed*.
21+
22+Irregular: `_foo` is `$_(foo)`.
23+
24+## Discussion
25+
26+`$_` ("buccab") discards the sample it's supposedly normalizing
27+and produces its *example* instead.
28+
29+## Examples
30+
31+```
32+~zod:dojo> =foo $_([%foobar %moobaz])
33+
34+~zod:dojo> (foo %foo %bar)
35+[%foobar %moobaz]
36+
37+~zod:dojo> `foo`[%foobar %moobaz]
38+[%foobar %moobaz]
39+
40+~zod:dojo $:foo
41+[%foobar %moobaz]
42+```
docs/hoon/rune/buc/cen.mdnew file+45
@@ -0,0 +1,45 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 5
5+title: $% "buccen"
6+---
7+
8+# `$% "buccen"`
9+
10+`[%bccn p=(list [[aura @] model])]`: mold which recognizes a union tagged by head atom.
11+
12+## Normalizes to
13+
14+For any item `i` in `p`, a cell whose head is the atom `q.p.i.p`,
15+and whose tail recognizes `q.i.p`.
16+
17+Void if `p` is empty.
18+
19+## Defaults to
20+
21+For the first item `i` in `p`, the cell `[q.p.i.p $:q.i.p]`.
22+Crashes if `p` is empty.
23+
24+## Syntax
25+
26+Regular form: *2-running*.
27+
28+## Discussion
29+
30+A `$%` ("buccen") is a tagged union, an extremely common data model.
31+
32+Make sure the first item in your `$%` terminates, or the default will
33+be an infinite loop!
34+
35+## Examples
36+
37+```
38+~zod:dojo> =foo $%([%foo p=@ud q=@ud] [%bar p=@ud])
39+
40+~zod:dojo> (foo [%bar 37])
41+[%bar p=37]
42+
43+~zod:dojo> $:foo
44+[%foo p=0 q=0]~
45+```
docs/hoon/twig/buc-mold/col-bank.md → docs/hoon/rune/buc/col.mdrenamed+8−19
@@ -1,12 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 2
4+sort: 3
4−
5+title: $: "buccol"
5---
6---
6
7
7−# `:bank $: "buccol"`
8+# `$: "buccol"`
8
9
9−`{$bank p/(list moss)}`: form a mold which recognizes a tuple.
10+`[%bccl p=(list model)]`: form a mold which recognizes a tuple.
10
11
11## Normalizes
12## Normalizes
12
13
@@ -25,25 +26,13 @@ Crashes if `p` is empty.
25
26
26Regular: *running*.
27Regular: *running*.
27
28
28−Irregular: `{a b c}` is `:bank(a b c)`.
29+Irregular (noun mode): `,[a b c]` is `$:(a b c)`.
30+Irregular (mold mode): `[a b c]` is `$:(a b c)`.
29
31
30## Examples
32## Examples
31
33
32```
34```
33−~zod:dojo> =foo :bank(p/@ud q/@tas)
35+~zod:dojo> =foo $:(p=@ud q=@tas)
34−
35−~zod:dojo> (foo 33 %foo)
36−[p=33 q=%foo]
37−
38−~zod:dojo> `foo`[33 %foo]
39−[p=33 q=%foo]
40−
41−~zod:dojo> $:foo
42−[p=0 q=%$]
43−```
44−
45−```
46−~zod:dojo> =foo $:(p/@ud q/@tas)
47
36
48~zod:dojo> (foo 33 %foo)
37~zod:dojo> (foo 33 %foo)
49[p=33 q=%foo]
38[p=33 q=%foo]
docs/hoon/rune/buc/hep.mdnew file+35
@@ -0,0 +1,35 @@
1+---
2+navhome: /docs/
3+sort: 10
4+title: $- "buchep"
5+---
6+
7+# `$- "buchep"`
8+
9+`[%bchp p=model q=model]`: mold which normalizes to an example gate.
10+
11+## Expands to
12+
13+```
14+$_ ^|
15+|=(p $:q)
16+```
17+
18+## Syntax
19+
20+Regular: *2-fixed*.
21+
22+## Discussion
23+
24+Since a `$-` ("buchep") is a [`$_` ("buccab")](../cab/), it is not useful for
25+normalizing, just for typechecking. In particular, the existence of `$-`s does
26+*not* let us send gates or other cores over the network!
27+
28+## Examples
29+
30+```
31+~zod:dojo> =foo $-(%foo %bar)
32+
33+~zod:dojo> ($:foo %foo)
34+%bar
35+```
docs/hoon/rune/buc/ket.mdnew file+41
@@ -0,0 +1,41 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 7
5+title: $^ "bucket"
6+---
7+
8+# `$^ "bucket"`
9+
10+`[%bckt p=model q=model]`: mold which normalizes a union tagged by head depth (cell).
11+
12+## Normalizes to
13+
14+Default, if the sample is an atom; `p`, if the head of the sample
15+is an atom; `q` otherwise.
16+
17+## Defaults to
18+
19+The default of `p`.
20+
21+## Syntax
22+
23+Regular: *2-fixed*.
24+
25+## Examples
26+
27+```
28+~zod:dojo> =a $%([%foo p=@ud q=@ud] [%bar p=@ud])
29+
30+~zod:dojo> =b $^([a a] a)
31+
32+~zod:dojo> (b [[%bar 33] [%foo 19 22]])
33+[[%bar p=33] [%foo p=19 q=22]]
34+
35+~zod:dojo> (b [%foo 19 22])
36+[%foo p=19 q=22]
37+
38+~zod:dojo> $:b
39+[%bar p=0]
40+```
41+
docs/hoon/twig/buc-mold/pat-claw.md → docs/hoon/rune/buc/pat.mdrenamed+6−17
@@ -1,12 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 5
4+sort: 6
4−
5+title: $@ "bucpat"
5---
6---
6
7
7−# `:claw $@ "bucpat"`
8+# `$@ "bucpat"`
8
9
9−`{$claw p/moss q/moss}`: mold which normalizes a union tagged by depth.
10+`[%bcpt p=model q=model]`: mold which normalizes a union tagged by head depth (atom).
10
11
11## Normalizes to
12## Normalizes to
12
13
@@ -27,21 +28,9 @@ Product: a mold which applies `p` if its sample is an atom,
27Regular form: *2-fixed*.
28Regular form: *2-fixed*.
28
29
29Example:
30Example:
30−```
31−~zod:dojo> =a :claw($foo :bank(p/$bar q/@ud))
32−
33−~zod:dojo> (a %foo)
34−%foo
35−
36−~zod:dojo> `a`[%bar 99]
37−[p=%bar q=99]
38−
39−~zod:dojo> $:a
40−[%foo p=0 q=0]
41−```
42
31
43```
32```
44−~zod:dojo> =a $@($foo $:(p/$bar q/@ud))
33+~zod:dojo> =a $@(%foo $:(p=%bar q=@ud))
45
34
46~zod:dojo> (a %foo)
35~zod:dojo> (a %foo)
47%foo
36%foo
docs/hoon/rune/buc/tis.mdnew file+41
@@ -0,0 +1,41 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 8
5+title: $= "buctis"
6+---
7+
8+# `$= "buctis"`
9+
10+`[%bcts p=@tas q=model]`: mold which wraps a face around another mold.
11+
12+## Expands to
13+
14+```
15+|= *
16+^=(p %-(q +6))
17+```
18+
19+## Syntax
20+
21+Regular: *2-fixed*.
22+
23+Irregular (mold mode): `foo=bar` is `$=(foo bar)`.
24+
25+## Discussion
26+
27+Note that the Hoon compiler is at least slightly clever about
28+compiling molds, and almost never has to actually put in a gate
29+layer (as seen in the expansion above) to apply a `$=`.
30+
31+## Examples
32+
33+```
34+~zod:dojo> =a $=(p %foo)
35+
36+~zod:dojo> (a %foo)
37+p=%foo
38+
39+~zod:dojo> (a %bar)
40+p=%foo
41+```
docs/hoon/rune/buc/wut.mdnew file+49
@@ -0,0 +1,49 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 4
5+title: $? "bucwut"
6+---
7+
8+# `$? "bucwut"`
9+
10+`[%bcwt p=(list model)]`: mold which normalizes a general union.
11+
12+## Normalizes to
13+
14+The first item in `p` which normalizes the sample to itself;
15+otherwise, default.
16+
17+Void, if `p` is empty.
18+
19+## Defaults to
20+
21+The first item in `p`.
22+
23+## Syntax
24+
25+Regular: *running*.
26+
27+Irregular: `?(%foo %bar)` is `$?(%foo %bar)`.
28+
29+## Discussion
30+
31+For a union of atoms, a `$?` ("bucwut") is fine. For more complex nouns,
32+always try to use a [`$%` ("buccen")](../cen/), [`$@` ("bucpat")](../pat/) or
33+[`$^` ("bucket")](../ket/), at least if you expect your mold to be used as a
34+normalizer.
35+
36+## Examples
37+
38+```
39+~zod:dojo> =a ?(%foo %bar %baz)
40+
41+~zod:dojo> (a %baz)
42+%baz
43+
44+~zod:dojo> (a [37 45])
45+%baz
46+
47+~zod:dojo> $:a
48+%baz
49+```
docs/hoon/rune/cen.mdnew file+16
@@ -0,0 +1,16 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 18
5+title: Call % ("cen")
6+---
7+
8+# Call `%` ("cen")
9+
10+We've already covered [`%wing`](../limb/wing) and [`%limb`](../limb/limb). These are simple
11+forms of the *invocation* family of hoons, `%`, whose general
12+form is `%=` ("centis").
13+
14+## Stems
15+
16+<list dataPreview="true" className="runes"></list>
docs/hoon/rune/cen/cab.mdnew file+39
@@ -0,0 +1,39 @@
1+---
2+navhome: /docs/
3+sort: 8
4+title: %_ "cencab"
5+---
6+
7+# `%_ "cencab"`
8+
9+`[%cncb p=wing q=(list (pair wing hoon))]`: take a wing with changes,
10+preserving type.
11+
12+## Expands to
13+
14+```
15+^+(p %=(p q))
16+```
17+
18+## Syntax
19+
20+Regular: *1-fixed*, then *jogging*.
21+
22+## Discussion
23+
24+`%_` ("cencab") is different from `%=` ("centis") because `%=`
25+can change the type of a limb with mutations.
26+
27+## Examples
28+
29+```
30+~zod:dojo> =foo [p=42 q=6]
31+~zod:dojo> foo(p %bar)
32+[p=%bar q=6]
33+~zod:dojo> foo(p [55 99])
34+[p=[55 99] q=6]
35+~zod:dojo> %_(foo p %bar)
36+[p=7.496.034 99]
37+~zod:dojo> %_(foo p [55 99])
38+! nest-fail
39+```
docs/hoon/rune/cen/dot.mdnew file+29
@@ -0,0 +1,29 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 3
5+title: %. "cendot"
6+---
7+
8+# `%. "cendot"`
9+
10+`[%cndt p=hoon q=hoon]`: call a gate (function), reversed.
11+
12+## Expands to
13+
14+```
15+%-(q p)
16+```
17+
18+## Syntax
19+
20+Regular: *2-fixed*.
21+
22+## Examples
23+
24+```
25+~zod:dojo> =add-triple |=([a=@ b=@ c=@] :(add a b c))
26+~zod:dojo> %.([1 2 3] add-triple)
27+6
28+```
29+
docs/hoon/twig/cen-call/hep-call.md → docs/hoon/rune/cen/hep.mdrenamed+10−20
@@ -1,18 +1,16 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 4
4+sort: 2
5+title: %- "cenhep"
4---
6---
5
7
6−# `:call %- "cenhep"`
8+# `%- "cenhep"`
7
9
8−`{$call p/seed q/seed}`: call a gate (function).
10+`[%cnhp p=hoon q=hoon]`: call a gate (function).
9
11
10## Expands to
12## Expands to
11
13
12−```
13−:open($ p q)
14−```
15−
16```
14```
17%~($ p q)
15%~($ p q)
18```
16```
@@ -21,13 +19,13 @@ sort: 4
21
19
22Regular: *2-fixed*.
20Regular: *2-fixed*.
23
21
24−Irregular: `(a)` is `$:a`; `(a b c d)` is `:call(a [b c d])`.
22+Irregular: `(a)` is `$:a`; `(a b c d)` is `%-(a [b c d])`.
25
23
26## Discussion
24## Discussion
27
25
28−`$call` is a function call; `p` is the function (`gate`), `q` the
26+`%-` ("cenhep") is a function call; `p` is the function ([`gate`](../../bar/tis),
29−argument. `$call` is a special case of `$open`, and a gate is a
27+`q` the argument. `%-` is a special case of [`%~` ("censig")](../sig), and a gate
30−special case of a door.
28+is a special case of a [door](../../bar/cab).
31
29
32In a gate, the modified core has only one anonymous arm; in a
30In a gate, the modified core has only one anonymous arm; in a
33door it gets a full battery. Intuitively, a gate defines one
31door it gets a full battery. Intuitively, a gate defines one
@@ -41,15 +39,7 @@ Hoon, this shared sample is likely to be pulled into a door.
41## Examples
39## Examples
42
40
43```
41```
44−~zod:dojo> =add-triple :gate({a/@ b/@ c/@} :(add a b c))
42+~zod:dojo> =add-triple |=([a=@ b=@ c=@] :(add a b c))
45−~zod:dojo> (add-triple 1 2 3)
46−6
47−~zod:dojo> :call(add-triple [1 2 3])
48−6
49−```
50−
51−```
52−~zod:dojo> =add-triple |=({a/@ b/@ c/@} :(add a b c))
53~zod:dojo> (add-triple 1 2 3)
43~zod:dojo> (add-triple 1 2 3)
546
446
55~zod:dojo> %-(add-triple [1 2 3])
45~zod:dojo> %-(add-triple [1 2 3])
docs/hoon/rune/cen/ket.mdnew file+28
@@ -0,0 +1,28 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 5
5+title: %^ "cenket"
6+---
7+
8+# `%^ "cenket"`
9+
10+`[%cnkt p=hoon q=hoon r=hoon s=hoon]`: call with triple sample.
11+
12+## Expands to
13+
14+```
15+%-(p [q r s])
16+```
17+
18+## Syntax
19+
20+Regular: *4-fixed*.
21+
22+## Examples
23+
24+```
25+~zod:dojo> =add-triple |=([a/@ b/@ c/@] :(add a b c))
26+~zod:dojo> %^(add-triple 1 2 3)
27+6
28+```
docs/hoon/rune/cen/lus.mdnew file+28
@@ -0,0 +1,28 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 4
5+title: %+ "cenlus"
6+---
7+
8+# `%+ "cenlus"`
9+
10+`[%cnls p=hoon q=hoon r=hoon]`: call with pair sample.
11+
12+## Expands to
13+
14+```
15+%-(p [q r])
16+```
17+
18+## Syntax
19+
20+Regular: *3-fixed*.
21+
22+## Examples
23+
24+```
25+~zod:dojo> =add-triple |=([a=@ b=@ c=@] :(add a b c))
26+~zod:dojo> %+(add-triple 1 [2 3])
27+6
28+```
docs/hoon/rune/cen/sig.mdnew file+42
@@ -0,0 +1,42 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 6
5+title: %~ "censig"
6+---
7+
8+# `%~ "censig"`
9+
10+`[%cnsg p=wing q=hoon r=hoon]`: call with multi-armed door.
11+
12+## Expands to
13+
14+```
15+=+ a=q
16+=<(p %=(a +6 r))
17+```
18+
19+> Note: the expansion implementation is hygienic -- it doesn't actually add the
20+> `a` face to the subject. It's shown here because `%=` ("centis") requires a `wing`.
21+
22+## Syntax
23+
24+Regular: *3-fixed*.
25+
26+Irregular: `~(a b c)` is `%~(a b c)`; `~(a b c d e)` is `%~(a b
27+[c d e])`.
28+
29+## Discussion
30+
31+`%~` ("censig") is the general case of a function call, `%-` ("cenhep"). In
32+both, we replace the sample (`+6`) of a core. In `%-` the
33+core is a gate and we pull the `$` arm. In `%~` the
34+core is a door and we can pull any of its arms.
35+
36+Most languages do not have cores, doors, or `%~`. "Just
37+learn to step outside your linear, Western way of thinking."
38+
39+## Examples
40+
41+See [`|_`](../../bar/cab).
42+
docs/hoon/twig/cen-call/tar-bake.md → docs/hoon/rune/cen/tar.mdrenamed+9−13
@@ -1,21 +1,17 @@
1---
1---
2−navhome: /docs
2+navhome: /docs/
3+next: true
3−sort: 8
4+sort: 7
5+title: %* "centar"
4---
6---
5
7
6−# `:bake %* "centar"`
8+# `%* "centar"`
7
9
8−`{$bake p/wing q/twig r/(list (pair wing seed))}`: make
10+`[%cntr p=wing q=hoon r=(list (pair wing hoon))]`: make
9−with arbitrary twig.
11+with arbitrary hoon.
10
12
11## Expands to
13## Expands to
12
14
13−```
14−:pin q
15−:make p
16−r
17−```
18−
19```
15```
20=+ q
16=+ q
21%= p
17%= p
@@ -28,8 +24,8 @@ Regular: *2-fixed*, then *jogging*.
28
24
29## Discussion
25## Discussion
30
26
31−`%*` makes a limb from a twig, with changes. It's useful when you want
27+`%*` makes a limb from a hoon, with changes. It's useful when you want
32−evaluate a twig, pull out a single limb from the result,
28+evaluate a hoon, pull out a single limb from the result,
33and then change some parts of the limb before using it.
29and then change some parts of the limb before using it.
34
30
35## Examples
31## Examples
docs/hoon/twig/cen-call/tis-make.md → docs/hoon/rune/cen/tis.mdrenamed+9−7
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 1
4sort: 1
5+title: %= "centis"
4---
6---
5
7
6−# `:make %= "centis"`
8+# `%= "centis"`
7
9
8−`{$make p/wing q/(list (pair wing seed))}`: take a wing with changes.
10+`[%cnts p=wing q=(list (pair wing hoon))]`: take a wing with changes.
9
11
10## Produces
12## Produces
11
13
@@ -19,21 +21,21 @@ containing that arm. We compute the arm on the modified core.
19
21
20Regular: *1-fixed*, then *jogging*.
22Regular: *1-fixed*, then *jogging*.
21
23
22−Irregular: `foo(x 1, y 2, z 3)` is `:make(foo x 1, y 2, z 3)`.
24+Irregular: `foo(x 1, y 2, z 3)` is `%=(foo x 1, y 2, z 3)`.
23
25
24## Discussion
26## Discussion
25
27
26−Note that `p` is a wing, not a twig. Knowing that a function
28+Note that `p` is a wing, not a hoon. Knowing that a function
27call `(foo bar)` involves making `foo`, replacing its sample
29call `(foo bar)` involves making `foo`, replacing its sample
28at slot `+6` with `bar`, and taking the `$` limb, you might think
30at slot `+6` with `bar`, and taking the `$` limb, you might think
29−`(foo bar)` would mean `:make(foo +6 bar)`.
31+`(foo bar)` would mean `%=(foo +6 bar)`.
30
32
31−But it's actually `:pin(foo :per(:make(+2 +6 bar) $))`. Even if `foo` is
33+But it's actually `=+(foo =>(%=(+2 +6 bar) $))`. Even if `foo` is
32a wing, we would just be mutating `+6` within the core that defines the
34a wing, we would just be mutating `+6` within the core that defines the
33`foo` arm. Instead we want to modify the *product* of `foo` -- the gate
35`foo` arm. Instead we want to modify the *product* of `foo` -- the gate
34-- so we have to pin it into the subject.
36-- so we have to pin it into the subject.
35
37
36−Here's that again using runes:
38+Here's that again in tall form:
37```
39```
38=+ foo
40=+ foo
39=> %= +2
41=> %= +2
docs/hoon/rune/col.mdnew file+16
@@ -0,0 +1,16 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 17
5+title: Cell : ("col")
6+---
7+
8+# Cell `:` ("col")
9+
10+The `:` ("col") hoons, `:-` and friends, are simple and regular.
11+All `:` hoons expand to `:-` ("colhep"), which makes a pair
12+(just like the Lisp [`cons`](https://en.wikipedia.org/wiki/Cons) operator).
13+
14+## Stems
15+
16+<list dataPreview="true" className="runes"></list>
docs/hoon/rune/col/cab.mdnew file+27
@@ -0,0 +1,27 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 2
5+title: :_ "colcab"
6+---
7+
8+# `:_ "colcab"`
9+
10+`[%clcb p=hoon q=hoon]`; construct a cell, inverted.
11+
12+### Expands to
13+
14+```
15+:-(q p)
16+```
17+
18+### Syntax
19+
20+Regular: *2-fixed*.
21+
22+### Examples
23+
24+```
25+~zod:dojo> :_(1 2)
26+[2 1]
27+```
docs/hoon/rune/col/hep.mdnew file+51
@@ -0,0 +1,51 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 1
5+title: :- "colhep"
6+---
7+
8+# `:- "colhep"`
9+
10+`[%clhp p=hoon q=hoon]`: construct a cell (2-tuple).
11+
12+## Produces
13+
14+The cell of `p` and `q`.
15+
16+## Syntax
17+
18+Regular: *2-fixed*.
19+
20+Irregular: `[a b]` is `:-(a b)`.
21+
22+Irregular: `[a b c]` is `[a [b c]]`.
23+
24+Irregular: `a^b^c` is `[a b c]`.
25+
26+Irregular: `a/b` is `[%a b]`.
27+
28+Irregular: `` `a `` is `[~ a]`.
29+
30+Irregular: `~[a b]` is `[a b ~]`.
31+
32+Irregular: `[a b c]~` is `[[a b c] ~]`.
33+
34+## Discussion
35+
36+Hoon hoons actually use the same "autocons" pattern as Nock
37+formulas. If you're assembling hoons (which usually only the
38+compiler does), `[a b]` is the same as `[%clhp a b]`.
39+
40+## Examples
41+
42+```
43+~zod:dojo> :-(1 2)
44+[1 2]
45+~zod:dojo> 1^2
46+[1 2]
47+~zod:dojo> 1/2
48+[%1 2]
49+~zod:dojo> `1
50+[~ 1]
51+```
docs/hoon/rune/col/ket.mdnew file+32
@@ -0,0 +1,32 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 4
5+title: :^ "colket"
6+---
7+
8+# `:^ "colket"`
9+
10+`[%clkt p=hoon q=hoon r=hoon s=hoon]`: construct a quadruple (4-tuple).
11+
12+## Expands to
13+
14+```
15+:-(p :-(q :-(r s)))
16+```
17+
18+## Syntax
19+
20+Regular: *4-fixed*.
21+
22+## Examples
23+
24+```
25+/~zod:dojo> :^(1 2 3 4)
26+[1 2 3 4]
27+/~zod:dojo> :^ 5
28+ 6
29+ 7
30+ 8
31+[5 6 7 8]
32+```
docs/hoon/rune/col/lus.mdnew file+31
@@ -0,0 +1,31 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 3
5+title: :+ "collus"
6+---
7+
8+# `:+ "collus"`
9+
10+`[%clls p=hoon q=hoon r=hoon]`: construct a triple (3-tuple).
11+
12+## Expands to:
13+
14+```
15+:-(p :-(q r))
16+```
17+
18+## Syntax
19+
20+Regular: *3-fixed*.
21+
22+## Examples
23+
24+```
25+/~zod:dojo> :+ 1
26+ 2
27+ 3
28+[1 2 3]
29+/~zod:dojo> :+(%a ~ 'b')
30+[%a ~ 'b']
31+```
docs/hoon/rune/col/sig.mdnew file+47
@@ -0,0 +1,47 @@
1+---
2+navhome: /docs/
3+sort: 6
4+title: :~ "colsig"
5+---
6+
7+# `:~ "colsig"`
8+
9+`[%clsg p=(list hoon)]`: construct a null-terminated list.
10+
11+## Expands to
12+
13+*Pseudocode*: `a`, `b`, `c`, ... as elements of `p`:
14+
15+```
16+:-(a :-(b :-(c :-(... :-(z ~)))))
17+```
18+
19+### Compiler macro
20+
21+```
22+|-
23+?~ p
24+ ~
25+:- i.p
26+$(p t.p)
27+```
28+
29+## Syntax
30+
31+Regular: *running*.
32+
33+## Examples
34+
35+```
36+~zod:dojo> :~(5 3 4 2 1)
37+[5 3 4 2 1 ~]
38+~zod:dojo> ~[5 3 4 2 1]
39+[5 3 4 2 1 ~]
40+~zod:dojo> :~ 5
41+ 3
42+ 4
43+ 2
44+ 1
45+ ==
46+[5 3 4 2 1 ~]
47+```
docs/hoon/rune/col/tar.mdnew file+54
@@ -0,0 +1,54 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 5
5+title: :* "coltar"
6+---
7+
8+# `:* "coltar"`
9+
10+`[%cltr p=(list hoon)]`: construct an n-tuple.
11+
12+## Expands to
13+
14+*Pseudocode*: `a`, `b`, `c`, ... as elements of `p`:
15+
16+```
17+:-(a :-(b :-(c :-(... z)))))
18+```
19+
20+### Compiler macro
21+
22+```
23+|-
24+?~ p
25+ !!
26+?~ t.p
27+ i.p
28+:- i.p
29+$(p t.p)
30+```
31+
32+## Syntax
33+
34+Regular: *running*.
35+
36+## Examples
37+
38+```
39+/~zod:dojo> :*(5 3 4 1 4 9 0 ~ 'a')
40+[5 3 4 1 4 9 0 ~ 'a']
41+/~zod:dojo> [5 3 4 1 4 9 0 ~ 'a']
42+[5 3 4 1 4 9 0 ~ 'a']
43+/~zod:dojo> :* 5
44+ 3
45+ 4
46+ 1
47+ 4
48+ 9
49+ 0
50+ ~
51+ 'a'
52+ ==
53+[5 3 4 1 4 9 0 ~ 'a']
54+```
docs/hoon/twig/dot-nock.md → docs/hoon/rune/dot.mdrenamed+4−3
@@ -1,10 +1,11 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 10
4+sort: 11
4−
5+title: Nock . ("dot")
5---
6---
6
7
7−# Nock, `.` (dot)
8+# Nock `.` ("dot")
8
9
9Anything Nock can do, Hoon can do also.
10Anything Nock can do, Hoon can do also.
10
11
docs/hoon/twig/dot-nock/ket-wish.md → docs/hoon/rune/dot/ket.mdrenamed+4−3
@@ -1,11 +1,12 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3sort: 5
3sort: 5
4+title: .^ "dotket"
4---
5---
5
6
6−# `:wish .^ "dotket"`
7+# `.^ "dotket"`
7
8
8−`{$wish p/moss q/seed}`: load from the Arvo namespace with Nock `11`.
9+`[%dtkt p=model q=value]`: load from the Arvo namespace with Nock `11`.
9
10
10## Produces
11## Produces
11
12
@@ -17,5 +18,5 @@ Nock has no `11` instruction, of course. But the virtual Nock
17used to run userspace code does. Nock `11` loads from a
18used to run userspace code does. Nock `11` loads from a
18typed immutable namespace defined by its virtual context.
19typed immutable namespace defined by its virtual context.
19
20
20−We don't remold dynamically nouns in a `:wish`, but we do check
21+We don't remold dynamically nouns in a `.^`, but we do check
21that the type of the value nests in `p`.
22that the type of the value nests in `p`.
docs/hoon/twig/dot-nock/lus-bump.md → docs/hoon/rune/dot/lus.mdrenamed+5−3
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 3
4sort: 3
5+title: .+ "dotlus"
4---
6---
5
7
6−# `:bump .+ "dotlus"`
8+# `.+ "dotlus"`
7
9
8−`{$bump p/atom}`: increment an atom with Nock `4`.
10+`[%dtls p=atom]`: increment an atom with Nock `4`.
9
11
10## Produces
12## Produces
11
13
@@ -21,7 +23,7 @@ Irregular: `+(6)` is `.+(6)`.
21## Examples
23## Examples
22
24
23```
25```
24−~zod:dojo> :bump(6)
26+~zod:dojo> .+(6)
257
277
26~zod:dojo> +(6)
28~zod:dojo> +(6)
277
297
docs/hoon/twig/dot-nock/tar-nock.md → docs/hoon/rune/dot/tar.mdrenamed+6−19
@@ -1,15 +1,17 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 1
4sort: 1
5+title: .* "dottar"
4---
6---
5
7
6−# `:nock .* "dottar"`
8+# `.* "dottar"`
7
9
8−`{$nock p/seed q/seed}`: evaluate with Nock `2`.
10+`[%dttr p=hoon q=hoon]`: evaluate with Nock `2`.
9
11
10## Produces
12## Produces
11
13
12−Nock of formula `q` and subject `p`, with span `%noun`.
14+Nock of formula `q` and subject `p`, with type `%noun`.
13
15
14## Syntax
16## Syntax
15
17
@@ -17,27 +19,12 @@ Regular: *2-fixed*.
17
19
18## Discussion
20## Discussion
19
21
20−Note that `:nock` can be used to bypass the type system,
22+Note that `.*` ("dottar") can be used to bypass the type system,
21though its product contains no type information. It's
23though its product contains no type information. It's
22perfectly practical to use Hoon as a typeless language.
24perfectly practical to use Hoon as a typeless language.
23
25
24## Examples
26## Examples
25
27
26−```
27−~zod:dojo> :nock([20 30] [0 2])
28−20
29−~zod:dojo> :nock(33 [4 0 1])
30−34
31−~zod:dojo> :nock(|.(50) [9 2 0 1])
32−50
33−~zod:dojo> :nock(12 [7 [`1 [4 `1]] [`2 `3 `2]])
34−[12 13 12]
35−~zod:dojo> :nock(~ [5 1^4 [4 1^3]])
36−0
37−~zod:dojo> :nock(~ [5 1^5 [4 1^3]])
38−1
39−```
40−
41```
28```
42~zod:dojo> .*([20 30] [0 2])
29~zod:dojo> .*([20 30] [0 2])
4320
3020
docs/hoon/twig/dot-nock/tis-same.md → docs/hoon/rune/dot/tis.mdrenamed+8−8
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 4
4sort: 4
5+title: .= "dottis"
4---
6---
5
7
6−# `:same .= "dottis"`
8+# `.= "dottis"`
7
9
8−`{$same p/seed q/seed}`: test for equality with Nock `5`.
10+`[%dtts p=hoon q=hoon]`: test for equality with Nock `5`.
9
11
10## Produces
12## Produces
11
13
@@ -19,7 +21,7 @@ Irregular: `=(a b)` is `.=(a b)`.
19
21
20## Discussion
22## Discussion
21
23
22−Like Nock equality, `:same` tests if two nouns are the same,
24+Like Nock equality, `.=` ("dottis") tests if two nouns are the same,
23ignoring invisible pointer structure. Because in a conventional
25ignoring invisible pointer structure. Because in a conventional
24noun implementation each noun has a lazy short hash, comparisons
26noun implementation each noun has a lazy short hash, comparisons
25are fast unless the hash needs to be computed, or we are comparing
27are fast unless the hash needs to be computed, or we are comparing
@@ -29,14 +31,12 @@ is a common cause of performance bugs.)
29## Examples
31## Examples
30
32
31```
33```
32−~zod:dojo> :same(0 0)
34+~zod:dojo> .=(0 0)
33%.y
35%.y
34−~zod:dojo> :same(1 2)
35−%.n
36−```
37−```
38~zod:dojo> =(0 0)
36~zod:dojo> =(0 0)
39%.y
37%.y
38+~zod:dojo> .=(1 2)
39+%.n
40~zod:dojo> =(1 2)
40~zod:dojo> =(1 2)
41%.n
41%.n
42```
42```
docs/hoon/rune/dot/wut.mdnew file+27
@@ -0,0 +1,27 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 2
5+title: .? "dotwut"
6+---
7+
8+# `.? "dotwut"`
9+
10+`[%dtwt p=hoon]`: test for cell or atom with Nock `3`.
11+
12+## Produces
13+
14+`&`, `%.y`, `0` if `p` is a cell; otherwise `|`, `%.n`, `1`.
15+
16+## Syntax
17+
18+Regular: *1-fixed*.
19+
20+## Examples
21+
22+```
23+~zod:dojo> .?(42)
24+%.n
25+~zod:dojo> .?([42 43])
26+%.y
27+```
docs/hoon/rune/ket.mdnew file+19
@@ -0,0 +1,19 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 19
5+title: Cast ^ ("ket")
6+---
7+
8+# Cast `^` ("ket")
9+
10+[`^-` ("kethep")](./hep/), [`^+` ("ketlus")](./lus/), and
11+[`^=` ("kettis")](./tis/) let us adjust types without violating type
12+constraints.
13+
14+The `nest` algorithm which tests subtyping is conservative;
15+it never allows invalid nests, it sometimes rejects valid nests.
16+
17+## Twigs
18+
19+<list dataPreview="true" className="runes"></list>
docs/hoon/twig/ket-cast/bar-iron.md → docs/hoon/rune/ket/bar.mdrenamed+6−11
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 5
4sort: 5
5+title: ^| "ketbar"
4---
6---
5
7
6−# `:iron ^| "ketbar"`
8+# `^| "ketbar"`
7
9
8−`{$iron p/seed}`: convert a gold core to an iron core (contravariant).
10+`[%ktbr p=hoon]`: convert a gold core to an iron core (contravariant).
9
11
10## Produces
12## Produces
11
13
@@ -19,8 +21,8 @@ Regular: *1-fixed*.
19
21
20An iron core is an opaque function (gate or door).
22An iron core is an opaque function (gate or door).
21
23
22−Theorem: if span `x` nests within span `a`, and span `y` nests
24+Theorem: if type `x` nests within type `a`, and type `y` nests
23−within span `b`, a core accepting `b` and producing `x` nests
25+within type `b`, a core accepting `b` and producing `x` nests
24within a iron core accepting `y` and producing `a`.
26within a iron core accepting `y` and producing `a`.
25
27
26Informally, a function fits an interface if the function has a
28Informally, a function fits an interface if the function has a
@@ -31,13 +33,6 @@ interface.
31
33
32The prettyprinter shows the core metal (`.` gold, `|` iron):
34The prettyprinter shows the core metal (`.` gold, `|` iron):
33
35
34−```
35−~zod:dojo> :gate(@ 1)
36−<1.gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
37−~zod:dojo> :iron(:gate(@ 1))
38−<1|gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
39−```
40−
41```
36```
42~zod:dojo> |=(@ 1)
37~zod:dojo> |=(@ 1)
43<1.gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
38<1.gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
docs/hoon/twig/ket-cast/hep-cast.md → docs/hoon/rune/ket/hep.mdrenamed+8−24
@@ -1,18 +1,16 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 2
4+sort: 1
5+title: ^- "kethep"
4---
6---
5
7
6−# `:cast ^- "kethep"`
8+# `^- "kethep"`
7
9
8−`{$cast p/moss q/seed}`: typecast by mold.
10+`[%kthp p=model q=value]`: typecast by mold.
9
11
10## Expands to
12## Expands to
11
13
12−```
13−:like(:bunt(p) q)
14−```
15−
16```
14```
17^+(*p q)
15^+(*p q)
18```
16```
@@ -21,11 +19,11 @@ sort: 2
21
19
22Regular: *2-fixed*.
20Regular: *2-fixed*.
23
21
24−Irregular: `` `foo`bar`` is `:cast(foo bar)`.
22+Irregular: `` `foo`bar`` is `^-(foo bar)`.
25
23
26## Discussion
24## Discussion
27
25
28−It's a good practice to put a `:cast` at the top of every arm
26+It's a good practice to put a `^-` ("kethep") at the top of every arm
29(including gates, loops, etc). This cast is strictly necessary
27(including gates, loops, etc). This cast is strictly necessary
30only in the presence of head recursion (otherwise you'll get a
28only in the presence of head recursion (otherwise you'll get a
31`rest-loop` error, or if you really screw up spectacularly an
29`rest-loop` error, or if you really screw up spectacularly an
@@ -33,20 +31,6 @@ infinite loop in the compiler).
33
31
34## Examples
32## Examples
35
33
36−```
37−~zod:dojo> (add 90 7)
38−97
39−~zod:dojo> `@t`(add 90 7)
40−'a'
41−~zod:dojo> :cast(@t (add 90 7))
42−'a'
43−/~zod:dojo> =foo :gate a/@tas
44− :cast (unit @ta)
45− `a
46−/~zod:dojo> (foo 97)
47−[~ ~.a]
48−```
49−
50```
34```
51~zod:dojo> (add 90 7)
35~zod:dojo> (add 90 7)
5297
3697
@@ -54,7 +38,7 @@ infinite loop in the compiler).
54'a'
38'a'
55~zod:dojo> ^-(@t (add 90 7))
39~zod:dojo> ^-(@t (add 90 7))
56'a'
40'a'
57−/~zod:dojo> =foo |= a/@tas
41+/~zod:dojo> =foo |= a=@tas
58 ^- (unit @ta)
42 ^- (unit @ta)
59 `a
43 `a
60/~zod:dojo> (foo 97)
44/~zod:dojo> (foo 97)
docs/hoon/rune/ket/lus.mdnew file+26
@@ -0,0 +1,26 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 2
5+title: ^+ "ketlus"
6+---
7+
8+# `^+ "ketlus"`
9+
10+`[%ktls p=value q=value]`: typecast by example (hoon).
11+
12+## Produces
13+
14+The value of `q` with the type of `p`, if the type of `q` nests
15+within the type of `p`. Otherwise, `nest-fail`.
16+
17+## Syntax
18+
19+Regular: *2-fixed*.
20+
21+## Examples
22+
23+```
24+~zod:dojo> ^+('text' %a)
25+'a'
26+```
docs/hoon/twig/ket-cast/sig-burn.md → docs/hoon/rune/ket/sig.mdrenamed+5−9
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 6
4+sort: 4
5+title: ^~ "ketsig"
4---
6---
5
7
6−# `:burn ^~ "ketsig"`
8+# `^~ "ketsig"`
7
9
8−`{$burn p/seed}`: fold constant at compile time.
10+`[%ktsg p=hoon]`: fold constant at compile time.
9
11
10## Produces
12## Produces
11
13
@@ -24,9 +26,3 @@ Regular: *1-fixed*.
24[%1 p=42]
26[%1 p=42]
25```
27```
26
28
27−```
28−~zod:dojo> (make ':loop(42)')
29−[%8 p=[%1 p=[1 42]] q=[%9 p=2 q=[%0 p=1]]]
30−~zod:dojo> (make ':burn(:loop(42))')
31−[%1 p=42]
32−```
docs/hoon/twig/ket-cast/tis-name.md → docs/hoon/rune/ket/tis.mdrenamed+9−6
@@ -1,23 +1,26 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 3
4sort: 3
5+title: ^= "kettis"
4---
6---
5
7
6−# `:name ^= "kettis"`
7
8
9+# `^= "kettis"`
10+
8−`{$name p/toga q/seed}`: name a value.
11+`[%ktts p=toga q=value]`: name a value.
9
12
10## Produces
13## Produces
11
14
12−If `p` is a term, the product `q` with span `[%face p q]`. `p`
15+If `p` is a term, the product `q` with type `[%face p q]`. `p`
13−may also be a tuple of terms, or a term-toga pair; the span of
16+may also be a tuple of terms, or a term-toga pair; the type of
14`q` must divide evenly into cells to match it.
17`q` must divide evenly into cells to match it.
15
18
16## Syntax
19## Syntax
17
20
18Regular: *2-fixed*.
21Regular: *2-fixed*.
19
22
20−Irregular: `foo=bar` is `:name(foo bar)`.
23+Irregular: `foo=bar` is `^=(foo bar)`.
21
24
22## Examples
25## Examples
23
26
@@ -27,7 +30,7 @@ a=1
27~zod:dojo> ^= a
30~zod:dojo> ^= a
28 1
31 1
29a=1
32a=1
30−~zod:dojo> :name(a 1)
33+~zod:dojo> ^=(a 1)
31a=1
34a=1
32~zod:dojo> [b c d]=[1 2 3 4]
35~zod:dojo> [b c d]=[1 2 3 4]
33[b=1 c=2 d=[3 4]]
36[b=1 c=2 d=[3 4]]
docs/hoon/twig/ket-cast/wut-lead.md → docs/hoon/rune/ket/wut.mdrenamed+5−11
@@ -1,11 +1,12 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3−sort: 4
3+sort: 6
4+title: ^? "ketwut"
4---
5---
5
6
6−# `:lead ^? "ketwut"`
7+# `^? "ketwut"`
7
8
8−`{$lead p/seed}`: convert any core to a lead core (bivariant).
9+`[%ktwt p=hoon]`: convert any core to a lead core (bivariant).
9
10
10## Produces
11## Produces
11
12
@@ -20,7 +21,7 @@ Regular: *1-fixed*.
20A lead core is an opaque generator; the payload can't be read or
21A lead core is an opaque generator; the payload can't be read or
21written.
22written.
22
23
23−Theorem: if span `x` nests within span `a`, a lead core producing
24+Theorem: if type `x` nests within type `a`, a lead core producing
24`x` nests within a lead core producing `a`.
25`x` nests within a lead core producing `a`.
25
26
26Informally, a more specific generator can be used as a less
27Informally, a more specific generator can be used as a less
@@ -30,13 +31,6 @@ specific generator.
30
31
31The prettyprinter shows the core metal (`.` gold, `?` lead):
32The prettyprinter shows the core metal (`.` gold, `?` lead):
32
33
33−```
34−~zod:dojo> :gate(@ 1)
35−<1.gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
36−~zod:dojo> :lead(:gate(@ 1))
37−<1?gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
38−```
39−
40```
34```
41~zod:dojo> |=(@ 1)
35~zod:dojo> |=(@ 1)
42<1.gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
36<1.gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
docs/hoon/twig/sem-make.md → docs/hoon/rune/sem.mdrenamed+3−3
@@ -1,10 +1,10 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3−sort: 11
3+sort: 21
4−
4+title: Make ; ("sem")
5---
5---
6
6
7−# Make, `;` ("sem")
7+# Make `;` ("sem")
8
8
9Miscellaneous useful macros.
9Miscellaneous useful macros.
10
10
docs/hoon/twig/sem-make/col-wad.md → docs/hoon/rune/sem/col.mdrenamed+13−19
@@ -1,31 +1,32 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 3
4+sort: 1
5+title: ;: "semcol"
4---
6---
5
7
6−# `:wad ;: "semcol"`
8+# `;: "semcol"`
7
9
8−`{$wad p/seed q/(list seed)}`: call a binary function as an n-ary function.
10+`[%smcl p=hoon q=(list hoon)]`: call a binary function as an n-ary function.
9
11
10## Expands to
12## Expands to
11
13
12−*Pseudocode*, `a`, `b`, `c`, ... as elements of `q`
14+*Pseudocode*: `a`, `b`, `c`, ... as elements of `q`:
15+
16+Regular form:
13
17
14```
18```
15−:call(p a :call(p b :call(p c ...)))
19+%-(p a %-(p b %-(p c ...)))
16```
20```
17
21
18−### Compiler macro
22+Irregular form:
19
23
20```
24```
21−:loop
25+(p a (p b (p c ...)))
22−:ifno q !!
23−:ifno t.q !!
24−:ifno t.t.q
25− :call(p i.q i.t.q)
26−:call(p i.q :moar(q t.q))
27```
26```
28
27
28+### Compiler macro
29+
29```
30```
30|-
31|-
31?~ q !!
32?~ q !!
@@ -43,13 +44,6 @@ Irregular: `:(add a b c)` is `;:(add a b c)`.
43
44
44## Examples
45## Examples
45
46
46−```
47−~zod:dojo> (add 3 (add 4 5))
48−12
49−~zod:dojo> :wad(add 3 4 5)
50−12
51−```
52−
53```
47```
54~zod:dojo> (add 3 (add 4 5))
48~zod:dojo> (add 3 (add 4 5))
5512
4912
docs/hoon/twig/sem-make/fas-nub.md → docs/hoon/rune/sem/fas.mdrenamed+3−6
@@ -1,18 +1,15 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3sort: 4
3sort: 4
4+title: ;/ "semfas"
4---
5---
5
6
6−# `:nub ;/ "semfas"`
7+# `;/ "semfas"`
7
8
8−`{$nub p/seed}`: tape as XML element.
9+`[%smfs p=hoon]`: tape as XML element.
9
10
10## Expands to
11## Expands to
11
12
12−```
13−:conl(%$ :conl(%$ p))
14−```
15−
16```
13```
17~[%$ ~[%$ 'p']]
14~[%$ ~[%$ 'p']]
18```
15```
docs/hoon/twig/sem-make/sem-fry.md → docs/hoon/rune/sem/sem.mdrenamed+5−25
@@ -1,20 +1,16 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 1
4+sort: 3
5+title: ;; "semsem"
4---
6---
5
7
6−# `:fry ;; "semsem"`
8+# `;; "semsem"`
7
9
8−`{$fry p/moss q/seed}`: normalize with a mold, asserting fixpoint.
10+`[%smsm p=model q=value]`: normalize with a mold, asserting fixpoint.
9
11
10## Expands to
12## Expands to
11
13
12−```
13−:pin :name(a (p q))
14−:sure =(`*`a `*`q)
15−a
16−```
17−
18```
14```
19=+ a=(p q)
15=+ a=(p q)
20?> =(`*`a `*`q)
16?> =(`*`a `*`q)
@@ -32,12 +28,6 @@ Regular: *2-fixed*.
32
28
33Fails because of auras:
29Fails because of auras:
34
30
35−```
36−~zod:dojo> :cast(tape ~[97 98 99])
37−! nest-fail
38−! exit
39−```
40−
41```
31```
42~zod:dojo> ^-(tape ~[97 98 99])
32~zod:dojo> ^-(tape ~[97 98 99])
43! nest-fail
33! nest-fail
@@ -46,11 +36,6 @@ Fails because of auras:
46
36
47Succeeds because molds don't care about auras:
37Succeeds because molds don't care about auras:
48
38
49−```
50−~zod:dojo> :fry(tape ~[97 98 99])
51−"abc"
52−```
53−
54```
39```
55~zod:dojo> ;;(tape ~[97 98 99])
40~zod:dojo> ;;(tape ~[97 98 99])
56"abc"
41"abc"
@@ -65,11 +50,6 @@ Succeeds because the mold normalizes:
65
50
66Fails because not a fixpoint:
51Fails because not a fixpoint:
67
52
68−```
69−~zod:dojo> :fry(tape [50 51 52])
70−! exit
71−```
72−
73```
53```
74~zod:dojo> ;;(tape [50 51 52])
54~zod:dojo> ;;(tape [50 51 52])
75! exit
55! exit
docs/hoon/twig/sem-make/sig-dip.md → docs/hoon/rune/sem/sig.mdrenamed+16−14
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 2
4sort: 2
5+title: ;~ "semsig"
4---
6---
5
7
6−# `:dip ;~ "semsig"`
8+# `;~ "semsig"`
7
9
8−`{$dip p/seed q/(list seed)}`: glue a pipeline together with a
10+`[%smsg p=hoon q=(list hoon)]`: glue a pipeline together with a
9product-sample adapter.
11product-sample adapter.
10
12
11## Produces
13## Produces
@@ -22,14 +24,14 @@ transforms a `q` product and a `q` gate into a `q` sample.
22`;~(a b c)` expands to
24`;~(a b c)` expands to
23
25
24```
26```
25−|= arg/*
27+|= arg=*
26(a (b arg) c(+6 arg))
28(a (b arg) c(+6 arg))
27```
29```
28
30
29`;~(a b c d)` expands to
31`;~(a b c d)` expands to
30
32
31```
33```
32−|= arg/*
34+|= arg=*
33%+ a (b arg)
35%+ a (b arg)
34=+ arg=arg
36=+ arg=arg
35|. (a (c arg) d(+6 arg))
37|. (a (c arg) d(+6 arg))
@@ -49,12 +51,12 @@ transforms a `q` product and a `q` gate into a `q` sample.
49
51
50## Discussion
52## Discussion
51
53
52−Apparently `:dip` is a "Kleisli arrow." Whatevs. It's also
54+Apparently `;~` ("semsig") is a "Kleisli arrow." Whatevs. It's also
53a close cousin of the infamous "monad." Don't let that bother
55a close cousin of the infamous "monad." Don't let that bother
54you either. Hoon doesn't know anything about category theory,
56you either. Hoon doesn't know anything about category theory,
55so you don't need to either.
57so you don't need to either.
56
58
57−`:dip` is often used in parsers, but is not only for parsers.
59+`;~` is often used in parsers, but is not only for parsers.
58
60
59This can be thought of as user-defined function composition; instead of simply
61This can be thought of as user-defined function composition; instead of simply
60nesting the gates in `q`, each is passed individually to `p` with the product
62nesting the gates in `q`, each is passed individually to `p` with the product
@@ -71,7 +73,7 @@ A simple "parser." `trip` converts a `cord` (atomic string) to
71a `tape` (linked string).
73a `tape` (linked string).
72
74
73```
75```
74−~zod:dojo> =cmp |=({a/tape b/$-(char tape)} `tape`?~(a ~ (weld (b i.a) t.a)))
76+~zod:dojo> =cmp |=([a=tape b=$-(char tape)] `tape`?~(a ~ (weld (b i.a) t.a)))
75~zod:dojo> ;~(cmp trip)
77~zod:dojo> ;~(cmp trip)
76<1.zje {a/@ <409.yxa 110.lxv 1.ztu $151>}>
78<1.zje {a/@ <409.yxa 110.lxv 1.ztu $151>}>
77~zod:dojo> (;~(cmp trip) 'a')
79~zod:dojo> (;~(cmp trip) 'a')
@@ -81,23 +83,23 @@ a `tape` (linked string).
81With just one gate in the pipeline `q`, the glue `p` is unused:
83With just one gate in the pipeline `q`, the glue `p` is unused:
82
84
83```
85```
84−~zod:dojo> (;~(cmp trip |=(a/@ ~[a a])) 'a')
86+~zod:dojo> (;~(cmp trip |=(a=@ ~[a a])) 'a')
85"aa"
87"aa"
86−~zod:dojo> (;~(cmp trip |=(a/@ ~[a a])) '')
88+~zod:dojo> (;~(cmp trip |=(a=@ ~[a a])) '')
87""
89""
88```
90```
89
91
90But for multiple gates, we need it to connect the pipeline:
92But for multiple gates, we need it to connect the pipeline:
91
93
92```
94```
93−~zod:dojo> (;~(cmp trip ;~(cmp |=(a/@ ~[a a]) |=(a/@ <(dec a)>))) 'b')
95+~zod:dojo> (;~(cmp trip ;~(cmp |=(a=@ ~[a a]) |=(a=@ <(dec a)>))) 'b')
94"97b"
96"97b"
95−~zod:dojo> (;~(cmp trip |=(a/@ ~[a a]) |=(a/@ <(dec a)>)) 'b')
97+~zod:dojo> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'b')
96"97b"
98"97b"
97−~zod:dojo> (;~(cmp trip |=(a/@ ~[a a]) |=(a/@ <(dec a)>)) '')
99+~zod:dojo> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) '')
98""
100""
99−~zod:dojo> (;~(cmp trip |=(a/@ ~[a a]) |=(a/@ <(dec a)>)) 'a')
101+~zod:dojo> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'a')
100"96a"
102"96a"
101−~zod:dojo> (;~(cmp trip |=(a/@ ~[a a]) |=(a/@ <(dec a)>)) 'acd')
103+~zod:dojo> (;~(cmp trip |=(a=@ ~[a a]) |=(a=@ <(dec a)>)) 'acd')
102"96acd"
104"96acd"
103```
105```
docs/hoon/twig/sig-hint.md → docs/hoon/rune/sig.mdrenamed+4−3
@@ -1,10 +1,11 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 12
4+sort: 16
4−
5+title: Hint ~ ("sig")
5---
6---
6
7
7−# Hints, `~` ("sig")
8+# Hint `~` ("sig")
8
9
9Twigs that use Nock `10` to pass non-semantic info to the
10Twigs that use Nock `10` to pass non-semantic info to the
10interpreter.
11interpreter.
docs/hoon/twig/sig-hint/bar-show.md → docs/hoon/rune/sig/bar.mdrenamed+8−7
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 2
4+sort: 4
5+title: ~| "sigbar"
4---
6---
5
7
6−# `:show ~| "sigbar"`
8+# `~| "sigbar"`
7
9
8−`{$show p/seed q/seed}`: tracing printf.
10+`[%sgbr p=hoon q=hoon]`: tracing printf.
9
11
10## Expands to
12## Expands to
11
13
@@ -22,13 +24,12 @@ Regular: *2-fixed*.
22## Examples
24## Examples
23
25
24```
26```
25−~zod:dojo> :show('sample error message' !!)
27+~zod:dojo> ~|('sample error message' !!)
26'sample error message'
28'sample error message'
27ford: build failed
29ford: build failed
28−```
29
30
30−```
31−~zod:dojo> ~|('sample error message' !!)
31+~zod:dojo> ~| 'sample error message'
32+ !!
32'sample error message'
33'sample error message'
33ford: build failed
34ford: build failed
34```
35```
docs/hoon/twig/sig-hint/buc-poll.md → docs/hoon/rune/sig/buc.mdrenamed+5−8
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 12
4+sort: 8
5+title: ~$ "sigbuc"
4---
6---
5
7
6−# `:poll ~$ "sigbuc"`
8+# `~$ "sigbuc"`
7
9
8−`{$poll p/term q/seed}`: profiling hit counter.
10+`[%sgbc p=term q=hoon]`: profiling hit counter.
9
11
10## Expands to
12## Expands to
11
13
@@ -21,11 +23,6 @@ Regular: *2-fixed*.
21
23
22## Examples
24## Examples
23
25
24−```
25−~zod:dojo> :poll(%foo 3)
26−3
27−```
28−
29```
26```
30~zod:dojo> ~$(%foo 3)
27~zod:dojo> ~$(%foo 3)
313
283
docs/hoon/twig/sig-hint/cab-lurk.md → docs/hoon/rune/sig/cab.mdrenamed+8−7
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 3
4+sort: 5
5+title: ~_ "sigcab"
4---
6---
5
7
6−# `:lurk ~_ "sigcab"`
8+# `~_ "sigcab"`
7
9
8−`{$lurk p/seed q/seed}`: user-formatted tracing printf.
10+`[%sgcb p=hoon q=hoon]`: user-formatted tracing printf.
9
11
10## Expands to
12## Expands to
11
13
@@ -22,13 +24,12 @@ Shows `p` in stacktrace if `q` crashes.
22## Examples
24## Examples
23
25
24```
26```
25−~zod:dojo> :lurk([%leaf "sample error message"] !!)
27+~zod:dojo> ~_([%leaf "sample error message"] !!)
26"sample error message"
28"sample error message"
27ford: build failed
29ford: build failed
28−```
29
30
30−```
31−~zod:dojo> ~_([%leaf "sample error message"] !!)
31+~zod:dojo> ~_ [%leaf "sample error message"]
32+ !!
32"sample error message"
33"sample error message"
33ford: build failed
34ford: build failed
34```
35```
docs/hoon/twig/sig-hint/cen-fast.md → docs/hoon/rune/sig/cen.mdrenamed+8−6
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 10
4sort: 10
5+title: ~% "sigcen"
4---
6---
5
7
6−# `:fast ~% "sigcen"`
8+# `~% "sigcen"`
7
9
8−`{$fast p/term q/wing r/(list {term seed}) s/seed}`: jet registration.
10+`[%sgcn p=term q=wing r=(list [term hoon]) s=hoon]`: jet registration.
9
11
10## Expands to
12## Expands to
11
13
@@ -23,7 +25,7 @@ between opening and closing `==`.
23
25
24## Discussion
26## Discussion
25
27
26−`:fast` is for registering cores. A registered core declares its
28+`~%` ("sigcen" is for registering cores. A registered core declares its
27formal identity to the interpreter, which may or may not be able
29formal identity to the interpreter, which may or may not be able
28to recognize and/or accelerate it.
30to recognize and/or accelerate it.
29
31
@@ -48,7 +50,7 @@ general-purpose hotspot optimizer or "JIT"; or (c) merely a
48hotspot declaration for profiling.
50hotspot declaration for profiling.
49
51
50As always with hints, the programmer has no idea which of (a),
52As always with hints, the programmer has no idea which of (a),
51−(b), and (c) will be applied. She should use `:fast`
53+(b), and (c) will be applied. She should use `~%`
52indiscriminately on all hotspots, bottlenecks, etc, real or
54indiscriminately on all hotspots, bottlenecks, etc, real or
53suspected.
55suspected.
54
56
@@ -80,12 +82,12 @@ Here's the AES
80 |%
82 |%
81 ++ en :: ECB enc
83 ++ en :: ECB enc
82 ~/ %en
84 ~/ %en
83− |= {a/@I b/@H} ^- @uxH
85+ |= [a=@I b=@H] ^- @uxH
84 =+ ahem
86 =+ ahem
85 (be & (ex a) b)
87 (be & (ex a) b)
86 ++ de :: ECB dec
88 ++ de :: ECB dec
87 ~/ %de
89 ~/ %de
88− |= {a/@I b/@H} ^- @uxH
90+ |= [a=@I b=@H] ^- @uxH
89 =+ ahem
91 =+ ahem
90 (be | (ix (ex a)) b)
92 (be | (ix (ex a)) b)
91 --
93 --
docs/hoon/twig/sig-hint/fas-funk.md → docs/hoon/rune/sig/fas.mdrenamed+6−8
@@ -1,19 +1,17 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 11
4+sort: 9
5+title: ~/ "sigfas"
4---
6---
5
7
6−# `:funk ~/ "sigfas"`
8+# `~/ "sigfas"`
7
9
8−`{$funk p/term q/seed}`: jet registration for gate with
10+`[%sgfs p=term q=hoon]`: jet registration for gate with
9registered context.
11registered context.
10
12
11## Expands to
13## Expands to
12
14
13−```
14−:fast(p +7 ~ q)
15−```
16−
17```
15```
18~%(p +7 ~ q)
16~%(p +7 ~ q)
19```
17```
@@ -28,7 +26,7 @@ From the kernel:
28```
26```
29++ add
27++ add
30 ~/ %add
28 ~/ %add
31− |= {a/@ b/@}
29+ |= [a=@ b=@]
32 ^- @
30 ^- @
33 ?: =(0 a) b
31 ?: =(0 a) b
34 $(a (dec a), b +(b))
32 $(a (dec a), b +(b))
docs/hoon/rune/sig/gal.mdnew file+34
@@ -0,0 +1,34 @@
1+---
2+navhome: /docs/
3+sort: 12
4+title: ~< "siggal"
5+---
6+
7+# `~< "siggal"`
8+
9+`[%sggl p=$@(term [p=term q=hoon]) q=hoon]`: raw hint, applied to
10+product.
11+
12+## Expands to
13+
14+`q`.
15+
16+## Syntax
17+
18+Regular: *2-fixed*. For the dynamic form, write `%term.hoon`.
19+
20+## Discussion
21+
22+`~<` ("siggal") is only used for jet hints ([`~/` ("sigfas")](../fas/)
23+and [`~%` ("sigcen")](../cen/)) at the moment; we are not telling the
24+interpreter something about the computation we're about to perform, but
25+rather about its product.
26+
27+## Examples
28+
29+```
30+~zod:dojo> (make '~<(%a 42)')
31+[%7 p=[%1 p=42] q=[%10 p=97 q=[%0 p=1]]]
32+~zod:dojo> (make '~<(%a.+(.) 42)')
33+[%7 p=[%1 p=42] q=[%10 p=[p=97 q=[%4 p=[%0 p=1]]] q=[%0 p=1]]]
34+```
docs/hoon/twig/sig-hint/gar-hint.md → docs/hoon/rune/sig/gar.mdrenamed+7−16
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 5
4+sort: 11
5+title: ~> "siggar"
4---
6---
5
7
6−# `:hint ~> "siggar"`
8+# `~> "siggar"`
7
9
8−`{$hint p/$@(term {p/term q/seed}) q/seed}`: raw hint, applied
10+`[%sggr p=$@(term [p=term q=hoon]) q=hoon]`: raw hint, applied
9to computation.
11to computation.
10
12
11## Expands to
13## Expands to
@@ -14,7 +16,7 @@ to computation.
14
16
15## Syntax
17## Syntax
16
18
17−Regular: *2-fixed*. For the dynamic form, write `%term.twig`.
19+Regular: *2-fixed*. For the dynamic form, write `%term.hoon`.
18
20
19## Discussion
21## Discussion
20
22
@@ -23,11 +25,6 @@ Hints are all conventions at the interpreter level.
23
25
24## Examples
26## Examples
25
27
26−```
27−~zod:dojo> :hint(%a 42)
28−42
29−```
30−
31```
28```
32~zod:dojo> ~>(%a 42)
29~zod:dojo> ~>(%a 42)
3342
3042
@@ -35,16 +32,10 @@ Hints are all conventions at the interpreter level.
35
32
36Running the compiler:
33Running the compiler:
37
34
38−```
39−~zod:dojo> (make ':hint(%a 42)')
40−[%10 p=97 q=[%1 p=42]]
41−~zod:dojo> (make ':hint(%a.+(2) 42)')
42−[%10 p=[p=97 q=[%4 p=[%1 p=2]]] q=[%1 p=42]]
43−```
44−
45```
35```
46~zod:dojo> (make '~>(%a 42)')
36~zod:dojo> (make '~>(%a 42)')
47[%10 p=97 q=[%1 p=42]]
37[%10 p=97 q=[%1 p=42]]
38+
48~zod:dojo> (make '~>(%a.+(2) 42)')
39~zod:dojo> (make '~>(%a.+(2) 42)')
49[%10 p=[p=97 q=[%4 p=[%1 p=2]]] q=[%1 p=42]]
40[%10 p=[p=97 q=[%4 p=[%1 p=2]]] q=[%1 p=42]]
50```
41```
docs/hoon/twig/sig-hint/lus-memo.md → docs/hoon/rune/sig/lus.mdrenamed+8−6
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 7
4+sort: 6
5+title: ~+ "siglus"
4---
6---
5
7
6−# `:memo ~+ "siglus"`
8+# `~+ "siglus"`
7
9
8−`{$memo p/seed}`: cache a computation.
10+`[%sgls p=hoon]`: cache a computation.
9
11
10## Expands to
12## Expands to
11
13
@@ -25,20 +27,20 @@ Regular: *1-fixed*.
25This may pause for a second:
27This may pause for a second:
26
28
27```
29```
28−~zod:dojo> %.(25 |=(a/@ ?:((lth a 2) 1 (add $(a (sub a 2)) $(a (dec a))))))
30+~zod:dojo> %.(25 |=(a=@ ?:((lth a 2) 1 (add $(a (sub a 2)) $(a (dec a))))))
29121.393
31121.393
30```
32```
31
33
32This may make you want to press `ctrl-c`:
34This may make you want to press `ctrl-c`:
33
35
34```
36```
35−~zod:dojo> %.(30 |=(a/@ ?:((lth a 2) 1 (add $(a (sub a 2)) $(a (dec a))))))
37+~zod:dojo> %.(30 |=(a=@ ?:((lth a 2) 1 (add $(a (sub a 2)) $(a (dec a))))))
361.346.269
381.346.269
37```
39```
38
40
39This should work fine:
41This should work fine:
40
42
41```
43```
42−~zod:dojo> %.(100 |=(a/@ ~+(?:((lth a 2) 1 (add $(a (sub a 2)) $(a (dec a)))))))
44+~zod:dojo> %.(100 |=(a=@ ~+(?:((lth a 2) 1 (add $(a (sub a 2)) $(a (dec a)))))))
43573.147.844.013.817.084.101
45573.147.844.013.817.084.101
44```
46```
docs/hoon/twig/sig-hint/pam-dump.md → docs/hoon/rune/sig/pam.mdrenamed+7−6
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 1
4sort: 1
5+title: ~& "sigpam"
4---
6---
5
7
6−# `:dump ~& "sigpam"`
8+# `~& "sigpam"`
7
9
8−`{$dump p/seed q/seed}`: debugging printf.
10+`[%sgpm p=hoon q=hoon]`: debugging printf.
9
11
10## Expands to
12## Expands to
11
13
@@ -22,13 +24,12 @@ Regular: *2-fixed*.
22## Examples
24## Examples
23
25
24```
26```
25−~zod:dojo> :dump('halp' ~)
27+~zod:dojo> ~&('halp' ~)
26'halp'
28'halp'
27~
29~
28−```
29
30
30−```
31−~zod:dojo> ~&('halp' ~)
31+~zod:dojo> ~& 'halp'
32+ ~
32'halp'
33'halp'
33~
34~
34```
35```
docs/hoon/twig/sig-hint/tis-ddup.md → docs/hoon/rune/sig/tis.mdrenamed+8−6
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 8
4+sort: 7
5+title: ~= "sigtis"
4---
6---
5
7
6−# `:ddup ~= "sigtis"`
8+# `~= "sigtis"`
7
9
8−`{$ddup p/seed q/seed}`: detect duplicate.
10+`[%sgts p=hoon q=hoon]`: detect duplicate.
9
11
10## Expands to
12## Expands to
11
13
@@ -18,7 +20,7 @@ If `p` equals `q`, produce `p` instead of `q`.
18## Discussion
20## Discussion
19
21
20Duplicates are especially bad news in Hoon, because comparing them
22Duplicates are especially bad news in Hoon, because comparing them
21−takes O(n) time. Use `~=` to kill them as they breed.
23+takes O(n) time. Use `~=` ("sigtis") to kill them as they breed.
22
24
23## Examples
25## Examples
24
26
@@ -26,8 +28,8 @@ This code traverses a tree and replaces all instances of `42` with
26`420`:
28`420`:
27
29
28```
30```
29−~zod:dojo> =foo |= a/(tree)
31+~zod:dojo> =foo |= a=(tree)
30− ?~(a ~ ~=(a [?:(=(n.a 42) 420 n.a) $(a l.a) $(a r.a)]))
32+ ?~(a ~ ~=(a [?:(=(n.a 42) 420 n.a) $(a l.a) $(a r.a)]))
31~zod:dojo> (foo 42 ~ ~)
33~zod:dojo> (foo 42 ~ ~)
32[420 ~ ~]
34[420 ~ ~]
33```
35```
docs/hoon/twig/sig-hint/wut-warn.md → docs/hoon/rune/sig/wut.mdrenamed+15−9
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 4
4+sort: 2
5+title: ~? "sigwut"
4---
6---
5
7
6−# `:warn ~? "sigwut"`
8+# `~? "sigwut"`
7
9
8−`{$warn p/seed q/seed r/seed}`: conditional debug printf.
10+`[%sgwt p=hoon q=hoon r=hoon]`: conditional debug printf.
9
11
10## Expands to
12## Expands to
11
13
@@ -22,17 +24,21 @@ Regular: *4-fixed*.
22## Examples
24## Examples
23
25
24```
26```
25−~zod:dojo> :warn((gth 1 2) 'oops' ~)
27+~zod:dojo> ~?((gth 1 2) 'oops' ~)
26~
28~
29+
27−~zod:dojo> :warn((gth 1 0) 'oops' ~)
30+~zod:dojo> ~?((gth 1 0) 'oops' ~)
28'oops'
31'oops'
29~
32~
30−```
31
33
32−```
33−~zod:dojo> ~?((gth 1 2) 'oops' ~)
34+~zod:dojo> ~? (gth 1 2)
35+ 'oops'
36+ ~
34~
37~
38+
35−~zod:dojo> ~?((gth 1 0) 'oops' ~)
39+~zod:dojo> ~? (gth 1 0)
40+ 'oops'
41+ ~
36'oops'
42'oops'
37~
43~
38```
44```
docs/hoon/rune/sig/zap.mdnew file+38
@@ -0,0 +1,38 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 3
5+title: ~! "sigzap"
6+---
7+
8+# `~! "sigzap"`
9+
10+`[%sgzp p=hoon q=hoon]`: print type on compilation fail.
11+
12+## Expands to
13+
14+`q`.
15+
16+## Convention
17+
18+If compilation of `q` fails, prints the type of `p` in the trace.
19+
20+## Syntax
21+
22+Regular: *2-fixed*.
23+
24+## Examples
25+
26+```
27+~zod:dojo> a
28+! -find.a
29+
30+~zod:dojo> ~!('foo' a)
31+! @t
32+! find.a
33+
34+~zod:dojo> ~! 'foo'
35+ a
36+! @t
37+! find.a
38+```
docs/hoon/rune/tis.mdnew file+35
@@ -0,0 +1,35 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 13
5+title: Flow = ("tis")
6+---
7+
8+# Flow `=` ("tis")
9+
10+Flow hoons change the subject. (Or more precisely, a flow hoon
11+compiles at least one of its subhoons with a different subject.)
12+All non-flow hoons (except cores) pass the subject down unchanged.
13+
14+## Overview
15+
16+The simplest way to change the subject is to compose two hoons,
17+`p` and `q`. Let `x` be `(mint subject p)`, with product type
18+`p.x` and nock formula `q.x`. Let `y` be `(mint p.x q)`. Then
19+their composition is `[p.y [7 q.x q.y]]`.
20+
21+This composition is the `=>` ("tisgar") rune. A close relative is
22+`=+` ("tislus"), which is `=>` over `[p .]`. The new subject is a
23+cell of `p` and the old subject. `=+` is the simplest Hoon equivalent of
24+"declaring a variable" (introducing new data into the subject).
25+
26+Another way to change the subject is to mutate it. With the
27+`=.` ("tisdot") rune, given a wing that resolves to a leg, we can write
28+instead of reading, *installing* a new value at that leg. Of
29+course, we are creating a copy, not modifying the original.
30+
31+There are many flow stems, all small variations on these three.
32+
33+## Twigs
34+
35+<list dataPreview="true" className="runes"></list>
docs/hoon/rune/tis/bar.mdnew file+36
@@ -0,0 +1,36 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 8
5+title: =| "tisbar"
6+---
7+
8+# `=| "tisbar"`
9+
10+`[%tsbr p=model q=value]`: combine a defaulted mold with the subject.
11+
12+## Expands to
13+
14+```
15+=+(*p q)
16+```
17+
18+## Syntax
19+
20+Regular: *2-fixed*.
21+
22+## Discussion
23+
24+`=|` "declares a variable" which is "uninitialized," presumably
25+because you'll set it in a loop or similar.
26+
27+## Examples
28+
29+```
30+~zod:dojo> =foo |= a=@
31+ =| b=@
32+ =- :(add a b c)
33+ c=2
34+~zod:dojo> (foo 5)
35+7
36+```
docs/hoon/rune/tis/col.mdnew file+31
@@ -0,0 +1,31 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 11
5+title: =: "tiscol"
6+---
7+
8+# `=: "tiscol"`
9+
10+`[%tscl p=(list (pair wing hoon)) q=hoon]`: change multiple legs in the subject.
11+
12+## Expands to
13+
14+```
15+=>(%_(. p) q)
16+```
17+
18+## Syntax
19+
20+Regular: *jogging*, then *1-fixed*.
21+
22+## Examples
23+
24+```
25+~zod:dojo> =+ a=[b=1 c=2]
26+ =: c.a 4
27+ b.a 3
28+ ==
29+ a
30+[b=3 c=4]
31+```
docs/hoon/twig/tis-flow/dot-set.md → docs/hoon/rune/tis/dot.mdrenamed+7−18
@@ -1,18 +1,16 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 8
4+sort: 10
5+title: =. "tisdot"
4---
6---
5
7
6−# `:set =. "tisdot"`
8+# `=. "tisdot"`
7
9
8−`{$set p/wing q/seed r/seed}`: change one leg in the subject.
10+`[%tsdt p=wing q=hoon r=hoon]`: change one leg in the subject.
9
11
10## Expands to
12## Expands to
11
13
12−```
13−:per(:keep(. p q) r)
14−```
15−
16```
14```
17=>(%_(. p q) r)
15=>(%_(. p q) r)
18```
16```
@@ -25,25 +23,16 @@ Regular: *3-fixed*.
25
23
26As usual, we are not actually mutating the subject, just creating
24As usual, we are not actually mutating the subject, just creating
27a new subject with a changed value. Note that the mutation uses
25a new subject with a changed value. Note that the mutation uses
28−`:keep` (`%_`), so the type doesn't change.
26+[`%_` ("cencab")](../../cen/cab/), so the type doesn't change.
29
27
30## Examples
28## Examples
31
29
32−```
33−~zod:dojo> :pin a=[b=1 c=2]
34− :set b.a 3
35− a
36−[b=3 c=2]
37−~zod:dojo> :pin a=[b=1 c=2]
38− :set(b.a 3 a)
39−[b=3 c=2]
40−```
41−
42```
30```
43~zod:dojo> =+ a=[b=1 c=2]
31~zod:dojo> =+ a=[b=1 c=2]
44 =. b.a 3
32 =. b.a 3
45 a
33 a
46[b=3 c=2]
34[b=3 c=2]
35+
47~zod:dojo> =+ a=[b=1 c=2]
36~zod:dojo> =+ a=[b=1 c=2]
48 =.(b.a 3 a)
37 =.(b.a 3 a)
49[b=3 c=2]
38[b=3 c=2]
docs/hoon/twig/tis-flow/fas-var.md → docs/hoon/rune/tis/fas.mdrenamed+7−30
@@ -1,45 +1,31 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 6
4sort: 6
5+title: =/ "tisfas"
4---
6---
5
7
6−# `:var =/ "tisfas"`
8+# `=/ "tisfas"`
7
9
8−`{$var p/taco q/seed r/seed}`: combine a named and/or typed
10+`[%tsfs p=taco q=hoon r=hoon]`: combine a named and/or typed
9noun with the subject.
11noun with the subject.
10
12
11## Expands to
13## Expands to
12
14
13*if `p` is a symbol*:
15*if `p` is a symbol*:
14
16
15−```
16−:pin(:name(p q) r)
17−```
18−
19```
17```
20=+(^=(p q) r)
18=+(^=(p q) r)
21```
19```
22
20
23*if `p` is a symbol with a mold*:
21*if `p` is a symbol with a mold*:
24
22
25−```
26−:pin(:cast(p q) r)
27−```
28−
29```
23```
30=+(^-(p q) r)
24=+(^-(p q) r)
31```
25```
32
26
33### Compiler macro
27### Compiler macro
34
28
35−```
36−:ifat p
37− :pin :name(p q)
38− r
39−:pin :cast(:coat(p.p q.p) q)
40−r
41−```
42−
43```
29```
44?@ p
30?@ p
45 =+ p=q
31 =+ p=q
@@ -55,24 +41,15 @@ Regular: *3-fixed*.
55## Discussion
41## Discussion
56
42
57`p` can be either a symbol or a symbol/mold. If it's just a symbol,
43`p` can be either a symbol or a symbol/mold. If it's just a symbol,
58−`:var` "declares a type-inferred variable." If it has a mold, `:var`
44+`=/` ("tisfas") "declares a type-inferred variable." If it has a mold, `=/`
59"declares a type-checked variable."
45"declares a type-checked variable."
60
46
61## Examples
47## Examples
62
48
63```
49```
64−~zod:dojo> =foo :gate a/@
50+~zod:dojo> =foo |= a=@
65− :var b 1
66− :var c/@ 2
67− :(add a b c)
68−~zod:dojo> (foo 5)
69−8
70−```
71−
72−```
73−~zod:dojo> =foo |= a/@
74 =/ b 1
51 =/ b 1
75− =/ c/@ 2
52+ =/ c=@ 2
76 :(add a b c)
53 :(add a b c)
77~zod:dojo> (foo 5)
54~zod:dojo> (foo 5)
788
558
docs/hoon/rune/tis/gal.mdnew file+39
@@ -0,0 +1,39 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 2
5+title: =< "tisgal"
6+---
7+
8+# `=< "tisgal"`
9+
10+`[%tsgl p=hoon q=hoon]`: compose two hoons, inverted.
11+
12+## Expands to
13+
14+```
15+=>(q p)
16+```
17+
18+## Syntax
19+
20+Regular: *2-fixed*.
21+
22+Irregular: `foo:bar` is `=<(foo bar)`.
23+
24+## Examples
25+
26+```
27+~zod:dojo> =<(b [a=1 b=2 c=3])
28+2
29+
30+~zod:dojo> =< b
31+ [a=1 b=2 c=3]
32+2
33+
34+~zod:dojo> b:[a=1 b=2 c=3]
35+2
36+
37+~zod:dojo> [. .]:(add 2 4)
38+[6 6]
39+```
docs/hoon/twig/tis-flow/gar-per.md → docs/hoon/rune/tis/gar.mdrenamed+4−9
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 1
4sort: 1
5+title: => "tisgar"
4---
6---
5
7
6−# `:per => "tisgar"`
8+# `=> "tisgar"`
7
9
8−`{$per p/seed q/seed}`: compose two twigs.
10+`[%tsgr p=hoon q=hoon]`: compose two hoons.
9
11
10## Produces
12## Produces
11
13
@@ -17,13 +19,6 @@ Regular: *2-fixed*.
17
19
18## Examples
20## Examples
19
21
20−```
21−~zod:dojo> :per([a=1 b=2 c=3] b)
22−2
23−~zod:dojo> :per((add 2 4) [. .])
24−[6 6]
25−```
26−
27```
22```
28~zod:dojo> =>([a=1 b=2 c=3] b)
23~zod:dojo> =>([a=1 b=2 c=3] b)
292
242
docs/hoon/rune/tis/hep.mdnew file+36
@@ -0,0 +1,36 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 5
5+title: =- "tishep"
6+---
7+
8+# `=- "tishep"`
9+
10+`[%tshp p=hoon q=hoon]`: combine a new noun with the subject, inverted.
11+
12+## Expands to
13+
14+```
15+=>([q .] p)
16+```
17+
18+## Syntax
19+
20+Regular: *2-fixed*.
21+
22+## Discussion
23+
24+`=-` looks better than `=+` when the hoon you're pinning
25+is much smaller than the hoon that uses it.
26+
27+## Examples
28+
29+```
30+~zod:dojo> =foo |= a=@
31+ =+ b=1
32+ =- (add a b c)
33+ c=2
34+~zod:dojo> (foo 5)
35+8
36+```
docs/hoon/twig/tis-flow/ket-sip.md → docs/hoon/rune/tis/ket.mdrenamed+6−17
@@ -1,19 +1,16 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3−sort: 10
3+sort: 12
4+title: =^ "tisket"
4---
5---
5
6
6−# `:sip =^ "tisket"`
7+# `=^ "tisket"`
7
8
8−`{$sip p/taco q/wing r/seed s/seed}`: pin the head of a pair; change
9+`[%tskt p=taco q=wing r=hoon s=hoon]`: pin the head of a pair; change
9a leg with the tail.
10a leg with the tail.
10
11
11## Expands to
12## Expands to
12
13
13−```
14−:var(p -.r :set(q +.r s))
15−```
16−
17```
14```
18=/(p -.r =.(q +.r s))
15=/(p -.r =.(q +.r s))
19```
16```
@@ -24,7 +21,7 @@ Regular: *4-fixed*.
24
21
25## Discussion
22## Discussion
26
23
27−We use `:sip` when we have a state machine with a function that
24+We use `=^` ("tisket" when we have a state machine with a function that
28produces a cell, whose head is a result and whose tail is a new
25produces a cell, whose head is a result and whose tail is a new
29state. We want to use the head as a new variable, and stuff the
26state. We want to use the head as a new variable, and stuff the
30tail back into wherever we stored the old state.
27tail back into wherever we stored the old state.
@@ -35,15 +32,7 @@ This may also remind you of Haskell's State monad.
35
32
36The `og` core is a stateful pseudo-random number generator.
33The `og` core is a stateful pseudo-random number generator.
37We have to change the core state every time we generate a
34We have to change the core state every time we generate a
38−random number, so we need to `:sip`:
35+random number, so we use `=^`:
39−
40−```
41−~zod:dojo> :pin rng=~(. og 420)
42− :sip r1 rng (rads:rng 100)
43− :sip r2 rng (rads:rng 100)
44− [r1 r2]
45−[99 46]
46−```
47
36
48```
37```
49~zod:dojo> =+ rng=~(. og 420)
38~zod:dojo> =+ rng=~(. og 420)
docs/hoon/rune/tis/lus.mdnew file+35
@@ -0,0 +1,35 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 4
5+title: =+ "tislus"
6+---
7+
8+# `=+ "tislus"`
9+
10+`[%tsls p=hoon q=hoon]`: combine a new noun with the subject.
11+
12+## Expands to
13+
14+```
15+=>([p .] q)
16+```
17+
18+## Syntax
19+
20+Regular: *2-fixed*.
21+
22+## Discussion
23+
24+`=+` ("tislus") is the simplest way of "declaring a variable."
25+
26+## Examples
27+
28+```
29+~zod:dojo> =foo |= a=@
30+ =+ b=1
31+ =+ c=2
32+ :(add a b c)
33+~zod:dojo> (foo 5)
34+8
35+```
docs/hoon/rune/tis/sem.mdnew file+32
@@ -0,0 +1,32 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 7
5+title: =; "tissem"
6+---
7+
8+# `=; "tissem"`
9+
10+`[%tssm p=taco q=hoon r=hoon]`: combine a named and/or typed noun with the
11+subject, inverted.
12+
13+## Expands to
14+
15+```
16+=/(p r q)
17+```
18+
19+## Syntax
20+
21+Regular: *3-fixed*.
22+
23+## Examples
24+
25+```
26+~zod:dojo> =foo |= a=@
27+ =/ b 1
28+ =; c=@ :(add a b c)
29+ 2
30+~zod:dojo> (foo 5)
31+8
32+```
docs/hoon/rune/tis/sig.mdnew file+36
@@ -0,0 +1,36 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 3
5+title: =~ "tissig"
6+---
7+
8+# `=~ "tissig"`
9+
10+`[%tssg p=(list hoon)]`: compose many hoons.
11+
12+## Produces
13+
14+The product of the chain composition.
15+
16+## Syntax
17+
18+Regular: *running*.
19+
20+## Examples
21+
22+```
23+~zod:dojo> =foo =| n=@
24+ =< =~ increment
25+ increment
26+ increment
27+ n
28+ ==
29+ |%
30+ ++ increment
31+ |-
32+ ..increment(n +(n))
33+ --
34+~zod:dojo> foo
35+3
36+```
docs/hoon/twig/tis-flow/tar-aka.md → docs/hoon/rune/tis/tar.mdrenamed+7−18
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 11
4+sort: 9
5+title: =* "tistar"
4---
6---
5
7
6−# `:aka =* "tistar"`
8+# `=* "tistar"`
7
9
8−`{$aka p/term q/seed r/seed}`: define an alias.
10+`[%tstr p=term q=hoon r=hoon]`: define an alias.
9
11
10## Produces
12## Produces
11
13
@@ -18,31 +20,18 @@ Regular: *3-fixed*.
18## Discussion
20## Discussion
19
21
20The difference between aliasing and pinning is that the subject
22The difference between aliasing and pinning is that the subject
21−noun stays the same; the alias is just recorded in its span.
23+noun stays the same; the alias is just recorded in its type.
22`q` is calculated every time you use the `p` alias, of course.
24`q` is calculated every time you use the `p` alias, of course.
23
25
24## Examples
26## Examples
25
27
26−```
27−~zod:dojo>
28− :pin a=1
29− :aka b a
30− [a b]
31−[1 1]
32−~zod:dojo>
33− :pin a=1
34− :aka b a
35− :set a 2
36− [a b]
37−[2 2]
38−```
39−
40```
28```
41~zod:dojo>
29~zod:dojo>
42 =+ a=1
30 =+ a=1
43 =* b a
31 =* b a
44 [a b]
32 [a b]
45[1 1]
33[1 1]
34+
46~zod:dojo>
35~zod:dojo>
47 =+ a=1
36 =+ a=1
48 =* b a
37 =* b a
docs/hoon/rune/wut.mdnew file+35
@@ -0,0 +1,35 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 14
5+title: Test ? ("wut")
6+---
7+
8+# Test `?` ("wut")
9+
10+Hoon has the usual branches and logical tests. For pattern
11+matching, it also has a [`?=` ("wuttis")](./tis/) rune that tests whether a value
12+matches the icon of a mold. And it has branch inference,
13+learning from `?=` tests in the condition of [`?:` ("wutcol")](./col/) hoons.
14+
15+## Overview
16+
17+All `?` runes expand to `?:` and/or `?=`.
18+
19+If the condition of an `?:` is a `?=`, *and* the `?=` is
20+testing a leg of the subject, the compiler specializes the subject
21+type for the branches of the `?:`. Branch inference also works
22+for expressions which expand to `?:`.
23+
24+The test does not have to be a single `?=`; the compiler can
25+analyze arbitrary boolean logic ([`?&` ("wutpam")](./pam/),
26+[`?|` ("wutbar")](./bar/), [`?!` ("wutzap")](./zap/)) with full
27+short-circuiting. Equality tests ([`.=` ("dottis")](../dot/tis/)) are *not*
28+analyzed.
29+
30+If the compiler detects that the branch is degenerate (only one
31+side is taken), it fails with an error.
32+
33+## Twigs
34+
35+<list dataPreview="true" className="runes"></list>
docs/hoon/rune/wut/bar.mdnew file+45
@@ -0,0 +1,45 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 6
5+title: ?| "wutbar"
6+---
7+
8+# `?| "wutbar"`
9+
10+`[%wtbr p=(list hoon)]`: logical or.
11+
12+## Expands to
13+
14+*Pseudocode*: `a`, `b`, `c`, ... as elements of `p`:
15+
16+```
17+?:(a & ?:(b & ?:(c & ?:(... ?:(z & |)))))
18+```
19+
20+### Compiler macro
21+
22+```
23+|-
24+?~ p
25+ |
26+?: i.p
27+ &
28+$(p t.p)
29+```
30+
31+## Syntax
32+
33+Regular: *running*.
34+
35+Irregular: `|(foo bar baz)` is `?|(foo bar baz)`.
36+
37+## Examples
38+
39+```
40+~zod:dojo> |(=(6 42) =(42 42))
41+%.y
42+
43+~zod:dojo> |(=(6 42) =(42 43))
44+%.n
45+```
docs/hoon/twig/wut-test/col-if.md → docs/hoon/rune/wut/col.mdrenamed+23−12
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 1
4sort: 1
5+title: ?: "wutcol"
4---
6---
5
7
6−# `:if ?: "wutcol"`
8+# `?: "wutcol"`
7
9
8−`{$if p/seed q/seed r/seed}`: branch on a boolean test.
10+`[%wtcl p=hoon q=hoon r=hoon]`: branch on a boolean test.
9
11
10## Produces
12## Produces
11
13
@@ -14,13 +16,14 @@ If `p` is not a boolean, compiler yells at you.
14
16
15The subjects of `q` and `r` are constrained to match any
17The subjects of `q` and `r` are constrained to match any
16pattern-matching algebra in `p`. The analysis, which is
18pattern-matching algebra in `p`. The analysis, which is
17−conservative, understands any combination of `:fits`
19+conservative, understands any combination of [`?=` ("wuttis")](../tis/),
18−(`?=`), `:and` (`?&`), `:or` (`?|`), and `:not` (`?!`),
20+[`?&` ("wutpam")](../pam/), [`?|` ("wutbar")](../bar/), and
19−and reduces the subject appropriately when compiling.
21+[`?!` ("wutzap")](../zap/), and reduces the subject appropriately when
22+compiling.
20
23
21If test analysis reveals that either branch is not taken,
24If test analysis reveals that either branch is not taken,
22or if `p` is not a boolean, compilation fails. However,
25or if `p` is not a boolean, compilation fails. However,
23−an untaken branch can be indicated with the `:lost` twig.
26+an untaken branch can be indicated with the `%lost` hoon.
24
27
25## Syntax
28## Syntax
26
29
@@ -30,19 +33,27 @@ Regular: *3-fixed*.
30
33
31Short-circuiting in boolean tests works as you'd expect
34Short-circuiting in boolean tests works as you'd expect
32and includes the expected inference. For instance,
35and includes the expected inference. For instance,
33−if you write `:and(a b)`, `b` is only executed if `a` is
36+if you write `?&(a b)`, `b` is only executed if `a` is
34positive, and compiled with that assumption.
37positive, and compiled with that assumption.
35
38
36−Note also that all other branching twigs reduce to `:if`.
39+Note also that all other branching hoons reduce to `?:`.
37
40
38## Examples
41## Examples
39
42
40```
43```
41−~zod:dojo> :if((gth 1 2) 3 4)
44+~zod:dojo> ?:((gth 1 0) 3 4)
45+3
46+
47+~zod:dojo> ?: (gth 1 0)
48+ 3
42−4
49+ 4
43−```
50+3
44
51
45−```
46~zod:dojo> ?:((gth 1 2) 3 4)
52~zod:dojo> ?:((gth 1 2) 3 4)
474
534
54+
55+~zod:dojo> ?: (gth 1 2)
56+ 3
57+ 4
58+4
48```
59```
docs/hoon/rune/wut/dot.mdnew file+42
@@ -0,0 +1,42 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 2
5+title: ?. "wutdot"
6+---
7+
8+# `?. "wutdot"`
9+
10+`[%wtdt p=hoon q=hoon r=hoon]`: branch on a boolean test, inverted.
11+
12+## Expands to
13+
14+```
15+?:(p r q)
16+```
17+
18+## Syntax
19+
20+Regular: *3-fixed*.
21+
22+## Discussion
23+
24+As usual with inverted forms, use `?.` ("wutdot") when the positive
25+hoon of an `?:` ("wutcol") is much heavier than the negative hoon.
26+
27+## Examples
28+
29+```
30+~zod:dojo> ?.((gth 1 2) 3 4)
31+3
32+
33+~zod:dojo> ?.(?=(%a 'a') %not-a %yup)
34+%yup
35+
36+~zod:dojo> ?. %.y
37+ 'this false case is less heavy than the true case'
38+ ?: =(2 3)
39+ 'two not equal to 3'
40+ 'but see how \'r is much heavier than \'q?'
41+'but see how \'r is much heavier than \'q?'
42+```
docs/hoon/twig/wut-test/gal-deny.md → docs/hoon/rune/wut/gal.mdrenamed+8−14
@@ -1,20 +1,16 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 10
4+sort: 4
5+title: ?< "wutgal"
4---
6---
5
7
6−# `:deny ?< "wutgal"`
8+# `?< "wutgal"`
7
9
8−`{$deny p/seed q/seed}`: negative assertion.
10+`[%wtgl p=hoon q=hoon]`: negative assertion.
9
11
10## Expands to
12## Expands to
11
13
12−```
13−:if p
14− !!
15−q
16−```
17−
18```
14```
19?:(p !! q)
15?:(p !! q)
20```
16```
@@ -25,13 +21,11 @@ Regular: *2-fixed*.
25
21
26## Examples
22## Examples
27
23
28−```
29−~zod:dojo> :deny(=(3 4) %foo)
30−%foo
31−```
32−
33```
24```
34~zod:dojo> ?<(=(3 4) %foo)
25~zod:dojo> ?<(=(3 4) %foo)
35%foo
26%foo
27+
28+~zod:dojo> ?<(=(3 3) %foo)
29+ford: build failed
36```
30```
37
31
docs/hoon/twig/wut-test/gar-sure.md → docs/hoon/rune/wut/gar.mdrenamed+8−14
@@ -1,20 +1,16 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 11
4+sort: 3
5+title: ?> "wutgar"
4---
6---
5
7
6−# `:sure ?> "wutgar"`
8+# `?> "wutgar"`
7
9
8−`{$sure p/seed q/seed}`: positive assertion.
10+`[%wtgr p=hoon q=hoon]`: positive assertion.
9
11
10## Expands to
12## Expands to
11
13
12−```
13−:lest p
14− !!
15−q
16−```
17−
18```
14```
19?.(p !! q)
15?.(p !! q)
20```
16```
@@ -25,12 +21,10 @@ Regular: *2-fixed*.
25
21
26## Examples
22## Examples
27
23
28−```
29−~zod:dojo> :sure(=(3 3) %foo)
30−%foo
31−```
32−
33```
24```
34~zod:dojo> ?>(=(3 3) %foo)
25~zod:dojo> ?>(=(3 3) %foo)
35%foo
26%foo
27+
28+~zod:dojo> ?>(=(3 4) %foo)
29+ford: build failed
36```
30```
docs/hoon/twig/wut-test/hep-case.md → docs/hoon/rune/wut/hep.mdrenamed+12−33
@@ -1,36 +1,29 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 12
4sort: 12
5+title: ?- "wuthep"
4---
6---
5
7
6−# `:case ?- "wuthep"`
8+# `?- "wuthep"`
7
9
8−`{$case p/wing q/(list (pair moss seed))}`: switch against a
10+`[%wthp p=wing q=(list (pair model value))]`: switch against a
9union, with no default.
11union, with no default.
10
12
11## Expands to
13## Expands to
12
14
13−*Pseudocode*, `a`, `b`, `c`, ... as elements of `q`
15+*Pseudocode*: `a`, `b`, `c`, ... as elements of `q`:
14
16
15```
17```
16−:if :fits(p.a) q.a
18+?: ?=(p.a) q.a
17−:if :fits(p.b) q.b
19+?: ?=(p.b) q.b
18−:if :fits(p.c) q.c
20+?: ?=(p.c) q.c
19...
21...
20−:show(%mint-lost !!)
22+~|(%mint-lost !!)
21```
23```
22
24
23### Compiler macro
25### Compiler macro
24
26
25−```
26−:loop
27−:ifno q
28− :show(%mint-lost !!)
29−:if :fits(p.i.q p)
30− q.i.q
31−:moar(q t.q)
32−```
33−
34```
27```
35|-
28|-
36?. q
29?. q
@@ -48,8 +41,8 @@ Regular: *1-fixed*, then *jogging*.
48
41
49The compiler makes sure that your code neither misses a case of
42The compiler makes sure that your code neither misses a case of
50the union, nor includes a double case that isn't there. This is
43the union, nor includes a double case that isn't there. This is
51−not special handling for `:case`, just a consequence of the
44+not special handling for `?-` ("wuthep"), just a consequence of the
52−semantics of `:if`, which `:case` reduces to.
45+semantics of `?:` ("wutcol"), which `?-` reduces to.
53
46
54A missing case will throw the `mint-lost` error. An extra case
47A missing case will throw the `mint-lost` error. An extra case
55will throw `mint-vain`. (Ecclesiastes did nothing wrong.)
48will throw `mint-vain`. (Ecclesiastes did nothing wrong.)
@@ -57,21 +50,7 @@ will throw `mint-vain`. (Ecclesiastes did nothing wrong.)
57## Examples
50## Examples
58
51
59```
52```
60−~zod:dojo> =cor :gate vat/?($a $b)
53+~zod:dojo> =cor |= vat=?($a $b)
61− :case vat
62− $a 20
63− $b 42
64− ==
65−~zod:dojo> (cor %a)
66−20
67−~zod:dojo> (cor %b)
68−42
69−~zod:dojo> (cor %c)
70−! nest-fail
71−```
72−
73−```
74−~zod:dojo> =cor |= vat/?($a $b)
75 ?- vat
54 ?- vat
76 $a 20
55 $a 20
77 $b 42
56 $b 42
docs/hoon/twig/wut-test/ket-ifcl.md → docs/hoon/rune/wut/ket.mdrenamed+7−19
@@ -1,21 +1,17 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 5
4+sort: 11
5+title: ?^ "wutket"
4---
6---
5
7
6−# `:ifcl ?^ "wutket"`
8+# `?^ "wutket"`
7
9
8−`{$ifcl p/wing q/seed r/seed}`: branch on whether a wing
10+`[%wtkt p=wing q=hoon r=hoon]`: branch on whether a wing
9of the subject is a cell.
11of the subject is a cell.
10
12
11## Expands to
13## Expands to
12
14
13−```
14−:if :fits(^ p)
15− q
16−r
17−```
18−
19```
15```
20?:(?=(^ p) q r)
16?:(?=(^ p) q r)
21```
17```
@@ -30,22 +26,14 @@ Regular form: *3-fixed*
30
26
31## Examples
27## Examples
32
28
33−```
34−~zod:dojo> :ifcl(0 1 2)
35−! mint-vain
36−! exit
37−~zod:dojo> :ifcl(`*`0 1 2)
38−2
39−~zod:dojo> :ifcl(`*`[1 2] 3 4)
40−3
41−```
42−
43```
29```
44~zod:dojo> ?^(0 1 2)
30~zod:dojo> ?^(0 1 2)
45! mint-vain
31! mint-vain
46! exit
32! exit
33+
47~zod:dojo> ?^(`*`0 1 2)
34~zod:dojo> ?^(`*`0 1 2)
482
352
36+
49~zod:dojo> ?^(`*`[1 2] 3 4)
37~zod:dojo> ?^(`*`[1 2] 3 4)
503
383
51```
39```
docs/hoon/rune/wut/lus.mdnew file+57
@@ -0,0 +1,57 @@
1+---
2+navhome: /docs/
3+sort: 13
4+title: ?+ "wutlus"
5+---
6+
7+# `?+ "wutlus"`
8+
9+`[%wtls p=wing q=value r=(list (pair model value))]`: switch against
10+a union, with a default.
11+
12+## Expands to
13+
14+*Pseudocode*: `a`, `b`, `c`, ... as elements of `r`:
15+
16+```
17+?: ?=(p.a) q.a
18+?: ?=(p.b) q.b
19+?: ?=(p.c) q.c
20+...
21+q
22+```
23+
24+### Compiler macro
25+
26+```
27+|-
28+?. r
29+ q
30+?: ?=(p.i.r p)
31+ q.i.r
32+$(r t.r)
33+```
34+
35+## Syntax
36+
37+Regular: *2-fixed*, then *jogging*.
38+
39+## Discussion
40+
41+An extra case will throw `mint-vain`. A lost case defaults.
42+
43+## Examples
44+
45+```
46+~zod:dojo> =cor |= vat=?($a $b)
47+ ?+ vat 240
48+ $a 20
49+ $b 42
50+ ==
51+~zod:dojo> (cor %a)
52+20
53+~zod:dojo> (cor %b)
54+42
55+~zod:dojo> (cor %c)
56+240
57+```
docs/hoon/rune/wut/pam.mdnew file+45
@@ -0,0 +1,45 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 5
5+title: ?& "wutpam"
6+---
7+
8+# `?& "wutpam"`
9+
10+`[%wtpm p=(list hoon)]`: logical and.
11+
12+## Expands to
13+
14+*Pseudocode*: `a`, `b`, `c`, ... as elements of `p`:
15+
16+```
17+?.(a | ?.(b | ?.(c | ?.(... ?.(z | &)))))
18+```
19+
20+### Compiler macro
21+
22+```
23+|-
24+?~ p
25+ &
26+?. i.p
27+ |
28+$(p t.p)
29+```
30+
31+## Syntax
32+
33+Regular: *running*.
34+
35+Irregular: `&(foo bar baz)` is `?&(foo bar baz)`.
36+
37+## Examples
38+
39+```
40+~zod:dojo> &(=(6 6) =(42 42))
41+%.y
42+
43+~zod:dojo> &(=(6 7) =(42 43))
44+%.n
45+```
docs/hoon/twig/wut-test/pat-ifat.md → docs/hoon/rune/wut/pat.mdrenamed+5−19
@@ -1,21 +1,17 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 4
4+sort: 10
5+title: ?@ "wutpat"
4---
6---
5
7
6−# `:ifat ?@ "wutpat"`
8+# `?@ "wutpat"`
7
9
8−`{$ifat p/wing q/seed r/seed}`: branch on whether a wing
10+`[%wtpt p=wing q=hoon r=hoon]`: branch on whether a wing
9of the subject is an atom.
11of the subject is an atom.
10
12
11## Expands to
13## Expands to
12
14
13−```
14−:if :fits(@ p)
15− q
16−r
17−```
18−
19```
15```
20?:(?=(@ p) q r)
16?:(?=(@ p) q r)
21```
17```
@@ -26,16 +22,6 @@ Regular: *3-fixed*.
26
22
27## Examples
23## Examples
28
24
29−```
30−~zod:dojo> :ifat(0 1 2)
31−! mint-vain
32−! exit
33−~zod:dojo> :ifat(`*`0 1 2)
34−1
35−~zod:dojo> :ifat(`*`[1 2] 3 4)
36−4
37−```
38−
39```
25```
40~zod:dojo> ?@(0 1 2)
26~zod:dojo> ?@(0 1 2)
41! mint-vain
27! mint-vain
docs/hoon/rune/wut/sig.mdnew file+34
@@ -0,0 +1,34 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 9
5+title: ?~ "wutsig"
6+---
7+
8+# `?~ "wutsig"`
9+
10+`[%wtsg p=wing q=hoon r=hoon]`: branch on whether a wing
11+of the subject is null.
12+
13+## Expands to
14+
15+```
16+?:(?=($~ p) q r)
17+```
18+
19+## Syntax
20+
21+Regular: *3-fixed*.
22+
23+## Discussion
24+
25+It's bad style to use `?~` to test for any zero atom. Use it
26+only for a true null, `~`.
27+
28+## Examples
29+
30+```
31+~zod:dojo> =foo ""
32+~zod:dojo> ?~(foo 1 2)
33+1
34+```
docs/hoon/twig/wut-test/tis-fits.md → docs/hoon/rune/wut/tis.mdrenamed+9−13
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 6
4+sort: 8
5+title: ?= "wuttis"
4---
6---
5
7
6−# `:fits ?= "wuttis"`
8+# `?= "wuttis"`
7
9
8−`{$fits p/moss q/wing}`: test pattern match.
10+`[%wtts p=model q=wing]`: test pattern match.
9
11
10## Produces
12## Produces
11
13
@@ -18,7 +20,7 @@ Regular: *2-fixed*.
18
20
19## Discussion
21## Discussion
20
22
21−`:fits` is not as powerful as it might seem. For instance, it
23+`?=` ("wuttis") is not as powerful as it might seem. For instance, it
22can't generate a loop -- you cannot (and should not) use it to
24can't generate a loop -- you cannot (and should not) use it to
23test whether a `*` is a `(list @)`. Nor can it validate atomic
25test whether a `*` is a `(list @)`. Nor can it validate atomic
24auras.
26auras.
@@ -26,8 +28,8 @@ auras.
26Patterns should be as weak as possible. Unpack one layer of
28Patterns should be as weak as possible. Unpack one layer of
27union at a time. Don't confirm things the type system knows.
29union at a time. Don't confirm things the type system knows.
28
30
29−For example, when matching a book containing a page `{$foo p/@
31+For example, when matching a book containing a page `[%foo p=@
30−q/{@ @}}`, the proper pattern is `{$foo *}`. You have one
32+q=[@ @]]`, the proper pattern is `[%foo *]`. You have one
31question, which is whether the head of the noun is `%foo`.
33question, which is whether the head of the noun is `%foo`.
32
34
33A common error is `find.$`, meainng `p` is not a mold.
35A common error is `find.$`, meainng `p` is not a mold.
@@ -36,12 +38,6 @@ A common error is `find.$`, meainng `p` is not a mold.
36
38
37```
39```
38~zod:dojo> =bar [%foo %bar %baz]
40~zod:dojo> =bar [%foo %bar %baz]
39−~zod:dojo> :fits({$foo *} bar)
41+~zod:dojo> ?=([%foo *] bar)
40−%.y
41−```
42−
43−```
44−~zod:dojo> =bar [%foo %bar %baz]
45−~zod:dojo> ?=({$foo *} bar)
46%.y
42%.y
47```
43```
docs/hoon/twig/wut-test/zap-not.md → docs/hoon/rune/wut/zap.mdrenamed+7−17
@@ -1,18 +1,16 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3sort: 7
4sort: 7
5+title: ?: "wutzap"
4---
6---
5
7
6−# `:not ?! "wutzap"`
8+# `?! "wutzap"`
7
9
8−`{$not p/seed}`: logical not.
10+`[%wtzp p=hoon]`: logical not.
9
11
10## Expands to
12## Expands to
11
13
12−```
13−:same(%.n p)
14−```
15−
16```
14```
17.=(| p)
15.=(| p)
18```
16```
@@ -27,24 +25,16 @@ Irregular: `!foo` is `?!(foo)`.
27
25
28## Examples
26## Examples
29
27
30−```
31−~zod:dojo> not:(=(1 2))
32−%.y
33−~zod:dojo> :not(&)
34−%.n
35−~zod:dojo> :not(|)
36−%.y
37−~zod:dojo> :not(gth 5 6)
38−%.y
39−```
40−
41```
28```
42~zod:dojo> ?!(.=(1 2))
29~zod:dojo> ?!(.=(1 2))
43%.y
30%.y
31+
44~zod:dojo> !&
32~zod:dojo> !&
45%.n
33%.n
34+
46~zod:dojo> !|
35~zod:dojo> !|
47%.y
36%.y
37+
48~zod:dojo> !(gth 5 6)
38~zod:dojo> !(gth 5 6)
49%.y
39%.y
50```
40```
docs/hoon/twig/zap-wild.md → docs/hoon/rune/zap.mdrenamed+4−3
@@ -1,10 +1,11 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 13
4+sort: 12
4−
5+title: Wild ! ("zap")
5---
6---
6
7
7−# Wild, `!` ("zap")
8+# Wild `!` ("zap")
8
9
9## Twigs
10## Twigs
10
11
docs/hoon/rune/zap/gar.mdnew file+30
@@ -0,0 +1,30 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 3
5+title: !> "zapgar"
6+---
7+
8+# `!> "zapgar"`
9+
10+`[%zpgr p=hoon]`: wrap a noun in its type.
11+
12+## Produces
13+
14+A cell whose tail is `p`, and whose head is the static type of p.
15+
16+## Syntax
17+
18+Regular: *1-fixed*.
19+
20+## Discussion
21+
22+In Hoon, dynamic type is static type compiled at runtime. This
23+type-noun cell is generally called a `vase`.
24+
25+## Examples
26+
27+```
28+~zod:dojo> !>(1)
29+[p=#t/@ud q=1]
30+```
docs/hoon/twig/zap-wild/tis-code.md → docs/hoon/rune/zap/tis.mdrenamed+5−12
@@ -1,11 +1,13 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3+next: true
3−sort: 3
4+sort: 2
5+title: != "zaptis"
4---
6---
5
7
6−# `:code != "zaptis"`
8+# `!= "zaptis"`
7
9
8−`{$code p/seed}`: make the Nock formula for a twig.
10+`[%zpts p=hoon]`: make the Nock formula for a hoon.
9
11
10## Produces
12## Produces
11
13
@@ -17,15 +19,6 @@ Regular: *1-fixed*.
17
19
18## Examples
20## Examples
19
21
20−```
21−~zod:dojo> :code(20)
22−[1 20]
23−~zod:dojo> :code(~zod)
24−[1 0]
25−~zod:dojo> :code((add 2 2))
26−[8 [9 3.110.356 0 31] 9 2 [0 4] [7 [0 3] 1 2 2] 0 11]
27−```
28−
29```
22```
30~zod:dojo> !=(20)
23~zod:dojo> !=(20)
31[1 20]
24[1 20]
docs/hoon/twig/zap-wild/wut-need.md → docs/hoon/rune/zap/wut.mdrenamed+4−12
@@ -1,16 +1,17 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3sort: 4
3sort: 4
4+title: !? "zapwut"
4---
5---
5
6
6−# `:need !? "zapwut"`
7+# `!? "zapwut"`
7
8
8−`{$need p/@ q/seed}`: restrict Hoon version.
9+`[%zpwt p=@ q=hoon]`: restrict Hoon version.
9
10
10## Produces
11## Produces
11
12
12`q`, if `p` is greater than or equal to the Hoon kelvin version.
13`q`, if `p` is greater than or equal to the Hoon kelvin version.
13−(Versions count down; the current version is 150.)
14+(Versions count down; the current version is 143.)
14
15
15## Syntax
16## Syntax
16
17
@@ -18,15 +19,6 @@ Regular: *2-fixed*.
18
19
19## Examples
20## Examples
20
21
21−```
22−~zod:dojo> :need(264 (add 2 2))
23−4
24−~zod:dojo> :need(164 (add 2 2))
25−4
26−~zod:dojo> :need(64 (add 2 2))
27−! exit
28−```
29−
30```
22```
31~zod:dojo> !?(264 (add 2 2))
23~zod:dojo> !?(264 (add 2 2))
324
244
docs/hoon/rune/zap/zap.mdnew file+29
@@ -0,0 +1,29 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 1
5+title: !! "zapzap"
6+---
7+
8+# `!! "zapzap"`
9+
10+`[%zpzp ~]`: crash.
11+
12+## Produces
13+
14+Nothing. Always crashes, with type `%void`.
15+
16+## Syntax
17+
18+`!!`
19+
20+## Discussion
21+
22+`%void` nests in every other type, so you can stub out anything with `!!`.
23+
24+## Examples
25+
26+```
27+~zod:dojo> !!
28+ford: build failed
29+```
docs/hoon/syntax.md+3−3
@@ -1,6 +1,6 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3−sort: 12
3+sort: 13
4next: true
4next: true
5title: Syntax
5title: Syntax
6---
6---
@@ -132,7 +132,7 @@ the first of which, when evaluated, becomes the *head* (i.e., the left)
132and the second of which becomes the *tail* (i.e., the right).
132and the second of which becomes the *tail* (i.e., the right).
133
133
134Hoon expressions are just called
134Hoon expressions are just called
135−[hoons](../about/glossary/#-twig), because a rune's subexpression can itself
135+[hoons](../about/glossary/#-a-hoon), because a rune's subexpression can itself
136be a Hoon expression (i.e. another rune). You'll start to see this tree-like,
136be a Hoon expression (i.e. another rune). You'll start to see this tree-like,
137recursive structure the more you program in Hoon. You can think of one Hoon
137recursive structure the more you program in Hoon. You can think of one Hoon
138file being composed of multiple hoons. The subexpressions following the
138file being composed of multiple hoons. The subexpressions following the
@@ -141,7 +141,7 @@ rune are sometimes called the *children* of that hoon.
141## Tall and flat forms
141## Tall and flat forms
142
142
143There are two kinds of Hoon expression syntax: *tall* and *flat*.
143There are two kinds of Hoon expression syntax: *tall* and *flat*.
144−Most runes can be used in both tall and flat twigs. Tall hoons can
144+Most runes can be used in both tall and flat hoons. Tall hoons can
145contain flat hoons, but not vice versa.
145contain flat hoons, but not vice versa.
146
146
147The `:-` expression in the last subsection was in tall form. Here's
147The `:-` expression in the last subsection was in tall form. Here's
docs/hoon/troubleshooting.md+22−25
@@ -1,8 +1,8 @@
1---
1---
2navhome: /docs/
2navhome: /docs/
3−sort: 19
4−title: Troubleshooting
5next: true
3next: true
4+sort: 23
5+title: Troubleshooting
6---
6---
7
7
8# Troubleshooting
8# Troubleshooting
@@ -24,8 +24,8 @@ a correct Hoon file. These values are always correct.
24Usually, the line and column tell you everything you need to
24Usually, the line and column tell you everything you need to
25know. But the worst-case scenario for a syntax error is that,
25know. But the worst-case scenario for a syntax error is that,
26somewhere above, you've confused Hoon's tall form by using the
26somewhere above, you've confused Hoon's tall form by using the
27−wrong fanout for a rune. For example, `%+` (`:calt`, a function
27+wrong fanout for a rune. For example, `%+` ([*cenlus*](../rune/cen/lus),
28−call whose sample is a cell) has three subtwigs:
28+a function call whose sample is a cell) has three subhoons:
29
29
30```
30```
31%+ foo
31%+ foo
@@ -40,12 +40,12 @@ But if you make a mistake and write
40bar
40bar
41```
41```
42
42
43−the parser will eat the next twig below and try to treat it as a
43+the parser will eat the next hoon below and try to treat it as a
44part of the `%+`. This can cause a cascading error somewhere
44part of the `%+`. This can cause a cascading error somewhere
45below, usually stopped by a `==` or `--`.
45below, usually stopped by a `==` or `--`.
46
46
47When this happens, don't panic! Binary search actually works
47When this happens, don't panic! Binary search actually works
48−quite well. Any twig can be stubbed out as `!!`. Find the
48+quite well. Any hoon can be stubbed out as `!!`. Find the
49prefix of your file that compiles, then work forward until
49prefix of your file that compiles, then work forward until
50the actual error appears.
50the actual error appears.
51
51
@@ -57,12 +57,12 @@ Now your code parses but doesn't compile.
57
57
58Your first step should be to put a `!:` ("zapcol") rune at the
58Your first step should be to put a `!:` ("zapcol") rune at the
59top of the file. This is like calling the C compiler with `-g`;
59top of the file. This is like calling the C compiler with `-g`;
60−it tells the Hoon compiler to generate tracing twigs.
60+it tells the Hoon compiler to generate tracing hoons.
61
61
62Bear in mind that `!:` breaks tail-call optimization. This is a
62Bear in mind that `!:` breaks tail-call optimization. This is a
63bug, but a relatively low-priority bug. `!.` turns off `!:`.
63bug, but a relatively low-priority bug. `!.` turns off `!:`.
64−Note that `!:` and `!.` are twig-level, not file-level; you can
64+Note that `!:` and `!.` are hoon-level, not file-level; you can
65−wrap any twig in either.
65+wrap any hoon in either.
66
66
67### Error trace
67### Error trace
68
68
@@ -78,7 +78,7 @@ If you have `!:` on, you'll see an error trace, like
78nest-fail
78nest-fail
79```
79```
80
80
81−The bottom of this trace is the line and column of the twig which
81+The bottom of this trace is the line and column of the hoon which
82failed to compile, then the cause of the error (`nest-fail`).
82failed to compile, then the cause of the error (`nest-fail`).
83
83
84Hoon does not believe in inundating you with possibly irrelevant
84Hoon does not believe in inundating you with possibly irrelevant
@@ -104,8 +104,8 @@ means you tried to pound a square peg into a round hole.
104What was the peg and what was the hole? Hoon doesn't tell you by
104What was the peg and what was the hole? Hoon doesn't tell you by
105default, because moral fiber, and also because in too many cases
105default, because moral fiber, and also because in too many cases
106trivial errors lead to large intimidating dumps. However, you
106trivial errors lead to large intimidating dumps. However, you
107−can use the `~!` rune ("sigzap", `:peep`) to print the type of
107+can use the `~!` rune ([*sigzap*](../rune/sig/zap)) to print the type of
108−any twig in your stack trace.
108+any hoon in your stack trace.
109
109
110For instance, you wrote `(foo bar)` and got a `nest-fail`. Change
110For instance, you wrote `(foo bar)` and got a `nest-fail`. Change
111your code to be:
111your code to be:
@@ -126,18 +126,15 @@ In other words, "undeclared variable."
126
126
127The most common subspecies of `find` error is `find.$`, meaning
127The most common subspecies of `find` error is `find.$`, meaning
128the empty name `$` was not found. This often happens when you
128the empty name `$` was not found. This often happens when you
129−use a twig that does not produce a gate/mold, as a gate/mold.
129+use a hoon that does not produce a gate/mold, as a gate/mold. For
130−
131−For instance, `(foo bar)` will give `find.$` if `foo` is not
130+instance, `(foo bar)` will give `find.$` if `foo` is not actually a
132−actually a function. `?=([%foo %bar] baz)` will give `find.$`,
131+function.
133−because `?=` ("wuttis", `:fits`) needs a mold rather than a seed
134−(you probably meant `?=({$foo $bar} baz)`).
135
132
136### `mint-vain` and `mint-lost`
133### `mint-vain` and `mint-lost`
137
134
138These are errors caused by type inference in pattern matching.
135These are errors caused by type inference in pattern matching.
139−`mint-vain` means this twig is never executed. `mint-lost` means
136+`mint-vain` means this hoon is never executed. `mint-lost` means
140−there's a case in a `?-` ("wuthep", `:case`) that isn't handled.
137+there's a case in a `?-` ([*wuthep*](../rune/wut/hep)) that isn't handled.
141
138
142## Runtime crashes
139## Runtime crashes
143
140
@@ -150,8 +147,8 @@ need to be developing on the local console; otherwise, the
150infinite loop will time out either too slowly or too fast). The
147infinite loop will time out either too slowly or too fast). The
151stack trace will show what your code was doing when interrupted.
148stack trace will show what your code was doing when interrupted.
152
149
153−The counterpart of `~!` for runtime crashes is `~|` ("sigbar",
150+The counterpart of `~!` for runtime crashes is `~|`
154−`:show`):
151+([*sigbar*](../rune/sig/bar)):
155
152
156```
153```
157~| foo
154~| foo
@@ -167,8 +164,8 @@ The worst possibility, of course, is that your code runs but does
167the wrong thing. This is relatively unusual in a typed
164the wrong thing. This is relatively unusual in a typed
168functional language, but it still happens.
165functional language, but it still happens.
169
166
170−`~&` ("sigpam", `:dump`) is Hoon's debugging printf. This
167+`~&` ([*sigpam*](../rune/sig/pam)) is Hoon's debugging printf.
171−pretty-prints its argument:
168+This pretty-prints its argument:
172
169
173```
170```
174~& foo
171~& foo
@@ -176,7 +173,7 @@ pretty-prints its argument:
176```
173```
177
174
178will always print `foo` every time it executes. A variant is
175will always print `foo` every time it executes. A variant is
179−`~?` ("sigwut", `:warn`), which prints only if a condition is
176+`~?` ([*sigwut*](../rune/sig/wut)), which prints only if a condition is
180true:
177true:
181
178
182```
179```
docs/hoon/twig.mddeleted−75
@@ -1,75 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 14
4−next: true
5−title: Expressions
6−---
7−
8−# Expressions
9−
10−A Hoon expression is called a `twig`. A `twig` is an AST node:
11−the noun that the Hoon compiler makes when it parses a source
12−expression.
13−
14−The definition of `twig` is the definition of Hoon. So let's
15−define the syntax and semantics of Hoon, a twig at a time. But
16−first, basic twig anatomy.
17−
18−## Twig anatomy and jargon
19−
20−A twig is a tagged union (`book`) with the form `{stem bulb}`,
21−where the `stem` is an atomic symbol. The bulb for each stem has
22−its own type, which varies by stem. (Compare with Lisp, where
23−every AST node is a tag and a list of child nodes.)
24−
25−There are no user-level macros. All stems are built into Hoon.
26−Most stems are implemented as internal macros, however.
27−
28−The bulb is usually a tuple, sometimes a list or map. An element
29−of this structure is a *subexpression* or just *leg*.
30−
31−Usually a subexpression is itself a `twig`; sometimes it's a
32−`@tas` (symbol) or a `wing` (reference path).
33−
34−## Moldy moss; woody seed
35−
36−When defining each page in the `twig` book, we never use `twig`
37−itself as a leg. Instead, we use the mold `moss` to describe
38−twigs whose product is used as a mold, and `seed` for twigs whose
39−product could be anything. Both `moss` and `seed` are just
40−aliases for `twig`, but they serve as documentation.
41−
42−For adjectives, we say *moldy* and *woody* respectively. An
43−example of X is the woody form of X; a mold producing X is its
44−moldy form.
45−
46−For instance, `[%foo %bar]` is woody: a twig producing the noun
47−`[7.303.014 7.496.034]`. `{$foo $bar}` is moldy: a twig
48−producing a function whose product is always `[7.303.014
49−7.496.034]`.
50−
51−This mold, of course, is a noun (a gate). The value of that noun
52−is not `[7.303.014 7.496.034]`, or anything remotely like it.
53−The noun is a pile of code. It is probably a big pile of code,
54−because most cores include a lot of formulas, contexts, etc,
55−generally including the whole standard library. (Having a
56−pointer to the standard library does not burden a noun much,
57−unless of course you're trying to print that noun and you don't
58−have a span that describes it.)
59−
60−And of course, Hoon is a functional language, so seeds sometimes
61−produce a mold -- because we do pass around functions as values.
62−Don't worry about this issue. It will totally make sense soon.
63−
64−But writing `[%foo %bar]` where you mean `{$foo $bar}`, or the
65−reverse, is a common beginner's mistake in Hoon. At least it
66−always results in a compiler error (since the noun types are so
67−different). There's really no way around learning not to make
68−this mistake the hard way, but designating subexpressions as
69−`moss` or `seed` can't hurt.
70−
71−## Twig categories
72−
73−Most twigs fit into clear categories by meaning and rune prefix:
74−
75−<div><list/></div>
docs/hoon/twig/bar-core.mddeleted−30
@@ -1,30 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 5
4−
5−---
6−
7−# Core, `|` ("bar")
8−
9−Core twigs are flow twigs. The compiler essentially pins a Nock
10−formula, or battery of formulas, to the subject.
11−
12−All `|` twigs are macros around `$core`. (See the `$core`
13−section in [`span`](../../basic#-core-p-span-q-map-term-span) above.)
14−`$core` uses the subject as the payload of a battery, whose arms are
15−compiled with the core itself as the subject.
16−
17−Four of these twigs (`:gate`, `:trap`, `:loop`, and `:gill`) produce a
18−core with a single arm, named `$`. We can recompute this arm with changes,
19−useful for recursion among other things:
20−
21−> `:moar()` expands to `:make($)`, accepting a *jogging* body
22−> containing a list of changes to the subject.
23−
24−> `$()` expands to `%=($)`, accepting a *jogging* body
25−> containing a list of changes to the subject.
26−
27−
28−## Stems
29−
30−<list dataPreview="true" className="runes"></list>
docs/hoon/twig/bar-core/col-gasp.mddeleted−30
@@ -1,30 +0,0 @@
1−---
2−navhome: /docs
3−sort: 8
4−
5−---
6−
7−# `:gasp |: "barcol"`
8−
9−`{$gasp p/seed q/seed}`: form a gate with burnt sample.
10−
11−## Expands to
12−
13−```
14−:pin :burn(p)
15−:trap(q)
16−```
17−
18−```
19−=> ^~ p
20− |. q
21−```
22−
23−## Discussion
24−
25−Note that `p` is a seed, not a moss; `:gasp` doesn't bunt your sample as
26−`:gate` does.
27−
28−## Syntax
29−
30−Regular: *2-fixed*.
docs/hoon/twig/bar-core/dot-trap.mddeleted−85
@@ -1,85 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 3
4−
5−---
6−
7−# `:trap |. "bardot"`
8−
9−`{$trap p/seed}`: form a trap, a core with one arm `$`.
10−
11−## Expands to
12−
13−```
14−:core
15−++ $ p
16−--
17−```
18−
19−```
20−|% ++ $ p
21−--
22−```
23−
24−## Syntax
25−
26−Regular: *1-fixed*.
27−
28−## Discussion
29−
30−A trap is a deferred computation.
31−
32−## Examples
33−
34−A trivial trap:
35−
36−```
37−~zod:dojo> =foo :trap(42)
38−~zod:dojo> :rap($ foo)
39−42
40−~zod:dojo> (foo)
41−42
42−```
43−
44−```
45−~zod:dojo> =foo |.(42)
46−~zod:dojo> $:foo
47−42
48−~zod:dojo> (foo)
49−42
50−```
51−
52−A more interesting trap:
53−
54−```
55−~zod:dojo> =foo :var reps 10
56− :var step 0
57− :var outp 0
58− :trap
59− :if =(step reps)
60− outp
61− :moar(outp (add outp 2), step +(step))
62−~zod:dojo> (foo)
63−20
64−```
65−
66−```
67−~zod:dojo> =foo =/ reps 10
68− =/ step 0
69− =/ outp 0
70− |.
71− ?: =(step reps)
72− outp
73− $(outp (add outp 2), step +(step))
74−~zod:dojo> (foo)
75−20
76−```
77−
78−Note that we can use `:moar()` or `$()` to recurse back into the
79−trap, since it's a core with an `$` arm.
80−
81−> `:moar()` expands to `:make($)`, accepting a *jogging* body containing a list
82−> of changes to the subject.
83−
84−> `$()` expands to `%=($)`, accepting a *jogging* body containing a
85−> list of changes to the subject.
docs/hoon/twig/bar-core/hep-loop.mddeleted−74
@@ -1,74 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 4
4−
5−---
6−
7−# `:loop |- "barhep"`
8−
9−`{$loop p/seed}`: form a trap and kick ("*call*") it.
10−
11−## Expands to
12−
13−```
14−:rap $
15−:trap p
16−```
17−
18−```
19−=<($ |.(p))
20−```
21−
22−## Syntax
23−
24−Regular: *1-fixed*.
25−
26−## Discussion
27−
28−The `:loop` keyword (and `|-` rune) can be thought of as a "recursion point" -
29−since `:loop` makes a `:trap` (a core with one arm named `$`), we can recurse
30−back into it with `:moar()` or `$()`.
31−
32−> `:moar()` expands to `:make($)`, accepting a *jogging* body containing a list
33−> of changes to the subject.
34−
35−> `$()` expands to `%=($)`, accepting a *jogging* body containing a
36−> list of changes to the subject.
37−
38−## Examples
39−
40−A trivial loop doesn't even recurse:
41−
42−```
43−~zod:dojo> :loop(42)
44−42
45−```
46−
47−```
48−~zod:dojo> |-(42)
49−42
50−```
51−
52−The classic loop is a decrement:
53−
54−```
55−~zod:dojo> =foo :var a 42
56− :var b 0
57− :loop
58− :if =(a +(b))
59− b
60− :moar(b +(b))
61−~zod:dojo> foo
62−41
63−```
64−
65−```
66−~zod:dojo> =foo =/ a 42
67− =/ b 0
68− |-
69− ?: =(a +(b))
70− b
71− $(b +(b))
72−~zod:dojo> foo
73−41
74−```
docs/hoon/twig/bar-core/sig-port.mddeleted−38
@@ -1,38 +0,0 @@
1−---
2−navhome: /docs
3−sort: 10
4−
5−---
6−
7−# `:port |~ "barsig"`
8−
9−`{$port p/moss q/seed}`: form an iron gate.
10−
11−## Expands to
12−
13−```
14−:iron :gate(p q)
15−```
16−
17−```
18−^| |=(p q)
19−```
20−
21−## Syntax
22−
23−Regular: *2-fixed*.
24−
25−## Discussion
26−
27−See [this discussion of core variance models](../../../advanced)
28−
29−## Examples
30−
31−```
32−~zod:dojo> :per ~ :like(:port(a/@ *@) :gate(a/* *@))
33−```
34−
35−```
36−~zod:dojo> => ~ ^+(|~(a/@ *@) |=(a/* *@))
37−<1|usl {a/@ $~}>
38−```
docs/hoon/twig/bar-core/tar-gill.mddeleted−74
@@ -1,74 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 6
4−---
5−
6−# `:gill |* "bartar"`
7−
8−`{$gill p/moss q/seed}`: form a gill, a wet one-armed
9−core with sample.
10−
11−## Expands to
12−
13−```
14−:new p
15−:core
16−+- $
17− q
18−--
19−```
20−
21−```
22−=| p
23−|%
24−+- $
25− q
26−--
27−```
28−
29−## Syntax
30−
31−Regular: *2-fixed*.
32−
33−## Discussion
34−
35−In a normal (dry) gate, your argument is converted into the
36−sample type. In a generic (wet) gate or gill, your argument type
37−passes through the function, rather as if it was a macro (there
38−is still only one copy of the code, however).
39−
40−Genericity is a powerful and dangerous tool. Use gills only if
41−you think you know what you're doing.
42−
43−Just as with a `:gate`, we can recurse back into a `:gill` with `:moar()` or `$()`.
44−
45−> `:moar()` expands to `:make($)`, accepting a *jogging* body containing a list
46−> of changes to the subject.
47−
48−> `$()` expands to `%=($)`, accepting a *jogging* body containing a
49−> list of changes to the subject.
50−
51−## Examples
52−
53−Wet and dry gates in a nutshell:
54−
55−```
56−~zod:dojo> =foo :gate({a/* b/*} [b a])
57−~zod:dojo> =bar :gill({a/* b/*} [b a])
58−~zod:dojo> (foo %cat %dog)
59−[6.778.724 7.627.107]
60−~zod:dojo> (bar %cat %dog)
61−[%dog %cat]
62−```
63−
64−```
65−~zod:dojo> =foo |=({a/* b/*} [b a])
66−~zod:dojo> =bar |*({a/* b/*} [b a])
67−~zod:dojo> (foo %cat %dog)
68−[6.778.724 7.627.107]
69−~zod:dojo> (bar %cat %dog)
70−[%dog %cat]
71−```
72−
73−The dry gate does not preserve the span of `a` and `b`; the wet
74−gate does.
docs/hoon/twig/bar-core/tis-gate.mddeleted−73
@@ -1,73 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 2
4−
5−---
6−
7−# `:gate |= "bartis"`
8−
9−`{$gate p/moss q/seed}`: form a gate, a dry one-armed core with sample.
10−
11−## Expands to
12−
13−```
14−:new p
15−:core
16−++ $
17− q
18−--
19−```
20−
21−```
22−=| p
23−|% ++ $ q
24−--
25−```
26−
27−## Syntax
28−
29−Regular: *2-fixed*.
30−
31−## Discussion
32−
33−A gate is a core with one arm named `$`, so, just as with `:loop` (`|-`),
34−we can recurse back into it with `:moar()` or `$()`.
35−
36−
37−> `:moar()` expands to `:make($)`, accepting a *jogging* body containing a list
38−> of changes to the subject.
39−
40−> `$()` expands to `%=($)`, accepting a *jogging* body containing a
41−> list of changes to the subject.
42−
43−## Examples
44−
45−A trivial gate:
46−
47−```
48−~zod:dojo> =foo :gate(a/@ +(a))
49−~zod:dojo> (foo 20)
50−21
51−```
52−
53−```
54−~zod:dojo> =foo |=(a/@ +(a))
55−~zod:dojo> (foo 20)
56−21
57−```
58−
59−A slightly less trivial gate:
60−
61−```
62−~zod:dojo> =foo :gate {a/@ b/@}
63− (add a b)
64−~zod:dojo> :call(foo [20 400])
65−420
66−```
67−
68−```
69−~zod:dojo> =foo |= {a/@ b/@}
70− (add a b)
71−~zod:dojo> (foo 20 400)
72−420
73−```
docs/hoon/twig/buc-mold/base.mddeleted−33
@@ -1,33 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 1
4−
5−---
6−
7−# `:base`
8−
9−`{$base p/$@(?($noun $cell $bean $null) {$atom p/aura})}`: trivial molds.
10−
11−## Produces
12−
13−A mold for the base in `p`. `$noun` is any noun; `$atom` is any
14−atom; `$cell` is a cell of nouns; `$bean` is a loobean, ``?(`@f`0
15−`@f`1)``. `$null` is zero with aura `@n`.
16−
17−## Syntax
18−
19−Irregular: `*` makes `$noun`, `^` makes `$cell`, `?` makes
20−`$bean`, `$~` makes `$null`, `@aura` makes atom `aura`.
21−
22−## Examples
23−
24−```
25−~zod:dojo> (* %foo)
26−7.303.014
27−~zod:dojo> ($~ 0)
28−~
29−~zod:dojo> (^ 0)
30−^
31−~zod:dojo> (@ux [1 1])
32−0x0
33−```
docs/hoon/twig/buc-mold/cab-shoe.mddeleted−58
@@ -1,58 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 9
4−---
5−
6−# `:shoe $_ "buccab"`
7−
8−`{$shoe p/seed}`: mold which normalizes to an example.
9−
10−## Expands to
11−
12−```
13−:gate *
14−p
15−```
16−
17−```
18−|=(* p)
19−```
20−
21−## Syntax
22−
23−Regular: *1-fixed*.
24−
25−Irregular: `_foo` is `:shoe(foo)`.
26−
27−## Discussion
28−
29−A shoe discards the sample it's supposedly normalizing, and
30−produces its example instead.
31−
32−## Examples
33−
34−```
35−~zod:dojo> =foo :shoe([%foobar %moobaz])
36−
37−~zod:dojo> (foo %foo %bar)
38−[%foobar %moobaz]
39−
40−~zod:dojo> `foo`[%foobar %moobaz]
41−[%foobar %moobaz]
42−
43−~zod:dojo $:foo
44−[%foobar %moobaz]
45−```
46−
47−```
48−~zod:dojo> =foo $_([%foobar %moobaz])
49−
50−~zod:dojo> (foo %foo %bar)
51−[%foobar %moobaz]
52−
53−~zod:dojo> `foo`[%foobar %moobaz]
54−[%foobar %moobaz]
55−
56−~zod:dojo $:foo
57−[%foobar %moobaz]
58−```
docs/hoon/twig/buc-mold/cen-book.mddeleted−54
@@ -1,54 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 4
4−
5−---
6−
7−# `:book $% "buccen"`
8−
9−`{$book p/(list {{aura @} moss})}`: mold which recognizes a union tagged by head atom.
10−
11−## Normalizes to
12−
13−For any item `i` in `p`, a cell whose head is the atom `q.p.i.p`,
14−and whose tail recognizes `q.i.p`.
15−
16−Void if `p` is empty.
17−
18−## Defaults to
19−
20−For the first item `i` in `p`, the cell `[q.p.i.p $:q.i.p]`.
21−Crashes if `p` is empty.
22−
23−## Syntax
24−
25−Regular form: *2-running*.
26−
27−## Discussion
28−
29−A book is a tagged union, an extremely common data model.
30−
31−Each item in a book is called a "page." Make sure the first page
32−in the book terminates, or the default will be an infinite loop!
33−
34−## Examples
35−
36−```
37−~zod:dojo> =foo :book({$foo p/@ud q/@ud} {$bar p/@ud})
38−
39−~zod:dojo> (foo [%bar 37])
40−[%bar p=37]
41−
42−~zod:dojo> $:foo
43−[%foo p=0 q=0]~
44−```
45−
46−```
47−~zod:dojo> =foo $%({$foo p/@ud q/@ud} {$bar p/@ud})
48−
49−~zod:dojo> (foo [%bar 37])
50−[%bar p=37]
51−
52−~zod:dojo> $:foo
53−[%foo p=0 q=0]~
54−```
docs/hoon/twig/buc-mold/hep-lamb.mddeleted−49
@@ -1,49 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 8
4−
5−---
6−
7−# `:lamb $- "buchep"`
8−
9−`{$lamb p/moss q/moss}`: mold which normalizes to an example gate.
10−
11−## Expands to
12−
13−```
14−:shoe
15−:iron
16−:gate p
17−$:q
18−```
19−
20−```
21−$_ ^|
22−|=(p $:q)
23−```
24−
25−## Syntax
26−
27−Regular: *2-fixed*.
28−
29−## Discussion
30−
31−Since a lamb (ie, lambda), is a shoe, it is not useful for normalizing, just
32−for typechecking. In particular, the existence of lambs does *not* let us send
33−gates or other cores over the network!
34−
35−## Examples
36−
37−```
38−~zod:dojo> =foo :lamb($foo $bar)
39−
40−~zod:dojo> ($:foo %foo)
41−%bar
42−```
43−
44−```
45−~zod:dojo> =foo $-($foo $bar)
46−
47−~zod:dojo> ($:foo %foo)
48−%bar
49−```
docs/hoon/twig/buc-mold/ket-bush.mddeleted−55
@@ -1,55 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 6
4−
5−---
6−
7−# `:bush $^ "bucket"`
8−
9−`{$bush p/moss q/moss}`: mold which normalizes a union tagged by head depth.
10−
11−## Normalizes to
12−
13−Default, if the sample is an atom; `p`, if the head of the sample
14−is an atom; `q` otherwise.
15−
16−## Defaults to
17−
18−The default of `p`.
19−
20−## Syntax
21−
22−Regular: *2-fixed*.
23−
24−## Examples
25−
26−```
27−~zod:dojo> =a :book({$foo p/@ud q/@ud} {$bar p/@ud})
28−
29−~zod:dojo> =b :bush({a a} a)
30−
31−~zod:dojo> (b [[%bar 33] [%foo 19 22]])
32−[[%bar p=33] [%foo p=19 q=22]]
33−
34−~zod:dojo> (b [%foo 19 22])
35−[%foo p=19 q=22]
36−
37−~zod:dojo> $:b
38−[%bar p=0]
39−```
40−
41−```
42−~zod:dojo> =a $%({$foo p/@ud q/@ud} {$bar p/@ud})
43−
44−~zod:dojo> =b $^({a a} a)
45−
46−~zod:dojo> (b [[%bar 33] [%foo 19 22]])
47−[[%bar p=33] [%foo p=19 q=22]]
48−
49−~zod:dojo> (b [%foo 19 22])
50−[%foo p=19 q=22]
51−
52−~zod:dojo> $:b
53−[%bar p=0]
54−```
55−
docs/hoon/twig/buc-mold/tis-coat.mddeleted−49
@@ -1,49 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 3
4−
5−---
6−
7−# `:coat $= "buctis"`
8−
9−`{$coat p/@tas q/moss}`: mold which wraps a face around another mold.
10−
11−## Expands to
12−
13−```
14−:gate *
15−:name(p :call(q +6))
16−```
17−
18−```
19−|= *
20−^=(p %-(q +6))
21−```
22−
23−## Syntax
24−
25−Regular: *2-fixed*.
26−
27−Irregular: `foo/bar` is `:coat(foo bar)`.
28−
29−## Discussion
30−
31−Note that the Hoon compiler is at least slightly clever about
32−compiling molds, and almost never has to actually put in a gate
33−layer (as seen in the expansion above) to apply a coat.
34−
35−## Examples
36−
37−```
38−~zod:dojo> =a :coat(p $foo)
39−
40−~zod:dojo> (a %bar)
41−p=%foo
42−```
43−
44−```
45−~zod:dojo> =a $=(p $foo)
46−
47−~zod:dojo> (a %bar)
48−p=%foo
49−```
docs/hoon/twig/buc-mold/wut-pick.mddeleted−60
@@ -1,60 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 7
4−
5−---
6−
7−# `:pick $? "bucwut"`
8−
9−`{$pick p/(list moss)}`: mold which normalizes a general union.
10−
11−## Normalizes to
12−
13−The first item in `p` which normalizes the sample to itself;
14−otherwise, default.
15−
16−Void, if `p` is empty.
17−
18−## Defaults to
19−
20−The first item in `p`.
21−
22−## Syntax
23−
24−Regular: *running*.
25−
26−Irregular: `?(%foo %bar)` is `$?(%foo %bar)`.
27−
28−## Discussion
29−
30−For a union of atoms, a pick is fine. For more complex nouns,
31−always try to use a book, claw or bush, at least if you expect
32−your mold to be used as a normalizer.
33−
34−## Examples
35−
36−```
37−~zod:dojo> =a :pick($foo $bar $baz)
38−
39−~zod:dojo> (a %baz)
40−%baz
41−
42−~zod:dojo> (a [37 45])
43−%foo
44−
45−~zod:dojo> $:a
46−$foo
47−```
48−
49−```
50−~zod:dojo> =a ?($foo $bar $baz)
51−
52−~zod:dojo> (a %baz)
53−%baz
54−
55−~zod:dojo> (a [37 45])
56−%foo
57−
58−~zod:dojo> $:a
59−$foo
60−```
docs/hoon/twig/cen-call.mddeleted−15
@@ -1,15 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 6
4−
5−---
6−
7−# Call, `%` ("cen")
8−
9−We've already covered `$wing` and `$limb`. These are simple
10−forms of the *invocation* family of twigs, `%`, whose general
11−form is `$make`, `%=`.
12−
13−## Stems
14−
15−<list dataPreview="true" className="runes"></list>
docs/hoon/twig/cen-call/cab-keep.mddeleted−55
@@ -1,55 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 2
4−
5−---
6−
7−# `:keep %_ "cencab"`
8−
9−`{$keep p/wing q/(list (pair wing seed))}`: take a wing with changes,
10−preserving type.
11−
12−## Expands to
13−
14−```
15−:like(p :make(p q))
16−```
17−
18−```
19−^+(p %=(p q))
20−```
21−
22−## Syntax
23−
24−Regular: *1-fixed*, then *jogging*.
25−
26−## Discussion
27−
28−`:keep` is different from `:make` because `:make` can change the
29−span of a limb with mutations.
30−
31−## Examples
32−
33−```
34−~zod:dojo> =foo [p=42 q=6]
35−~zod:dojo> foo(p %bar)
36−[p=%bar q=6]
37−~zod:dojo> foo(p [55 99])
38−[p=[55 99] q=6]
39−~zod:dojo> :keep(foo p %bar)
40−[p=7.496.034 99]
41−~zod:dojo> :keep(foo p [55 99])
42−! nest-fail
43−```
44−
45−```
46−~zod:dojo> =foo [p=42 q=6]
47−~zod:dojo> foo(p %bar)
48−[p=%bar q=6]
49−~zod:dojo> foo(p [55 99])
50−[p=[55 99] q=6]
51−~zod:dojo> %_(foo p %bar)
52−[p=7.496.034 99]
53−~zod:dojo> %_(foo p [55 99])
54−! nest-fail
55−```
docs/hoon/twig/cen-call/dot-lace.mddeleted−37
@@ -1,37 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 5
4−---
5−
6−# `:lace %. "cendot"`
7−
8−`{$lace p/seed q/seed}`: call a gate (function), reversed.
9−
10−## Expands to
11−
12−```
13−:call(q p)
14−```
15−
16−```
17−%-(q p)
18−```
19−
20−## Syntax
21−
22−Regular: *2-fixed*.
23−
24−## Examples
25−
26−```
27−~zod:dojo> =add-triple :gate({a/@ b/@ c/@} :(add a b c))
28−~zod:dojo> :lace([1 2 3] add-triple)
29−6
30−```
31−
32−```
33−~zod:dojo> =add-triple |=({a/@ b/@ c/@} :(add a b c))
34−~zod:dojo> %.([1 2 3] add-triple)
35−6
36−```
37−
docs/hoon/twig/cen-call/ket-calq.mddeleted−36
@@ -1,36 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 7
4−---
5−
6−# `:calq %^ "cenket"`
7−
8−`{$calq p/seed q/seed r/seed s/seed}`: call with triple sample.
9−
10−## Expands to
11−
12−```
13−:call(p [q r s])
14−```
15−
16−```
17−%-(p [q r s])
18−```
19−
20−## Syntax
21−
22−Regular: *4-fixed*.
23−
24−## Examples
25−
26−```
27−~zod:dojo> =add-triple :gate({a/@ b/@ c/@} :(add a b c))
28−~zod:dojo> :calq(add-triple 1 2 3)
29−6
30−```
31−
32−```
33−~zod:dojo> =add-triple |=({a/@ b/@ c/@} :(add a b c))
34−~zod:dojo> %^(add-triple 1 2 3)
35−6
36−```
docs/hoon/twig/cen-call/lus-calt.mddeleted−36
@@ -1,36 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 6
4−---
5−
6−# `:calt %+ "cenlus"`
7−
8−`{$calt p/seed q/seed r/seed}`: call with pair sample.
9−
10−## Expands to
11−
12−```
13−:call(p [q r])
14−```
15−
16−```
17−%-(p [q r])
18−```
19−
20−## Syntax
21−
22−Regular: *3-fixed*.
23−
24−## Examples
25−
26−```
27−~zod:dojo> =add-triple :gate({a/@ b/@ c/@} :(add a b c))
28−~zod:dojo> :calt(add-triple 1 [2 3])
29−6
30−```
31−
32−```
33−~zod:dojo> =add-triple |=({a/@ b/@ c/@} :(add a b c))
34−~zod:dojo> %+(add-triple 1 [2 3])
35−6
36−```
docs/hoon/twig/cen-call/sig-open.mddeleted−45
@@ -1,45 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 3
4−---
5−
6−# `:open %~ "censig"`
7−
8−`{$cnsg p/wing q/seed r/seed}`: call with multi-armed door.
9−
10−## Expands to
11−
12−```
13−:pin :name(a q)
14−:rap(p :make(a +6 r))
15−```
16−
17−```
18−=+ a=q
19−=<(p %=(a +6 r))
20−```
21−
22−> Note: the expansion implementation is hygienic -- it doesn't actually add the
23−> `a` face to the subject. It's shown here because `:make` requires a `wing`.
24−
25−## Syntax
26−
27−Regular: *3-fixed*.
28−
29−Irregular: `~(a b c)` is `%~(a b c)`; `~(a b c d e)` is `%~(a b
30−[c d e])`.
31−
32−## Discussion
33−
34−`:open` is the general case of a function call, `:call`. In
35−both, we replace the sample (`+6`) of a core. In `:call` the
36−core is a gate and we pull the `$` arm, in `:open` the
37−core is a door and we can pull any of its arms.
38−
39−Most languages do not have cores, doors, or `:open`. "Just
40−learn to step outside your linear, Western way of thinking."
41−
42−## Examples
43−
44−See [`:door`](../../bar-core/cab-door).
45−
docs/hoon/twig/col-cell.mddeleted−15
@@ -1,15 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 3
4−
5−---
6−
7−# Cells, `:` ("col")
8−
9−The cell twigs, `$cons` and friends, are simple and regular.
10−All `:` twigs expand to `$cons`, which makes a pair (just like
11−the Lisp `cons` operator).
12−
13−## Stems
14−
15−<list dataPreview="true" className="runes"></list>
docs/hoon/twig/col-cell/cab-scon.mddeleted−34
@@ -1,34 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 6
4−---
5−
6−# `:scon :_ "colcab"`
7−
8−`{$scon p/seed q/seed}`; construct a cell, inverted.
9−
10−### Expands to
11−
12−```
13−:cons(q p)
14−```
15−
16−```
17−:-(q p)
18−```
19−
20−### Syntax
21−
22−Regular: *2-fixed*.
23−
24−### Examples
25−
26−```
27−~zod:dojo> :scon(1 2)
28−[2 1]
29−```
30−
31−```
32−~zod:dojo> :_(1 2)
33−[2 1]
34−```
docs/hoon/twig/col-cell/hep-cons.mddeleted−51
@@ -1,51 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 1
4−---
5−
6−# `:cons :- "colhep"`
7−
8−`{$cons p/seed q/seed}`: construct a cell (2-tuple).
9−
10−## Produces
11−
12−The cell of `p` and `q`.
13−
14−## Syntax
15−
16−Regular: *2-fixed*.
17−
18−Irregular: `[a b]` is `:cons(a b)`.
19−
20−Irregular: `[a b c]` is `[a [b c]]`.
21−
22−Irregular: `a^b^c` is `[a b c]`.
23−
24−Irregular: `a+b` is `[%a b]`.
25−
26−Irregular: `` `a`` is `[~ a]`.
27−
28−Irregular: `~[a b]` is `[a b ~]`.
29−
30−Irregular: `[a b c]~` is `[[a b c] ~]`.
31−
32−## Discussion
33−
34−Hoon twigs actually use the same "autocons" pattern as Nock
35−formulas. If you're assembling twigs (which usually only the
36−compiler does), `[a b]` is the same as `[%cons a b]`.
37−
38−## Examples
39−
40−```
41−~zod:dojo> :cons(1 2)
42−[1 2]
43−~zod:dojo> :-(1 2)
44−[1 2]
45−~zod:dojo> 1^2
46−[1 2]
47−~zod:dojo> 1+2
48−[%1 2]
49−~zod:dojo> `1
50−[~ 1]
51−```
docs/hoon/twig/col-cell/ket-conq.mddeleted−44
@@ -1,44 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 3
4−---
5−
6−# `:conq :^ "colket"`
7−
8−`{$conq p/seed q/seed r/seed s/seed}`: construct a quadruple (4-tuple).
9−
10−## Expands to
11−
12−```
13−:cons(p :cons(q :cons(r s)))
14−```
15−
16−```
17−:-(p :-(q :-(r s)))
18−```
19−
20−## Syntax
21−
22−Regular: *4-fixed*.
23−
24−## Examples
25−
26−```
27−/~zod:dojo> :conq(1 2 3 4)
28−[1 2 3 4]
29−/~zod:dojo> :conq 5
30− 6
31− 7
32− 8
33−[5 6 7 8]
34−```
35−
36−```
37−/~zod:dojo> :^(1 2 3 4)
38−[1 2 3 4]
39−/~zod:dojo> :^ 5
40− 6
41− 7
42− 8
43−[5 6 7 8]
44−```
docs/hoon/twig/col-cell/lus-cont.mddeleted−42
@@ -1,42 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 2
4−---
5−
6−# `:cont :+ "collus"`
7−
8−`{$cont p/seed q/seed r/seed}`: construct a triple (3-tuple).
9−
10−## Expands to:
11−
12−```
13−:cons(p :cons(q r))
14−```
15−
16−```
17−:-(p :-(q r))
18−```
19−
20−## Syntax
21−
22−Regular: *3-fixed*.
23−
24−## Examples
25−
26−```
27−/~zod:dojo> :cont 1
28− 2
29− 3
30−[1 2 3]
31−/~zod:dojo> :cont(%a ~ 'b')
32−[%a ~ 'b']
33−```
34−
35−```
36−/~zod:dojo> :+ 1
37− 2
38− 3
39−[1 2 3]
40−/~zod:dojo> :+(%a ~ 'b')
41−[%a ~ 'b']
42−```
docs/hoon/twig/col-cell/sig-conl.mddeleted−68
@@ -1,68 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 5
4−---
5−
6−# `:conl :~ "colsig"`
7−
8−`{$conl p/(list seed)}`: construct a null-terminated list.
9−
10−## Expands to
11−
12−*Pseudocode*, `a`, `b`, `c`, ... as elements of `p`
13−
14−```
15−:cons(a :cons(b :cons(c :cons(... :cons(z ~)))))
16−```
17−
18−### Compiler macro
19−
20−```
21−:loop
22−:ifno p
23− ~
24−:cons i.p
25−:moar(p t.p)
26−```
27−
28−```
29−|-
30−?~ p
31− ~
32−:- i.p
33−$(p t.p)
34−```
35−
36−## Syntax
37−
38−Regular: *running*.
39−
40−## Examples
41−
42−```
43−~zod:dojo> :conl(6 5 3 4 2 1)
44−[6 5 3 4 2 1 ~]
45−~zod:dojo> ~[6 5 3 4 2 1]
46−[6 5 3 4 2 1 ~]
47−~zod:dojo> :conl 5
48− 3
49− 4
50− 2
51− 1
52− ==
53−[5 3 4 2 1 ~]
54−```
55−
56−```
57−~zod:dojo> :~(5 3 4 2 1)
58−[5 3 4 2 1 ~]
59−~zod:dojo> ~[5 3 4 2 1]
60−[5 3 4 2 1 ~]
61−~zod:dojo> :~ 5
62− 3
63− 4
64− 2
65− 1
66− ==
67−[5 3 4 2 1 ~]
68−```
docs/hoon/twig/col-cell/tar-conp.mddeleted−78
@@ -1,78 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 4
4−---
5−
6−# `:conp :* "coltar"`
7−
8−`{$conp p/(list twig)}`: construct an n-tuple.
9−
10−## Expands to
11−
12−*Pseudocode*, `a`, `b`, `c`, ... as elements of `p`
13−
14−```
15−:cons(a :cons(b :cons(c :cons(... z)))))
16−```
17−
18−### Compiler macro
19−
20−```
21−:loop
22−:ifno p
23− !!
24−:ifno t.p
25− i.p
26−:cons i.p
27−:moar(p t.p)
28−```
29−
30−```
31−|-
32−?~ p
33− !!
34−?~ t.p
35− i.p
36−:- i.p
37−$(p t.p)
38−```
39−
40−## Syntax
41−
42−Regular: *running*.
43−
44−## Examples
45−```
46−/~zod:dojo> :conp(5 3 4 1 4 9 0 ~ 'a')
47−[5 3 4 1 4 9 0 ~ 'a']
48−/~zod:dojo> [5 3 4 1 4 9 0 ~ 'a']
49−[5 3 4 1 4 9 0 ~ 'a']
50−/~zod:dojo> :conp 5
51− 3
52− 4
53− 1
54− 4
55− 9
56− 0
57− ~
58− 'a'
59− ==
60−[5 3 4 1 4 9 0 ~ 'a']
61−```
62−```
63−/~zod:dojo> :*(5 3 4 1 4 9 0 ~ 'a')
64−[5 3 4 1 4 9 0 ~ 'a']
65−/~zod:dojo> [5 3 4 1 4 9 0 ~ 'a']
66−[5 3 4 1 4 9 0 ~ 'a']
67−/~zod:dojo> :* 5
68− 3
69− 4
70− 1
71− 4
72− 9
73− 0
74− ~
75− 'a'
76− ==
77−[5 3 4 1 4 9 0 ~ 'a']
78−```
docs/hoon/twig/dot-nock/wut-deep.mddeleted−32
@@ -1,32 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 2
4−---
5−
6−# `:deep .? "dotwut"`
7−
8−`{$deep p/seed}`: test for cell or atom with Nock `3`.
9−
10−## Produces
11−
12−`&`, `%.y`, `0` if `p` is a cell; otherwise `|`, `%.n`, `1`.
13−
14−## Syntax
15−
16−Regular: *1-fixed*.
17−
18−## Examples
19−
20−```
21−~zod:dojo> :deep(~)
22−%.n
23−~zod:dojo> :deep([2 3])
24−%.y
25−```
26−
27−```
28−~zod:dojo> .?(~)
29−%.n
30−~zod:dojo> .?([2 3])
31−%.y
32−```
docs/hoon/twig/ket-cast.mddeleted−17
@@ -1,17 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 9
4−
5−---
6−
7−# Cast, `^` ("ket")
8−
9−`$cast`, `$like`, and `$name` let us adjust spans without
10−violating type constraints.
11−
12−The `nest` algorithm which tests span subtyping is conservative;
13−it never allows invalid nests, it sometimes rejects valid nests.
14−
15−## Twigs
16−
17−<list dataPreview="true" className="runes"></list>
docs/hoon/twig/ket-cast/lus-like.mddeleted−29
@@ -1,29 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 1
4−---
5−
6−# `:like ^+ "ketlus"`
7−
8−`{$like p/seed q/seed}`: typecast by example (seed).
9−
10−## Produces
11−
12−The value of `q` with the span of `p`, if the span of `q` nests
13−within the span of `p`. Otherwise, `nest-fail`.
14−
15−## Syntax
16−
17−Regular: *2-fixed*.
18−
19−## Examples
20−
21−```
22−~zod:dojo> :like('text' %a)
23−'a'
24−```
25−
26−```
27−~zod:dojo> ^+('text' %a)
28−'a'
29−```
docs/hoon/twig/sig-hint/gal-thin.mddeleted−39
@@ -1,39 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 6
4−---
5−
6−# `:thin ~< "siggal"`
7−
8−`{$thin p/$@(term {p/term q/seed}) q/seed}`: raw hint, applied to
9−product.
10−
11−## Expands to
12−
13−`q`.
14−
15−## Syntax
16−
17−Regular: *2-fixed*. For the dynamic form, write `%term.twig`.
18−
19−## Discussion
20−
21−`:thin` is only used for jet hints (`:funk` and `:fast`) at the
22−moment; we are not telling the interpreter something about the
23−computation we're about to perform, but rather about its product.
24−
25−## Examples
26−
27−```
28−~zod:dojo> (make ':thin(%a 42)')
29−[%7 p=[%1 p=42] q=[%10 p=97 q=[%0 p=1]]]
30−~zod:dojo> (make ':thin(%a.+(.) 42)')
31−[%7 p=[%1 p=42] q=[%10 p=[p=97 q=[%4 p=[%0 p=1]]] q=[%0 p=1]]]
32−```
33−
34−```
35−~zod:dojo> (make '~<(%a 42)')
36−[%7 p=[%1 p=42] q=[%10 p=97 q=[%0 p=1]]]
37−~zod:dojo> (make '~<(%a.+(.) 42)')
38−[%7 p=[%1 p=42] q=[%10 p=[p=97 q=[%4 p=[%0 p=1]]] q=[%0 p=1]]]
39−```
docs/hoon/twig/sig-hint/zap-peep.mddeleted−38
@@ -1,38 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 9
4−---
5−
6−# `:peep ~! "sigzap"`
7−
8−`{$peep p/seed q/seed}`: print type on compilation fail.
9−
10−## Expands to
11−
12−`q`.
13−
14−## Convention
15−
16−If compilation of `q` fails, prints the span of `p` in the trace.
17−
18−## Syntax
19−
20−Regular: *2-fixed*.
21−
22−## Examples
23−
24−```
25−~zod:dojo> a
26−! -find.a
27−~zod:dojo> :peep('foo' a)
28−! @t
29−! find.a
30−```
31−
32−```
33−~zod:dojo> a
34−! -find.a
35−~zod:dojo> ~!('foo' a)
36−! @t
37−! find.a
38−```
docs/hoon/twig/tis-flow.mddeleted−34
@@ -1,34 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 4
4−
5−---
6−
7−# Flow, `=` ("tis")
8−
9−Flow twigs change the subject. (Or more precisely, a flow twig
10−compiles at least one of its subtwigs with a different subject.)
11−All non-flow twigs (except cores) pass the subject down unchanged.
12−
13−## Overview
14−
15−The simplest way to change the subject is to compose two twigs,
16−`p` and `q`. Let `x` be `(mint subject p)`, with product span
17−`p.x` and nock formula `q.x`. Let `y` be `(mint p.x q)`. Then
18−their composition is `[p.y [7 q.x q.y]]`.
19−
20−This composition is the `$per` twig. A close relative is `$pin`,
21−which is `$per` over `[p .]`. The new subject is a cell of `p`
22−and the old subject. `$pin` is the simplest Hoon equivalent of
23−"declaring a variable" (introducing new data into the subject).
24−
25−Another way to change the subject is to mutate it. With the
26−`$set` twig, given a wing that resolves to a leg, we can write
27−instead of reading, *installing* a new value at that leg. Of
28−course, we are creating a copy, not modifying the original.
29−
30−There are many flow stems, all small variations on these three.
31−
32−## Twigs
33−
34−<list dataPreview="true" className="runes"></list>
docs/hoon/twig/tis-flow/bar-new.mddeleted−52
@@ -1,52 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 5
4−---
5−
6−# `:new =| "tisbar"`
7−
8−`{$new p/moss q/seed}`: combine a defaulted mold with the subject.
9−
10−## Expands to
11−
12−```
13−:pin(:bunt(p) q)
14−```
15−
16−```
17−=+(*p q)
18−```
19−
20−## Syntax
21−
22−Regular: *2-fixed*.
23−
24−## Discussion
25−
26−`:new` "declares a variable" which is "uninitialized," presumably
27−because you'll set it in a loop or similar.
28−
29−A common mistake is to forget that since `p` is moldy,
30−`:new(foo=@ bar)` is wrong; you mean `:new(foo/@ bar)`, since
31−`foo=@` is `:name(foo @)` (putting a face on a seed) and `foo/@`
32−is `:coat(foo @)` (wrapping a face around a mold).
33−
34−## Examples
35−
36−```
37−~zod:dojo> =foo :gate a/@
38− :new b/@
39− :nip :(add a b c)
40− c=2
41−~zod:dojo> (foo 5)
42−7
43−```
44−
45−```
46−~zod:dojo> =foo |= a/@
47− =| b/@
48− =- :(add a b c)
49− c=2
50−~zod:dojo> (foo 5)
51−7
52−```
docs/hoon/twig/tis-flow/col-fix.mddeleted−42
@@ -1,42 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 9
4−---
5−
6−# `:fix =: "tiscol"`
7−
8−`{$fix p/(list (pair wing seed)) q/seed}`: change multiple legs in the subject.
9−
10−## Expands to
11−
12−```
13−:per(:keep(. p) q)
14−```
15−
16−```
17−=>(%_(. p) q)
18−```
19−
20−## Syntax
21−
22−Regular: *jogging*, then *1-fixed*.
23−
24−## Examples
25−
26−```
27−~zod:dojo> :pin a=[b=1 c=2]
28− :fix c.a 4
29− b.a 3
30− ==
31− a
32−[b=3 c=4]
33−```
34−
35−```
36−~zod:dojo> =+ a=[b=1 c=2]
37− =: c.a 4
38− b.a 3
39− ==
40− a
41−[b=3 c=4]
42−```
docs/hoon/twig/tis-flow/gal-rap.mddeleted−35
@@ -1,35 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 2
4−---
5−
6−# `:rap =< "tisgal"`
7−
8−`{$rap p/seed q/seed}`: compose two twigs, inverted.
9−
10−## Expands to
11−
12−```
13−:per(q p)
14−```
15−
16−```
17−=>(q p)
18−```
19−
20−## Syntax
21−
22−Regular: *2-fixed*.
23−
24−Irregular: `foo:bar` is `:rap(foo bar)`.
25−
26−## Examples
27−
28−```
29−~zod:dojo> :rap(b [a=1 b=2 c=3])
30−2
31−~zod:dojo> b:[a=1 b=2 c=3]
32−2
33−~zod:dojo> [. .]:(add 2 4)
34−[6 6]
35−```
docs/hoon/twig/tis-flow/hep-nip.mddeleted−47
@@ -1,47 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 4
4−---
5−
6−# `:nip =- "tishep"`
7−
8−`{$nip p/seed q/seed}`: combine a new noun with the subject, inverted.
9−
10−## Expands to
11−
12−```
13−:per(:cons(q .) p)
14−```
15−
16−```
17−=>([q .] p)
18−```
19−
20−## Syntax
21−
22−Regular: *2-fixed*.
23−
24−## Discussion
25−
26−`:nip` looks better than `:pin` when the twig you're pinning
27−is much smaller than the twig that uses it.
28−
29−## Examples
30−
31−```
32−~zod:dojo> =foo :gate a/@
33− :pin :name(b 1)
34− :nip :(add a b c)
35− c=2
36−~zod:dojo> (foo 5)
37−8
38−```
39−
40−```
41−~zod:dojo> =foo |= a/@
42− =+ b=1)
43− =- (add a b c)
44− c=2
45−~zod:dojo> (foo 5)
46−8
47−```
docs/hoon/twig/tis-flow/lus-pin.mddeleted−46
@@ -1,46 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 3
4−---
5−
6−# `:pin =+ "tislus"`
7−
8−`{$pin p/seed q/seed}`: combine a new noun with the subject.
9−
10−## Expands to
11−
12−```
13−:per(:cons(p .) q)
14−```
15−
16−```
17−=>([p .] q)
18−```
19−
20−## Syntax
21−
22−Regular: *2-fixed*.
23−
24−## Discussion
25−
26−`:pin` is the simplest way of "declaring a variable."
27−
28−## Examples
29−
30−```
31−~zod:dojo> =foo :gate a/@
32− :pin :name(b 1)
33− :pin :name(c 2)
34− :(add a b c)
35−~zod:dojo> (foo 5)
36−8
37−```
38−
39−```
40−~zod:dojo> =foo |= a/@
41− =+ b=1
42− =+ c=2
43− :(add a b c)
44−~zod:dojo> (foo 5)
45−8
46−```
docs/hoon/twig/tis-flow/sem-rev.mddeleted−43
@@ -1,43 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 7
4−---
5−
6−# `:rev =; "tissem"`
7−
8−`{$rev p/taco q/seed r/seed}`: combine a named and/or typed noun with the
9−subject, inverted.
10−
11−## Expands to
12−
13−```
14−:var(p r q)
15−```
16−
17−```
18−=/(p r q)
19−```
20−
21−## Syntax
22−
23−Regular: *3-fixed*.
24−
25−## Examples
26−
27−```
28−~zod:dojo> =foo :gate a/@
29− :var b 1
30− :rev c/@ :(add a b c)
31− 2
32−~zod:dojo> (foo 5)
33−8
34−```
35−
36−```
37−~zod:dojo> =foo |= a/@
38− =/ b 1
39− =; c/@ :(add a b c)
40− 2
41−~zod:dojo> (foo 5)
42−8
43−```
docs/hoon/twig/tis-flow/sig-tow.mddeleted−50
@@ -1,50 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 12
4−---
5−
6−# `:tow =~ "tissig"`
7−
8−`{$tow p/(list twig)}`: compose many twigs.
9−
10−## Produces
11−
12−The product of the chain composition.
13−
14−## Syntax
15−
16−Regular: *running*.
17−
18−## Examples
19−
20−```
21−~zod:dojo> =foo :new n/@
22− :rap :tow increment
23− increment
24− increment
25− n
26− ==
27− :core
28− ++ increment
29− :loop
30− ..increment(n +(n))
31− --
32−~zod:dojo> foo
33−3
34−```
35−
36−```
37−~zod:dojo> =foo =| n/@
38− =< =~ increment
39− increment
40− increment
41− n
42− ==
43− |%
44− ++ increment
45− |-
46− ..increment(n +(n))
47− --
48−~zod:dojo> foo
49−3
50−```
docs/hoon/twig/wut-test.mddeleted−31
@@ -1,31 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 8
4−---
5−
6−# Test, `?` ("wut")
7−
8−Hoon has the usual branches and logical tests. For pattern
9−matching, it also has a `$fits` twig that tests whether a value
10−matches the icon of a mold. And it has branch inference,
11−learning from `$fits` tests in the condition of `:if` twigs.
12−
13−## Overview
14−
15−All `?` runes expand to `$if` (`?:`) and/or `$fits` (`?=`).
16−
17−If the condition of an `$if` is a `$fits`, *and* the `$fits` is
18−testing a leg of the subject, the compiler specializes the subject
19−span for the branches of the `$if`. Branch inference also works
20−for twigs which expand to `$if`.
21−
22−The test does not have to be a single `$fits`; the compiler can
23−analyze arbitrary boolean logic (`$and`, `$or`, `$not`) with full
24−short-circuiting. Equality tests (`=`) are *not* analyzed.
25−
26−If the compiler detects that the branch is degenerate (only one
27−side is taken), it fails with an error.
28−
29−## Twigs
30−
31−<list dataPreview="true" className="runes"></list>
docs/hoon/twig/wut-test/bar-or.mddeleted−54
@@ -1,54 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 9
4−---
5−
6−# `:or ?| "wutbar"`
7−
8−`{$or p/(list seed)}`: logical or.
9−
10−## Expands to
11−
12−*Pseudocode*, `a`, `b`, `c`, ... as elements of `p`
13−
14−```
15−:if(a & :if(b & :if(c & :if(... :if(z & |)))))
16−```
17−
18−### Compiler macro
19−
20−```
21−:loop
22−:ifno p
23− |
24−:if i.p
25− &
26−:moar(p t.p)
27−```
28−
29−```
30−|-
31−?~ p
32− |
33−?: i.p
34− &
35−$(p t.p)
36−```
37−
38−## Syntax
39−
40−Regular: *running*.
41−
42−Irregular: `|(foo bar baz)` is `?|(foo bar baz)`.
43−
44−## Examples
45−
46−```
47−~zod:dojo> :or(=(6 42) =(42 42))
48−%.y
49−```
50−
51−```
52−~zod:dojo> |(=(6 42) =(42 42))
53−%.y
54−```
docs/hoon/twig/wut-test/dot-lest.mddeleted−57
@@ -1,57 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 2
4−---
5−
6−# `:lest ?. "wutdot"`
7−
8−`{$lest p/seed q/seed r/seed}`: branch on a boolean test, inverted.
9−
10−## Expands to
11−
12−```
13−:if p
14− r
15−q
16−```
17−
18−```
19−?:(p r q)
20−```
21−
22−## Syntax
23−
24−Regular: *3-fixed*.
25−
26−## Discussion
27−
28−As usual with inverted forms, use `:lest` when the positive
29−twig of an `:if` is much heavier than the negative twig.
30−
31−## Examples
32−
33−```
34−~zod:dojo> :lest((gth 1 2) 3 4)
35−3
36−~zod:dojo> :lest(:fits(%a 'a') %not-a %yup)
37−%yup
38−~zod:dojo> :lest %.y
39− 'this false case is less heavy than the true case'
40− :if =(2 3)
41− 'two not equal to 3'
42− 'but see how \'r is much heavier than \'q?'
43−'but see how \'r is much heavier than \'q?'
44−```
45−
46−```
47−~zod:dojo> ?.((gth 1 2) 3 4)
48−3
49−~zod:dojo> ?.(?=(%a 'a') %not-a %yup)
50−%yup
51−~zod:dojo> ?. %.y
52− 'this false case is less heavy than the true case'
53− ?: =(2 3)
54− 'two not equal to 3'
55− 'but see how \'r is much heavier than \'q?'
56−'but see how \'r is much heavier than \'q?'
57−```
docs/hoon/twig/wut-test/lus-deft.mddeleted−79
@@ -1,79 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 13
4−---
5−
6−# `:deft ?+ "wutlus"`
7−
8−`{$case p/wing q/seed r/(list (pair moss seed))}`: switch against
9−a union, with a default.
10−
11−## Expands to
12−
13−*Pseudocode*, `a`, `b`, `c`, ... as elements of `r`
14−
15−```
16−:if :fits(p.a) q.a
17−:if :fits(p.b) q.b
18−:if :fits(p.c) q.c
19−...
20−q
21−```
22−
23−### Compiler macro
24−
25−```
26−:loop
27−:ifno r
28− q
29−:if :fits(p.i.r p)
30− q.i.r
31−:moar(r t.r)
32−```
33−
34−```
35−|-
36−?. r
37− q
38−?: ?=(p.i.r p)
39− q.i.r
40−$(r t.r)
41−```
42−
43−## Syntax
44−
45−Regular: *2-fixed*, then *jogging*.
46−
47−## Discussion
48−
49−An extra case will throw `mint-vain`. A lost case defaults.
50−
51−## Examples
52−
53−```
54−~zod:dojo> =cor :gate vat/?($a $b)
55− :deft vat 240
56− $a 20
57− $b 42
58− ==
59−~zod:dojo> (cor %a)
60−20
61−~zod:dojo> (cor %b)
62−42
63−~zod:dojo> (cor %c)
64−240
65−```
66−
67−```
68−~zod:dojo> =cor |= vat/?($a $b)
69− ?+ vat 240
70− $a 20
71− $b 42
72− ==
73−~zod:dojo> (cor %a)
74−20
75−~zod:dojo> (cor %b)
76−42
77−~zod:dojo> (cor %c)
78−240
79−```
docs/hoon/twig/wut-test/pam-and.mddeleted−54
@@ -1,54 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 8
4−---
5−
6−# `:and ?& "wutpam"`
7−
8−`{$and p/(list seed)}`: logical and.
9−
10−## Expands to
11−
12−*Pseudocode*, `a`, `b`, `c`, ... as elements of `p`
13−
14−```
15−:lest(a | :lest(b | :lest(c | :lest(... :lest(z | &)))))
16−```
17−
18−### Compiler macro
19−
20−```
21−:loop
22−:ifno p
23− &
24−:lest i.p
25− |
26−:moar(p t.p)
27−```
28−
29−```
30−|-
31−?~ p
32− &
33−?. i.p
34− |
35−$(p t.p)
36−```
37−
38−## Syntax
39−
40−Regular: *running*.
41−
42−Irregular: `&(foo bar baz)` is `?&(foo bar baz)`.
43−
44−## Examples
45−
46−```
47−~zod:dojo> :and(=(6 6) =(42 42))
48−%.y
49−```
50−
51−```
52−~zod:dojo> &(=(6 6) =(42 42))
53−%.y
54−```
docs/hoon/twig/wut-test/sig-ifno.mddeleted−44
@@ -1,44 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 3
4−---
5−
6−# `:ifno ?~ "wutsig"`
7−
8−`{$ifno p/wing q/seed r/seed}`: branch on whether a wing
9−of the subject is null.
10−
11−## Expands to
12−
13−```
14−:if :fits($~ p)
15− q
16−r
17−```
18−
19−```
20−?:(?=($~ p) q r)
21−```
22−
23−## Syntax
24−
25−Regular: *3-fixed*.
26−
27−## Discussion
28−
29−It's bad style to use `:ifno` to test for any zero atom. Use it
30−only for a true null, `~`.
31−
32−## Examples
33−
34−```
35−~zod:dojo> =foo ""
36−~zod:dojo> :ifno(foo 1 2)
37−1
38−```
39−
40−```
41−~zod:dojo> =foo ""
42−~zod:dojo> ?~(foo 1 2)
43−1
44−```
docs/hoon/twig/zap-wild/gar-wrap.mddeleted−33
@@ -1,33 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 2
4−---
5−
6−# `:wrap !> "zapgar"`
7−
8−`{$wrap p/seed}`: wrap a noun in its span.
9−
10−## Produces
11−
12−A cell whose tail is `p`, and whose head is the static span of p.
13−
14−## Syntax
15−
16−Regular: *1-fixed*.
17−
18−## Discussion
19−
20−In Hoon, dynamic type is static type compiled at runtime. This
21−span-noun cell is generally called a `vase`.
22−
23−## Examples
24−
25−```
26−~zod:dojo> :wrap(1)
27−[p=#t/@ud q=1]
28−```
29−
30−```
31−~zod:dojo> !>(1)
32−[p=#t/@ud q=1]
33−```
docs/hoon/twig/zap-wild/zap-fail.mddeleted−32
@@ -1,32 +0,0 @@
1−---
2−navhome: /docs/
3−sort: 1
4−---
5−
6−# `:fail !! "zapzap"`
7−
8−`{$fail $~}`: crash.
9−
10−## Produces
11−
12−Nothing. Always crashes, with span `%void`.
13−
14−## Syntax
15−
16−`!!`
17−
18−## Discussion
19−
20−`%void` nests in every other span, so you can stub out anything with `!!`.
21−
22−## Examples
23−
24−```
25−~zod:dojo> :fail
26−! exit
27−```
28−
29−```
30−~zod:dojo> !!
31−! exit
32−```
docs/nock.md+1−1
@@ -7,6 +7,6 @@ title: Nock
7
7
8# Nock
8# Nock
9
9
10−Nock is our nano-VM. If you're into combinators or want to understand the foundation of Urbit, dive in.
10+Nock is our nano-VM. If you want to understand the foundation of Urbit, dive in.
11
11
12<list/>
12<list/>
docs/byte.md → docs/urbyte.mdrenamed

The content is the same.

docs/byte/0.md → docs/urbyte/0.mdrenamed

The content is the same.

docs/byte/1.md → docs/urbyte/1.mdrenamed

The content is the same.

docs/byte/2.md → docs/urbyte/2.mdrenamed+6−7
@@ -143,8 +143,6 @@ which is its address. The root of the tree is `1`. If the
143address of a cell is `n`, the address of its head is `2n` and the
143address of a cell is `n`, the address of its head is `2n` and the
144address of its tail is `2n+1`.
144address of its tail is `2n+1`.
145
145
146−
147−
148A picture might help:
146A picture might help:
149```
147```
150 1
148 1
@@ -365,15 +363,16 @@ from "two or more spaces."
365 @ud
363 @ud
36642
36442
367
365
368−> ? :per a x
366+> ? => a x
369 @ud
367 @ud
37042
36842
371
369
372−> =b :per a :core ++ foo x ++ bar [q.y foo] --
370+> =b => a |% ++ foo x ++ bar [q.y foo] --
373```
371```
374
372
375We're seeing some Hoon regular forms for the first time. `x:a`
373We're seeing some Hoon regular forms for the first time. `x:a`
376−turns out to be an irregular relative of the regular `:per` form.
374+turns out to be an irregular relative of the regular `=>`
375+(["tisgar"](../../hoon/rune/tis/gar)) form.
377
376
378We'll get more into syntax in a later Urbyte. If some of these
377We'll get more into syntax in a later Urbyte. If some of these
379examples seem syntactically a little funky, this isn't usually
378examples seem syntactically a little funky, this isn't usually
@@ -381,8 +380,8 @@ way we'd do them in "real life." We don't normally write cores
381on a single command line. In a file this would be:
380on a single command line. In a file this would be:
382
381
383```
382```
384− :per a
383+ => a
385− :core
384+ |%
386 ++ foo x
385 ++ foo x
387 ++ bar [q.y foo]
386 ++ bar [q.y foo]
388 --
387 --