on master help sign in
Merge pull request #1 from urbit/master
5435bd3Sigilante
glossary/ames.md+5−2
@@ -7,8 +7,11 @@ category = "arvo"
7
7
8**Ames** is the name of the Urbit network and the [vane](../vane) that communicates over it. It's an encrypted peer-to-peer network composed of instances of the [Arvo](../arvo) operating system. Each [galaxy](../galaxy), [star](../star), [planet](../planet), [moon](../moon), and [comet](../comet) communicates over the network utilizing the Ames protocol.
8**Ames** is the name of the Urbit network and the [vane](../vane) that communicates over it. It's an encrypted peer-to-peer network composed of instances of the [Arvo](../arvo) operating system. Each [galaxy](../galaxy), [star](../star), [planet](../planet), [moon](../moon), and [comet](../comet) communicates over the network utilizing the Ames protocol.
9
9
10−Your ship upgrades itself with [OTA updates](../ota-updates) via communication over Ames. The web interface, [Landscape](../landscape), of ships can be accessed by typing `sampel-palnet.arvo.network` into a browser, where `sampel-palnet` is the name of your shape.
10+Your ship upgrades itself with [OTA updates](../ota-updates) via communication over Ames. The web interface, [Landscape](../landscape), of ships can be accessed by typing `sampel-palnet.arvo.network` into a browser, where `sampel-palnet` is the name of your ship.
11−
11+
12+Network continuity occasionally needs to be broken, either at an individual
13+level to fix networking issues or at a network-wide level to update Arvo beyond
14+what OTA updates are capable of doing. These events are called [breaches](../breach).
12### Further Reading
15### Further Reading
13
16
14- [The Ames tutorial](@/docs/tutorials/arvo/ames.md): An in-depth technical guide to the Ames protocol.
17- [The Ames tutorial](@/docs/tutorials/arvo/ames.md): An in-depth technical guide to the Ames protocol.
glossary/arm.mdnew file+14
@@ -0,0 +1,14 @@
1++++
2+title = "Arm"
3+
4+template = "doc.html"
5+[extra]
6+category = "hoon-nock"
7++++
8+
9+An **arm** is a Hoon expression encoded as a noun. You can find them as part of a [core](../core)
10+
11+### Further Reading
12+
13+- [The Hoon Tutorial](@/docs/tutorials/hoon/_index.md): Our guide to learning the Hoon programming language.
14+ - [Lesson 1.7: Arms and Cores](@/docs/tutorials/hoon/arms-and-cores.md): A Hoon Tutorial lesson that discusses cores.
glossary/atom.md+3−1
@@ -7,7 +7,9 @@ category = "hoon-nock"
7
7
8An **atom** is any non-negative integer of any size. The atom is the most basic data type in [Nock](../nock) and [Hoon](../hoon).
8An **atom** is any non-negative integer of any size. The atom is the most basic data type in [Nock](../nock) and [Hoon](../hoon).
9
9
10+A Hoon atom type consists of a Nock atom with two additional pieces of metadata:
11+an _aura_, which is a soft type that declares if an atom is a date, a ship name, a
10−A Hoon atom type consists of a Nock atom with two additional pieces of metadata: an [aura](../aura) and an optional constant. A Hoon atom type is _warm_ or _cold_ based on whether or not the constant exists:
12+number, etc, and an optional constant. A Hoon atom type is _warm_ or _cold_ based on whether or not the constant exists:
11* A Hoon atom type is **warm** if the constant is `~` (null), any atom is in the type.
13* A Hoon atom type is **warm** if the constant is `~` (null), any atom is in the type.
12* A Hoon atom type is **cold** if the constant is `[~ atom]`, its only legal value is atom.
14* A Hoon atom type is **cold** if the constant is `[~ atom]`, its only legal value is atom.
13
15
glossary/battery.mdnew file+14
@@ -0,0 +1,14 @@
1++++
2+title = "Battery"
3+
4+template = "doc.html"
5+[extra]
6+category = "hoon-nock"
7++++
8+
9+A **battery** is a collection of Hoon expressions and the head of a [core](../core).
10+
11+### Further Reading
12+
13+- [The Hoon Tutorial](@/docs/tutorials/hoon/_index.md): Our guide to learning the Hoon programming language.
14+ - [Lesson 1.7: Arms and Cores](@/docs/tutorials/hoon/arms-and-cores.md): A Hoon Tutorial lesson that discusses cores.
glossary/breach.mdnew file+34
@@ -0,0 +1,34 @@
1++++
2+title = "Breach"
3+template = "doc.html"
4+category = "arvo"
5++++
6+
7+Continuity on the [Ames](../ames) network occasionally needs to be broken at
8+this early stage in order to correct a networking error or make major changes to
9+Arvo. These infrequent events are known as
10+**breaches** which either cause an individual ship to forget its network message
11+history, called a **personal breach**, or cause the entire network to forget its
12+history, called a **network breach**.
13+
14+Personal breaches are always initiated by the user, frequently in response to a
15+connectivity error. The easiest way to do this is with [Bridge](../bridge).
16+There are two types of personal breaches: changing private keys, and changing
17+the Urbit ID ownership address. Each one increments the _life_ number of the ship by one, which is
18+an integer that represents how many personal breaches have been performed on
19+that ship. Transferring the ID to a new address will also increase the _rift_
20+number of the ship in addition to the life number.
21+
22+You can check your life and rift number by typing `+keys our`
23+into dojo and pressing Enter.
24+
25+Network breaches happen when a major Arvo revision that cannot be implemented
26+via an [OTA update](../ota-updates) occurs. When this happens, a new binary
27+will need to be downloaded, and your ship's pier needs to be moved to the
28+directory containing the new binary.
29+
30+### Further Reading
31+
32+- [Guide to breaches](@/docs/tutorials/guide-to-breaches.md): A more in-depth
33+ explanation of breaches, including how to perform a personal breach.
34+- [Ship Troubleshooting](@/docs/tutorials/ship-troubleshooting.md): General instructions on getting your ship to work, which includes network connectivity issues.
glossary/chat.md+1−3
@@ -12,12 +12,10 @@ A chat is a named collection of messages created by and hosted in a ship's chat-
12
12
13Chats are subscribed to by some number of ships which are permitted to post and retrieve messages from the chat.
13Chats are subscribed to by some number of ships which are permitted to post and retrieve messages from the chat.
14
14
15−There are four "kinds" of chats, that use different permission modes:
15+There are two "kinds" of chats, that use different permission modes:
16
16
17 * A `channel` is a chat that is publicly readable and writable, with a blacklist for blocking.
17 * A `channel` is a chat that is publicly readable and writable, with a blacklist for blocking.
18 * A `village` is an invite-only chat.
18 * A `village` is an invite-only chat.
19− * A `journal` is publicly readable and privately writable, with a whitelist for authors.
20− * A `mailbox` is readable by its owner and publicly writable, with a blacklist for blocking.
21
19
22### Further Reading
20### Further Reading
23
21
glossary/core.mdnew file+14
@@ -0,0 +1,14 @@
1++++
2+title = "Core"
3+
4+template = "doc.html"
5+[extra]
6+category = "hoon-nock"
7++++
8+
9+A **core** is a cell of a [battery](../battery) and a [payload](../payload). It is a Hoon construct similar in use to Objects in Object Oriented programming languages.
10+
11+### Further Reading
12+
13+- [The Hoon Tutorial](@/docs/tutorials/hoon/_index.md): Our guide to learning the Hoon programming language.
14+ - [Lesson 1.7: Arms and Cores](@/docs/tutorials/hoon/arms-and-cores.md): A Hoon Tutorial lesson that discusses cores.
glossary/dojo.md+2−1
@@ -7,7 +7,8 @@ category = "arvo"
7
7
8The **Dojo** is Urbit's command-line application that processes system commands and returns output. It also runs [Hoon](../hoon) and [Nock](../nock) code, making it a good place to play around with those languages.
8The **Dojo** is Urbit's command-line application that processes system commands and returns output. It also runs [Hoon](../hoon) and [Nock](../nock) code, making it a good place to play around with those languages.
9
9
10+The other default command-line app is [Chat](../chat). To switch between Dojo
10−The other default command-line app is [Chat](../chat). To switch between Dojo and [Chat](../chat). The Dojo is the first thing you encounter after successfully booting your [ship](../ship).
11+and [Chat](../chat) press Ctrl-X. The Dojo is the first thing you encounter after successfully booting your [ship](../ship).
11
12
12### Further Reading
13### Further Reading
13- [Using Your Ship](@/using/operations/using-your-ship.md): The "Shell" section contains instructions on using the Dojo.
14- [Using Your Ship](@/using/operations/using-your-ship.md): The "Shell" section contains instructions on using the Dojo.
glossary/door.mdnew file+14
@@ -0,0 +1,14 @@
1++++
2+title = "Door"
3+
4+template = "doc.html"
5+[extra]
6+category = "hoon-nock"
7++++
8+
9+A **door** is a [core](../core) the payload of which is a cell of sample and context.
10+
11+### Further Reading
12+
13+- [The Hoon Tutorial](@/docs/tutorials/hoon/_index.md): Our guide to learning the Hoon programming language.
14+ - [Lesson 1.8: Doors](@/docs/tutorials/hoon/doors.md): A Hoon Tutorial lesson that discusses doors.
glossary/galaxy.md+2−2
@@ -6,10 +6,10 @@ template = "doc.html"
6category = "arvo"
6category = "arvo"
7+++
7+++
8
8
9−A **galaxy** is can be one of two related things:
9+A **galaxy** can be one of two related things:
10
10
11- A kind of [Azimuth](../azimuth) Urbit identity that sits at the top of the identity hierarchy. Galaxies, in this sense, have the power to issue [stars](../star), meaning that all other kinds of identities ultimate derive from galaxies. Galaxies also form a [Senate](../senate), the governing body of Azimuth. The Senate has the power to update the logic of Azimuth by [majority vote](../voting).
11- A kind of [Azimuth](../azimuth) Urbit identity that sits at the top of the identity hierarchy. Galaxies, in this sense, have the power to issue [stars](../star), meaning that all other kinds of identities ultimate derive from galaxies. Galaxies also form a [Senate](../senate), the governing body of Azimuth. The Senate has the power to update the logic of Azimuth by [majority vote](../voting).
12
12
13- A [ship](../ship) on the Arvo network whose identity is a planet in the former definition. In this sense, galaxies act as infrastructure for the [Arvo](../arvo) network, providing [Ames](../ames)-related services, such as peer-to-peer routing and distributing [over-the-air software updates](../ota-updates). Stars rely on galaxies for these services in the way that planets rely on stars.
13- A [ship](../ship) on the Arvo network whose identity is a planet in the former definition. In this sense, galaxies act as infrastructure for the [Arvo](../arvo) network, providing [Ames](../ames)-related services, such as peer-to-peer routing and distributing [over-the-air software updates](../ota-updates). Stars rely on galaxies for these services in the way that planets rely on stars.
14
14
15−Galaxies are 8-bit, representable by numbers 0 to 255. This means that there are 256 possible galaxies; each of these galaxies is able to issue 256 [stars](../star). Galaxies have one-syllable names like `~mul` or `~lux`.
15+Galaxies are 8-bit, representable by numbers 0 to 255. This means that there are 256 possible galaxies; each of these galaxies is able to issue 255 [stars](../star). Galaxies have one-syllable names like `~mul` or `~lux`.
glossary/gate.mdnew file+14
@@ -0,0 +1,14 @@
1++++
2+title = "Gate"
3+
4+template = "doc.html"
5+[extra]
6+category = "hoon-nock"
7++++
8+
9+A **gate** is [core](../core) with one [arm](../arm) named $. They are often called Hoon Functions because they have many of the same properties of functions from other programming languages.
10+
11+### Further Reading
12+
13+- [The Hoon Tutorial](@/docs/tutorials/hoon/_index.md): Our guide to learning the Hoon programming language.
14+- [Lesson 1.4 Gates](@/docs/tutorials/hoon/gates.md): A Hoon tutorial lesson about gates.
glossary/hdwallet.md+2−2
@@ -8,10 +8,10 @@ category = "azimuth"
8
8
9The **Urbit HD Wallet** (_Hierarchical Deterministic_ Wallet) is a system of related Ethereum addresses that's used to store and manage an Urbit identity. Each of these Ethereum addresses have different powers over the same identity, from setting networking keys for communicating in the [Arvo](../arvo) network to transferring ownership of identities. HD Wallets are created with the [Wallet Generator](../wallet-generator) software.
9The **Urbit HD Wallet** (_Hierarchical Deterministic_ Wallet) is a system of related Ethereum addresses that's used to store and manage an Urbit identity. Each of these Ethereum addresses have different powers over the same identity, from setting networking keys for communicating in the [Arvo](../arvo) network to transferring ownership of identities. HD Wallets are created with the [Wallet Generator](../wallet-generator) software.
10
10
11−The Ethereum address that has full powers over a given Urbit identity, including the ability to transfer ownership of the identity, is called the ownership address. Ethereum addresses with fewer powers – the ability to transfer ownership being notably absent – are known as [proxies](../proxy). This scheme of compartmentalized powers allows wallet holders to only handle less valuable keys when they want to perform operations on an Urbit identity without risking their entire asset.
11+The Ethereum address that has full powers over a given Urbit identity, including the ability to transfer ownership of the identity, is called the ownership address. Ethereum addresses with fewer powers – the ability to transfer ownership being notably absent – are known as [proxies](../proxies). This scheme of compartmentalized powers allows wallet holders to only handle less valuable keys when they want to perform operations on an Urbit identity without risking their entire asset.
12
12
13If a proxy or ownership address is compromised or has its keys lost, it can always be rederived using the master ticket, which is the piece of entropy that was initially used to derive the HD wallet.
13If a proxy or ownership address is compromised or has its keys lost, it can always be rederived using the master ticket, which is the piece of entropy that was initially used to derive the HD wallet.
14
14
15### Further Reading
15### Further Reading
16
16
17−- [The Azimuth concepts page](@/docs/tutorials/concepts/azimuth.md): A more in-depth explanation of Azimuth, including information the HD wallet.
17+- [The Azimuth concepts page](@/docs/tutorials/concepts/azimuth.md): A more in-depth explanation of Azimuth, including information about the HD wallet.
glossary/iris.md+1−1
@@ -8,4 +8,4 @@ category = "arvo"
8
8
9**Iris** is the web-server [vane](../vane) that handles everything HTTP-related on the server side. It is the counterpart to [Eyre](../eyre), which is the client-facing HTTP vane.
9**Iris** is the web-server [vane](../vane) that handles everything HTTP-related on the server side. It is the counterpart to [Eyre](../eyre), which is the client-facing HTTP vane.
10
10
11−Eyre is located at `/home/sys/vane/iris.hoon` within [Arvo](../arvo).
11+Iris is located at `/home/sys/vane/iris.hoon` within [Arvo](../arvo).
glossary/landscape.md+1−1
@@ -6,6 +6,6 @@ template = "doc.html"
6category = "arvo"
6category = "arvo"
7+++
7+++
8
8
9−**Landscape** is a graphical web interface for your [ship](../ship). Right now, Landscape allows for social networking functions, such as to participating in IRC-like chats such as `~dopzod/urbit-help`, subscribing to forum-like pages of other ships called Notebooks, and message other ships directly. It also has weather and clock apps. Landscape is an alternative messaging interface to the command-line app [Chat](../chat).
9+**Landscape** is a graphical web interface for your [ship](../ship). Right now, Landscape allows for social networking functions, such as to participating in IRC-like chats such as `~/~dopzod/urbit-help`, subscribing to forum-like pages of other ships called Notebooks, and message other ships directly. It also has weather and clock apps. Landscape is an alternative messaging interface to the command-line app [Chat](../chat).
10
10
11Landscape can be accessed with a browser via [ship.arvo.network](../shiparvonetwork) or by `localhost:80`. You'll be greeted with a login prompt; type `+code` into your [Dojo](../dojo), and use the output as your password.
11Landscape can be accessed with a browser via [ship.arvo.network](../shiparvonetwork) or by `localhost:80`. You'll be greeted with a login prompt; type `+code` into your [Dojo](../dojo), and use the output as your password.
glossary/payload.mdnew file+14
@@ -0,0 +1,14 @@
1++++
2+title = "Payload"
3+
4+template = "doc.html"
5+[extra]
6+category = "hoon-nock"
7++++
8+
9+A **payload** is the set of data needed to run computations in a [core](../core)
10+
11+### Further Reading
12+
13+- [The Hoon Tutorial](@/docs/tutorials/hoon/_index.md): Our guide to learning the Hoon programming language.
14+ - [Lesson 1.7: Arms and Cores](@/docs/tutorials/hoon/arms-and-cores.md): A Hoon Tutorial lesson that discusses cores.
glossary/shiparvonetwork.md+1−1
@@ -6,4 +6,4 @@ template = "doc.html"
6category = "arvo"
6category = "arvo"
7+++
7+++
8
8
9−**ship.arvo.network** is a way to connect to ships, primarily [galaxies](../galaxy), via HTTP utilizing DNS lookup. For example, the address for `~zod` would be `zod.arvo.network`.
9+**ship.arvo.network** is a way to connect to [ships](../ship) via HTTP utilizing DNS lookup. For example, the address for `~zod` would be `zod.arvo.network`.
glossary/star.md+2−2
@@ -8,10 +8,10 @@ category = "arvo"
8
8
9A **star** is the kind of Urbit identity that sits between the [galaxy](../galaxy) and [planets](../planet) in the identity hierarchy. Stars act as infrastructure for the [Arvo](../arvo) network, providing planets with [Ames](../ames)-related services, such as peer-to-peer routing and distributing [over-the-air software updates](../ota-updates). Stars rely on galaxies for these services in the way that planets rely on stars.
9A **star** is the kind of Urbit identity that sits between the [galaxy](../galaxy) and [planets](../planet) in the identity hierarchy. Stars act as infrastructure for the [Arvo](../arvo) network, providing planets with [Ames](../ames)-related services, such as peer-to-peer routing and distributing [over-the-air software updates](../ota-updates). Stars rely on galaxies for these services in the way that planets rely on stars.
10
10
11−A **star** is can be to one of two related things:
11+A **star** can be one of two related things:
12
12
13- A kind of [Azimuth](../azimuth) Urbit identity that sits between the [galaxy](../galaxy) and [planets](../planet) in the identity hierarchy. Stars, in this sense, have the power to issue [planets](../planet), and are themselves are issued by galaxies.
13- A kind of [Azimuth](../azimuth) Urbit identity that sits between the [galaxy](../galaxy) and [planets](../planet) in the identity hierarchy. Stars, in this sense, have the power to issue [planets](../planet), and are themselves are issued by galaxies.
14
14
15- A [ship](../ship) on the Arvo network whose identity is a star in the former definition. In this sense, stars act as infrastructure for the [Arvo](../arvo) network, providing planets with [Ames](../ames)-related services, such as peer-to-peer routing and distributing [over-the-air software updates](../ota-updates). Stars rely on galaxies for these services in the way that planets rely on stars.
15- A [ship](../ship) on the Arvo network whose identity is a star in the former definition. In this sense, stars act as infrastructure for the [Arvo](../arvo) network, providing planets with [Ames](../ames)-related services, such as peer-to-peer routing and distributing [over-the-air software updates](../ota-updates). Stars rely on galaxies for these services in the way that planets rely on stars.
16
16
17−Stars have addresses that are representable by 16 bits. This means that there are 65,535 possible stars, and each of these stars is able to issue 65,535 planets. Stars have two-syllable names like `~taglux` or `~hallet`.
17+Stars have addresses that are representable by 16 bits. This means that there are 65,280 possible stars, and each of these stars is able to issue 65,535 planets. Stars have two-syllable names like `~taglux` or `~hallet`.
glossary/trap.mdnew file+14
@@ -0,0 +1,14 @@
1++++
2+title = "Trap"
3+
4+template = "doc.html"
5+[extra]
6+category = "hoon-nock"
7++++
8+
9+A **trap** is a [core](../core) with one arm named $ and no sample. They are often used in similar ways to looping structures in other programming languages.
10+
11+### Further Reading
12+
13+- [The Hoon Tutorial](@/docs/tutorials/hoon/_index.md): Our guide to learning the Hoon programming language.
14+ - [Lesson 1.4.1: Walkthrough: Recursion](@/docs/tutorials/hoon/recursion.md): A Hoon Tutorial lesson that uses traps to build recursive functions.
glossary/vane.md+1−1
@@ -13,7 +13,7 @@ A **vane** is an [Arvo](../arvo) kernel module that performs essential system op
13- [Behn](../behn), the timer vane.
13- [Behn](../behn), the timer vane.
14- [Clay](../clay), the filesystem and revision-control vane.
14- [Clay](../clay), the filesystem and revision-control vane.
15- [Dill](../dill), the terminal-driver vane.
15- [Dill](../dill), the terminal-driver vane.
16−- [Eyre](../dill), the HTTP vane.
16+- [Eyre](../eyre), the HTTP vane.
17- [Ford](../ford), the build-system vane.
17- [Ford](../ford), the build-system vane.
18- [Gall](../gall), the application vane.
18- [Gall](../gall), the application vane.
19- [Iris](../iris), the server HTTP vane.
19- [Iris](../iris), the server HTTP vane.
reference/hoon-expressions/irregular.md−1
@@ -254,4 +254,3 @@ See [%sand](@/docs/reference/hoon-expressions/rune/constants.md#warm) for other
254
254
255In our in-house examples throughout our documentation, we use irregular forms instead of regular for the sake of verbosity. But remember with irregular forms: everything is just runes! Like magic. In general, irregular forms (usually) read better, but of course regular forms provide more information about what you're doing by showing you the full rune. Of course, it's up to you, the Hoon programmer, as to whether or not you want to use these.
255In our in-house examples throughout our documentation, we use irregular forms instead of regular for the sake of verbosity. But remember with irregular forms: everything is just runes! Like magic. In general, irregular forms (usually) read better, but of course regular forms provide more information about what you're doing by showing you the full rune. Of course, it's up to you, the Hoon programmer, as to whether or not you want to use these.
256
256
257−##### If we missed any, or if you saw something weird that's not in here, feel free to comment below!
reference/hoon-expressions/rune/bar.md+89−17
@@ -8,13 +8,81 @@ Core expressions produce cores. A core is a cell of `[battery payload]`.
8The `battery` is code, a battery of Nock formulas. The `payload` is the data
8The `battery` is code, a battery of Nock formulas. The `payload` is the data
9needed to run those formulas correctly.
9needed to run those formulas correctly.
10
10
11−Four core runes (`|=`, `|.`, `|-`, and `|*`) produce a
11+Five core runes (`|=`, `|.`, `|-`, `|*`, and `|$`) produce a
12−core with a single arm, named `$`. We can recompute this arm
12+core with a single arm, named `$`. As with all arms, we can recompute `$``
13−with changes, which useful for recursion among other things:
13+with changes, which is useful for recursion among other things.
14
14
15## Runes
15## Runes
16
16
17+### |$ "barbuc"
18+
19+Declares a mold builder wet gate with one or more molds as its
20+sample.
21+
22+##### Syntax
23+
24+Regular:
25+```hoon
26+|$ a=(lest term) b=spec
27+```
28+
29+AST:
30+```hoon
31+[%brbs sample=(lest term) body=spec]
32+```
33+
34+##### Semantics
35+
36+`|$` is used to declare a wet gate mold builder that is polymorphic in its input molds. `a` is a `lest` of `term` used as
37+identifiers for the input molds. `b` is a structure built from elements of `a`.
38+The output of `|$` is a mold builder obtained by
39+substituting the input molds parameterized by `a` into `b`.
40+
41+##### Expands to
42+
43+```hoon
44+|$ [a b]
45+body
46+```
47+becomes
48+```hoon
49+|* [a=$~(* $-(* *)) b=$~(* $-(* *))]
50+^:
51+body
52+```
53+
54+##### Discussion
55+
56+A mold builder is a wet gate from one or more molds to a mold. A mold is a
57+function from nouns to nouns with types that may be partial, is always
58+idempotent, and usually the identity function on the noun itself.
59+
60+`|$` is a restricted form of `|*`. The use of `|$` over `|*` is one of style, as either could
61+be used to make wet gates that are mold builders. The buc in `|$` is a hint that
62+`|$` is closely related to buc runes, and thus `|$` should be used to make mold builders, while `|*` should be used for any other sort of
63+wet gate. Thus, the second argument of `|$` is frequently a buc
64+rune. For further discussion of wet gates, see the entry for [`|*`](#bartar).
65+
66+Like other single-arm cores, the arm for `|$` is named `$` and this can be used to
67+define recursive structures. Note however that Hoon is evaluated eagerly, and so
68+infinite structures are not permitted.
69+
70+Proper style for `|$` is to enclose the first argument with brackets, even if it
71+is only a single term. The interpeter will accept a single term without brackets
72+just fine, but this style is for consistency with the fact that the first argument is a `lest`.
73+
74+##### Examples
75+
76+```
77+~zod:dojo> =foo |$([a b] [b a])
78+
79+~zod:dojo> =bar (foo [@ @tas])
80+
81+~zod:dojo> (bar %cat 3)
82+[%cat 3]
83+```
84+
17−### |_ "barcab"
85+### `|_` "barcab"
18
86
19Produce a **door** (a core with a sample).
87Produce a **door** (a core with a sample).
20
88
@@ -104,7 +172,7 @@ The `ne` door prints a digit in base 10, 16, 32 or 64:
104'c'
172'c'
105```
173```
106
174
107−### |% "barcen"
175+### `|%` "barcen"
108
176
109Produce a core, `[battery payload]`.
177Produce a core, `[battery payload]`.
110
178
@@ -164,7 +232,7 @@ A trivial core:
164101
232101
165```
233```
166
234
167−### |: "barcol"
235+### `|:` "barcol"
168
236
169Produce a gate with a custom sample.
237Produce a gate with a custom sample.
170
238
@@ -212,7 +280,7 @@ This is useful if you want a gate to have a sample of a particular type, but you
21212
28012
213```
281```
214
282
215−### |. "bardot"
283+### `|.` "bardot"
216
284
217Produce a trap (a core with one arm `$`).
285Produce a trap (a core with one arm `$`).
218
286
@@ -230,7 +298,7 @@ AST:
230[%brdt p=hoon]
298[%brdt p=hoon]
231```
299```
232
300
233−Semantics:
301+##### Semantics
234
302
235A `|.` expression produces a core with a single arm, `$`. The core isn't explicitly given a sample. `a` is a Hoon expression that defines the computation of the `$` arm.
303A `|.` expression produces a core with a single arm, `$`. The core isn't explicitly given a sample. `a` is a Hoon expression that defines the computation of the `$` arm.
236
304
@@ -280,7 +348,7 @@ trap, since it's a core with an `$` arm.
280
348
281> `$(...)` expands to `%=($ ...)` (["centis"](/docs/reference/hoon-expressions/rune/cen#centis)).
349> `$(...)` expands to `%=($ ...)` (["centis"](/docs/reference/hoon-expressions/rune/cen#centis)).
282
350
283−### |- "barhep"
351+### `|-` "barhep"
284
352
285Produce a trap (a core with one arm `$`) and evaluate it.
353Produce a trap (a core with one arm `$`) and evaluate it.
286
354
@@ -336,7 +404,7 @@ The classic loop is a decrement:
33641
40441
337```
405```
338
406
339−### |^ "barket"
407+### `|^` "barket"
340
408
341Produce a core whose battery includes a `$` arm and compute the latter.
409Produce a core whose battery includes a `$` arm and compute the latter.
342
410
@@ -395,7 +463,7 @@ A trivial example:
395100
463100
396```
464```
397
465
398−### |~ "barsig"
466+### `|~` "barsig"
399
467
400Produce an iron gate.
468Produce an iron gate.
401
469
@@ -434,7 +502,7 @@ See [this discussion of core variance models](@/docs/reference/hoon-expressions/
434<1|usl {a/@ $~}>
502<1|usl {a/@ $~}>
435```
503```
436
504
437−### |* "bartar"
505+### `|*` "bartar"
438
506
439Produce a wet gate (one-armed core with sample).
507Produce a wet gate (one-armed core with sample).
440
508
@@ -454,7 +522,8 @@ AST:
454
522
455##### Semantics
523##### Semantics
456
524
525+A `|*` expression produces a wet gate. `a` defines the gate's sample, and `b`
457−A `|*` expression produces a wet gate. `a` defines the gate's sample, and `b` is a Hoon expression that determines the output value of the gate.
526+is a Hoon expression that determines the output value of the gate.
458
527
459##### Expands to
528##### Expands to
460
529
@@ -481,6 +550,9 @@ with `$()`.
481
550
482> `$(...)` expands to `%=($ ...)` (["centis"](@/docs/reference/hoon-expressions/rune/cen.md#centis)).
551> `$(...)` expands to `%=($ ...)` (["centis"](@/docs/reference/hoon-expressions/rune/cen.md#centis)).
483
552
553+`|*` can be used to make wet gates that produce structures, but this usage is
554+discouraged in favor of `|$`.
555+
484##### Examples
556##### Examples
485
557
486Wet and dry gates in a nutshell:
558Wet and dry gates in a nutshell:
@@ -500,7 +572,7 @@ Wet and dry gates in a nutshell:
500The dry gate does not preserve the type of `a` and `b`; the wet
572The dry gate does not preserve the type of `a` and `b`; the wet
501gate does.
573gate does.
502
574
503−### |= "bartis"
575+### `|=` "bartis"
504
576
505Produce a gate (a one-armed core with a sample).
577Produce a gate (a one-armed core with a sample).
506
578
@@ -560,7 +632,7 @@ A slightly less trivial gate:
560430
632430
561```
633```
562
634
563−### |@ "barpat"
635+### `|@` "barpat"
564
636
565Produce a 'wet' core `[battery payload]`.
637Produce a 'wet' core `[battery payload]`.
566
638
@@ -593,7 +665,7 @@ A `|@` expression produces a 'wet' core whose payload is the expression's subjec
593
665
594The `|@` rune is just like the `|%` rune except that instead of producing a 'dry' core, it produces a 'wet' one. This allows for type polymorphism of its arms, using 'genericity'. See [Advanced types](@/docs/reference/hoon-expressions/advanced.md).
666The `|@` rune is just like the `|%` rune except that instead of producing a 'dry' core, it produces a 'wet' one. This allows for type polymorphism of its arms, using 'genericity'. See [Advanced types](@/docs/reference/hoon-expressions/advanced.md).
595
667
596−### |? "barwut"
668+### `|?` "barwut"
597
669
598Produce a lead trap.
670Produce a lead trap.
599
671
@@ -633,4 +705,4 @@ See this [discussion of the core variance model](@/docs/reference/hoon-expressio
633
705
634~zod:dojo> => ~ ^+ |?(%a) |.(%b)
706~zod:dojo> => ~ ^+ |?(%a) |.(%b)
635nest-fail
707nest-fail
636−```
708+```
reference/hoon-expressions/rune/buc.md+95−13
@@ -7,9 +7,9 @@ aliases = ["docs/reference/hoon-expressions/rune/buc/"]
7The `$` family of runes is used for defining custom types. Strictly speaking,
7The `$` family of runes is used for defining custom types. Strictly speaking,
8these runes are used to produce 'structures'. A structure is a compile-time
8these runes are used to produce 'structures'. A structure is a compile-time
9value that at runtime can be converted to either an example value (sometimes
9value that at runtime can be converted to either an example value (sometimes
10−called a 'bunt' value) for its corresponding type, or to a 'factory' (sometimes
10+called a 'bunt' value) for its corresponding type, or to a 'mold'. An example
11−called a 'mold'). An example value is used as a placeholder for sample values,
11+value is used as a placeholder for sample values, among other things. A
12−among other things. A factory/mold is used as a data validator.
12+mold is an idempotent function used as a data validator.
13
13
14## Overview
14## Overview
15
15
@@ -52,7 +52,7 @@ Irregular: `*` makes `%noun`, `^` makes `%cell`, `?` makes
52
52
53## Runes
53## Runes
54
54
55−### $_ "buccab"
55+### `$_` "buccab"
56
56
57`[%bscb p=hoon]`: structure that normalizes to an example.
57`[%bscb p=hoon]`: structure that normalizes to an example.
58
58
@@ -88,7 +88,7 @@ and produces its **example** instead.
88[%foobaz %moobaz]
88[%foobaz %moobaz]
89```
89```
90
90
91−### $% "buccen"
91+### `$%` "buccen"
92
92
93`[%bscn p=(list spec)]`: structure which recognizes a union tagged by head atom.
93`[%bscn p=(list spec)]`: structure which recognizes a union tagged by head atom.
94
94
@@ -123,7 +123,7 @@ type default value.
123[%baz p=0]
123[%baz p=0]
124```
124```
125
125
126−### $: "buccol"
126+### `$:` "buccol"
127
127
128`[%bscl p=(list spec)]`: form a cell type.
128`[%bscl p=(list spec)]`: form a cell type.
129
129
@@ -157,7 +157,88 @@ Irregular (structure mode): `[a b c]` is `$:(a b c)`.
157[p=0 q=%$]
157[p=0 q=%$]
158```
158```
159
159
160+
161+### `$<` "bucgal"
162+
163+`[%bsld p=spec q=spec]`: Filters a pre-existing mold to obtain a mold
164+that excludes a particular structure.
165+
166+##### Syntax
167+
168+Regular: **2-fixed**.
169+
170+##### Discussion
171+
172+This can be used to obtain type(s) from a list of types `q` that do not satisfy a
173+requirement given by `p`.
174+
175+##### Examples
176+
177+```
178+~zod:dojo> =foo $%([%bar p=@ud q=@ud] [%baz p=@ud])
179+
180+~zod:dojo> =m $<(%bar foo)
181+
182+~zod:dojo> (m [%bar 2 4])
183+ford: %ride failed to execute:
184+
185+~zod:dojo> (m [%baz 2])
186+[%baz p=2]
187+
188+~zod:dojo> ;;($<(%foo [@tas *]) [%foo 1])
189+ford: %ride failed to execute:
190+
191+~zod:dojo> ;;($<(%foo [@tas *]) [%bar 1])
192+[%bar 1]
193+ ```
194+
195+
196+### `$>` "bucgar"
197+
198+`[%bsbn p=spec q=spec]`: Filters a mold to obtain a new mold
199+matching a particular structure.
200+
201+##### Syntax
202+
203+Regular: **2-fixed**.
204+
205+##### Discussion
206+
207+This can be used to obtain type(s) from a list of types `q` that satisfy a
208+requirement given by `p`.
209+
210+##### Examples
211+
212+Examples with `$%`:
213+```
214+~zod:dojo> =foo $%([%bar p=@ud q=@ud] [%baz p=@ud])
215+
216+~zod:dojo> =m $>(%bar foo)
217+
218+~zod:dojo> (m [%bar 2 4])
219+[%bar p=2 q=4]
220+
221+>~zod:dojo> (m [%baz 2])
222+ford: %ride failed to execute:
223+```
224+
225+Examples with `;;`:
226+```
227+~zod:dojo> ;;([@tas *] [%foo 1])
228+[%foo 1]
229+
230+~zod:dojo> ;;([@tas *] [%bar 1])
231+[%bar 1]
232+
233+~zod:dojo> ;;($>(%foo [@tas *]) [%foo 1])
234+[%foo 1]
235+
236+~zod:dojo> ;;($>(%foo [@tas *]) [%bar 1])
237+ford: %ride failed to execute:
238+ ```
239+
240+
160−### $- "buchep"
241+### `$-` "buchep"
161
242
162`[%bshp p=spec q=spec]`: structure that normalizes to an example gate.
243`[%bshp p=spec q=spec]`: structure that normalizes to an example gate.
163
244
@@ -185,7 +266,8 @@ Since a `$-` reduces to a [`$_`](#buccab), it is not useful for normalizing, jus
185%baz
266%baz
186```
267```
187
268
269+
188−### $^ "bucket"
270+### `$^` "bucket"
189
271
190`[%bskt p=spec q=spec]`: structure which normalizes a union tagged by head depth (cell).
272`[%bskt p=spec q=spec]`: structure which normalizes a union tagged by head depth (cell).
191
273
@@ -219,7 +301,7 @@ Regular: **2-fixed**.
219[%baz p=0]
301[%baz p=0]
220```
302```
221
303
222−### $~ "bucsig"
304+### `$~` "bucsig"
223
305
224`[%bssg p=hoon q=spec]`: define a custom type default value
306`[%bssg p=hoon q=spec]`: define a custom type default value
225
307
@@ -282,7 +364,7 @@ Using `$~`:
282%default-value
364%default-value
283```
365```
284
366
285−### $@ "bucpat"
367+### `$@` "bucpat"
286
368
287`[%bsvt p=spec q=spec]`: structure which normalizes a union tagged by head depth (atom).
369`[%bsvt p=spec q=spec]`: structure which normalizes a union tagged by head depth (atom).
288
370
@@ -319,7 +401,7 @@ Example:
319```
401```
320
402
321
403
322−### $= "buctis"
404+### `$=` "buctis"
323
405
324`[%bsts p=skin q=spec]`: structure which wraps a face around another structure.
406`[%bsts p=skin q=spec]`: structure which wraps a face around another structure.
325
407
@@ -354,7 +436,7 @@ p=%foo
354ford: %ride failed to execute:
436ford: %ride failed to execute:
355```
437```
356
438
357−### $? "bucwut"
439+### `$?` "bucwut"
358
440
359`[%bswt p=(list spec)]`: form a type from a union of other types.
441`[%bswt p=(list spec)]`: form a type from a union of other types.
360
442
@@ -394,4 +476,4 @@ ford: %ride failed to execute:
394
476
395~zod:dojo> $:a
477~zod:dojo> $:a
396%baz
478%baz
397−```
479+```
reference/hoon-expressions/rune/cen.md+10−10
@@ -10,7 +10,7 @@ These runes reduce to the `%=` rune.
10
10
11## Runes
11## Runes
12
12
13−### %_ "cencab"
13+### `%_` "cencab"
14
14
15Resolve a wing with changes, preserving type.
15Resolve a wing with changes, preserving type.
16
16
@@ -73,7 +73,7 @@ See [how wings are resolved](@/docs/reference/hoon-expressions/limb/_index.md).
73! nest-fail
73! nest-fail
74```
74```
75
75
76−### %: "cencol"
76+### `%:` "cencol"
77
77
78Call a gate with many arguments.
78Call a gate with many arguments.
79
79
@@ -127,7 +127,7 @@ When `%:` is used in tall-form syntax, the series of expressions after `p` must
12799
12799
128```
128```
129
129
130−### %. "cendot"
130+### `%.` "cendot"
131
131
132Call a gate (function), inverted.
132Call a gate (function), inverted.
133
133
@@ -168,7 +168,7 @@ The `%.` rune is for evaluating the `$` arm of a gate, i.e., calling a function.
1686
1686
169```
169```
170
170
171−### %- "cenhep" {#cenhep}
171+### `%-` "cenhep" {#cenhep}
172
172
173Call a gate (function).
173Call a gate (function).
174
174
@@ -217,7 +217,7 @@ This rune is for evaluating the `$` arm of a gate, i.e., calling a gate as a fun
2176
2176
218```
218```
219
219
220−### %^ "cenket"
220+### `%^` "cenket"
221
221
222Call gate with triple sample.
222Call gate with triple sample.
223
223
@@ -251,7 +251,7 @@ AST:
2516
2516
252```
252```
253
253
254−### %+ "cenlus"
254+### `%+` "cenlus"
255
255
256Call gate with a cell sample.
256Call gate with a cell sample.
257
257
@@ -288,7 +288,7 @@ A `%+` expression is for calling a gate with a cell sample. `a` is the gate to
2886
2886
289```
289```
290
290
291−### %~ "censig"
291+### `%~` "censig"
292
292
293Evaluate an arm in a door.
293Evaluate an arm in a door.
294
294
@@ -340,7 +340,7 @@ See also [`|_`](@/docs/reference/hoon-expressions/rune/bar.md#barcab).
34020
34020
341```
341```
342
342
343−### %* "centar"
343+### `%*` "centar"
344
344
345Evaluate an expression, then resolve a wing with changes.
345Evaluate an expression, then resolve a wing with changes.
346
346
@@ -403,7 +403,7 @@ A `%*` expression evaluates some arbitrary Hoon expression, `b`, and then resolv
403[a=1 b=7 c=10]
403[a=1 b=7 c=10]
404```
404```
405
405
406−### %= "centis"
406+### `%=` "centis"
407
407
408Resolve a wing with changes.
408Resolve a wing with changes.
409
409
@@ -468,4 +468,4 @@ Here's that again in tall form:
468[p=42 q=6]
468[p=42 q=6]
469~zod:dojo> foo(+3 99)
469~zod:dojo> foo(+3 99)
470[p=5 99]
470[p=5 99]
471−```
471+```
reference/hoon-expressions/rune/col.md+8−8
@@ -8,7 +8,7 @@ The `:` ("col") expressions are used to produce cells, which are pairs of values
8
8
9## Runes
9## Runes
10
10
11−### :_ "colcab"
11+### `:_` "colcab"
12
12
13`[%clcb p=hoon q=hoon]`; construct a cell, inverted.
13`[%clcb p=hoon q=hoon]`; construct a cell, inverted.
14
14
@@ -29,7 +29,7 @@ Regular: **2-fixed**.
29[2 1]
29[2 1]
30```
30```
31
31
32−### :: "colcol"
32+### `::` "colcol"
33
33
34Code comment
34Code comment
35
35
@@ -48,7 +48,7 @@ Code comment
48 :: to the input
48 :: to the input
49```
49```
50
50
51−### :- "colhep"
51+### `:-` "colhep"
52
52
53`[%clhp p=hoon q=hoon]`: construct a cell (2-tuple).
53`[%clhp p=hoon q=hoon]`: construct a cell (2-tuple).
54
54
@@ -96,7 +96,7 @@ compiler does), `[a b]` is the same as `:-(a b)`.
96[~ 1]
96[~ 1]
97```
97```
98
98
99−### :^ "colket"
99+### `:^` "colket"
100
100
101`[%clkt p=hoon q=hoon r=hoon s=hoon]`: construct a quadruple (4-tuple).
101`[%clkt p=hoon q=hoon r=hoon s=hoon]`: construct a quadruple (4-tuple).
102
102
@@ -123,7 +123,7 @@ Regular: **4-fixed**.
123[5 6 7 8]
123[5 6 7 8]
124```
124```
125
125
126−### :+ "collus"
126+### `:+` "collus"
127
127
128
128
129`[%clls p=hoon q=hoon r=hoon]`: construct a triple (3-tuple).
129`[%clls p=hoon q=hoon r=hoon]`: construct a triple (3-tuple).
@@ -150,7 +150,7 @@ Regular: **3-fixed**.
150[%a ~ 'b']
150[%a ~ 'b']
151```
151```
152
152
153−### :~ "colsig"
153+### `:~` "colsig"
154
154
155`[%clsg p=(list hoon)]`: construct a null-terminated list.
155`[%clsg p=(list hoon)]`: construct a null-terminated list.
156
156
@@ -194,7 +194,7 @@ Regular: **running**.
194[5 3 4 2 1 ~]
194[5 3 4 2 1 ~]
195```
195```
196
196
197−### :* "coltar"
197+### `:*` "coltar"
198
198
199`[%cltr p=(list hoon)]`: construct an n-tuple.
199`[%cltr p=(list hoon)]`: construct an n-tuple.
200
200
@@ -242,4 +242,4 @@ Regular: **running**.
242 'a'
242 'a'
243 ==
243 ==
244[5 3 4 1 4 9 0 ~ 'a']
244[5 3 4 1 4 9 0 ~ 'a']
245−```
245+```
reference/hoon-expressions/rune/constants.md+4−4
@@ -45,7 +45,7 @@ We can see the contrast with warm atoms by using the compiler parser function, `
45[%rock p=%ud q=12]
45[%rock p=%ud q=12]
46```
46```
47
47
48−### `:_ "Paths"`
48+### `:_` "Paths"
49
49
50`[%path p=(list (each @ta hoon))]`: path with interpolation.
50`[%path p=(list (each @ta hoon))]`: path with interpolation.
51
51
@@ -74,7 +74,7 @@ Irregular: `/this/is/a/path`.
74~
74~
75```
75```
76
76
77−### `:_ "Strings with Interpolation"`
77+### `:_` "Strings with Interpolation"
78
78
79`[%knit p=(list (each @t hoon))]`: text string with interpolation.
79`[%knit p=(list (each @t hoon))]`: text string with interpolation.
80
80
@@ -122,7 +122,7 @@ String with interpolated prettyprinting:
122"hello, %world."
122"hello, %world."
123```
123```
124
124
125−### `:_ "Warm Atoms"` {#warm}
125+### `:_` "Warm Atoms" {#warm}
126
126
127`[%sand p=term q=@]`; a constant, warm atom.
127`[%sand p=term q=@]`; a constant, warm atom.
128
128
@@ -190,4 +190,4 @@ Irregular. A table of examples:
190```
190```
191
191
192The `@uv` characters are `0-9`, `a-v`. The `@uw` characters are
192The `@uv` characters are `0-9`, `a-v`. The `@uw` characters are
193−`0-9`, `a-z`, `A-Z`, `-` and `~`.
193+`0-9`, `a-z`, `A-Z`, `-` and `~`.
reference/hoon-expressions/rune/dot.md+6−6
@@ -8,7 +8,7 @@ Anything Nock can do, Hoon can do also. These runes are used for carrying out N
8
8
9## Runes
9## Runes
10
10
11−### .^ "dotket"
11+### `.^` "dotket"
12
12
13`[%dtkt p=spec q=hoon]`: load from the Arvo namespace with a fake Nock instruction: 'Nock `12`''.
13`[%dtkt p=spec q=hoon]`: load from the Arvo namespace with a fake Nock instruction: 'Nock `12`''.
14
14
@@ -83,7 +83,7 @@ You can modify the time of the file listing quite simply and ask for a listing f
83
83
84`our` is the value for your ship's name.
84`our` is the value for your ship's name.
85
85
86−### .+ "dotlus"
86+### `.+` "dotlus"
87
87
88`[%dtls p=hoon]`: increment an atom with Nock `4`.
88`[%dtls p=hoon]`: increment an atom with Nock `4`.
89
89
@@ -113,7 +113,7 @@ Irregular: `+(6)` is `.+(6)`.
113nest-fail
113nest-fail
114```
114```
115
115
116−### .* "dottar"
116+### `.*` "dottar"
117
117
118`[%dttr p=hoon q=hoon]`: evaluate with Nock `2`.
118`[%dttr p=hoon q=hoon]`: evaluate with Nock `2`.
119
119
@@ -156,7 +156,7 @@ therefore possible to use Hoon as a typeless language.
1561
1561
157```
157```
158
158
159−### .= "dottis" {#dottis}
159+### `.=` "dottis" {#dottis}
160
160
161`[%dtts p=hoon q=hoon]`: test for equality with Nock `5`.
161`[%dtts p=hoon q=hoon]`: test for equality with Nock `5`.
162
162
@@ -200,7 +200,7 @@ is a common cause of performance bugs.)
200nest-fail
200nest-fail
201```
201```
202
202
203−### .? "dotwut"
203+### `.?` "dotwut"
204
204
205`[%dtwt p=hoon]`: test for cell or atom with Nock `3`.
205`[%dtwt p=hoon]`: test for cell or atom with Nock `3`.
206
206
@@ -220,4 +220,4 @@ Regular: **1-fixed**.
220
220
221> .?([42 43])
221> .?([42 43])
222%.y
222%.y
223−```
223+```
reference/hoon-expressions/rune/ket.md+13−13
@@ -13,7 +13,7 @@ it never allows invalid nests, it sometimes rejects valid nests.
13
13
14## Runes
14## Runes
15
15
16−### ^| "ketbar"
16+### `^|` "ketbar"
17
17
18`[%ktbr p=hoon]`: convert a gold core to an iron core (contravariant).
18`[%ktbr p=hoon]`: convert a gold core to an iron core (contravariant).
19
19
@@ -49,9 +49,9 @@ The prettyprinter shows the core metal (`.` gold, `|` iron):
49<1|gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
49<1|gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
50```
50```
51
51
52−### ^: "ketcol"
52+### `^:` "ketcol"
53
53
54−`[%ktcl p=spec]`: 'factory' gate for type `p`.
54+`[%ktcl p=spec]`: mold gate for type `p`.
55
55
56##### Produces
56##### Produces
57
57
@@ -63,7 +63,7 @@ Regular: **1-fixed**.
63
63
64##### Discussion
64##### Discussion
65
65
66−In older versions of Hoon, a 'mold' was an idempotent gate that was guaranteed to produce a noun of that type. If an input value wasn't of the correct type, the bunt value of that type was returned. (See `^*`.)
66+A mold is an idempotent gate that is guaranteed to produce a noun of that type. If an input value isn't of the correct type, the bunt value of that type is returned. (See `^*`.)
67
67
68`^:` is used to produce a gate that is much like a mold, except that instead of producing a bunt value when the input value is of the wrong type, it crashes.
68`^:` is used to produce a gate that is much like a mold, except that instead of producing a bunt value when the input value is of the wrong type, it crashes.
69
69
@@ -85,7 +85,7 @@ In older versions of Hoon, a 'mold' was an idempotent gate that was guaranteed t
85ford: %ride failed to execute:
85ford: %ride failed to execute:
86```
86```
87
87
88−### ^. "ketdot"
88+### `^.` "ketdot"
89
89
90`[%ktdt p=hoon q=hoon]`: typecast on value produced by passing `q` to `p`.
90`[%ktdt p=hoon q=hoon]`: typecast on value produced by passing `q` to `p`.
91
91
@@ -126,7 +126,7 @@ mint-vain
126~[22 33]
126~[22 33]
127```
127```
128
128
129−### ^- "kethep"
129+### `^-` "kethep"
130
130
131`[%kthp p=spec q=hoon]`: typecast by explicit type label.
131`[%kthp p=spec q=hoon]`: typecast by explicit type label.
132
132
@@ -170,7 +170,7 @@ infinite loop in the compiler).
170[~ ~.a]
170[~ ~.a]
171```
171```
172
172
173−### ^+ "ketlus"
173+### `^+` "ketlus"
174
174
175`[%ktls p=hoon q=hoon]`: typecast by inferred type.
175`[%ktls p=hoon q=hoon]`: typecast by inferred type.
176
176
@@ -189,7 +189,7 @@ Regular: **2-fixed**.
189'a'
189'a'
190```
190```
191
191
192−### ^& "ketpam"
192+### `^&` "ketpam"
193
193
194`[%ktpm p=hoon]`: convert a core to a zinc core (covariant).
194`[%ktpm p=hoon]`: convert a core to a zinc core (covariant).
195
195
@@ -242,7 +242,7 @@ ford: %slim failed:
242ford: %ride failed to compute type:
242ford: %ride failed to compute type:
243```
243```
244
244
245−### ^~ "ketsig"
245+### `^~` "ketsig"
246
246
247`[%ktsg p=hoon]`: fold constant at compile time.
247`[%ktsg p=hoon]`: fold constant at compile time.
248
248
@@ -264,7 +264,7 @@ Regular: **1-fixed**.
264[%1 p=42]
264[%1 p=42]
265```
265```
266
266
267−### ^* "kettar"
267+### `^*` "kettar"
268
268
269`[%kttr p=spec]`: Produce example type value.
269`[%kttr p=spec]`: Produce example type value.
270
270
@@ -315,7 +315,7 @@ Irregular:
315""
315""
316```
316```
317
317
318−### ^= "kettis"
318+### `^=` "kettis"
319
319
320`[%ktts p=skin q=hoon]`: Bind name to a value.
320`[%ktts p=skin q=hoon]`: Bind name to a value.
321
321
@@ -351,7 +351,7 @@ a=1
351[b=1 c=2 d=[x=3 y4]]
351[b=1 c=2 d=[x=3 y4]]
352```
352```
353
353
354−### ^? "ketwut"
354+### `^?` "ketwut"
355
355
356`[%ktwt p=hoon]`: convert any core to a lead core (bivariant).
356`[%ktwt p=hoon]`: convert any core to a lead core (bivariant).
357
357
@@ -384,4 +384,4 @@ The prettyprinter shows the core metal (`.` gold, `?` lead):
384
384
385~zod:dojo> ^?(|=(@ 1))
385~zod:dojo> ^?(|=(@ 1))
386<1?gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
386<1?gcq [@ @n <250.yur 41.wda 374.hzt 100.kzl 1.ypj %151>]>
387−```
387+```
reference/hoon-expressions/rune/lus.md+5−5
@@ -12,7 +12,7 @@ There are various arm runes you can use to produce different kinds of arms. Nor
12
12
13## Runes
13## Runes
14
14
15−### +| "lusbar"
15+### `+|` "lusbar"
16
16
17Chapter label.
17Chapter label.
18
18
@@ -60,7 +60,7 @@ Notice that `p.q` has the label `%numbers`. Contrast with:
60]
60]
61```
61```
62
62
63−### +$ "lusbuc"
63+### `+$` "lusbuc"
64
64
65Produce a structure arm (type definition).
65Produce a structure arm (type definition).
66
66
@@ -98,7 +98,7 @@ nest-fail
98[%.y 22]
98[%.y 22]
99```
99```
100
100
101−### ++ "luslus"
101+### `++` "luslus"
102
102
103Produce a normal arm.
103Produce a normal arm.
104
104
@@ -133,7 +133,7 @@ Any Hoon expression, `q`, may be used to define the arm computation.
13312
13312
134```
134```
135
135
136−### +* "lustar"
136+### `+*` "lustar"
137
137
138
138
139Produce a type constructor arm.
139Produce a type constructor arm.
@@ -173,4 +173,4 @@ nest-fail
173
173
174> `(wrap-flag.c @)`[& 22]
174> `(wrap-flag.c @)`[& 22]
175[%.y 22]
175[%.y 22]
176−```
176+```
reference/hoon-expressions/rune/mic.md+12−10
@@ -9,7 +9,7 @@ Miscellaneous useful macros.
9
9
10## Runes
10## Runes
11
11
12−### ;: "miccol"
12+### `;:` "miccol"
13
13
14`[%mccl p=hoon q=(list hoon)]`: call a binary function as an n-ary function.
14`[%mccl p=hoon q=(list hoon)]`: call a binary function as an n-ary function.
15
15
@@ -59,7 +59,7 @@ Irregular: `:(add a b c)` is `;:(add a b c)`.
5912
5912
60```
60```
61
61
62−### ;+ "miclus"
62+### `;+` "miclus"
63
63
64make a single XML node (Sail)
64make a single XML node (Sail)
65
65
@@ -118,7 +118,7 @@ One interesting thing about Sail is that it allows you to use complex Hoon expre
118]
118]
119```
119```
120
120
121−### ;; "micmic"
121+### `;;` "micmic"
122
122
123`[%mcmc p=spec q=hoon]`: normalize with a mold, asserting fixpoint.
123`[%mcmc p=spec q=hoon]`: normalize with a mold, asserting fixpoint.
124
124
@@ -142,8 +142,10 @@ Fails because of auras:
142
142
143```
143```
144~zod:dojo> ^-(tape ~[97 98 99])
144~zod:dojo> ^-(tape ~[97 98 99])
145+mint-nice
145−! nest-fail
146+nest-fail
146−! exit
147+ford: %slim failed:
148+ford: %ride failed to compute type:
147```
149```
148
150
149Succeeds because molds don't care about auras:
151Succeeds because molds don't care about auras:
@@ -157,10 +159,10 @@ Fails because not a fixpoint:
157
159
158```
160```
159~zod:dojo> ;;(tape [50 51 52])
161~zod:dojo> ;;(tape [50 51 52])
160−! exit
162+ford: %ride failed to execute:
161```
163```
162
164
163−### ;/ "micfas"
165+### `;/` "micfas"
164
166
165`[%mcnt p=hoon]`: tape as XML element.
167`[%mcnt p=hoon]`: tape as XML element.
166
168
@@ -182,7 +184,7 @@ Fails because not a fixpoint:
182[[%~. [%~. "foo] ~] ~]
184[[%~. [%~. "foo] ~] ~]
183```
185```
184
186
185−### ;~ "micsig"
187+### `;~` "micsig"
186
188
187`[%mcsg p=hoon q=(list hoon)]`: glue a pipeline together with a
189`[%mcsg p=hoon q=(list hoon)]`: glue a pipeline together with a
188product-sample adapter.
190product-sample adapter.
@@ -286,7 +288,7 @@ A more complicated example:
286"96acd"
288"96acd"
287```
289```
288
290
289−### ;* "mictar"
291+### `;*` "mictar"
290
292
291make a list of XML nodes from complex Hoon expression (Sail)
293make a list of XML nodes from complex Hoon expression (Sail)
292
294
@@ -338,7 +340,7 @@ If you need a complex Hoon expression to produce a `marl`, use the `;*` rune. O
338]
340]
339```
341```
340
342
341−### ;= "mictis"
343+### `;=` "mictis"
342
344
343make a list of XML nodes (Sail)
345make a list of XML nodes (Sail)
344
346
reference/hoon-expressions/rune/sig.md+13−13
@@ -7,7 +7,7 @@ Runes that use Nock `11` to pass non-semantic info to the interpreter.
7
7
8## Runes
8## Runes
9
9
10−### ~> "siggar"
10+### `~>` "siggar"
11
11
12`[%sggr p=$@(term [p=term q=hoon]) q=hoon]`: raw hint, applied
12`[%sggr p=$@(term [p=term q=hoon]) q=hoon]`: raw hint, applied
13to computation.
13to computation.
@@ -42,7 +42,7 @@ Running the compiler:
42[%10 p=[p=97 q=[%4 p=[%1 p=2]]] q=[%1 p=42]]
42[%10 p=[p=97 q=[%4 p=[%1 p=2]]] q=[%1 p=42]]
43```
43```
44
44
45−### ~| "sigbar"
45+### `~|` "sigbar"
46
46
47
47
48`[%sgbr p=hoon q=hoon]`: tracing printf.
48`[%sgbr p=hoon q=hoon]`: tracing printf.
@@ -72,7 +72,7 @@ ford: build failed
72ford: build failed
72ford: build failed
73```
73```
74
74
75−### ~$ "sigbuc"
75+### `~$` "sigbuc"
76
76
77`[%sgbc p=term q=hoon]`: profiling hit counter.
77`[%sgbc p=term q=hoon]`: profiling hit counter.
78
78
@@ -95,7 +95,7 @@ Regular: **2-fixed**.
953
953
96```
96```
97
97
98−### ~_ "sigcab"
98+### `~_` "sigcab"
99
99
100`[%sgcb p=hoon q=hoon]`: user-formatted tracing printf.
100`[%sgcb p=hoon q=hoon]`: user-formatted tracing printf.
101
101
@@ -124,7 +124,7 @@ ford: build failed
124ford: build failed
124ford: build failed
125```
125```
126
126
127−### ~% "sigcen"
127+### `~%` "sigcen"
128
128
129`[%sgcn p=term q=wing r=(list [term hoon]) s=hoon]`: jet registration.
129`[%sgcn p=term q=wing r=(list [term hoon]) s=hoon]`: jet registration.
130
130
@@ -214,7 +214,7 @@ Here we label the entire `++aesc` core for optimization. You can see the
214jet in `jets/e/aesc.c`.
214jet in `jets/e/aesc.c`.
215
215
216
216
217−### ~< "siggal"
217+### `~<` "siggal"
218
218
219
219
220`[%sggl p=$@(term [p=term q=hoon]) q=hoon]`: raw hint, applied to
220`[%sggl p=$@(term [p=term q=hoon]) q=hoon]`: raw hint, applied to
@@ -244,7 +244,7 @@ rather about its product.
244[%7 p=[%1 p=42] q=[%10 p=[p=97 q=[%4 p=[%0 p=1]]] q=[%0 p=1]]]
244[%7 p=[%1 p=42] q=[%10 p=[p=97 q=[%4 p=[%0 p=1]]] q=[%0 p=1]]]
245```
245```
246
246
247−### ~+ "siglus"
247+### `~+` "siglus"
248
248
249`[%sgls p=hoon]`: cache a computation.
249`[%sgls p=hoon]`: cache a computation.
250
250
@@ -284,7 +284,7 @@ This should work fine:
284573.147.844.013.817.084.101
284573.147.844.013.817.084.101
285```
285```
286
286
287−### ~/ "sigfas"
287+### `~/` "sigfas"
288
288
289`[%sgfs p=term q=hoon]`: jet registration for gate with
289`[%sgfs p=term q=hoon]`: jet registration for gate with
290registered context.
290registered context.
@@ -311,7 +311,7 @@ From the kernel:
311 $(a (dec a), b +(b))
311 $(a (dec a), b +(b))
312```
312```
313
313
314−### ~& "sigpam"
314+### `~&` "sigpam"
315
315
316`[%sgpm p=hoon q=hoon]`: debugging printf.
316`[%sgpm p=hoon q=hoon]`: debugging printf.
317
317
@@ -346,7 +346,7 @@ Regular: **2-fixed**.
346~
346~
347```
347```
348
348
349−### ~= "sigtis"
349+### `~=` "sigtis"
350
350
351`[%sgts p=hoon q=hoon]`: detect duplicate.
351`[%sgts p=hoon q=hoon]`: detect duplicate.
352
352
@@ -378,7 +378,7 @@ This code traverses a tree and replaces all instances of `32` with
378
378
379Without `~=`, it would build a copy of a completely unchanged tree. Sad!
379Without `~=`, it would build a copy of a completely unchanged tree. Sad!
380
380
381−### ~? "sigwut"
381+### `~?` "sigwut"
382
382
383`[%sgwt p=hoon q=hoon r=hoon]`: conditional debug printf.
383`[%sgwt p=hoon q=hoon r=hoon]`: conditional debug printf.
384
384
@@ -416,7 +416,7 @@ Regular: **4-fixed**.
416~
416~
417```
417```
418
418
419−### ~! "sigzap"
419+### `~!` "sigzap"
420
420
421`[%sgzp p=hoon q=hoon]`: print type on compilation fail.
421`[%sgzp p=hoon q=hoon]`: print type on compilation fail.
422
422
@@ -446,4 +446,4 @@ Regular: **2-fixed**.
446 a
446 a
447! @t
447! @t
448! find.a
448! find.a
449−```
449+```
reference/hoon-expressions/rune/terminators.md+3−3
@@ -7,7 +7,7 @@ The `--` and `==` are used as terminators: `--` for core expressions, and `==` f
7
7
8## Runes
8## Runes
9
9
10−### -- "hephep"
10+### `--` "hephep"
11
11
12##### Syntax
12##### Syntax
13
13
@@ -36,7 +36,7 @@ The `|%`, `|_`, and `|^` runes are used to create cores that can have arbitraril
3624
3624
37```
37```
38
38
39−### == "tistis"
39+### `==` "tistis"
40
40
41##### Syntax
41##### Syntax
42
42
@@ -75,4 +75,4 @@ Certain runes are used to create expressions that may include arbitrarily many s
75 e 21
75 e 21
76 ==
76 ==
77[a=13 b=15 c=17 d=19 e=21]
77[a=13 b=15 c=17 d=19 e=21]
78−```
78+```
reference/hoon-expressions/rune/tis.md+18−18
@@ -24,7 +24,7 @@ different situations. Hence the whole family of `=` runes.
24
24
25## Runes
25## Runes
26
26
27−### => "tisgar"
27+### `=>` "tisgar"
28
28
29`[%tsgr p=hoon q=hoon]`: compose two expressions.
29`[%tsgr p=hoon q=hoon]`: compose two expressions.
30
30
@@ -46,7 +46,7 @@ Regular: **2-fixed**.
46[6 6]
46[6 6]
47```
47```
48
48
49−### =| "tisbar"
49+### `=|` "tisbar"
50
50
51
51
52`[%tsbr p=spec q=hoon]`: combine a default type value with the subject.
52`[%tsbr p=spec q=hoon]`: combine a default type value with the subject.
@@ -78,7 +78,7 @@ Speaking more loosely, `=|` usually "declares a variable" which is "uninitialize
787
787
79```
79```
80
80
81−### =: "tiscol"
81+### `=:` "tiscol"
82
82
83`[%tscl p=(list (pair wing hoon)) q=hoon]`: change multiple legs in the subject.
83`[%tscl p=(list (pair wing hoon)) q=hoon]`: change multiple legs in the subject.
84
84
@@ -107,7 +107,7 @@ This rune is like `=.`, but for modifying the values of multiple legs of the sub
107[b=3 c=4]
107[b=3 c=4]
108```
108```
109
109
110−### =, "tiscom"
110+### `=,` "tiscom"
111
111
112`[%tscm p=hoon q=hoon]`: expose namespace
112`[%tscm p=hoon q=hoon]`: expose namespace
113
113
@@ -142,7 +142,7 @@ With a dojo-defined face:
142[2 4]
142[2 4]
143```
143```
144
144
145−### =. "tisdot"
145+### `=.` "tisdot"
146
146
147`[%tsdt p=wing q=hoon r=hoon]`: change one leg in the subject.
147`[%tsdt p=wing q=hoon r=hoon]`: change one leg in the subject.
148
148
@@ -178,7 +178,7 @@ a new subject just like the old one except for a changed value at `p`. Note tha
178nest-fail
178nest-fail
179```
179```
180
180
181−### =- "tishep"
181+### `=-` "tishep"
182
182
183`[%tshp p=hoon q=hoon]`: combine a new noun with the subject, inverted.
183`[%tshp p=hoon q=hoon]`: combine a new noun with the subject, inverted.
184
184
@@ -207,7 +207,7 @@ Regular: **2-fixed**.
2078
2078
208```
208```
209
209
210−### =^ "tisket"
210+### `=^` "tisket"
211
211
212`[%tskt p=skin q=wing r=hoon s=hoon]`: pin the head of a pair; change
212`[%tskt p=skin q=wing r=hoon s=hoon]`: pin the head of a pair; change
213a leg with the tail.
213a leg with the tail.
@@ -247,7 +247,7 @@ random number, so we use `=^`:
247[99 46]
247[99 46]
248```
248```
249
249
250−### =< "tisgal"
250+### `=<` "tisgal"
251
251
252`[%tsgl p=hoon q=hoon]`: compose two expressions, inverted.
252`[%tsgl p=hoon q=hoon]`: compose two expressions, inverted.
253
253
@@ -284,7 +284,7 @@ Irregular: `foo:baz` is `=<(foo baz)`.
284[6 6]
284[6 6]
285```
285```
286
286
287−### =+ "tislus"
287+### `=+` "tislus"
288
288
289
289
290`[%tsls p=hoon q=hoon]`: combine a new noun with the subject.
290`[%tsls p=hoon q=hoon]`: combine a new noun with the subject.
@@ -307,7 +307,7 @@ Loosely speaking, `=+` is the simplest way of "declaring a variable."
307
307
308##### Examples
308##### Examples
309
309
310−### =; "tismic"
310+### `=;` "tismic"
311
311
312`[%tsmc p=skin q=hoon r=hoon]`: combine a named noun with the subject, possibly with type annotation; inverted order.
312`[%tsmc p=skin q=hoon r=hoon]`: combine a named noun with the subject, possibly with type annotation; inverted order.
313
313
@@ -336,7 +336,7 @@ Regular: **3-fixed**.
3368
3368
337```
337```
338
338
339−### =/ "tisfas"
339+### `=/` "tisfas"
340
340
341`[%tsfs p=skin q=hoon r=hoon]`: combine a named noun with the subject, possibly with type annotation.
341`[%tsfs p=skin q=hoon r=hoon]`: combine a named noun with the subject, possibly with type annotation.
342
342
@@ -385,7 +385,7 @@ Regular: **3-fixed**.
3858
3858
386```
386```
387
387
388−### =~ "tissig"
388+### `=~` "tissig"
389
389
390
390
391`[%tssg p=(list hoon)]`: compose many expressions.
391`[%tssg p=(list hoon)]`: compose many expressions.
@@ -421,13 +421,13 @@ Regular: **running**.
4213
4213
422```
422```
423
423
424−### =* "tistar"
424+### `=*` "tistar"
425
425
426−`[%tstr p=term q=hoon r=hoon]`: define an alias.
426+`[%tstr p=term q=hoon r=hoon]`: define a macro.
427
427
428##### Produces
428##### Produces
429
429
430−`r`, compiled with a subject in which `p` is aliased to `q`.
430+`r`, compiled with a subject in which `p` is a macro for `q`.
431
431
432##### Syntax
432##### Syntax
433
433
@@ -435,7 +435,7 @@ Regular: **3-fixed**.
435
435
436##### Discussion
436##### Discussion
437
437
438−The difference between aliasing and pinning is that pinning changes the subject, but for aliasing the subject noun stays the same. The aliased expression, `q`, is recorded in the type information of `p`. `q` is calculated every time you use the `p` alias.
438+The difference between macroing and pinning is that pinning changes the subject, but for macroing the subject noun stays the same. The macro'd expression, `q`, is recorded in the type information of `p`. `q` is calculated every time you use the `p` macro.
439
439
440##### Examples
440##### Examples
441
441
@@ -454,7 +454,7 @@ The difference between aliasing and pinning is that pinning changes the subject,
454[2 2]
454[2 2]
455```
455```
456
456
457−### =? "tiswut"
457+### `=?` "tiswut"
458
458
459`[$tswt p=wing q=hoon r=hoon s=hoon]`: conditionally change one leg in the subject.
459`[$tswt p=wing q=hoon r=hoon s=hoon]`: conditionally change one leg in the subject.
460
460
@@ -487,4 +487,4 @@ the type of `p`.
487
487
488> =?(a =(1 2) 22 a)
488> =?(a =(1 2) 22 a)
48912
48912
490−```
490+```
reference/hoon-expressions/rune/wut.md+14−14
@@ -30,7 +30,7 @@ side is taken), it fails with an error.
30
30
31## Runes
31## Runes
32
32
33−### ?> "wutgar"
33+### `?>` "wutgar"
34
34
35`[%wtgr p=hoon q=hoon]`: positive assertion.
35`[%wtgr p=hoon q=hoon]`: positive assertion.
36
36
@@ -68,7 +68,7 @@ nest-fail
68123
68123
69```
69```
70
70
71−### ?| "wutbar"
71+### `?|` "wutbar"
72
72
73`[%wtbr p=(list hoon)]`: logical OR.
73`[%wtbr p=(list hoon)]`: logical OR.
74
74
@@ -107,7 +107,7 @@ Irregular: `|(foo bar baz)` is `?|(foo bar baz)`.
107%.n
107%.n
108```
108```
109
109
110−### ?: "wutcol" {#wutcol}
110+### `?:` "wutcol" {#wutcol}
111
111
112`[%wtcl p=hoon q=hoon r=hoon]`: branch on a boolean test.
112`[%wtcl p=hoon q=hoon r=hoon]`: branch on a boolean test.
113
113
@@ -155,7 +155,7 @@ Note also that all other branching expressions reduce to `?:`.
1554
1554
156```
156```
157
157
158−### ?. "wutdot"
158+### `?.` "wutdot"
159
159
160`[%wtdt p=hoon q=hoon r=hoon]`: branch on a boolean test, inverted.
160`[%wtdt p=hoon q=hoon r=hoon]`: branch on a boolean test, inverted.
161
161
@@ -192,7 +192,7 @@ As is usual with inverted forms, use `?.` when the yes-case expression is much t
192'but see how \'r is much heavier than \'q?'
192'but see how \'r is much heavier than \'q?'
193```
193```
194
194
195−### ?- "wuthep"
195+### `?-` "wuthep"
196
196
197`[%wthp p=wing q=(list (pair spec value))]`: switch against a union, with no default.
197`[%wthp p=wing q=(list (pair spec value))]`: switch against a union, with no default.
198
198
@@ -254,7 +254,7 @@ will throw `mint-vain`.
254! nest-fail
254! nest-fail
255```
255```
256
256
257−### ?^ "wutket"
257+### `?^` "wutket"
258
258
259`[%wtkt p=wing q=hoon r=hoon]`: branch on whether a wing
259`[%wtkt p=wing q=hoon r=hoon]`: branch on whether a wing
260of the subject is a cell.
260of the subject is a cell.
@@ -287,7 +287,7 @@ The type of the wing, `p`, must not be known to be either an atom or a cell, or
2873
2873
288```
288```
289
289
290−### ?< "wutgal"
290+### `?<` "wutgal"
291
291
292`[%wtgl p=hoon q=hoon]`: negative assertion.
292`[%wtgl p=hoon q=hoon]`: negative assertion.
293
293
@@ -325,7 +325,7 @@ nest-fail
325[12 14]
325[12 14]
326```
326```
327
327
328−### ?+ "wutlus"
328+### `?+` "wutlus"
329
329
330`[%wtls p=wing q=hoon r=(list (pair spec hoon))]`: switch against
330`[%wtls p=wing q=hoon r=(list (pair spec hoon))]`: switch against
331a union, with a default.
331a union, with a default.
@@ -382,7 +382,7 @@ If there is a case that is never taken you'll get a `mint-vain` error.
382240
382240
383```
383```
384
384
385−### ?& "wutpam"
385+### `?&` "wutpam"
386
386
387`[%wtpm p=(list hoon)]`: logical AND.
387`[%wtpm p=(list hoon)]`: logical AND.
388
388
@@ -421,7 +421,7 @@ Irregular: `&(foo bar baz)` is `?&(foo bar baz)`.
421%.n
421%.n
422```
422```
423
423
424−### ?~ "wutsig"
424+### `?~` "wutsig"
425
425
426`[%wtsg p=wing q=hoon r=hoon]`: branch on whether a wing of the subject is null.
426`[%wtsg p=wing q=hoon r=hoon]`: branch on whether a wing of the subject is null.
427
427
@@ -448,7 +448,7 @@ It's bad style to use `?~` to test for any zero atom. Use it only for a true nu
4481
4481
449```
449```
450
450
451−### ?= "wuttis"
451+### `?=` "wuttis"
452
452
453`[%wtts p=spec q=wing]`: test pattern match.
453`[%wtts p=spec q=wing]`: test pattern match.
454
454
@@ -484,7 +484,7 @@ A common error is `find.$`, meaning `p` is not a type.
484%.y
484%.y
485```
485```
486
486
487−### ?@ "wutpat"
487+### `?@` "wutpat"
488
488
489`[%wtpt p=wing q=hoon r=hoon]`: branch on whether a wing of the subject is an atom.
489`[%wtpt p=wing q=hoon r=hoon]`: branch on whether a wing of the subject is an atom.
490
490
@@ -516,7 +516,7 @@ The type of the wing, `p`, must not be known to be either an atom or a cell, or
5164
5164
517```
517```
518
518
519−### ?! "wutzap"
519+### `?!` "wutzap"
520
520
521`[%wtzp p=hoon]`: logical NOT.
521`[%wtzp p=hoon]`: logical NOT.
522
522
@@ -548,4 +548,4 @@ Irregular: `!foo` is `?!(foo)`.
548
548
549~zod:dojo> !(gth 5 6)
549~zod:dojo> !(gth 5 6)
550%.y
550%.y
551−```
551+```
reference/hoon-expressions/rune/zap.md+43−7
@@ -6,7 +6,7 @@ aliases = ["docs/reference/hoon-expressions/rune/zap/"]
6+++
6+++
7## Runes
7## Runes
8
8
9−### !> "zapgar"
9+### `!>` "zapgar"
10
10
11`[%zpgr p=hoon]`: wrap a noun in its type.
11`[%zpgr p=hoon]`: wrap a noun in its type.
12
12
@@ -36,7 +36,43 @@ If you want just the type value, use a 'type spear'. This is `-:!>`, i.e., the
36#t/@ud
36#t/@ud
37```
37```
38
38
39+### `!<` "zapgal"
40+
41+`[%zpld p=spec q=hoon]`
42+
43+Takes a mold and a `vase` and dynamically checks that the type in the `vase`
44+matches the mold.
45+
46+##### Produces
47+
48+The value of `vase` typed with the type of the mold if possible, else a
49+`nest-fail`.
50+
51+##### Syntax
52+
53+Regular: **2-fixed**
54+
55+##### Discussion
56+
57+This is something like a partial inverse to the `!>` rune and can be used to extract
58+a typed value from a `vase`.
59+
60+##### Examples
61+
62+```
63+> !< @ !> ~zod
64+0
65+
66+> !< @p !> 0
67+nest-fail
68+
69+> =m !> 0
70+> =n !> 1
71+> !< [@ @] (slop m n)
72+[0 1]
73+```
74+
39−### !: "zapcol"
75+### `!:` "zapcol"
40
76
41`[%dbug p=hoon]`: turn on stack trace
77`[%dbug p=hoon]`: turn on stack trace
42
78
@@ -68,7 +104,7 @@ ford: %ride failed to execute:
68ford: %ride failed to execute:
104ford: %ride failed to execute:
69```
105```
70
106
71−### !. "zapdot"
107+### `!.` "zapdot"
72
108
73Turn off stack trace for a subexpression `p`
109Turn off stack trace for a subexpression `p`
74
110
@@ -112,7 +148,7 @@ ford: %ride failed to execute:
112ford: %ride failed to execute:
148ford: %ride failed to execute:
113```
149```
114
150
115−### != "zaptis"
151+### `!=` "zaptis"
116
152
117`[%zpts p=hoon]`: make the Nock formula for a Hoon expression.
153`[%zpts p=hoon]`: make the Nock formula for a Hoon expression.
118
154
@@ -153,7 +189,7 @@ Don't confuse the `!=` rune with:
153
189
154The syntax difference is that a test for equality takes two subexpressions, and the `!=` rune only one.
190The syntax difference is that a test for equality takes two subexpressions, and the `!=` rune only one.
155
191
156−### !? "zapwut"
192+### `!?` "zapwut"
157
193
158`[%zpwt p=@ q=hoon]`: restrict Hoon version.
194`[%zpwt p=@ q=hoon]`: restrict Hoon version.
159
195
@@ -179,7 +215,7 @@ Regular: **2-fixed**.
179! exit
215! exit
180```
216```
181
217
182−### !! "zapzap"
218+### `!!` "zapzap"
183
219
184`[%zpzp ~]`: crash.
220`[%zpzp ~]`: crash.
185
221
@@ -200,4 +236,4 @@ Nothing. Always crashes, with type `%void`.
200```
236```
201> !!
237> !!
202ford: build failed
238ford: build failed
203−```
239+```
reference/library/2b.md+17−17
@@ -1046,23 +1046,23 @@ A list
1046
1046
1047Gate to list, with state
1047Gate to list, with state
1048
1048
1049−Accepts a `++list` `a`, a gate `b`, and some state `c`. Produces a list with
1049+Accepts a `++list` `a`, some state `b`, and a gate `c`. `c` is called with
1050−the gate applied to each element of the original list. `b` is called with
1051−a tuple -- the head is an element of `a` and the tail is the state `c`, and
1050+a tuple -- the head is an element of `a` and the tail is the state `b`, and
1052should produce a tuple of the transformed element and the (potentially
1051should produce a tuple of the transformed element and the (potentially
1053−modified) state `c`.
1052+modified) state `b`. Produces a pair where the first element is a list of the
1053+transformed elements of `a`, and the second element is the final value of `b`.
1054
1054
1055#### Accepts
1055#### Accepts
1056
1056
1057`a` is a `++list`.
1057`a` is a `++list`.
1058
1058
1059−`b` is a gate.
1059+`b` is a noun.
1060
1060
1061−`c` is a noun.
1061+`c` is a gate.
1062
1062
1063#### Produces
1063#### Produces
1064
1064
1065−A list.
1065+A pair of a list and a noun.
1066
1066
1067#### Source
1067#### Source
1068
1068
@@ -1082,20 +1082,20 @@ A list.
1082#### Examples
1082#### Examples
1083
1083
1084```
1084```
1085− > %^ spin (limo ~[4 5 6]) :: trivial example -- does nothing with the state
1085+ > %^ spin (limo ~[4 5 6]) :: Trivial example -- does nothing with the state
1086− |=([n=@ a=@] [n a])
1086+ 0
1087− 0
1087+ |=([n=@ a=@] [n a])
1088− ~[4 5 6]
1088+ [p=~[4 5 6] q=0]
1089
1089
1090− > %^ spin (limo ~[4 5 6]) :: `p` as the index and `q` as the list element
1090+ > %^ spin (limo ~[4 5 6]) :: Form a pair with `p` as the index and `q` as the list element
1091+ 0
1091− |=([n=@ a=@] [`(pair)`[a n] +(a)])
1092+ |=([n=@ a=@] [`(pair)`[a n] +(a)])
1092− 0
1093− ~[[p=0 q=4] [p=1 q=5] [p=2 q=6]]
1093+ [p=~[[p=0 q=4] [p=1 q=5] [p=2 q=6]] q=3]
1094
1094
1095 > %^ spin (reap 10 0) :: Create 10 random numbers less than `10`
1095 > %^ spin (reap 10 0) :: Create 10 random numbers less than `10`
1096+ ~(. og eny)
1096 |=([n=@ rng=_og] (rads:rng 10))
1097 |=([n=@ rng=_og] (rads:rng 10))
1097− ~(. og eny)
1098+ [p=~[7 8 6 0 1 5 4 7 9 3] q=<4.rvi {a/@uvJ <51.qyl 129.pdd 41.mac 1.ane $141>}>]
1098− ~[5 5 9 4 1 7 9 9 9 6]
1099```
1099```
1100
1100
1101#### Discussion
1101#### Discussion
reference/library/2i.md+43
@@ -503,6 +503,49 @@ A noun.
503 ! exit
503 ! exit
504```
504```
505
505
506+---
507+### `+-gut:by`
508+
509+Grab value with default
510+
511+Produce the value located at key `b` within map `a`. Use default value `c` if
512+key does not exist.
513+
514+#### Accepts
515+
516+`a` is a map.
517+
518+`b` is a key as a noun.
519+
520+`c` is a noun.
521+
522+#### Produces
523+
524+A noun.
525+
526+#### Source
527+
528+```hoon
529+ ++ gut :: fall value by key
530+ |* [b=* c=*]
531+ (fall (get b) c)
532+
533+```
534+
535+#### Examples
536+
537+```
538+ > =m (my [['a' 1] ['b' 2] ~])
539+ > m
540+ [n=[p='b' q=2] l={[p='a' q=1]} r={}]
541+
542+ > (~(gut by m) 'a' 0)
543+ 1
544+
545+ > (~(gut by m) 'c' 0)
546+ 0
547+```
548+
506---
549---
507### `+-has:by`
550### `+-has:by`
508
551
reference/library/_index.md+2
@@ -614,6 +614,7 @@ Can be navigated [alphabetically](#alphabetical) or [by section](#by-section).
614<a class="tooltip" href='/docs/reference/library/4m/#smyt' title="Render path as tank"><code>++smyt</code></a>
614<a class="tooltip" href='/docs/reference/library/4m/#smyt' title="Render path as tank"><code>++smyt</code></a>
615<a class="tooltip" href='/docs/reference/library/2b/#snag' title="Produce element at specific index (list)"><code>++snag</code></a>
615<a class="tooltip" href='/docs/reference/library/2b/#snag' title="Produce element at specific index (list)"><code>++snag</code></a>
616<a class="tooltip" href='/docs/reference/library/2m/#snag-nl' title="Produce element from list at specific null-terminated noun"><code>++snag:nl</code></a>
616<a class="tooltip" href='/docs/reference/library/2m/#snag-nl' title="Produce element from list at specific null-terminated noun"><code>++snag:nl</code></a>
617+<a class="tooltip" href='/docs/reference/library/2b/#snap' title="Replace item at index"><code>++snap</code></a>
617<a class="tooltip" href='/docs/reference/library/2b/#snoc' title="Append noun to list"><code>++snoc</code></a>
618<a class="tooltip" href='/docs/reference/library/2b/#snoc' title="Append noun to list"><code>++snoc</code></a>
618<a class="tooltip" href='/docs/reference/library/4l/#so' title="Coin parser engine"><code>++so</code></a>
619<a class="tooltip" href='/docs/reference/library/4l/#so' title="Coin parser engine"><code>++so</code></a>
619<a class="tooltip" href='/docs/reference/library/2n/#soft' title="Maybe remold"><code>++soft</code></a>
620<a class="tooltip" href='/docs/reference/library/2n/#soft' title="Maybe remold"><code>++soft</code></a>
@@ -884,6 +885,7 @@ Can be navigated [alphabetically](#alphabetical) or [by section](#by-section).
884<a class="tooltip" href='/docs/reference/library/2b/#skip' title="Produce list of elements failing boolean gate"><code>++skip</code></a>
885<a class="tooltip" href='/docs/reference/library/2b/#skip' title="Produce list of elements failing boolean gate"><code>++skip</code></a>
885<a class="tooltip" href='/docs/reference/library/2b/#slag' title="Produce all elements from index in list"><code>++slag</code></a>
886<a class="tooltip" href='/docs/reference/library/2b/#slag' title="Produce all elements from index in list"><code>++slag</code></a>
886<a class="tooltip" href='/docs/reference/library/2b/#snag' title="Produce element at specific index (list)"><code>++snag</code></a>
887<a class="tooltip" href='/docs/reference/library/2b/#snag' title="Produce element at specific index (list)"><code>++snag</code></a>
888+<a class="tooltip" href='/docs/reference/library/2b/#snap' title="Replace item at index"><code>++snap</code></a>
887<a class="tooltip" href='/docs/reference/library/2b/#snoc' title="Append noun to list"><code>++snoc</code></a>
889<a class="tooltip" href='/docs/reference/library/2b/#snoc' title="Append noun to list"><code>++snoc</code></a>
888<a class="tooltip" href='/docs/reference/library/2b/#sort' title="Quicksort (list)"><code>++sort</code></a>
890<a class="tooltip" href='/docs/reference/library/2b/#sort' title="Quicksort (list)"><code>++sort</code></a>
889<a class="tooltip" href='/docs/reference/library/2b/#spin' title="Gate to list (with state)"><code>++spin</code></a>
891<a class="tooltip" href='/docs/reference/library/2b/#spin' title="Gate to list (with state)"><code>++spin</code></a>
reference/vane-apis/ames.mdnew file+284
@@ -0,0 +1,284 @@
1++++
2+title = "Ames Public API"
3+weight = 1
4+template = "doc.html"
5++++
6+
7+# Ames
8+
9+In this document we describe the public interface for Ames. Namely, we describe
10+each `task` that Ames can be `%pass`ed, and which `gift`(s) Ames can `%give` in return.
11+
12+Some `task`s appear to have more than one arm associated to them, e.g. there are
13+four `+on-hear` arms. We denote this where it occurs, but always refer to the
14+`on-hear:event-core` arm.
15+
16+Ames `task`s can be naturally divided into two categories: messaging tasks and
17+system/lifecycle tasks.
18+
19+## Messaging Tasks
20+
21+### %hear
22+
23+`%hear` handles raw packet receipt. This `task` only ever originates from Unix.
24+It does the initial processing of a packet, namely by passing the raw packet
25+information to `+decode-packet` which deserializes the packet and giving that data and the origin of the
26+packet to `+on-hear-packet`, which begins the transformation of the packet into
27+a new event in the form of a `+event-core`.
28+
29+There are multiple `+on-hear` arms in `ames.hoon`. Here we refer to
30+`on-hear:event-core`, as that is the one called by a `%hear` `task`. The other ones are used
31+primarily for ack and nack processing, or receiving message fragments.
32+
33+#### Accepts
34+
35+```hoon
36+[=lane =blob]
37+```
38+
39+`%hear` takes in a `blob`, which is essentially a large atom (around 1kB or less)
40+that is the raw data of the message, and a `lane`, which is the origin of the
41+message (typically an IP address).
42+
43+#### Returns
44+
45+`%hear` can trigger a number of possible returns. It can trigger the release of
46+zero or more additional packets via `%send` `gift`s. It may also trigger a `%boon`
47+or `%plea` `gift` (collectively referred to as a `%memo` within Ames) to a local vane in the case of a completed message.
48+
49+
50+### %heed
51+
52+A vane can pass Ames a `%heed` `task` to request Ames track a peer's
53+responsiveness. If our `%boon`s to it start backing up locally,
54+Ames will `give` a `%clog` back to the requesting vane containing the
55+unresponsive peer's Urbit address.
56+
57+Stop tracking a peer by sending Ames a
58+`%jilt` `task`.
59+
60+
61+#### Accepts
62+
63+```hoon
64+=ship
65+```
66+
67+The ship to be tracked.
68+
69+#### Returns
70+
71+If the `ship` is indeed being unresponsive, as measured by backed up `%boon`s,
72+Ames will `give` a `%clog` `gift` to the requesting vane containing the
73+unresponsive peer's urbit address.
74+
75+
76+### %hole
77+
78+`%hole` handles packet crash notification. `%hole` works much like `%hear`, in
79+that it passes an incoming raw packet to `+decode-packet` to be deserialized,
80+and then passes that data along with the source of the packet to
81+`+on-hear-packet` along with a `?` set to `%.n` denoting that there is something wrong with
82+the packet.
83+
84+#### Accepts
85+
86+```hoon
87+[=lane =blob]
88+```
89+`%hole` takes in a `blob`, which is essentially a large atom (around 1kB or less)
90+that is the raw data of the message, and a `lane`, which is the origin of the
91+message (typically an IP address).
92+
93+#### Returns
94+
95+Like `%hear`, `%hole` can trigger additional packets in the form of `%send`
96+`gift`s, and may also yield a `%boon` or `%plea` `gift` to a local vane.
97+
98+### %jilt
99+
100+`%jilt` stops tracking a potentially unresponsive peer that was previously being
101+tracked as a result of the `%heed` `task`.
102+
103+There are two `+on-jilt` arms, this `task` utilizes `on-hear:event-core`.
104+
105+#### Accepts
106+
107+```hoon
108+=ship
109+```
110+
111+The `ship` we no longer wish to track.
112+
113+#### Returns
114+
115+This `task` returns no `gift`s.
116+
117+### %plea
118+
119+`%plea` is the `task` used to send messages over Ames. It extends the
120+`%pass`/`%give` semantics across the network. As such, it is the most
121+fundamental `task` in Ames and the primary reason for its existence.
122+
123+Ames also `pass`es a `%plea` `note` to another vane when it receives a message on a
124+"forward flow" from a peer, originally passed from one of the peer's vanes to the
125+peer's Ames.
126+
127+#### Accepts
128+
129+```hoon
130+[=ship =plea]
131+```
132+
133+A `%plea` `task` takes in the `ship` the `plea` is addressed to, and a `$plea`,
134+which is
135+
136+```hoon
137+ +$ plea [vane=@tas =path payload=*]
138+```
139+Here, `vane` is the destination vane on the remote ship, `path` is the internal
140+route on the receiving ship, and `payload` is the semantic message content.
141+
142+#### Returns
143+
144+This `task` returns no `gift`s.
145+
146+
147+## System and Lifecycle Tasks
148+
149+### %born
150+
151+Each time you start your Urbit, the Arvo kernel calls the `%born` task for Ames.
152+
153+#### Accepts
154+
155+`%born` takes no arguments.
156+
157+#### Returns
158+
159+In response to a `%born` `task`, Ames `%give`s Jael a `%turf` `gift`.
160+
161+
162+### %crud
163+
164+`%crud` is called whenever an error involving Ames occurs. It produces a crash
165+report in response.
166+
167+#### Accepts
168+
169+```hoon
170+=error
171+```
172+
173+A `$error` is a `[tag=@tas =tang]`.
174+
175+#### Returns
176+
177+Ames does not `give` a `gift` in response to a `%crud` `task`, but it does
178+`%pass` Dill a `%flog` `task` instructing it to print `error`.
179+
180+
181+## %init
182+
183+`%init` is called a single time during the very first boot process, immediately
184+after the [larval stage](@/docs/tutorials/arvo/arvo.md#larval-stage-core)
185+is completed. This initializes the vane. Jael is initialized first, followed by
186+other vanes such as Ames.
187+
188+In response to receiving the `%init` `task`, Ames subscribes to the information
189+contained by Jael.
190+
191+#### Accepts
192+
193+```hoon
194+our=ship
195+```
196+
197+`%init` takes in the name of our ship, which is a `@p`.
198+
199+#### Returns
200+
201+```hoon
202+ =~ (emit duct %pass /turf %j %turf ~)
203+ (emit duct %pass /private-keys %j %private-keys ~)
204+```
205+
206+`%init` sends two moves that subscribe to `%turf` and `%private-keys` in Jael.
207+
208+
209+### %sift
210+
211+This `task` filters debug output by ship.
212+
213+#### Accepts
214+
215+```hoon
216+ships=(list ship)
217+```
218+
219+The list of ships for which debug output is desired.
220+
221+#### Returns
222+
223+This `task` returns no `gift`s.
224+
225+
226+### %spew
227+
228+Sets verbosity toggles on debug output. These toggles are as follows.
229+
230+* `%snd` - sending packets
231+* `%rcv` - receiving packets
232+* `%odd` - unusual events
233+* `%msg` - message-level events
234+* `%ges` - congestion control
235+* `%for` - packet forwarding
236+* `%rot` - routing attempts
237+
238+Each toggle is a flag set to `%.n` by default.
239+
240+#### Accepts
241+
242+```hoon
243+verbs=(list verb)
244+```
245+
246+`%spew` takes in a `list` of `verb`, which are verbosity flags for Ames.
247+
248+```hoon
249++$ verb ?(%snd %rcv %odd %msg %ges %for %rot)
250+```
251+
252+`%spew` flips each toggle given in `verbs`.
253+
254+#### Returns
255+
256+This `task` returns no `gift`s.
257+
258+
259+### %vega
260+
261+`%vega` is called whenever the kernel is updated. Ames currently does not do
262+anything in response to this.
263+
264+#### Accepts
265+
266+`%vega` takes no arguments.
267+
268+#### Returns
269+
270+This `task` returns no `gift`s.
271+
272+
273+### %wegh
274+
275+This `task` is a request to Ames to produce a memory usage report.
276+
277+#### Accepts
278+
279+This `task` has no arguments.
280+
281+#### Returns
282+
283+In response to this `task,` Ames `%give`s a `%mass` `gift` containing Ames'
284+current memory usage.
reference/vane-apis/behn.mdnew file+248
@@ -0,0 +1,248 @@
1++++
2+title = "Behn"
3+weight = 2
4+template = "doc.html"
5++++
6+
7+# Behn
8+
9+In this document we describe the public interface for Behn. Namely, we describe
10+each `task` that Behn can be `pass`ed, and which `gift`(s) Behn can `give` in return.
11+
12+
13+## Tasks
14+
15+### `%born`
16+
17+Each time you start your Urbit, the Arvo kernel calls the `%born` task for Behn. When
18+called, Behn gets the current time from Unix and updates its list of timers
19+accordingly.
20+
21+#### Accepts
22+
23+```hoon
24+[~]
25+```
26+
27+#### Returns
28+
29+`%born` does not return a `gift`.
30+
31+
32+### `%crud`
33+
34+`%crud` is called whenever an error involving Behn occurs, such as trying to
35+`%wake` a program that has crashed.
36+
37+When called, it checks to see if the set of timers is empty. If so, it prints
38+an error report containing `error`, otherwise it passes the error to `+wake`.
39+
40+#### Accepts
41+
42+```hoon
43+[tag=@tas error=tang]
44+```
45+Here, `tag` is a `@tas` denoting the type of error, and `error` is an error message.
46+
47+#### Returns
48+
49+```hoon
50+[%wake %behn-crud-no-timer tag error]
51+```
52+
53+If the set of timers is nonempty when Behn is `%pass`ed a `%crud` `task`, Behn
54+`%give`s a `%wake` `card` containing the error to the next client in the set of timers.
55+
56+
57+#### Example
58+
59+The most common error that occurs is when Behn tries to `%wake` up a program that has crashed. When this happens
60+the entire event (i.e. sequence of `move`s) that led up to the `%wake` is thrown
61+away, and Vere then causes the kernel to `pass` Behn a `%crud` `task` containing
62+the stack trace.
63+
64+
65+### `%drip`
66+
67+`%drip` allows one to delay a `gift` until a timer set for `now` fires.
68+
69+A Client `%slip`s Behn a `%drip` task wrapping a `gift` to be `give`n to a Target.
70+This launches a sequence of `move`s as written here:
71+
72+```
73+Client -- %slip %drip --> Behn -- %pass %wait --> Behn -- %give %wake --> Behn -- %give %meta --> Target
74+```
75+Here the `%meta` `move` is a wrapper for the `%gift` inside of the initial `%drip` wrapper.
76+
77+`%drip` only handles `gift`s, and can only schedule `gift`s for as soon as
78+possible after the prescribed timer fires.
79+
80+
81+#### Accepts
82+
83+```hoon
84+mov=vase
85+```
86+
87+`%drip` takes in a `%give` `move` in a `vase`.
88+
89+#### Returns
90+
91+In response to a `%drip` `task`, Behn will `%pass` a `%wait` to itself, which
92+then triggers a `%wake` `gift` to itself, which then causes Behn to `%give` a `%meta` `gift` containing
93+the `gift` originally `%give`n to Behn when `%drip` was first called. That makes
94+Behn its own client for `%drip`.
95+
96+#### Example
97+
98+
99+Say an app (the Target) is subscribed to updates from Clay (the Client). If Clay `%give`s
100+updates to the app directly and the app crashes, this may cause Clay to crash as
101+well. If instead Clay `%pass`es Behn a `%drip` `task` wrapping the update
102+`gift`, Behn will set a timer for `now` that, when fired, will cause the update
103+`gift` to be given. If it causes a crash then it will have been in response to
104+the `%drip` move, thereby isolating Clay from the crash. Thus `%drip` acts as a sort of buffer against cascading
105+sequences of crashes.
106+
107+
108+
109+### `%huck`
110+
111+Immediately gives back an input move.
112+
113+#### Accepts
114+
115+```hoon
116+mov=vase
117+```
118+
119+Behn takes in a `move` contained in a `vase`.
120+
121+#### Returns
122+
123+```hoon
124+[%give %meta mov]
125+```
126+
127+Behn returns the input `move` as a `%meta` `gift`.
128+
129+
130+
131+### `%rest`
132+
133+Cancels a timer that was previously set.
134+
135+Behn takes in a `@da` and cancels the timer at that time if it exists, then
136+adjusts the next wakeup call from Unix if necessary.
137+
138+#### Task
139+
140+```hoon
141+@da
142+```
143+
144+
145+#### Gift
146+
147+This `task` returns no `gift`s.
148+
149+
150+
151+### `%trim`
152+
153+This `task` is sent by the interpreter in order to free up memory.
154+ This `task` is empty for Behn, since it is not a good idea to forget your timers.
155+
156+#### Accepts
157+
158+This `task` has no arguments.
159+
160+#### Returns
161+
162+This task returns nothing.
163+
164+### `%vega`
165+
166+This `task` informs the vane that the kernel has been upgraded. Behn does not do
167+anything in response to this.
168+
169+#### Accepts
170+
171+This `task` has no arguments.
172+
173+#### Returns
174+
175+This `task` returns nothing.
176+
177+
178+
179+### `%wait`
180+
181+This `task` takes in a `@da` which Behn then adds to `timers.state`, the list of timers.
182+
183+#### Accepts
184+
185+```hoon
186+@da
187+```
188+
189+#### Returns
190+
191+This `task` returns a `%wake` `gift` once the timer has fired.
192+
193+
194+### `%wake`
195+
196+This `task` is sent by the kernel when the Unix timer tells the kernel that it
197+is time for Behn to wake up. This is often caused by a `%doze` `gift` that
198+Behn originally sent to the kernel that is then forwarded to Unix, which is
199+where the real timekeeping occurs.
200+
201+Upon receiving this `task`, Behn processes the elapsed timer and then sets
202+`:next-wake`.
203+
204+`%wake` is also a `gift` that Behn can `%give`. This is done to inform other
205+vanes or apps that a timer has expired, and may include an error message.
206+
207+#### Accepts
208+
209+As a `task`, `%wake` takes in `~`.
210+
211+As a `gift`, `%wake` may include an error message.
212+
213+```hoon
214+error=(unit tang)
215+```
216+
217+
218+#### Returns
219+
220+In response to receiving this `task`, Behn may `%give` a `%doze` `gift`
221+containing the `@da` of the next timer to elapse. Behn may also `%give` a
222+`%wake` `gift` to itself.
223+
224+
225+
226+### `%wegh`
227+
228+This `task` asks Behn to product a memory usage report.
229+
230+#### Accepts
231+
232+This `task` has no arguments.
233+
234+#### Returns
235+
236+```hoon
237+:_ state :_ ~
238+ :^ duct %give %mass
239+ :+ %behn %|
240+ :~ timers+&+timers.state
241+ dot+&+state
242+```
243+
244+When Behn is `%pass`ed this `task`, it will `%give` a `%mass` `gift` in response
245+containing Behn's current memory usage.
246+
247+
248+
reference/vane-apis/dill.mdnew file+368
@@ -0,0 +1,368 @@
1++++
2+title = "Dill"
3+weight = 3
4+template = "doc.html"
5++++
6+
7+# Dill
8+
9+In this document we describe the public interface for Dill. Namely, we describe
10+each `task` that Dill can be `pass`ed, and which `gift`(s) Dill can `give` in return.
11+
12+Dill is unique among vanes since it is technically the first vane to be booted (though we
13+regard Jael as the "true" first vane). As a result, there are four `task`s in
14+`task:able:dill` for which Dill acts only as a middleman that passes the `task`s
15+directly to the Arvo kernel. Thus we have split this document into a [Dill
16+tasks](#dill-tasks) section and an [Arvo tasks](#arvo-tasks) section.
17+
18+## Dill Tasks
19+
20+
21+### `%belt`
22+
23+Every keystroke entered into the console triggers a `%belt` `task` for Dill which contains information about the keystroke, such as which key was pressed
24+and from which terminal.
25+
26+#### Accepts
27+
28+`%belt` `task`s come in a number of different types, corresponding to different
29+keystrokes. You can find this list in `+dill-belt` in `zuse.hoon`.
30+
31+```hoon
32+++ dill-belt :: new belt
33+ $% {$aro p/?($d $l $r $u)} :: arrow key
34+ {$bac ~} :: true backspace
35+ {$cru p/@tas q/(list tank)} :: echo error
36+ {$ctl p/@} :: control-key
37+ {$del ~} :: true delete
38+ {$hey ~} :: refresh
39+ {$met p/@} :: meta-key
40+ {$ret ~} :: return
41+ {$rez p/@ud q/@ud} :: resize, cols, rows
42+ {$txt p/(list @c)} :: utf32 text
43+ {$yow p/gill:gall} :: connect to app
44+ == ::
45+```
46+
47+#### Returns
48+
49+Dill returns no `gift` in response to a `%belt` `task`.
50+
51+
52+### `%blew`
53+
54+This `task` is called whenever the terminal emulator is resized, so that Dill can adjust
55+the text output to fit the new window size.
56+
57+#### Accepts
58+
59+```hoon
60+[p=@ud q=@ud]
61+```
62+
63+`p` is the number of columns and `q` is the number of rows.
64+
65+#### Returns
66+
67+Dill returns no `gift` in response to a `%blew` `task`.
68+
69+
70+### `%boot`
71+
72+This `task` is used only once, when Arvo first enters the [adult
73+stage](@/docs/tutorials/arvo/arvo.md#structural-interface-core). Dill is
74+technically the first vane to be activated, via the `%boot` `task`, which then
75+send Jael (considered the the "true" first vane) an `%init` `task`, which then goes on to
76+call `%init` `task`s for other vanes (including Dill).
77+
78+#### Accepts
79+
80+`%boot` takes an argument that is either `%dawn` or `%fake`. `%dawn` is the one
81+used in any typical scenario and activates the ordinary vane initialization
82+process outlined above, while `%fake` is a debugging tool.
83+
84+#### Returns
85+
86+`%boot` does not return a `gift`.
87+
88+
89+
90+### `%crud`
91+
92+This `task` is used by Dill to produce error reports. It prints the received
93+error message(s) (a `(list tank)`) to the terminal. The level of detail of the
94+error message is set by `$log-level`, which is either `%hush`, `%soft`, or `%loud`.
95+
96+#### Accepts
97+
98+```hoon
99+[err=@tas tac=(list tank)]
100+```
101+
102+`err` is the type of error and `tac` is the associated error message.
103+
104+#### Returns
105+
106+`%crud` does not return a `gift`.
107+
108+
109+### `%flog`
110+
111+A `%flog` `task` is a wrapper over a `task` sent by another vane. Dill removes the wrapper
112+and sends the bare `task` to itself over the default `duct`.
113+
114+#### Accepts
115+
116+`%flog` `task`s can take any valid Dill `task` as an argument.
117+
118+#### Returns
119+
120+`%flog` never returns a `gift` on its own, but the wrapped `task` might.
121+
122+#### Example
123+
124+`%crud` `task`s from other vanes are typically passed to Dill wrapped in a
125+`%flog` `task` to print errors to the terminal.
126+
127+
128+
129+### `%flow`
130+
131+This `task` is not used.
132+
133+
134+### `%hail`
135+
136+`%hail` refreshes the terminal by sending an empty message to the default duct
137+for Dill,
138+causing the terminal to redraw itself (?)
139+
140+#### Accepts
141+
142+```hoon
143+[ ~ ]
144+```
145+
146+#### Returns
147+
148+`%hail` returns no `gift`s.
149+
150+
151+### `%heft`
152+
153+`%heft` causes Dill to `pass` a `%wegh` `task` to all other vanes (but not to
154+itself), thus obtaining a complete digest of Arvo's memory usage.
155+
156+#### Accepts
157+
158+```hoon
159+[ ~ ]
160+```
161+
162+#### Returns
163+
164+`%heft` does not directly return any `gift`s, but each `%wegh` `task` sent will
165+return a `%mass` `gift`.
166+
167+
168+### `%hook`
169+
170+This task is not used.
171+
172+
173+### `%harm`
174+
175+This `task` is not used.
176+
177+
178+### `%init`
179+
180+This `task` is called only once, when Arvo first enters the [adult
181+stage](@/docs/tutorials/arvo/arvo.md#structural-interface-core). It performs
182+initial setup for Dill, such as setting the width of the console.
183+
184+Note that this is not actually the first `task` passed to Dill - see [%boot](#%boot).
185+
186+#### Accepts
187+
188+`%init` takes no arguments.
189+
190+#### Returns
191+
192+`%init` returns no `gift`s.
193+
194+
195+### `%knob`
196+
197+`%knob` sets the verbosity level for each error tag.
198+
199+#### Accepts
200+
201+```hoon
202+[tag=@tas level=log-level]
203+```
204+
205+`tag` is the error tag. `level` is the verbosity, set to either `%hush`,
206+`%soft`, or `%loud`.
207+
208+#### Returns
209+
210+`%knob` does not return a gift.
211+
212+
213+
214+
215+### `%noop`
216+
217+`%noop` does nothing - it stands for "no operation".
218+
219+#### Accepts
220+
221+```hoon
222+[ ~ ]
223+```
224+
225+#### Returns
226+
227+This `task`, predictably, returns nothing.
228+
229+#### Example
230+
231+This can be useful if a shell command requires a Dill `task` but you don't want
232+Dill to do anything.
233+
234+
235+
236+### `%talk`
237+
238+This `task` is not used.
239+
240+### `%text`
241+
242+This `task` prints a `tape` to the dojo by first converting it from a UTF8
243+`tape` to a `list` of UTF32 codepoints (`@c`'s) and then recursively popping off a character from the
244+`tape` and sending it to to Unix to be printed into the terminal via a `%blit` event.
245+
246+#### Accepts
247+
248+```hoon
249+[p=tape]
250+```
251+
252+#### Returns
253+
254+This `task` returns zero or more `%blit` `gift`s, each containing a .
255+
256+
257+### `%trim`
258+
259+`%trim` is a common vane `task` used to reduce memory usage. However, it does
260+nothing for Dill.
261+
262+#### Accepts
263+
264+```hoon
265+[p=@ud]
266+```
267+
268+This is a common parameter for `%trim` `task`s across all vanes but does nothing
269+for Dill.
270+
271+#### Returns
272+
273+This `task` returns no `gift`s.
274+
275+
276+
277+### `%vega`
278+
279+This is a common vane `task` used to inform the vane that the kernel has been
280+upgraded. Dill does not do anything in response to this.
281+
282+#### Accepts
283+
284+```hoon
285+[ ~ ]
286+```
287+
288+#### Returns
289+
290+This `task` returns no `gift`s.
291+
292+
293+
294+## Arvo tasks
295+
296+These `task`s live in `task:able:dill` but are passed directly to the Arvo
297+kernel for processing.
298+
299+### `%lyra`
300+
301+This `task` updates the kernel.
302+
303+#### Accepts
304+
305+```hoon
306+[p=@t q=@t]
307+```
308+
309+`p` is the contents of the new `hoon.hoon` and `q` is the contents of the new `arvo.hoon`.
310+
311+#### Returns
312+
313+This `task` returns no `gift`s.
314+
315+
316+### `%pack`
317+
318+This `task` defragments and deduplicates Arvo's memory. This is ultimately
319+performed by the interpreter so you won't find the code in `arvo.hoon` but
320+rather under `c3__pack` in `urbit/worker/main.c`.
321+
322+#### Accepts
323+
324+```hoon
325+[ ~ ]
326+```
327+
328+#### Returns
329+
330+This `task` returns no `gift`s.
331+
332+
333+### `%veer`
334+
335+This `task` is used to install `zuse` and vanes. It is handled by `+veer` in
336+`arvo.hoon`.
337+
338+#### Accepts
339+
340+```hoon
341+[p=@ta q=path r=@t]
342+```
343+
344+`p` is the vane letter, `q` is the formal `path` to the
345+vane, and `r` is the source code for the vane. The vane letter is `%` followed
346+by the first letter of the vane in lowercase, such as `%d` for Dill. `p=%$` in
347+the case of `zuse`.
348+
349+#### Returns
350+
351+This `task` returns no `gift`s.
352+
353+
354+### `%verb`
355+
356+This `task` toggles verbose mode for all of Arvo, which is located here since
357+Dill is the vane that prints errors. To be precise, `%verb` toggles the laconic
358+bit `lac` in the [Arvo state](@/docs/tutorials/arvo/arvo.md#the-state).
359+
360+#### Accepts
361+
362+```hoon
363+[ ~ ]
364+```
365+
366+#### Returns
367+
368+This `task` returns no `gift`s.
reference/vane-apis/gall.md+10−4
@@ -84,7 +84,7 @@ exposes a scry namespace to inspect everyone's number.
84 :: Increment local counter and send new counter to subscribers
84 :: Increment local counter and send new counter to subscribers
85 ::
85 ::
86 [%increment ~]
86 [%increment ~]
87− :- [%give %fact `/local %atom !>(+(local))]~
87+ :- [%give %fact ~[/local] %atom !>(+(local))]~
88 this(local +(local))
88 this(local +(local))
89 ::
89 ::
90 :: Send remote %increment poke
90 :: Send remote %increment poke
@@ -412,7 +412,7 @@ List of cards and new agent.
412 :: Increment local counter and send new counter to subscribers
412 :: Increment local counter and send new counter to subscribers
413 ::
413 ::
414 [%increment ~]
414 [%increment ~]
415− :- [%give %fact `/local %atom !>(+(local))]~
415+ :- [%give %fact ~[/local] %atom !>(+(local))]~
416 this(local +(local))
416 this(local +(local))
417 ::
417 ::
418 :: Send remote %increment poke
418 :: Send remote %increment poke
@@ -819,10 +819,10 @@ subscription content for all subscribers on a given path.
819#### Structure
819#### Structure
820
820
821```hoon
821```hoon
822−[%fact (unit path) =cage]
822+[%fact (list path) =cage]
823```
823```
824
824
825−`(unit path)` is the path of the subscription being updated. If no path is
825+`(list path)` is a list of the paths to send the update on. If no path is
826 given, then the update is only given to the program that instigated the
826 given, then the update is only given to the program that instigated the
827 request. Typical use of this mode is in `+on-watch` to give an initial update
827 request. Typical use of this mode is in `+on-watch` to give an initial update
828 to a new subscriber to get them up to date.
828 to a new subscriber to get them up to date.
@@ -836,6 +836,12 @@ subscription content for all subscribers on a given path.
836::
836::
837:: Gives current local state to new subscribers.
837:: Gives current local state to new subscribers.
838[%give %fact ~ %atom !>(local.sta)]
838[%give %fact ~ %atom !>(local.sta)]
839+
840+
841+:: From ++on-poke in reference agent
842+::
843+:: Gives incremented local state to any subscribers on /local
844+[%give %fact ~[/local] %atom !>(+(local))]
839```
845```
840
846
841### `%kick`
847### `%kick`
reference/vane-apis/iris.mdnew file+193
@@ -0,0 +1,193 @@
1++++
2+title = "Iris Public API"
3+weight = 5
4+template = "doc.html"
5++++
6+
7+# Iris
8+
9+In this document we describe the public interface for Iris. Namely, we describe
10+each `task` that Iris can be `%pass`ed, and which `gift`(s) Iris can `%give` in
11+return.
12+
13+## Returns to Unix
14+
15+Much of what Iris does is translating `task`s from other vanes into `card`s
16+meant for Unix via the `%request` and `%cancel-request` `task`s. What this means in practice is that Iris may be `%pass`ed a
17+`task` via some `duct`, which in response Iris then `%give`s a `gift` to Unix
18+via another `duct`. This `gift` will actually be a response to the `%born`
19+`task` that Iris was `%pass`ed when the Urbit was resumed, which came along the
20+duct to Unix.
21+
22+
23+## Tasks
24+
25+### `%born`
26+
27+Each time you start your Urbit the Arvo kernel calls the `%born` `task` for
28+Iris. This causes Iris to cancel any outstanding http requests and resets all
29+connection states.
30+
31+#### Accepts
32+
33+```hoon
34+[ ~ ]
35+```
36+
37+#### Returns
38+
39+In response to a `%born` `task` Iris `give`s a `%http-response %cancel` `gift`
40+to each outstanding connection.
41+
42+
43+### `%cancel-request`
44+
45+This `task` cancels a previous fetch. Iris knows which request is meant based on the
46+`duct` that the `task` comes on.
47+
48+ We note that `%cancel-request` is also a `gift` that Iris can `%give`.
49+
50+#### Accepts
51+
52+```hoon
53+[ ~ ]
54+```
55+
56+#### Returns
57+
58+```hoon
59+[%cancel-request id=@ud]
60+```
61+Receiving this `task` causes Iris to `%give`s a `%cancel-request` `gift` to Unix,
62+which then cancels the request in the runtime. See [Returns to Unix](#returns-to-unix).
63+
64+`id` is obtained via a `(map duct @ud)`, with the `duct` corresponding to one along
65+which the `%cancel-request` `task` came with.
66+
67+
68+### `%crud`
69+
70+`%crud` is called whenever an error involving Iris occurs. It produces a crash
71+report in response.
72+
73+#### Accepts
74+
75+```hoon
76+[p=@tas q=(list tank)]
77+```
78+
79+`p` is the type of error, `q` is the error message.
80+
81+#### Returns
82+
83+Iris does not `%give` a `gift` in response to a `%crud` `task`, but it does
84+`%slip` Dill a `%flog` `task` instructing it to print the error.
85+
86+
87+### `%receive`
88+
89+The `%receive` `task` is used to receive a response from Unix to an `http-request` that
90+was made.
91+
92+#### Accepts
93+
94+```hoon
95+[id=@ud =http-event:http]
96+```
97+
98+`id` is the identification number assigned by Iris to the http connection under
99+consideration. `http-event` is a packet that contains a header and data.
100+
101+#### Returns
102+
103+The response depends on what kind of packet `http-event` is: `%start`,
104+`%continue`, or `%cancel` and whether the `complete` flag is `%.y` or `%.n`.
105+
106+If the packet says to `%start` or `%continue` and `complete=%.n`, Iris will `%give` a
107+`%http-response %progress` `gift`.
108+
109+If the packet says to `%start` or `%continue` and `complete=%.y`, Iris will
110+`%give` a `%http-response %finished` `gift`.
111+
112+If the packet says to `%cancel`, Iris will `%give` a `%http-response %cancel`
113+`gift` in return. The `complete` flag is unused here.
114+
115+
116+### `%request`
117+
118+`%request` is used to fetch a remote resource. `%request` is also a `gift` Iris
119+can `%give`.
120+
121+#### Accepts
122+
123+```hoon
124+[=request:http =outbound-config]
125+```
126+
127+A `$request` consists of the following:
128+ - `=method`, the http method, which is one of `CONNECT`, `DELETE`, `GET`,
129+ `HEAD`, `OPTIONS`, `POST`, `PUT`, and `TRACE`.
130+ - `url=@t`, the URL being requested
131+ - `=header-list`, a list of headers to pass with the request,
132+ - `body=(unit octs)`, optional data to include in the request.
133+
134+ A `$outbound-config` contains the number of redirects and retries that Iris
135+ will attempt. By default this is 5 redirects (the recommended limit for the
136+ http standard) and 3 retries.
137+
138+#### Returns
139+
140+```hoon
141+[id=@ud request=request:http]
142+```
143+Iris will `%give` a `%request` `gift` to Unix in response to a `%request`
144+`task`. See [Returns to Unix](#returns-to-unix). This `gift`
145+contains the `request` in the original `task` as well as the ID number assigned
146+by Iris for that particular http connection, which is extracted from the input `task`.
147+
148+
149+### `%trim`
150+
151+This `task` is sent by the interpreter to free up memory. It has no effect on Iris.
152+
153+#### Accepts
154+
155+```hoon
156+[ ~ ]
157+```
158+
159+#### Returns
160+
161+This `task` returns no `gift`s.
162+
163+
164+### `%vega`
165+
166+This `task` informs the vane that the kernel has been upgraded. Iris does not do
167+anything in response to this.
168+
169+#### Accepts
170+
171+```hoon
172+[ ~ ]
173+```
174+
175+#### Returns
176+
177+This `task` returns no `gift`s.
178+
179+
180+### `%wegh`
181+
182+This `task` asks Iris to product a memory usage report.
183+
184+#### Accepts
185+
186+This `task` has no arguments.
187+
188+#### Returns
189+
190+When Iris is `%pass`ed this `task`, it will `%give` a `%mass` `gift` in response
191+containing Iris' current memory usage.
192+
193+
tutorials/_index.md+1−1
@@ -18,7 +18,7 @@ Hoon is a high-level, statically typed, functional programming language, custom-
18
18
19## [Nock](@/docs/tutorials/nock/_index.md)
19## [Nock](@/docs/tutorials/nock/_index.md)
20
20
21−Nock is the low-level functional programming language that is interpreted by Vere. You don't need to know Nock to write Hoon, or even to work on most parts of Vere. But if you want to understand the foundations of Urbit and are mathematically-inclined, dive right in.
21+Nock is the low-level functional programming language that is interpreted by Vere. You don't need to know Nock to write Hoon, or even to work on most parts of Vere. But if you want to understand the foundations of Urbit and are mathematically-inclined, dive right in.
22
22
23## [Vere](@/docs/tutorials/vere/_index.md)
23## [Vere](@/docs/tutorials/vere/_index.md)
24
24
tutorials/arvo/_index.md+16−76
@@ -5,105 +5,45 @@ sort_by = "weight"
5template = "sections/docs/chapters.html"
5template = "sections/docs/chapters.html"
6aliases = ["/docs/learn/arvo/"]
6aliases = ["/docs/learn/arvo/"]
7+++
7+++
8+
9+## [Arvo](@/docs/tutorials/arvo/arvo.md)
10+
8Arvo is Urbit's functional operating system, written in [Hoon](@/docs/tutorials/hoon/_index.md). It's composed of modules called _vanes_:
11Arvo is Urbit's functional operating system, written in [Hoon](@/docs/tutorials/hoon/_index.md). It's composed of modules called _vanes_:
9
12
13+## Vanes
14+
10−## [Ames](@/docs/tutorials/arvo/ames.md)
15+### [Ames](@/docs/tutorials/arvo/ames.md)
11
16
12Ames is the name of our network and the vane that communicates over it. It's an encrypted P2P network composed of instances of the Arvo operating system.
17Ames is the name of our network and the vane that communicates over it. It's an encrypted P2P network composed of instances of the Arvo operating system.
13
18
14−## [Behn](@/docs/tutorials/arvo/behn.md)
19+### [Behn](@/docs/tutorials/arvo/behn.md)
15
20
16Behn is our timer. It allows vanes and applications to set and timer events, which are managed in a simple priority queue.
21Behn is our timer. It allows vanes and applications to set and timer events, which are managed in a simple priority queue.
17
22
18−## [Clay](@/docs/tutorials/arvo/clay.md)
23+### [Clay](@/docs/tutorials/arvo/clay.md)
19
24
20Clay is our filesystem and revision-control system.
25Clay is our filesystem and revision-control system.
21
26
22−## [Dill](@/docs/tutorials/arvo/dill.md)
27+### [Dill](@/docs/tutorials/arvo/dill.md)
23
28
24Dill is our terminal driver. Unix sends keyboard events to dill from the terminal, and dill produces terminal output.
29Dill is our terminal driver. Unix sends keyboard events to dill from the terminal, and dill produces terminal output.
25
30
26−## [Eyre](@/docs/tutorials/arvo/eyre.md)
31+### [Eyre](@/docs/tutorials/arvo/eyre.md)
27
32
28Eyre is our HTTP server. Unix sends HTTP messages to `%eyre`, and `%eyre` produces HTTP messages in response.
33Eyre is our HTTP server. Unix sends HTTP messages to `%eyre`, and `%eyre` produces HTTP messages in response.
29
34
30−## [Ford](@/docs/tutorials/arvo/ford.md)
35+### [Ford](@/docs/tutorials/arvo/ford.md)
31
36
32Ford is our build system. It handles resources and publishing.
37Ford is our build system. It handles resources and publishing.
33
38
34−## [Gall](@/docs/tutorials/arvo/gall.md)
39+### [Gall](@/docs/tutorials/arvo/gall.md)
35
40
36Gall is the vane for controlling userspace apps.
41Gall is the vane for controlling userspace apps.
37
42
38−## Principles
43+### Iris
39−
40−At a high level `%arvo` takes a mess of Unix I/O events and turns them into something clean and structured for the programmer.
41−
42−`%arvo` is designed to avoid the usual state of complex event networks: event spaghetti. We keep track of every event's cause so that we have a clear causal chain for every computation. At the bottom of every chain is a Unix I/O event, such as a network request, terminal input, file sync, or timer event. We push every step in the path the request takes onto the chain until we get to the terminal cause of the computation. Then we use this causal stack to route results back to the caller.
43−
44−### Ducts
45−
46−The `%arvo` causal stack is called a `++duct`. This is represented simply as a list of paths, where each path represents a step in the causal chain. The first element in the path is the first letter of whichever vane handled that step in the computation, or the empty span for Unix.
47−
48−Here's a duct that was recently observed in the wild:
49−
50−```
51−~[
52− /g/a/~zod/4_shell_terminal/u/time
53− /g/a/~zod/shell_terminal/u/child/4/main
54− /g/a/~zod/terminal/u/txt
55− /d/term-mess
56− //term/1
57−]
58−```
59−
60−This is the duct the timer vane receives when "timer" sample app asks the timer vane to set a timer. This is also the duct over which the response is produced at the specified time. Unix sent a terminal keystroke event (enter), and Arvo routed it to `%dill` (our terminal), which passed it on to the `%gall` app terminal, which sent it to shell, its child, which created a new child (with process id 4), which on startup asked the timer vane to set a timer.
61−
62−The timer vane saves this duct, so that when the specified time arrives and Unix sends a wakeup event to the timer vane, it can produce the response on the same duct. This response is routed to the place we popped off the top of the duct, i.e. the time app. This app produces the text "ding", which falls down to the shell, which drops it through to the terminal. Terminal drops this down to dill, which converts it into an effect that Unix will recognize as a request to print "ding" to the screen. When dill produces this, the last path in the duct has an
63−initial element of the empty span, so this is routed to Unix, which applies the effects.
64−
65−This is a call stack, with a crucial feature: the stack is a first-class citizen. You can respond over a duct zero, one, or many times. You can save ducts for later use. There are definitely parallels to Scheme-style continuations, but simpler and with more structure.
66−
67−### Making Moves
68−
69−If ducts are a call stack, then how do we make calls and produce results? Arvo processes "moves" which are a combination of message data and metadata. There are two types of moves. A `%pass` move is analogous to a call:
70−
71−```
72−[duct %pass return-path=path vane-name=@tD data=card]
73−```
74−
75−Arvo pushes the return path (preceded by the first letter of the vane name) onto the duct and sends the given data, a card, to the vane we specified. Any response will come along the same duct with the path `return-path`.
76−
77−A `%give` move is analogous to a return:
78−
79−```
80−[duct %give data=card]
81−```
82−
83−Arvo pops the top path off the duct and sends the given card back to the caller.
84−
85−### Vanes
86−
87−As shown above, we use Arvo proper to route and control the flow of moves. However, Arvo proper is rarely directly responsible for processing the event data that directly causes the desired outcome of a move. This event data is contained within a card, which is simply a `(pair term noun)`. Instead, Arvo proper passes the card off to one of its vanes, which each present an interface to clients for a particular well-defined, stable, and general-purpose piece of functionality.
88−
89−As of this writing, we have seven vanes, which each provide the following services:
90−
91−- `%ames`: the name of both our network and the vane that communicates over it.
92−- `%behn`: a simple timer.
93−- `%clay`: our version-controlled, referentially- transparent, and global filesystem.
94−- `%dill`: a terminal driver. Unix sends keyboard events to `%dill` from either the console or telnet, and `%dill` produces terminal output.
95−- `%eyre`: an http server. Unix sends http messages to `%eyre`, and `%eyre` produces http messages in response.
96−- `%ford`: handles resources and publishing.
97−- `%gall`: manages our userspace applications. `%gall` keeps state and manages subscribers.
98−
99−### Cards
100−
101−Cards are the vane-specific portion of a move. Each vane defines a protocol for interacting with other vanes (via Arvo) by defining four types of cards: tasks, gifts, notes, and signs.
102−
103−When one vane is `%pass`ed a card in its `++task` (defined in zuse), Arvo activates the `++call` gate with the card as its argument. To produce a result, the vane `%give`s one of the cards defined in its `++gift`. If the vane needs to request something of another vane, it `%pass`es it a `++note` card. When that other vane returns a result, Arvo activates the `++take` gate of the initial vane with one of the cards defined in its `++sign`.
104
44
105−In other words, there are only four ways of seeing a move: (1) as a request seen by the caller, which is a ++note. (2) that same request as seen by the callee, a `++task`. (3) the response to that first request as seen by the callee, a `++gift`. (4) the response to the first request as seen by the caller, a `++sign`.
45+Iris is our HTTP client.
106
46
107−When a `++task` card is passed to a vane, Arvo calls its `++call` gate, passing it both the card and its duct. This gate must be defined in every vane. It produces two things in the following order: a list of moves and a possibly modified copy of its context. The moves are used to interact with other vanes, while the new context allows the vane to save its state. The next time Arvo activates the vane it will have this context as its subject.
47+## [Move trace tutorial](@/docs/tutorials/arvo/move-trace.md)
108
48
109−This overview has detailed how to pass a card to a particular vane. To see the cards each vane can be `%pass`ed as a `++task` or return as a `++gift` (as well as the semantics tied to them), each vane's public interface is explained in detail in its respective overview.
49+A walkthrough of what the Arvo kernel does to respond to a simple command.
tutorials/arvo/ames.md+104−1929
@@ -1,1938 +1,113 @@
1+++
1+++
2title = "Ames"
2title = "Ames"
3−weight = 1
3+weight = 2
4template = "doc.html"
4template = "doc.html"
5aliases = ["/docs/learn/arvo/ames/"]
5aliases = ["/docs/learn/arvo/ames/"]
6+++
6+++
7Our networking protocol.
7Our networking protocol.
8
8
9−`%ames` is the name of both our network and the vane that communicates
9+Ames is the name of both our network and the vane that communicates
10over it. When Unix receives a packet over the correct UDP port, it pipes
10over it. When Unix receives a packet over the correct UDP port, it pipes
11−it straight into `%ames` for handling. Also, all packets sent over the
11+it straight into Ames for handling. Also, all packets sent over the
12−`%ames` network are sent by the `%ames` vane. Apps and vanes may use
12+Ames network are sent by the Ames vane. Apps and vanes may use
13−`%ames` to directly send messages to other ships. In general, apps use
13+Ames to directly send messages to other ships. In general, apps use
14+[Gall](@/docs/tutorials/arvo/gall.md) and [Clay](@/docs/tutorials/arvo/clay.md)
14−gall and clay to communicate with other ships rather than using `%ames`
15+to communicate with other ships rather than using Ames
15−directly, but this isn't a requirement. Of course, gall and clay use
16+directly, but this isn't a requirement. Of course, Gall and Clay use
16−`%ames` behind the scenes to communicate across the network. These are
17+Ames behind the scenes to communicate across the network. Jael is the only other
17−the only two vanes that use `%ames`.
18+vane to utilize Ames.
18−
19+
19−`%ames` includes several significant components. Although the actual
20+Ames includes several significant components. Although the actual
20−crypto algorithms are defined in zuse, they're used extensively in
21+crypto algorithms are defined in `zuse`, they're used extensively in
21−`%ames` for encrypting and decrypting packets. Congestion control and
22+Ames for encrypting and decrypting packets. Congestion control and
22−routing is handled entirely in `%ames`. Finally, the actual `%ames`
23+routing is handled entirely in Ames. Finally, the actual Ames
23protocol itself, including how to route incoming packets to the correct
24protocol itself, including how to route incoming packets to the correct
24−vane or app, is defined in `%ames`.
25+vane or app, is defined in Ames.
25−
26+
26−## Commentary
27+## Technical Overview
27−
28+Ames extends [Arvo's](@/docs/tutorials/arvo/arvo.md) `%pass`/`%give` `move` semantics across the network.
28−`%ames` is our networking protocol.
29+
29−
30+Ames receives packets as Arvo events and emits packets as Arvo
30−First we give commentary on the code, the algorithms involved, and the
31+effects. The runtime is responsible for transferring the bytes in
31−protocol. We trace through the code touched when a packet is sent,
32+an Ames packet across a physical network to another ship.
32−received, acknowledged, and that acknowledgment applied. This is fairly
33+
33−comprehensive, and contains many implementation details, but if you
34+The runtime tells Ames which physical address a packet came from,
34−understand this, then you understand `%ames`.
35+represented as an opaque atom. Ames can emit a packet effect to
35−
36+one of those opaque atoms or to the Urbit address of a galaxy
36−If you've scrolled down this page, you may be intimidated by the amount
37+(root node), which the runtime is responsible for translating to a
37−of Hoon code, especially if you are new to the language. Don't be afraid
38+physical address. One runtime implementation sends UDP packets
38−of it, you don't have to read any of it if you don't want to -- every
39+using IPv4 addresses for ships and DNS lookups for galaxies, but
39−interesting action the code takes is explained in plain English. In
40+other implementations may overlay over other kinds of networks.
40−fact, if you are new to the language, this may be a good learning
41+
41−opportunity. Even if you don't understand every line of Hoon code,
42+A local vane can pass Ames a `%plea` request message. Ames
42−you'll hopefully be able to follow most lines. By the time you've worked
43+transmits the message over the wire to the peer ship's Ames, which
43−through this, you'll have seen many common patterns and best practices.
44+passes the message to the destination vane.
44−Hoon, much more than other languages, is best learned by reading and
45+
45−understanding large quantities of existing code. In this way, it is
46+Once the peer has processed the `%plea` message, it sends a
46−similar to learning a natural language. All of this code is in
47+message-acknowledgment packet over the wire back to the local
47−`arvo/ames.hoon`.
48+Ames. This "ack" can either be positive to indicate the request was
48−
49+processed, or negative to indicate the request failed, in which
49−After the commentary, we have reference documentation for all the data
50+case it's called a "nack". (Don't confuse Ames nacks with TCP
50−structures that are specific to `%ames`. If you see a data structure or
51+nacks, which are a different concept).
51−a variable used that you don't recognize, search for it in the code, and
52+
52−it's very likely defined in one of these data structures. We recommend
53+When the local Ames receives either a positive message-ack or a
53−that another tab is kept open for easy access to the data structure
54+combination of a nack and "naxplanation" (explained in more detail
54−reference documentation. The code for these is split between
55+below), it gives an `%done` `move` to the local vane that had
55−`arvo/ames.hoon` and `arvo/zuse.hoon`.
56+requested the original `%plea` message be sent.
56−
57+
57−The Lifecycle of a Packet (or, How a Packet Becomes Law)
58+A local vane can give Ames zero or more `%boon` response messages in
58−
59+response to a `%plea`, on the same duct that Ames used to pass the
59−---
60+`%plea` to the vane. Ames transmits a `%boon` over the wire to the
60−
61+peer's Ames, which gives it to the destination vane on the same
61−Here, we will trace a packet as it makes its way through ames. There are
62+duct the vane had used to pass the original `%plea` to Ames.
62−actually two pathways through ames: the legacy path through `%want`, and
63+
63−the modern way, entered through `%wont`, with full end-to-end
64+`%boon` messages are acked automatically by the receiver Ames. They
64−acknowledgments. Here we will only trace the modern way, though much of
65+cannot be nacked, and Ames only uses the ack internally, without
65−the path is the same for both.
66+notifying the client vane that gave Ames the `%boon`.
66−
67+
67−When an app (or a vane) wishes to send a packet to another ship, it must
68+If the Arvo event that completed receipt of a `%boon` message
68−send a `%wont` card:
69+crashes, Ames instead sends the client vane a `%lost` message
69−
70+indicating the `%boon` was missed.
70−```hoon
71+
71− [%wont p=sock q=path r=*] :: e2e send message
72+`%plea` messages can be nacked, in which case the peer will send
72−```
73+both a message-nack packet and a naxplanation message, which is
73−
74+sent in a way that does not interfere with normal operation. The
74−This card takes three arguments. The `p` is a `sock`, that is, a pair of
75+naxplanation is sent as a full Ames message, instead of just a
75−two ships, the first of which is the sender and the second is the
76+packet, because the contained error information can be arbitrarily
76−receiver. But wait, you ask, why do I get to decide who is the sender?
77+large. A naxplanation can only give rise to a positive ack --
77−Can I fake like I'm someone else? The reason is that there are
78+never ack an ack, and never nack a naxplanation.
78−potentially multiple ships on the same pier, and the kernel can send a
79+
79−message from any of them. If you attempt to send a message from a ship
80+Ames guarantees a total ordering of messages within a "flow",
80−not on your pier, then ames will refuse to send it. If you hack around
81+identified in other vanes by a duct and over the wire by a "bone":
81−in your own copy of ames to go ahead and send it anyway, then the other
82+an opaque number. Each flow has a FIFO (first-in-first-out) queue of `%plea` requests
82−ship will reject it because your key is bad. Only send messages from
83+from the requesting ship to the responding ship and a FIFO queue
83−yourself.
84+of `%boon`'s in the other direction.
84−
85+
85−The `q` is a path, representing the place on the other side that you
86+Message order across flows is not specified and may vary based on
86−want to receive your message. It is approximately equivalent to a port
87+network conditions.
87−number. Messages on the same path are guaranteed to arrive in the same
88+
88−order as they were sent. No such guarantees are made across paths.
89+Ames guarantees that a message will only be delivered once to the
89−
90+destination vane.
90−The `r` is the actual data that you are sending. As the type implies,
91+
91−this can be an arbitrary noun, and it will be transferred to the
92+Ames encrypts every message using symmetric-key encryption by
92−receiver exactly as-is, in a well-typed way. Of course, this is data
93+performing an elliptic curve Diffie-Hellman using our private key
93−that is sent over the wire, so be careful not to send anything too
94+and the public key of the peer. For ships in the Jael PKI
94−massive unless you're willing to wait.
95+(public-key infrastructure), Ames looks up the peer's public key
95−
96+from Jael. Comets (128-bit ephemeral addresses) are not
96−But enough about the interface. Grepping in ames.hoon for `%wont`, we
97+cryptographic assets and must self-attest over Ames by sending a
97−find that it appears in `++knob`. We see that we go
98+single self-signed packet containing their public key.
98−directly into `++wise:am`.
99+
99−
100+When a peer suffers a continuity breach, Ames removes all
100−```hoon
101+messaging state related to it. Ames does not guarantee that all
101− ++ wise :: wise:am
102+messages will be fully delivered to the now-stale peer. From
102− |= [soq=sock hen=duct cha=path val=* ete=?] :: send a statement
103+Ames's perspective, the newly restarted peer is a new ship.
103− ^- [p=(list boon) q=fort]
104+Ames's guarantees are not maintained across a breach.
104− zork:zank:(wool:(ho:(um p.soq) q.soq) hen cha val ete)
105+
105−```
106+A vane can pass Ames a `%heed` `$task` to request Ames track a peer's
106−
107+responsiveness. If our `%boon`'s to it start backing up locally,
107−The inputs to this gate are exactly the sort of thing you'd expect. In
108+Ames will give a `%clog` back to the requesting vane containing the
108−particular, everything in the `%wont` gate is here plus the calling duct
109+unresponsive peer's urbit address. This interaction does not use
109−so that we know where to send the acknowledgment and `ete` to determine
110+ducts as unique keys. Stop tracking a peer by sending Ames a
110−if we're going to do the modern end-to-end acknowledgments.
111+`%jilt` `$task`.
111−
112+
112−The actual line of code looks intimidating, but it's really not all that
113+Debug output can be adjusted using `%sift` and `%spew` `$task`'s.
113−bad. Working from the inside out, the call to `++um` sets up our
114−domestic server, and the call to `++ho` sets up our knowledge about the
115−neighbor we're sending to. From the outside, `++zork` and `++zank` just
116−apply the changes made to our `++um` and `++am` cores, respectively. If
117−you're familiar with the common idiom of `++abet`, that's all this is.
118−The code predates the widespread usage of that name.
119−
120−The interesting part, then, is in `++wool:ho:um:am`. Let's look at the
121−code.
122−
123−```hoon
124− ++ wool :: wool:ho:um:am
125− |= [hen=duct cha=path val=* ete=?] :: send a statement
126− ^+ +>
127− =+ ^= rol ^- rill
128− =+ rol=(~(get by ryl.bah) cha)
129− ?~(rol *rill u.rol)
130− =+ sex=sed.rol
131− :: ~& [%tx [our her] cha sex]
132− =. ryl.bah
133− %+ ~(put by ryl.bah) cha
134− rol(sed +(sed.rol), san (~(put by san.rol) sex hen))
135− =+ cov=[p=p:sen:gus q=clon:diz]
136− %+ wind [cha sex]
137− ?: ete
138− [%bund q.cov cha sex val]
139− [%bond q.cov cha sex val]
140−```
141−
142−This is slightly more complicated, but it's still not all that bad. Our
143−inputs, at least, are fairly obvious.
144−
145−If you glance at the code for a second, you'll see that
146−`++wind:ho:um:am` seems to be able to send a message, or `++meal:ames`, given
147−a `++soup`. This gate, then, just sets up the things we need to for
148−`++wind` to do its job.
149−
150−We first get `rol`, which is a `++rill:ames`, that is, a particular outbound
151−stream. This stream is specific to the path on which we're sending. If
152−the path hasn't been used before, then we create it. We let `sex` be the
153−number of messages we've already sent on this path.
154−
155−Then, we update the outbound stream by incrementing the number of
156−messages sent and placing an entry in `san.rol` that associates the
157−message number with the `duct` that sent the message. This allows us to
158−give the acknowledgment to the one who sent the message.
159−
160−We let `cov` be the current life of our crypto and our neighbor's
161−crypto. At the moment, we only need our neighbor's life, which we put
162−into the meal.
163−
164−Finally, we call `++wind:ho:um:am` with the `++soup` of the path and
165−message number and the `++meal:ames` of the payload itself. For end-to-end
166−acknowledged messages, we use `%bund`.
167−
168−```hoon
169− [%bund p=life q=path r=@ud s=*] :: e2e message
170−```
171−
172−Looking at how we create the `%bund`, we can easily see what each field
173−is for.
174−
175−Following the trail a little further, we go to `++wind:ho:um:am`.
176−
177−```hoon
178− ++ wind :: wind:ho:um:am
179− |= [gom=soup ham=meal]
180− :: ~& [%wind her gom]
181− ^+ +>
182− =^ wyv diz (zuul:diz now ham)
183− =^ feh puz (whap:puz now gom wyv)
184− (busk xong:diz feh)
185−```
186−
187−`++wind` does three things: it (1) encodes the message into a list of
188−possibly-encrypted packets, (2) puts the message into the packet pump,
189−and (3) sends any packets that are ready to be sent. Yes, our nice
190−little linear run of each gate calling exactly one other interesting
191−gate is over. We'll go in order here.
192−
193−`++zuul:lax:as:go` is the what converts a `++meal:ames` into a list of
194−actual, 1KB packets.
195−
196−```hoon
197− ++ zuul :: zuul:lax:as:go
198− |= [now=@da ham=meal] :: encode message
199− ^- [p=(list rock) q=_+>]
200− =< weft
201− ++ wasp :: null security
202− ++ weft :: fragment message
203− ++ wisp :: generate message
204−```
205−
206−For organizational purposes, `++zuul` constructs an internal core with
207−three arms. `++wasp` encodes the meal into an atom with no encryption.
208−`++wisp` encodes a meal with possible encryption (else it simply calls
209−`++wasp`). `++weft` takes the result of `++wisp` and splits it into
210−actual packets.
211−
212−```hoon
213− ++ wasp :: null security
214− ^-([p=skin q=@] [%none (jam ham)])
215−```
216−
217−This simply jams the meal, wrapping it with the `skin` of `%none`,
218−meaning no encryption.
219−
220−Since `++wisp` is a little long, we'll go through it line-by-line.
221−
222−```hoon
223− ++ wisp :: generate message
224− ^- [[p=skin q=@] q=_..wisp]
225−```
226−
227−`++wisp` produces a pair of a `skin` and an atom, which is the meal
228−encoded as a single atom and possibly encrypted.
229−
230−```hoon
231− ?: =(%carp -.ham)
232− [wasp ..wisp]
233−```
234−
235−If the meal that we're encoding is a `%carp`, then we don't encrypt it.
236−A `%carp` meal is a partial meal, used when a message is more than 1KB.
237−Since the entire message is already encrypted, we don't need to encrypt
238−each packet individually again.
239−
240−```hoon
241− ?: !=(~ yed.caq.dur)
242− ?> ?=(^ yed.caq.dur)
243− :_ ..wisp
244− :- %fast
245− %^ cat 7
246− p.u.yed.caq.dur
247− (en:r:cluy q.u.yed.caq.dur (jam ham))
248−```
249−
250−If we have a symmetric key set up with this neighbor, then we simply use
251−it. The skin `%fast` is used to indicate a symmetric key.
252−
253−```hoon
254− ?: &(=(~ lew.wod.dur) |(=(%back -.ham) =(%buck -.ham)))
255− [wasp ..wisp]
256−```
257−
258−If we do not yet have our neighbor's will, then there is no way that we
259−can seal the message so that only they may read it. If what we're
260−sending is an acknowledgment, then we go ahead and just send it in the
261−clear.
262−
263−```hoon
264− =^ tuy +>.$
265− ?:(=(~ lew.wod.dur) [*code +>.$] (griz now))
266−```
267−
268−If we don't have our neighbor's will, then we "encrypt" with a key of 0.
269−If we do have their will, then we generate a new symmetric key that we
270−will propose.
271−
272−```hoon
273− :_ ..wisp
274− =+ yig=sen
275− =+ bil=law.saf :: XX send whole will
276− =+ hom=(jam ham)
277−```
278−
279−`yig` will be the life and engine for our current crypto. `bil` is our
280−will. `hom` is the meal encoded as a single atom.
281−
282−```hoon
283− ?: =(~ lew.wod.dur)
284− :- %open
285− %^ jam
286− [~ `life`p.yig]
287− bil
288− (sign:as:q.yig tuy hom)
289−```
290−
291−If we do not have our neighbor's will, then we send our current life
292−along with our will and the message. The message itself is "signed" with
293−a key of 0.
294−
295−```hoon
296− :- %full
297− =+ cay=cluy
298− %^ jam
299− [`life`p.cay `life`p.yig]
300− bil
301− (seal:as:q.yig pub:ex:r.cay tuy hom)
302− -- :: --zuul:lax:as:go
303−```
304−
305−If we do have our neighbor's will, then we send our perception of their
306−current life, our current life, our will, and the message. The message
307−is sealed with their public key so that only they can read our message.
308−
309−Once we have the message encoded as an atom, `++weft` goes to work.
310−
311−```hoon
312− ++ weft :: fragment message
313− ^- [p=(list rock) q=_+>.$]
314− =^ gim ..weft wisp
315− :_ +>.$
316− ^- (list rock)
317−```
318−
319−We're going to produce a list of the packets to send. First, we use the
320−aforementioned `++wisp` to get the message as an atom.
321−
322−```hoon
323− =+ wit=(met 13 q.gim)
324− ?< =(0 wit)
325−```
326−
327−`wit` is the number of 1KB (2\^13 bit) blocks in the message. We assert
328−that there is at least one block.
329−
330−```hoon
331− ?: =(1 wit)
332− =+ yup=(spit [our her] p.gim q.gim)
333− [yup ~]
334−```
335−
336−If there is exactly one block, then we just call `++spit` to turn the
337−message into a packet. We'll explain what `++spit` does momentarily.
338−
339−```hoon
340− =+ ruv=(rip 13 q.gim)
341− =+ gom=(shaf %thug q.gim)
342− =+ inx=0
343−```
344−
345−If there is more than one block, then we rip it into blocks in `ruv`.
346−`gom` is a hash of the message, used as an id. `inx` is the number of
347−packets we've already made.
348−
349−```hoon
350− |- ^- (list rock)
351− ?~ ruv ~
352− =+ ^= vie
353− %+ spit
354− [our her]
355− wasp(ham [%carp (ksin p.gim) inx wit gom i.ruv])
356− :- vie
357− $(ruv t.ruv, inx +(inx))
358−```
359−
360−Here we package each block into a packet with `++spit` and produce the
361−list of packets.
362−
363−```hoon
364− ++ spit :: cake to packet
365− |= kec=cake ^- @
366− =+ wim=(met 3 p.p.kec)
367− =+ dum=(met 3 q.p.kec)
368− =+ yax=?:((lte wim 2) 0 ?:((lte wim 4) 1 ?:((lte wim 8) 2 3)))
369− =+ qax=?:((lte dum 2) 0 ?:((lte dum 4) 1 ?:((lte dum 8) 2 3)))
370− =+ wix=(bex +(yax))
371− =+ vix=(bex +(qax))
372− =+ bod=:(mix p.p.kec (lsh 3 wix q.p.kec) (lsh 3 (add wix vix) r.kec))
373− =+ tay=(ksin q.kec)
374− %+ mix
375− %+ can 0
376− :~ [3 1]
377− [20 (mug bod)]
378− [2 yax]
379− [2 qax]
380− [5 tay]
381− ==
382− (lsh 5 1 bod)
383−```
384−
385−This is how we turn a message into a real packet. This has the
386−definition of the packet format.
387−
388−`wim` is the length of the sending ship, and `dum` is the length of the
389−receiving ship. There are only five possibilities for each of those,
390−corresponding to carriers, cruisers, destroyers, yachts, and submarines.
391−These are encoded in `yax` and `qax` as 0, 0, 1, 2, and 3, respectively.
392−Thus, `wix` and `vix` are the number of bytes that must be reserved for
393−the ship names in a packet.
394−
395−Next, we construct `bod` by simply concatenating the sending ship, the
396−receiving ship, and the body of the message. Then, we get the encryption
397−mechanism from `++skin:ames`, which may be a 0, 1, 2, or 3, and put it in
398−`tay`.
399−
400−Next, we concatenate together, bit by bit, some final metadata. We use
401−three bits for our protocol number, which is incremented modulo eight
402−when there is a continuity breach or the protocol changes. We use the
403−final twenty bits of a hash of the body (which, we suppose, makes it a
404−twenty bit hash) for error-checking. We use two bits to tell how much
405−room is used in the body for the sending ship, and another two bits for
406−the receiving ship. Finally, we use five bits to store the encryption
407−type. Note that since there are only two bits worth of encryption types,
408−there are three unused bits here. This adds up to 32 bits of header
409−data. Finally, we concatenate this onto the front of the packet. Thus,
410−we can summarize the packet header format as follows.
411−
412−```
413− 0 1 2 3
414− 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
415− +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
416− |Proto| Hash of Body |yax|qax| Crypto |
417− +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
418−```
419−
420−After this, there are `yax` bits of the sender name, `qax` bits of the
421−receiver name, and up to 8192 bits of data. Thus, the maximum size of a
422−packet is achieved in a message between two submarines with 8192 bits of
423−data. This will require 32+128+128+8192 = 8480 bits, or 1060 bytes.
424−
425−This concludes our discussion of `++zuul:lax:as:go`. If you recall from
426−`++wind:ho:um:am`, the list of packets from `++zuul` is passed into
427−`++whap:pu` to update the packet pump and get any packets that can be
428−sent immediately.
429−
430−```hoon
431− ++ whap :: whap:pu
432− |= [now=@da gom=soup wyv=(list rock)] :: send a message
433− ^- [(list rock) _+>]
434− =. pyz (~(put by pyz) gom (lent wyv))
435− =. +>
436− |- ^+ +>.^$
437− ?~ wyv +>.^$
438− %= $
439− wyv t.wyv
440− nus +(nus)
441− diq (~(put by diq) (shaf %flap i.wyv) nus)
442− puq (~(put to puq) [nus `soul`[gom 0 | ~2000.1.1 i.wyv]])
443− ==
444− (harv now)
445−```
446−
447−First, we put into `pyz` the id for this message and the number of its
448−packets that have not yet been acknowledged, which is of course the
449−total number of packets since we haven't even sent the packets.
450−
451−For every packet, we change three things in the state (`++shed:ames`) of our
452−packet pump: (1) we increment `nus`, the number of packets sent; (2) we
453−put the packet number into `diq` keyed by a hash of the packet; and (3)
454−we put the packet into the packet queue, with the basic metadata of its
455−id `gom`, 0 transmissions, not live yet, last sent in the year 2000, and
456−the packet itself.
457−
458−Finally, we harvest the packet pump.
459−
460−```hoon
461− ++ harv :: harv:pu
462− |= now=@da :: harvest queue
463− ^- [(list rock) _+>]
464− ?: =(~ puq) [~ +>(rtn ~)]
465− ?. (gth caw nif) [~ +>]
466− =+ wid=(sub caw nif)
467− =| rub=(list rock)
468− =< abet =< apse
469− |%
470−```
471−
472−`++harv` contains a core for most of its work. The meat is in `++apse`.
473−First, though, it sets itself up. If there aren't any packets in the
474−queue, then we simply do nothing except set `rtn`, our next timeout, to
475−nil because we don't have any packets that may need to be retransmitted.
476−If we have more live (that is, sent and unacknowledged) packets than our
477−window size, then we don't do anything.
478−
479−Otherwise, we let `wid` be the width of our remaining packet window, and
480−we initialize `rub` to nil. `rub` will be the list of packets that are
481−ready to be sent. We then call `++apse` and pass the result to `++abet`.
482−`++apse` decides which packets are ready to be sent.
483−
484−```hoon
485− ++ apse
486− ^+ .
487− ?~ puq .
488− ?: =(0 wid) .
489− => rigt =< left
490− ?> ?=(^ puq)
491− ?: =(0 wid) .
492− ?. =(| liv.q.n.puq) .
493− :: ~& [%harv nux.q.n.puq p.n.puq]
494− %_ .
495− wid (dec wid)
496− rub [pac.q.n.puq rub]
497− nif +(nif)
498− liv.q.n.puq &
499− nux.q.n.puq +(nux.q.n.puq)
500− lys.q.n.puq now
501− ==
502−```
503−
504−If there are no remaining packets to send, or if we've filled the packet
505−window, do nothing. We call `++rigt` and `++left` to process the left
506−and right branches of the packet queue.
507−
508−Now we assert that the queue is not empty, and we again check that we
509−haven't filled the packet window. We will operate on the head of the
510−queue. If the packet is live, then do nothing. Otherwise, we go ahead
511−and send it.
512−
513−To send, we (1) decrement `wid`, our packet window width; (2) cons the
514−packet onto the `rub`, which will be returned as the list of packets to
515−send; (3) increment `nif`, the number of live packets; (4) set the
516−packet to be live; (5) increment the number of transmissions of the
517−packet; and (6) set the last sent time of the packet to now.
518−
519−```hoon
520− ++ left
521− ?> ?=(^ puq)
522− ^+(. =+(lef=apse(puq l.puq) lef(puq [n.puq puq.lef r.puq])))
523− ++ rigt
524− ?> ?=(^ puq)
525− ^+(. =+(rig=apse(puq r.puq) rig(puq [n.puq l.puq puq.rig])))
526−```
527−
528−These do exactly what you would expect: they traverse the packet queue
529−so that `++apse` gets called recursively through it.
530−
531−Finally, `++abet` gets called, which resolves the changes.
532−
533−```hoon
534− ++ abet
535− ?~ rub [~ +>.$]
536− [(flop rub) +>.$(rtn [~ (add rto now)])]
537−```
538−
539−This returns the packets that we wish to send, and it updates the
540−timeout so that we know when to try resending unacknowledged packets.
541−
542−This concludes our discussion of `++whap:pu`. To finish
543−`++wind:ho:um:am`, we just need to delve into `++busk:ho:um:am`. But
544−wait, in the call to `++busk`, the first argument is `xong:diz`. What is
545−this? This, my dear reader, is one more detour, this time into
546−`++xong:lax:as:go`.
547−
548−```hoon
549− ++ xong :: xong:lax:as:go
550− ^- (list ship) :: route unto
551− =+ [fro=xen too=xeno]
552− =+ ^= oot ^- (list ship)
553− =| oot=(list ship)
554− |- ^+ oot
555− ?~ too ~
556− ?: (lien fro |=(a=ship =(a i.too))) ~
557− [i.too $(too t.too)]
558− :: ~& [%xong-to [our her] (weld oot ?>(?=(^ fro) t.fro))]
559− (weld oot ?>(?=(^ fro) t.fro))
560−```
561−
562−This gets the list of intermediate ships needed to get a packet from us
563−to our neighbor. First, we get `fro` and `too`, the "canons" of ourself
564−and our neighbor, respectively.
565−
566−What is this "canon", you ask? A canon is simply a ship plus its
567−"ancestors", as defined by `++sein:title`. For example, the canon of
568−`~hoclur-bicrel` is:
569−
570−```
571− ~hoclur-bicrel/try=> (saxo:title ~hoclur-bicrel)
572− ~[~hoclur-bicrel ~tasruc ~tug]
573−```
574−
575−If we follow the algorithm in `++xong`, we see that we are simply
576−creating a list of ships that form a path from our neighbor to ourself.
577−Essentially, we look through the canon of our neighbor until we find
578−something in our own cannon -- a common ancestor. Or, if we are from
579−different carriers, then there is no common ancestor. We then weld this
580−onto the tail of our own canon. In the end, this is simply a list of
581−possible ships to try to route via to get to our neighbor, ordered by
582−preferability (that is, closeness to our neighbor). We will end up
583−trying, in order, to find a lane to these.
584−
585−Now, we can finally get to `++busk:ho:um:am`.
586−
587−```hoon
588− ++ busk :: busk:ho:um:am
589− |= [waz=(list ship) pax=(list rock)] :: send packets
590− %_ +>
591− bin
592− |- ^+ bin
593− ?~ pax bin
594− $(pax t.pax, bin (weld (flop (wist:diz now waz ~ i.pax)) bin))
595− ==
596−```
597−
598−Thankfully, `++busk` is fairly simple. We go through the list of packets
599−and convert them to `++boon:ames`s with `++wist:lax:as:go`. These boons are
600−placed into `bin`, and they end up getting processed by `++clop` (this
601−happens in `++knob`).
602−
603−```hoon
604− ++ wist :: wist:lax:as:go
605− |= $: now=@da :: route via
606− waz=(list ,@p)
607− ryn=(unit lane)
608− pac=rock
609− ==
610− ^- (list boon)
611− ?: =(our her) [[%ouzo *lane pac] ~]
612− ?~ waz ~
613− =+ dyr=?:(=(her i.waz) dur (gur i.waz))
614− ?. ?& !=(our i.waz)
615− ?=(^ lun.wod.dyr)
616− ==
617− $(waz t.waz)
618− :_ ?: ?=(%ix -.u.lun.wod.dyr)
619− $(waz t.waz)
620− ~
621− :+ %ouzo u.lun.wod.dyr
622− ?: &(=(i.waz her) =(~ ryn)) pac
623− =+ mal=(jam `meal`[%fore her ryn pac])
624− %- spit
625− ^- cake
626− :* [our i.waz]
627− ?~ yed.caq.dyr [%none mal]
628− :- %fast
629− %^ cat 7
630− p.u.yed.caq.dyr
631− (en:crub:crypto q.u.yed.caq.dyr mal)
632− ==
633−```
634−
635−This takes a sample of the current time, the list of ships that we just
636−generated, a lane if we already know it, and the packet itself.
637−
638−First, if we are sending a message to ourself, then we simply create a
639−`%ouzo` boon with a bunted lane. Otherwise, if there are no routing
640−candidates, there is nothing we can do, so we return nil.
641−
642−Next, we get the `++dore:ames` of the first routing candidate. If we're looking
643−at the neighbor to whom we're trying to send the message, then we simply
644−use the `++dore:ames` that we already have. Otherwise, we get a default `++dore:ames`.
645−
646−If we're the first routing candidate, or if we have don't have a lane to
647−this candidate, then we skip this candidate and move on to the next one.
648−
649−If we have only a provisional ip address, then we try to send on it, but
650−we also try to send on later routing candidates as well. Otherwise, we
651−only send on this one candidate.
652−
653−Finally, we create the actual `%ouzo` boon. The lane is the one from our
654−`++dore:ames`. If we're sending it directly to our intended recipient, and we
655−haven't been told to use a specific lane, then we just send the packet
656−directly. Otherwise, we wrap it in a little `%fore` meal, telling the
657−intermediary to whom we wish it to be sent. If we have already set up a
658−symmetric key with the intermediary, then we encrypt it with that.
659−Otherwise, we send it in the clear.
660−
661−Now, if you recall, we have traced all the way through from the
662−beginning when, in `++knob`, the `%wont` card was handled by a call to
663−`++wise`. There is only one more step before the packet is finally sent.
664−Looking in `++knob`, we see that the resultant list of boons is passed
665−into `++clop`, which will execute the correct actions and return a list
666−of moves. In `++clop`, we see the handling of each specific boon. The
667−one we are interested in is `%ouzo`, since that is the only one we have
668−sent thus far.
669−
670−```hoon
671− %ouzo
672− :: ~& [%send now p.bon `@p`(mug (shaf %flap q.bon))]
673− :_ fox
674− [[gad.fox [%give %send p.bon q.bon]] ~]
675−```
676−
677−Very simply, we give a `%send` gift along the special duct that goes
678−straight into the bowels of unix. This is the last stop before we drop
679−into vere, and later libuv. And then... the world.
680−
681−The packet, after its creation, embarks on a journey across physical
682−time and space into the great unknown. Hurtling through fiber-optic
683−cables at hundreds of thousands of kilometers per second, it finally
684−arrives at our neighbor's network adapter. The adapter tells unix, unix
685−tells libuv, libuv tells vere, and vere sends a `%hear` task to ames.
686−And now we reenter the kernel.
687−
688−The `%hear` task goes straight to `++knob`, just as did the `%wont` task
689−earlier.
690−
691−```hoon
692− %hear
693− (~(gnaw am [now fox]) %good p.kyz q.kyz)
694−```
695−
696−Here, though, we call `++gnaw:am` to process the packet. The arguments
697−to `++gnaw` are the same as those to the `%hear` task: the lane on which
698−the packet was received and the packet itself. The other argument is
699−just `%good`, which is a `++cape:ames` saying that we expect the packet to
700−succeed. If a formal error occurs, then since we have a transactional
701−event system, the `%hear` event will never be considered to have
702−actually happened, and unix will send a `%hole` task so that we may send
703−a negative acknowledgment.
704−
705−```hoon
706− ++ gnaw :: gnaw:am
707− |= [kay=cape ryn=lane pac=rock] :: process packet
708− ^- [p=(list boon) q=fort]
709− ?. =(2 (end 0 3 pac)) [~ fox]
710− =+ kec=(bite pac)
711− ?: (goop p.p.kec) [~ fox]
712− ?. (~(has by urb.ton.fox) q.p.kec)
713− [~ fox]
714− =< zork
715− =< zank
716− %- ~(chew la:(ho:(um q.p.kec) p.p.kec) kay ryn %none (shaf %flap pac))
717− [q.kec r.kec]
718−```
719−
720−First, we check the protocol number. If it is not correct, then we
721−simply ignore the packet entirely. Otherwise, we parse the packet with
722−`++bite`, which converts a packet atom into a `++cake:ames`, that is, a triple
723−of the `sock` (pair of sender and receiver), the `skin` (encryption
724−type), and the data.
725−
726−```hoon
727− ++ bite :: packet to cake
728− |= pac=rock ^- cake
729− =+ [mag=(end 5 1 pac) bod=(rsh 5 1 pac)]
730− =+ :* vez=(end 0 3 mag) :: protocol version
731− chk=(cut 0 [3 20] mag) :: checksum
732− wix=(bex +((cut 0 [23 2] mag))) :: width of receiver
733− vix=(bex +((cut 0 [25 2] mag))) :: width of sender
734− tay=(cut 0 [27 5] mag) :: message type
735− ==
736− ?> =(2 vez)
737− ?> =(chk (end 0 20 (mug bod)))
738− :+ [(end 3 wix bod) (cut 3 [wix vix] bod)]
739− (kins tay)
740− (rsh 3 (add wix vix) bod)
741−```
742−
743−This is exactly the inverse of `++spit`. Note that here we check both
744−the protocol number and the hash, crashing on error. Remember that a
745−crash will result in a negative acknowledgment being sent.
746−
747−Continuing in `++gnaw`, we see that if the intended recipient is not on
748−our pier, then we drop the packet.
749−
750−If we've gotten this far, then we wish to process the packet. Recall
751−that `++ho` and `++um` set up the domestic server and foreign client
752−cores, respectively, and that `++zork` and `++zank` resolve any changes
753−to these cores.
754−
755−The new stuff here, then, is the `++la` core and the `++chew` arm. The
756−`++la` sets up a core for this particular packet, containing the current
757−success/failure `++cape:ames`, the lane it was sent on, the encryption type,
758−and a hash of the packet, used as an id.
759−
760−`++chew` is called with the encryption type and the message itself. It
761−contains a little helper core inside of it, which starts immediately
762−with `++apse`.
763−
764−```hoon
765− ++ apse
766− ^+ +>.$
767− =+ oub=bust:puz
768− =+ neg==(~ yed.caq.dur.diz)
769− =. +>.$ east
770− =+ eng==(~ yed.caq.dur.diz)
771− =+ bou=bust:puz
772− =. bin
773− ?. &(oub !bou) bin
774− :_(bin [%wine [our her] " is ok"])
775− =. bin
776− ?. &(neg !eng) bin
777− :_(bin [%wine [our her] " is your neighbor"])
778− +>.$
779−```
780−
781−First, we let `oub` be true if our neighbor hasn't been responding to us
782−for more than sixteen seconds. Let `neg` be true if we haven't yet
783−proposed a symmetric key, meaning that we haven't yet corresponded with
784−this ship, so they are not our neighbor. Next, we run `++east`, which
785−we'll go into in just a minute.
786−
787−We now do the same two checks and store the results in `eng` and `bou`.
788−If our neighbor has, like the prodigal son, returned after an extended
789−absence, then we send a `%wine` boon as the proverbial fatted calf,
790−which is simply printed out to the console. Likewise, if we are meeting
791−one with whom we have never had the pleasure of acquainting ourselves,
792−we send a message to the console to that effect.
793−
794−We skipped over `++east`, which contains the meat of the processing. It
795−first decrypts the message, then calls `++chow:la:ho:um:am` with the
796−resultant meal. We'll go through each of the four cases in turn, but
797−first since each one calls `++bilk:pu`, we'll take a brief detour.
798−
799−```hoon
800− ++ bilk :: bilk:pu
801− |= now=@da :: inbound packet
802− ^+ +>
803− =+ trt=(mul 2 rtt)
804− %= +>.$
805− rue [~ now]
806− rto trt
807− rtn ?~(puq ~ [~ (add now trt)])
808− ==
809−```
810−
811−This updates the timing information in our packet pump. `rue`, the last
812−time we have heard from this neighbor, is set to now. `rto`, the
813−retransmit timeout is set to twice the current ping time, and if there
814−is anything in the packet queue, then we reset the next timeout, since
815−we've just heard a message.
816−
817−Back to `++east`.
818−
819−```hoon
820− %none
821− =. puz (bilk:puz now)
822− (chow ((hard meal) (cue msg)))
823−```
824−
825−The simplest case is when the encryption type is `%none`. We first call
826−`++bilk` to update the packet pump, then we cue (unjam) the message into
827−a meal. We hard cast it into a meal -- if the cast fails, then we do
828−want to crash since someone is sending us malformed data. Finally, we
829−send the result to `++chow` for interpretation and handling.
830−
831−```hoon
832− %fast
833− =+ [mag=`hand`(end 7 1 msg) bod=(rsh 7 1 msg)]
834− =+ dey=(kuch:diz mag)
835− ?~ dey
836− ~& [%bad-key her mag]
837− +>.$ :: ignore unknown key
838− =. puz (bilk:puz now)
839− =^ key diz u.dey
840− (chow(aut sin) ((hard meal) (cue (dy:q:sen:gus key bod))))
841−```
842−
843−For symmetric encryption, we first get the `++hand`, which is the hash of
844−the symmetric key. We pass it to `++kuch:lax:as:go`, which returns the
845−key if we either have used it before or we have proposed it. If we have
846−proposed it, then we change its status from proposed to real. If
847−`++kuch` fails, then we drop the packet and print out a `%bad-key`
848−message.
849−
850−Otherwise, we call `++bilk` as before to update the packet pump and pass
851−into `++chow` the decrypted data.
852−
853−```hoon
854− %full
855− =+ mex=((hard ,[p=[p=life q=life] q=will r=@]) (cue msg))
856− =. diz (deng:diz q.mex)
857− =+ wug=cluy:diz
858− ?> =(q.p.mex p.wug)
859− =+ gey=(sev:gus p.p.mex)
860− =+ mes=(need (tear:as:q.gey pub:ex:r.wug r.mex))
861− =. diz (wasc:diz p.mes)
862− =. puz (bilk:puz now)
863− (west(msg q.mes))
864−```
865−
866−For sealed asymmetric encryption, we first take off the the layer of
867−data that gives us the life and will of our neighbor, and we apply try
868−to extend their former will with the new data. `++deng` will fail if
869−this is impossible.
870−
871−Next, we get our most current understanding of our neighbor's crypto,
872−and we verify that it's the same life as what they're sending. Then, we
873−get our own crypto from `++sev` and decrypt the message with the public
874−key from our neighbor's crypto. We register the proposed symmetric key,
875−update the packet pump, and call `++west`, which simply casts the
876−message to a meal and calls `++chow`, reporting any error.
877−
878−```hoon
879− %open
880− =+ mex=((hard ,[p=[~ q=life] q=will r=@]) (cue msg))
881− =. diz (deng:diz q.mex)
882− =+ wug=cluy:diz
883− ?> =(q.p.mex p.wug)
884− =+ mes=(need (sure:as:r.wug *code r.mex))
885− =. puz (bilk:puz now)
886− (west(msg mes))
887−```
888−
889−Finally, for signed asymmetric encryption, we, as before, take off the
890−layer of data that gives us the life and will of our neighbor. This
891−time, of course, we do not get our own crypto -- only that of our
892−neighbor.
893−
894−The rest you have seen. We call `++deng` to extend the will, we verify
895−that their crypto life is what we think it ought to be, we "decrypt" the
896−data, we update the packet pump, and we call `++west` to call `++chow`.
897−
898−```hoon
899− ++ chow :: chow:la:ho:um:am
900− |= fud=meal :: interpret meal
901− ^+ +>
902− =. diz ?:(=(%none aut) diz (wast:diz ryn))
903− (dine fud)
904−```
905−
906−Here, if the message was encrypted at all, then we call
907−`++wast:lax:as:go`, which simply updates the lane (route) to our
908−neighbor (unless we're given a provisional route). This ensures that we
909−always have the most direct possible path to them.
910−
911−We've been handling this meal for so long, we've almost forgotten what
912−we want to do with it. The telos is of any meal to be dined on. We will
913−choose out the cases here that are important to our current
914−investigation.
915−
916−```hoon
917− %fore
918− =+ ^= lyn ^- lane
919− ?~ q.fud ryn
920− ?. ?=(%if -.u.q.fud) u.q.fud
921− [%ix +.u.q.fud]
922− :: u.q.fud
923− ?: =(our p.fud)
924− (emit %mead lyn r.fud)
925− =+ zid=(myx:gus p.fud)
926− (emir (wist:zid now xong:zid [~ lyn] r.fud))
927−```
928−
929−Forwarding is the simplest case, since we've seen all the arms before,
930−except perhaps `++emit` and `++emir`, which simply take a boon or list
931−of boons respectively and queue them up to be handled when the core
932−resolves. If we're told to forward a packet to ourselves, then we emit a
933−`%mead` boon which simply sends another `%hear` task to ourselves with
934−the data. Otherwise, we try to find a route to the recipient, as before.
935−
936−```hoon
937− %carp
938− =+ zol=(~(get by olz.weg) s.fud)
939− ?^ zol cock(kay u.zol)
940− =^ neb nys.weg
941− =+ neb=(~(get by nys.weg) s.fud)
942− ?^ neb [u.neb nys.weg]
943− =+ neb=`bait`[(kins p.fud) 0 r.fud ~]
944− [neb (~(put by nys.weg) s.fud neb)]
945− ?> (lth q.fud p.r.neb)
946− ?> =((kins p.fud) p.neb)
947− ?> =(r.fud p.r.neb)
948− =+ doy=`(unit ,@)`(~(get by q.r.neb) q.fud)
949− ?^ doy cock
950− => ^+ . %= .
951− q.r.neb (~(put by q.r.neb) q.fud t.fud)
952− q.neb +(q.neb)
953− ==
954− :: ~& [%carp q.fud s.fud q.neb p.r.neb]
955− ?: =(q.neb p.r.neb)
956− =: nys.weg (~(del by nys.weg) s.fud)
957− olz.weg (~(put by olz.weg) s.fud kay)
958− ==
959− (golf p.neb r.neb)
960− =. +>.$ cock
961− +>.$(nys.weg (~(put by nys.weg) s.fud neb))
962−```
963−
964−Here, we have received a partial message, and we're just assembling the
965−individual packets into a message. Most of this code is fairly
966−algorithmic, so we'll just hit the high points. In the beginning, we
967−check if we've already received this message, and if so, we resend the
968−acknowledgment. Remember, "always ack a dupe, never ack an ack".
969−
970−In `nys.weg` we keep track of an incoming set of partial packets,
971−indexed by the `flap` hash that comes with every packet. We check to see
972−if we have already received this partial message, and if so we
973−acknowledge it. Otherwise, we put it in `nys.weg` unless this is the
974−last message, in which case we ack the last partial message, move the
975−complete message into `olz.weg`, and call `++golf`, which assembles the
976−message and calls `++chew`, to start the dance again with the complete
977−message.
978−
979−```hoon
980− %bund
981− :: ~& [%bund q.fud r.fud]
982− ?> =(p:sen:gus p.fud)
983− (deer q.fud r.fud ?-(kay %dead ~, %good [~ s.fud]))
984−```
985−
986−What if we're just receiving a regular old, garden variety message? We
987−call `++deer` with the data from the message. If we already know that
988−the message processing will fail (that is, if we got a `%hole` card from
989−unix rather than a `%hear` card), then we don't even send the data at
990−all. Remember, if a packet fails to process, it's as if it never even
991−arrived, except that we send a negative acknowledgment.
992−
993−```hoon
994− ++ deer :: deer:la:ho:um:am
995− |= [cha=path num=@ud dut=(unit)] :: interpret message
996− ^+ +>
997− =+ rum=(fall (~(get by raz.bah) cha) *race)
998− %= +>.$
999− +>
1000− ?. (gte num did.rum) :: always ack a dup
1001− (cook (~(get by bum.rum) num) cha ~ ryn dam)
1002− ?: dod.rum
1003− (coat cha rum(mis (~(put by mis.rum) num [kay ryn dam dut])))
1004− %= +>.+>.$
1005− raz.bah
1006− %+ ~(put by raz.bah) cha
1007− rum(mis (~(put by mis.rum) num [kay ryn dam dut]))
1008− ==
1009− ==
1010−```
1011−
1012−First, we get the race for this particular triple of sender, receiver,
1013−and path, creating it if it doesn't exist. If we've already acked the
1014−message, then we resend the ack. Note that `did.rum` is the number of
1015−packets we acknowledged, positively or negatively while `bum.rum` is a
1016−map of message numbers to negative acknowledgments. Thus, if a message
1017−number is less than `did.rum`, then if it's in `bum.rum` then it was
1018−negatively acknowledged, otherwise it's positively acknowledged. Thus, we
1019−are constant in space with the number of successful messages and linear
1020−in the number of failed messages. We'll document `++cook` later on, but
1021−suffice it to say that it sends an acknowledgment. It is to end-to-end
1022−acknowledgments what `++cock` is to packet-level acknowledgments.
1023−
1024−If we are still processing a message (that is, `dod.rum` is false), then
1025−we simply put this message in the map of misordered packets to be
1026−processed when their time comes. "Processing a message" in this case
1027−means that we've received the message and notified the correct
1028−application, but we're still waiting for the application-level
1029−acknowledgment.
1030−
1031−Otherwise, we're ready for a packet, so we process it.
1032−
1033−```hoon
1034− ++ coat :: coat:ho:um:am
1035− |= [cha=path rum=race] :: update input race
1036− ^+ +>
1037− =+ cun=(~(get by mis.rum) did.rum)
1038− ?~ cun
1039− +>.$(raz.bah (~(put by raz.bah) cha rum))
1040− ?. =(%good p.u.cun) +>.$
1041− ?> ?=(^ s.u.cun)
1042− %= +>.$
1043− raz.bah (~(put by raz.bah) cha rum(dod |))
1044− bin
1045− :_ bin
1046− :^ %mulk
1047− [our her]
1048− `soap:ames`[[p:sen:gus clon:diz] cha did.rum]
1049− u.s.u.cun
1050− ==
1051−```
1052−
1053−First, we grab the message we want to process and store it in `cun`. If
1054−it's a good packet, then we change `dod.rum` to false, meaning that
1055−we're in the middle of processing a packet and should not start
1056−processing another one. We also put a `%mulk` boon into the queue so
1057−that, when it all resolves, we send a mesage to the intended recipient
1058−application. The boon contains the sender, the receiver, the identity of
1059−the message, and the message itself.
1060−
1061−This bubbles up all the way back to `++knob`, where we were handling the
1062−`%hear` card. Following the logic in `++knob`, we can see that the boons
1063−get sent into `++clop` to be turned into actual arvo-level moves. We've
1064−been here before, if you recall, when we handled the `%cake` boon to
1065−send a message. Now, we're handling the `%mulk` boon, which is
1066−unfortunately slightly more complicated.
1067−
1068−```hoon
1069− %mulk
1070− :: ~& [%mulk p.bon q.bon]
1071− ?> ?=([@ @ *] q.q.bon)
1072− ?> ?=(%q i.q.q.bon)
1073− ?+ i.t.q.q.bon
1074− ~& %mulk-bad
1075− :_ fox
1076− :~ :- (claw p.p.bon)
1077− [%sick %wart p.bon i.t.q.q.bon t.t.q.q.bon r.bon]
1078− ==
1079− %ge :: %gall request
1080− ?> ?=([@ ~] t.t.q.q.bon)
1081− =+ app=`term`(need ((sand %tas) i.t.t.q.q.bon))
1082− =+ ^= pax
1083− :+ (scot %p p.p.bon)
1084− (scot %p q.p.bon)
1085− q.q.bon
1086− :_ fox [hen %pass pax %g %rote p.bon app r.bon]~
1087− %gh :: %gall response
1088− ?> ?=([@ ~] t.t.q.q.bon)
1089− =+ app=`term`(need ((sand %tas) i.t.t.q.q.bon))
1090− =+ ^= pax
1091− :+ (scot %p p.p.bon)
1092− (scot %p q.p.bon)
1093− q.q.bon
1094− :_ fox [hen %pass pax %g %roth p.bon app r.bon]~
1095− ==
1096−```
1097−
1098−We're dispatching messages based on the prefix of their path. Since only
1099−`%gall` apps use end-to-end acknowledgments at the moment, every path
1100−must have at least two elements, and the first one must be `%q`. Beyond
1101−that, we handle the `/q/ge` and `/q/gh` cases for gall requests and
1102−responses, respectively.
1103−
1104−In both cases, we require the next term in the path to be the name of
1105−the intended recipient `%gall` app. Thus, a message to `/q/ge/talk` for
1106−example, will send a message to the talk app.
1107−
1108−We then send a message to the app itself. The message is either a
1109−`%rote` or a `%roth` for a request and a response, respectively. The
1110−content is the `rook` or `roon` that was sent (stored in `r.bon`), but
1111−we don't actually handle that at all here. That's completely a
1112−`%gall`-level thing. We're just the messenger.
1113−
1114−Notice the path we send this over. We encode the sender, the receiver,
1115−and the path over which it was sent. This fully specifies the `race` so
1116−that when the app gives us the acknowledgment we know where to send it.
1117−
1118−We now have another interlude. We have entrusted our precious data, so
1119−carefully guarded and guided from the app on that far-away ship, to our
1120−local app. It has the ability to do whatever it pleases with it. It may
1121−take a significant amount of time to process. When the message has been
1122−handled by this app, though, it must produce an acknowledgment. Our
1123−final task is to deliver this acknowledgment to the sending app.
1124−
1125−We should describe here what exactly these oft-mentioned acknowledgments
1126−actually consist of. There are two kinds of acknowledgments: positive
1127−and negative. A positive acknowledgment contains no data other than its
1128−existence. A negative acknowledgment may optionally include a reason for
1129−said negativity. Formally, a negative acknowledgment is an `ares`, which
1130−is a unit pair of a term and a list of tanks. If this is null, this is
1131−simply a failure with no associated information. If the pair exists, the
1132−term is a short error code that is usually both human and computer
1133−readable. For example, if you try to send a message to a valid `%gall`
1134−app that doesn't have any `++poke` to handle it, then `%gall` will give
1135−a negative acknowledgment with error term `%poke-find-fail`. The list of
1136−tanks is a human-readable description of the error. This often contains
1137−a stack trace. At any rate, all this information is returned to the
1138−sending app on the other end of the wire.
1139−
1140−After this brief interlude, our story resumes in `++knap`, where we
1141−receive responses. In particular, a `%mean` indicates a negative
1142−acknowledgment while a `%nice` indicates a positive acknowledgment.
1143−
1144−```hoon
1145− ?(%mean %nice)
1146− ?> ?=([@ @ @ *] tea)
1147− =+ soq=[(slav %p i.tea) (slav %p i.t.tea)]
1148− =+ pax=t.t.tea
1149− =+ ^= fuy
1150− =< zork =< zank
1151− %^ ~(rack am [now fox]) soq pax
1152− ?-(+<.sih %mean `p.+.sih, %nice ~)
1153− => %_(. fox q.fuy)
1154− =| out=(list move)
1155− |- ^- [p=(list move) q=_+>.^$]
1156− ?~ p.fuy
1157− [(flop out) +>.^$]
1158− =^ toe fox (clop now hen i.p.fuy)
1159− $(p.fuy t.p.fuy, out (weld (flop toe) out))
1160−```
1161−
1162−Recall the format of the path we sent the message on, and you'll
1163−understand why `soq` and `pax` are the sender/receiver pair and path on
1164−which the message was sent. The rest of this is structured much like
1165−`++knob`, so we call `++rack:am` and send the resulting boons to
1166−`++clop`. Business as usual.
1167−
1168−```hoon
1169− ++ rack :: rack:am
1170− |= [soq=sock cha=path cop=coop] :: e2e ack
1171− =+ oh=(ho:(um p.soq) q.soq)
1172− =. oh (cook:oh cop cha ~)
1173− (cans:oh cha)
1174−```
1175−
1176−First, we set up `++um` and `++ho`, as we've done twice before, for our
1177−domestic and foreign servers, respectively. The other two things are
1178−new, though. Well, `++cook` is not actually new, but we delayed the
1179−explanation saying only that it sends an acknowledgment. The time has
1180−come.
1181−
1182−```hoon
1183− ++ cook :: cook:ho:um:am
1184− |= [cop=coop cha=path ram=(unit ,[ryn=lane dam=flap])]
1185− ^+ +> :: acknowledgment
1186− =+ rum=(need (~(get by raz.bah) cha))
1187− =+ lat=(~(get by mis.rum) did.rum)
1188− ?: &(?=(~ lat) ?=(~ ram)) ~&(%ack-late-or-redundant +>.$)
1189− =+ ^- [ryn=lane dam=flap]
1190− ?^ ram [ryn.u.ram dam.u.ram]
1191− ?< ?=(~ lat)
1192− [q r]:u.lat
1193− =. raz.bah
1194− ?^ ram raz.bah
1195− %+ ~(put by raz.bah) cha
1196− rum(dod &, bum ?~(cop bum.rum (~(put by bum.rum) did.rum u.cop)))
1197− =^ roc diz (zuul:diz now [%buck cop dam ~s0])
1198− (busk(diz (wast:diz ryn)) xong:diz roc)
1199−```
1200−
1201−If we are acknowledging a message that we have already acked, the `ram`
1202−will contain the new lane and flap to send the duplicate ack to. This
1203−happens if we call `++cook` in `++deer`, but it doesn't happen from
1204−`++rack`. If there is no message waiting to be acknowledged and we're
1205−not given an explicit lane and flap (that is, we're not sending a
1206−duplicate ack), then the app must have sent us multiple acknowledgments.
1207−We do the only sensible thing we can do and drop all acknowledgments
1208−after the first, printing a message. This is, in fact, an error, so it
1209−could be argued that we ought to crash. Whatever you do, don't depend on
1210−this not crashing.
1211−
1212−First, we grab the race specified by the given path, and we get the most
1213−recent in-order message, which must be the one which is being
1214−acknowledged.
1215−
1216−Then, we decide which lane/flap to respond on/to. Basically, in the
1217−usual case we respond on the lane through which the initial message was
1218−sent, which is stored along with the other packet information in
1219−`mis.rum`, since it has to be remembered across calls to ames. However,
1220−if we receive a duplicate message, then we must respond to the new
1221−message. It's quite possible the reason the other acknowledgment didn't
1222−get returned was that the lane between the ships was broken.
1223−
1224−At any rate, we update the race by saying that we've finished processing
1225−this packet (unless we're sending a duplicate ack) and, if we're sending
1226−a negative acknowledgment, putting the negative ack into `bum.rum` so
1227−that we can resend it if necessary.
1228−
1229−We encode our new message, updating the packet pump, with `++zuul`, as
1230−before, and we send it off with `++busk`, routed via `++wast` to one of
1231−the ships in `++xong`. Of course, in practice, we don't even look at the
1232−ships in `++xong` because we already have a lane directly to our
1233−neighbor (the one over which they sent their message to us).
1234−
1235−We glossed over the actual message we're sending back. We're sending a
1236−`%buck` meal, which is an acknowledgment. The `cop` specifies whether
1237−this is a positive or a negative ack, `dam` specifies the message we're
1238−acknowledging, and the `~s0` is a placeholder for the processing time
1239−required. This time is neither calculated (though it is hopefully
1240−obvious how to do so) nor used at present, but this information may be
1241−used in the future for improved congestion control. Since the round-trip
1242−time for an end-to-end acknowledged packet includes the processing time
1243−on the other end, most common congestion control algorithms will stumble
1244−when some messages take much longer to process than others. As noted,
1245−though, this is simply an opportunity for improvement -- our congestion
1246−control algorithms are relatively naive at the moment.
1247−
1248−Recall that `++busk` calls `++wist` to put the actual `%ouzo` boon in
1249−the queue, which gets handled by `++clop` to actually send the message.
1250−This is the same pipeline as sending any other message, so we'll refer
1251−you to the explanation above if you've forgotten it.
1252−
1253−The last thing we need to do on this ship is move on to the next packet
1254−in the queue if there is one. If you recall, in `++rack` after the call
1255−to `++cook` there was a call to `++cans:ho:um:am`.
1256−
1257−```hoon
1258− ++ cans :: cans:ho:um:am
1259− |= cha=path
1260− =+ rum=(need (~(get by raz.bah) cha))
1261− =. rum
1262− %= rum
1263− did +(did.rum)
1264− mis (~(del by mis.rum) did.rum)
1265− ==
1266− (coat cha rum)
1267−```
1268−
1269−This is very simple. We increment the number of packets that we've
1270−acknowledged on this race and we delete the packet that we just
1271−acknowledged from the set of misordered packets.
1272−
1273−Then, we call `++coat` again to process the next packet if we've already
1274−received it. And that's it for this.
1275−
1276−The acknowledgment now travels the same path that its forebearer, the
1277−original message, once tread, but this time not into the great unknown.
1278−The weary traveler is seeking out its familial roots, finding the app
1279−from whom sprung forth the original message way back in paragraph three.
1280−When it arrives at the network adapter of its ancestors, the adapter
1281−tells unix, unix tells libuv, libuv tells vere, and vere sends a `%hear`
1282−task to ames. Once more into the kernel.
1283−
1284−The `%hear` task is handled in `++knob` as before, leading to `++gnaw`,
1285−going over to `++chew`, `++apse`, `++chow`, and eventualy to `++dine`.
1286−We've seen most of the cases in `++dine`, but we haven't yet looked at
1287−the handling of this `%buck` meal.
1288−
1289−```hoon
1290− %buck
1291− =. +> ?.(=(%full aut) +> cock) :: finish key exch
1292− +>(..la (tock p.fud q.fud r.fud))
1293−```
1294−
1295−We send a packet level acknowledgment if we're finishing a key exchange,
1296−else we call `++tock` to process the acknowledgment.
1297−
1298−This will get a little involved, so if you don't much care about how
1299−exactly an acknowledgment happens, just know that the result gets gifted
1300−as a `%woot` card back to the app who sent it. For those brave souls who
1301−wish to see this thing through to the end, it's once more into the
1302−breach.
1303−
1304−```hoon
1305− ++ tock :: tock:ho:um:am
1306− |= [cop=coop fap=flap cot=@dr] :: e2e ack by hash
1307− ^+ +>
1308− =^ yoh puz (bick:puz now fap)
1309− =. +>.$
1310− ?~ p.yoh +>.$
1311− =^ hud +>.$
1312− (done p.u.p.yoh q.u.p.yoh)
1313− ?~ hud +>.$
1314− %= +>.$
1315− bin
1316− :_ bin
1317− `boon`[%cake [our her] [[p:sen:gus clon:diz] u.p.yoh] cop u.hud]
1318− ==
1319− (busk xong:diz q.yoh)
1320−```
1321−
1322−We're going to work through this one a little backwards since it's
1323−mostly fairly simple except the call to `++bick:pu`. In fact, we'll just
1324−skip `++bick` for the moment and finish the rest.
1325−
1326−If `++bick` succesfully acks the message, then we call `++done`.
1327−
1328−```hoon
1329− ++ done :: done:ho:um:am
1330− |= [cha=path num=@ud] :: complete outgoing
1331− ^- [(unit duct) _+>]
1332− =+ rol=(need (~(get by ryl.bah) cha))
1333− =+ rix=(~(get by san.rol) num)
1334− ?~ rix [~ +>.$]
1335− :- rix
1336− %_ +>.$
1337− ryl.bah
1338− (~(put by ryl.bah) cha rol(san (~(del by san.rol) num)))
1339− ==
1340−```
1341−
1342−This very simply gets the rill (the outgoing counterpart to a race, if
1343−you recall), pulls out of the map of outstanding messages the duct over
1344−which the original message was sent, and produces this duct while
1345−deleting that entry from the map of outstanding messages.
1346−
1347−Going back to `++tock`, we now have the duct we need to return the
1348−result over. We do the very sensible thing and put a `%cake` boon in the
1349−queue to be processed later by `++clop`.
1350−
1351−In `q.yoh` we have a list of messages that may need to be sent, which we
1352−pass to `++busk` to send, as usual. When an acknowledgment arrives, that
1353−may trigger other messages immediately. This often happens when sending
1354−more messages than the width of the logical window since for congestion
1355−control reasons another message cannot be sent until some of the earlier
1356−ones have been acknowledged.
1357−
1358−We'll look at the processing of the `%cake` boon in `++clop` before we
1359−get back to talking about `++bick`.
1360−
1361−```hoon
1362− %cake
1363− :_ fox
1364− :~ [s.bon %give %woot q.p.bon r.bon]
1365− ==
1366−```
1367−
1368−We very simply give, along the duct we found above, a `%woot` card with
1369−the ship who sent us the ack and the ack itself. This allows the
1370−application to decide what to do about the result. In case of a failure,
1371−we usually either resend the message or display it to the user.
1372−Sometimes, we recognize the error term and handle it internally. In any
1373−case, the decision of how to handle the acknowledgment is entirely up to
1374−the application. Our job is done.
1375−
1376−Well, except that we skipped `++bick:pu`. Let's go back to that.
1377−
1378−```hoon
1379− ++ bick :: bick:pu
1380− |= [now=@da fap=flap] :: ack by hash
1381− ^- [[p=(unit soup) q=(list rock)] _+>]
1382− =+ sun=(~(get by diq) fap)
1383− ?~ sun
1384− [[~ ~] +>.$]
1385− =. diq (~(del by diq) fap)
1386− =^ gub +>.$ (bock now u.sun)
1387− =^ yop +>.$ (harv now)
1388− [[gub yop] +>.$]
1389−```
1390−
1391−If you recall, in `++whap:pu` we created the packet pump's
1392−representation of the message, which included putting the message into
1393−`diq`, which maps from packet hashes to packet sequence numbers. Thus,
1394−`u.sun` is the sequence number of this particular message.
1395−
1396−We delete this message from `diq` since we have now received an ack for
1397−it. We call `++bock` to perform the ack by sequence number. We call
1398−`++harv` to harvest the packet queue, sending any messages that are now
1399−able to be sent.
1400−
1401−In `++bock`, there are three arms we haven't seen before: `++bine`,
1402−`+wept`, and `++beet`. We'll describe each of these before we get to
1403−`++bock`. `++bine` looks scariest.
1404−
1405−```hoon
1406− ++ bine :: bine:pu
1407− |= [now=@da num=@ud] :: apply ack
1408− ^- [(unit soup) _+>]
1409− ?~ puq !!
1410− ?. =(num p.n.puq)
1411− ?: (gth num p.n.puq)
1412− =+ lef=$(puq l.puq)
1413− [-.lef +.lef(puq [n.puq puq.lef r.puq])]
1414− =+ rig=$(puq r.puq)
1415− [-.rig +.rig(puq [n.puq l.puq puq.rig])]
1416− =: rtt ?. &(liv.q.n.puq =(1 nux.q.n.puq)) rtt
1417− =+ gap=(sub now lys.q.n.puq)
1418− :: ~& [%bock-trip num (div gap (div ~s1 1.000))]
1419− (div (add (mul 2 rtt) gap) 3)
1420− nif (sub nif !liv.q.n.puq)
1421− ==
1422− =+ lez=(dec (need (~(get by pyz) gom.q.n.puq)))
1423− =^ gub pyz
1424− ?: =(0 lez)
1425− [[~ gom.q.n.puq] (~(del by pyz) gom.q.n.puq)]
1426− [~ (~(put by pyz) gom.q.n.puq lez)]
1427− :- gub
1428− +>.$(puq ~(nap to puq))
1429−```
1430−
1431−The first few lines are simply looking through the packet queue until we
1432−find the correct packet to ack. This is basic queue manipulation that
1433−operates directly on the treap structure of the queue. If you understand
1434−treap queues, the logic is easy to follow. Otherwise, just trust us that
1435−by the time we get to the `=:`, the packet with sequence number `num` is
1436−on the top of the packet queue (that is, at `n.puq`).
1437−
1438−We first update the round-trip time. If the packet is either not alive
1439−or had to be transmitted more than once, then we don't have any reliable
1440−way of calculating the round-trip time since we're unsure of exactly
1441−which transmission was acknowledged. Otherwise, the round-trip time is
1442−the difference between now and when the packet was last sent. We set
1443−`rtt` by a little weighted average where the previous smoothed RTT is
1444−weighted twice as much as the RTT of the current packet. Thus,
1445−`(2*rtt+gap)/3`. This gives us a nice smooth RTT that is somewhat
1446−resilient to outlier data while still being responsive to our
1447−ever-changing world.
1448−
1449−If the packet wasn't already dead, then we decrement the number of live
1450−packets, which may allow more packets to be sent.
1451−
1452−We decrement the number of unacknowledged packets in our `pyz` for this
1453−particular message. If you recall, this was set in `++whap` to the
1454−number of packets required to send a message.
1455−
1456−If that was the last packet in the messge that needed to be acked, then
1457−we delete the messgae reference from `pyz` and produce the id of the
1458−message. Otherwise, we simply update `pyz` with the new number of
1459−unacked messages. In either case, we remove the packet from the packet
1460−queue.
1461−
1462−```hoon
1463− ++ wept :: wept:pu
1464− |= [fip=@ud lap=@ud] :: fip thru lap-1
1465− =< abet =< apse
1466− |%
1467− ++ abet +>.$
1468− ++ apse
1469− ^+ .
1470− ?~ puq .
1471− ?: (lth p.n.puq fip) ?~(l.puq . left)
1472− ?: (gte p.n.puq lap) ?~(r.puq . rigt)
1473− => rigt =< left
1474− ?> ?=(^ puq)
1475− ?.(liv.q.n.puq . .(nif (dec nif), liv.q.n.puq |))
1476− ::
1477− ++ left
1478− ?> ?=(^ puq)
1479− ^+(. =+(lef=apse(puq l.puq) lef(puq [n.puq puq.lef r.puq])))
1480− ++ rigt
1481− ?> ?=(^ puq)
1482− ^+(. =+(rig=apse(puq r.puq) rig(puq [n.puq l.puq puq.rig])))
1483− --
1484−```
1485−
1486−The algorithm is a simple case of traversing the packet queue.
1487−Essentialy, we mark as dead all packets in the queue between `fip` and
1488−`(dec lap)`. We also update `nif`, the number of live packets. Lest you
1489−mourn too much the passing of these packets, know that they shall soon
1490−rise again. Recall that in `++bick` after the call to `++bock` we call
1491−`++harv`. This will resend the packets that have just been labeled dead.
1492−
1493−```hoon
1494− ++ beet :: beet:pu
1495− ^+ . :: advance unacked
1496− =- +(nep ?~(foh nus u.foh))
1497− ^= foh
1498− |- ^- (unit ,@ud)
1499− ?~ puq ~
1500− ?: (lte p.n.puq nep) $(puq l.puq)
1501− =+ rig=$(puq r.puq)
1502− ?^(rig rig [~ p.n.puq])
1503−```
1504−
1505−Here we search for the next expected packet number. Basically, we search
1506−the queue for the leftmost packet whose number is greater than the
1507−current `nep`. If we don't find any such packet, we just use the total
1508−number of packets sent.
1509−
1510−We can now dive into `++bock`, our last arm.
1511−
1512−```hoon
1513− ++ bock :: bock:pu
1514− |= [now=@da num=@ud] :: ack by sequence
1515− ^- [(unit soup) _+>]
1516− =^ gym +> (bine now num)
1517− :- gym
1518− ?: (gth num nep)
1519− =+ cam=(max 2 (div caw 2))
1520− :: ~& [%bock-hole num nep cam]
1521− beet:(wept(nep num, cag cam, caw cam) nep num)
1522− =. caw ?: (lth caw cag) +(caw)
1523− (add caw !=(0 (mod (mug now) caw)))
1524− ?: =(num nep)
1525− :: ~& [%bock-fine num nif caw cag]
1526− beet
1527− :: ~& [%bock-fill num nif caw cag]
1528− +>.$
1529−```
1530−
1531−First, we call `++bine` to apply the ack to the packet pump information.
1532−We produce `gym`, which, if it exists, is the id of the packet that was
1533−acked. If we received an ack for a packet later than the one we
1534−expected, then we halve the logical packet window and kill all the
1535−earlier packets so that they may be resent.
1536−
1537−Otherwise, we possibly increase the congestion window. If the window is
1538−less than the congestion threshold, then we increment the size of the
1539−window. Otherwise, we only increment one out of every `caw` times.
1540−
1541−If we received an ack for the packet we expected, then we simply advance
1542−`nep` with `++beet`. If we received an ack for a packet earlier than we
1543−expected, we do nothing.
1544−
1545−It may be hard to believe, but we are, in fact, done. The message has
1546−been sent, received, acknowledged, and the acknowledgment has been
1547−returned to the original sender. We hope it's clear that, while the
1548−process has been somewhat involved, the algorithms are not all that
1549−complicated. If you've read this far, you know `%ames`. The only other
1550−code involves initialization, timeouts, and the like.
1551−
1552−Below, we give detailed reference documentation for the data models
1553−involved.
1554−
1555−## Data Models
1556−
1557−### `++sufi:ames`, domestic host
1558−
1559−```hoon
1560− ++ sufi :: domestic host
1561− $: hoy=(list ship) :: hierarchy
1562− val=wund :: private keys
1563− law=will :: server will
1564− seh=(map hand ,[p=ship q=@da]) :: key cache
1565− hoc=(map ship dore) :: neighborhood
1566− == ::
1567−```
1568−
1569−This is the security state of a domestic server.
1570−
1571−`hoy` is a list of the ships directly above us in the hierarchy of
1572−ships. For example, for `~hoclur-bicrel`, this would be `~tasruc` and
1573−`~tug`. See `++sein:title`.
1574−
1575−`val` is a list of our private keys.
1576−
1577−`law` is our certificate, which is a list of the XXX
1578−
1579−`seh`
1580−
1581−`hoc` is a map of ships to `++dore:ames`. The stores all the security
1582−information about foreign ships. The keys to this map are the neighbors
1583−(ships we have been in contact with) of this domestic server.
1584−
1585−### `++wund:ames`, private keys
1586−
1587−```hoon
1588− ++ wund (list ,[p=life q=ring r=acru]) :: mace in action
1589−```
1590−
1591−This is a list of our own private keys, indexed by life. The key itself
1592−is the `++ring`, and the `++acru:ames` is the encryption engine. We generate
1593−the `++acru:ames` from the private key by calling `++weur`. Thus, we can at
1594−any time regenerate our `++wund:ames` from a `++mace:ames`. The current crypto is
1595−at the head of the list and can be accessed with `++sen:as:go`.
1596−
1597−### `++ring`, private key
1598−
1599−```hoon
1600− ++ ring ,@ :: private key
1601−```
1602−
1603−This is a private key. The first byte is reserved to identify the type
1604−of cryptography. Lower-case means public key, upper-case means public
1605−key, and the letter identifies which `++acru:ames` to use.
1606−
1607−### `++pass`, public key
1608−
1609−```hoon
1610− ++ pass ,@ :: public key
1611−```
1612−
1613−This is a public key. The first byte is reserved to identify the type of
1614−cryptography. Lower-case means public key, upper-case means public key,
1615−and the letter identifies which `++acru:ames` to use.
1616−
1617−### `++mace:ames`, private secrets
1618−
1619−```hoon
1620− ++ mace (list ,[p=life q=ring]) :: private secrets
1621−```
1622−
1623−This is a list of the our private keys, indexed by life. From this we
1624−can generate a `++wund:ames` for actual use.
1625−
1626−### `++skin:ames`, encoding stem
1627−
1628−```hoon
1629− ++ skin ?(%none %open %fast %full) :: encoding stem
1630−```
1631−
1632−This defines the type of encryption used for each message. `%none`
1633−refers to messages sent in the clear, `%open` refers to signed messages,
1634−`%full` refers to sealed messages, and `%fast` refers to symmetrically
1635−encrypted messages. See `++acru:ames` for details.
1636−
1637−### `++acru:ames`, asymmetric cryptosuite
1638−
1639−```hoon
1640− ++ acru :: asym cryptosuite
1641− $_ ^? |% :: opaque object
1642− ++ as ^? :: asym ops
1643− |% ++ seal |=([a=pass b=@ c=@] _@) :: encrypt to a
1644− ++ sign |=([a=@ b=@] _@) :: certify as us
1645− ++ sure |=([a=@ b=@] *(unit ,@)) :: authenticate from us
1646− ++ tear |= [a=pass b=@] :: accept from a
1647− *(unit ,[p=@ q=@]) ::
1648− -- ::
1649− ++ de |+([a=@ b=@] *(unit ,@)) :: symmetric de, soft
1650− ++ dy |+([a=@ b=@] _@) :: symmetric de, hard
1651− ++ en |+([a=@ b=@] _@) :: symmetric en
1652− ++ ex ^? :: export
1653− |% ++ fig _@uvH :: fingerprint
1654− ++ pac _@uvG :: default passcode
1655− ++ pub *pass :: public key
1656− ++ sec *ring :: private key
1657− --
1658− ++ nu ^? :: reconstructors
1659− |% ++ pit |=([a=@ b=@] ^?(..nu)) :: from [width seed]
1660− ++ nol |=(a=@ ^?(..nu)) :: from naked ring
1661− ++ com |=(a=@ ^?(..nu)) :: from naked pass
1662− --
1663− --
1664−```
1665−
1666−This is an opaque interface for a general asymmetric cryptosuite. Any
1667−form of asymmetric cryptography can be dropped in to be used instead of
1668−the default. Right now, there is one cryptosuite: `++crub:crypto:crypto`,
1669−which is elliptic-curve cryptography.
1670−
1671−#### `++as:acru:ames`, asymmetric operations
1672−
1673−```hoon
1674− ++ as ^? :: asym ops
1675− |% ++ seal |=([a=pass b=@ c=@] _@) :: encrypt to a
1676− ++ sign |=([a=@ b=@] _@) :: certify as us
1677− ++ sure |=([a=@ b=@] *(unit ,@)) :: authenticate from us
1678− ++ tear |= [a=pass b=@] :: accept from a
1679− *(unit ,[p=@ q=@]) ::
1680− -- ::
1681−```
1682−
1683−This is the core that defines the standard asymmetric cryptography
1684−operations.
1685−
1686−`++seal:as:acru:ames` allows us to send a message encrypted with someone's
1687−public key so that only they may read it. If Alice seals a message with
1688−Bob's public key, then she can be sure that Bob is the only one who can
1689−read it. This is associated with the `++skin:ames` `%full`.
1690−
1691−`++sign:as:acru:ames` allows us to sign a message with our private key so
1692−that others can verify that we sent the message. If Alice signs a
1693−message with her private key, then Bob can verify with her public key
1694−that it was indeed Alice who sent it. This is associated with the
1695−`++skin:ames` `%open`.
1696−
1697−`++sure:as:acru:ames` is the dual to `++sign:as:acru:ames`. It allows us to verify
1698−that a message we have received is indeed from the claimed sender. If
1699−Alice sends a message with her private key, then Bob can use this arm to
1700−verify that it was indeed Alice who sent it. This is associated with the
1701−`++skin:ames` `%open`.
1702−
1703−`++tear:as:acru:ames` is the dual to `++seal:as:acru:ames`. It allows us to read a
1704−message that we can be sure is only read by us. If Alice seals a message
1705−with Bob's public key, then Bob can use this arm to read it. This is
1706−associated with the `++skin:ames` `%full`.
1707−
1708−#### `++de:acru:ames`, `++dy:acru:ames`, and `++en:acru:ames`, symmetric encryption/decryption
1709−
1710−```hoon
1711− ++ de |+([a=@ b=@] *(unit ,@)) :: symmetric de, soft
1712− ++ dy |+([a=@ b=@] _@) :: symmetric de, hard
1713− ++ en |+([a=@ b=@] _@) :: symmetric en
1714−```
1715−
1716−Symmetric encryption is associated with the `++skin:ames` `%fast`.
1717−
1718−`++de:acru:ames` decrypts a message with a symmetric key, returning `~` on
1719−failure and `[~ u=data]` on success.
1720−
1721−`++dy:acru:ames` decrypts a message with a symmetric key, crashing on
1722−failure. This should almost always be defined as, and should always be
1723−semantically equivalent to, `(need (de a b))`.
1724−
1725−`++en:acru:ames` encrypts a message with a symmetric key.
1726−
1727−#### `++ex:acru:ames`, exporting data
1728−
1729−```hoon
1730− ++ ex ^? :: export
1731− |% ++ fig _@uvH :: fingerprint
1732− ++ pac _@uvG :: default passcode
1733− ++ pub *pass :: public key
1734− ++ sec *ring :: private key
1735− --
1736−```
1737−
1738−`++fig:ex:acru:ames` is our fingerprint, usually a hash of our public key.
1739−This is used, for example, in `++zeno`, where every carrier owner's
1740−fingerprint is stored so that we can ensure that carriers are indeed
1741−owned by their owners
1742−
1743−`++pac:ex:acru:ames` is our default passcode, which is unused at present.
1744−
1745−`++pub:ex:acru:ames` is the `++pass` form of our public key.
1746−
1747−`++sec:ex:acru:ames` is the `++ring` form of our private key.
1748−
1749−#### `++nu:acru:ames`, reconstructors
1750−
1751−```hoon
1752− ++ nu ^? :: reconstructors
1753− |% ++ pit |=([a=@ b=@] ^?(..nu)) :: from [width seed]
1754− ++ nol |=(a=@ ^?(..nu)) :: from naked ring
1755− ++ com |=(a=@ ^?(..nu)) :: from naked pass
1756− --
1757−```
1758−
1759−These arms allow us to reconstruct a `++acru:ames` from basic data.
1760−
1761−`++pit:nu:acru:ames` constructs a `++acru:ames` from the width of our intended key
1762−and seed entropy. This is usually used in the initial construction of
1763−the `++acru:ames`.
1764−
1765−`++nol:nu:acru:ames` constructs a `++acru:ames` from a "naked ring", meaning a
1766−`++ring` without the initial byte identifying the type of crypto.
1767−
1768−`++com:nu:acru:ames` constructs a `++acru:ames` from a "naked pass", meaning a
1769−`++ring` without the initial byte identifying the type of crypto.
1770−
1771−### `++will`, certificate
1772−
1773−```hoon
1774− ++ will (list deed) :: certificate
1775−```
1776−
1777−This is a list of deeds associated with the current ship. There should
1778−be an item in this list for every ship from this point up in the
1779−hierarchy times the number of lives that each ship has had. For example,
1780−\~hoclur-bicrel may have a will with three items: one for itself, one
1781−for \~tasruc (who issued \~hoclur-bicrel's deed) and one for \~tug (who
1782−issued \~tasruc's deed).
1783−
1784−### `++deed`, identity
1785−
1786−```hoon
1787− ++ deed ,[p=@ q=step r=?] :: sig, stage, fake?
1788−```
1789−
1790−`p` is the signature of a particular deed, which is a signed copy of
1791−`q`.
1792−
1793−`q` is the stage in the identity.
1794−
1795−`r` is true if we're working on a fake network, where we don't check
1796−that the carrier fingerprints are correct. This allows us to create fake
1797−networks for development without interfering with the real network.
1798−
1799−### `++step:ames`, identity stage
1800−
1801−```hoon
1802− ++ step ,[p=bray q=gens r=pass] :: identity stage
1803−```
1804−
1805−This is a single stage in our identity. Thus, this is specific to a
1806−single life in a single ship. Everything in here may change between
1807−lives.
1808−
1809−`p`
1810−
1811−`q`
1812−
1813−`r` is the public key for this stage in the identity.
1814−
1815−### `++bray:ames`
1816−
1817−```hoon
1818− ++ bray ,[p=life q=(unit life) r=ship s=@da] :: our parent us now
1819−```
1820−
1821−XXX
1822−
1823−### `++gens:ames`, general identity
1824−
1825−```hoon
1826− ++ gens ,[p=lang q=gcos] :: general identity
1827−```
1828−
1829−`p` is the IETF language code for the preferred language of this
1830−identity. This is unused at the moment, but in the future text should be
1831−localized based on this.
1832−
1833−`q` is the description of the ship.
1834−
1835−### `++gcos:ames`, identity description
1836−
1837−```hoon
1838− ++ gcos :: id description
1839− $% [%czar ~] :: 8-bit ship
1840− [%duke p=what] :: 32-bit ship
1841− [%earl p=@t] :: 64-bit ship
1842− [%king p=@t] :: 16-bit ship
1843− [%pawn p=(unit ,@t)] :: 128-bit ship
1844− == ::
1845−```
1846−
1847−This is the description of the identity of a ship. Most types of
1848−identity have a `@t` field, which is their human-readable name. The
1849−identity of a `%duke` is more involved.
1850−
1851−A `%czar`, a carrier, is a ship with an 8-bit address. Thus, there are
1852−only 256 carriers. These are at the top of the namespace hierarchy, and
1853−the fingerprint of each carrier is stored in `++zeno`. These are the
1854−"senators" of Urbit.
1855−
1856−A `%king`, a cruiser, is a ship with a 16-bit address. Thus, there are
1857−65,536 cruisers. Each carrier may issue 256 cruisers. These are the
1858−infrastructure of Urbit.
1859−
1860−A `%duke`, a destroyer, is a ship with a 32-bit address. Thus, there are
1861−4,294,967,296 destroyers. Each cruiser may issue 65,536 cruisers. These
1862−are the individuals of Urbit.
1863−
1864−A `%earl`, a yacht, is a ship with a 64-bit address. Thus, there are
1865−18,446,744,073,709,551,616 yachts. Each destroyer may issue
1866−4,294,967,296 yachts. These are the devices of Urbit.
1867−
1868−A `%pawn`, a submarine, is a ship with a 128-bit address. Thus, there
1869−are a lot of submarines. The chance of random name collision is
1870−negligible, so submarines are not issued by any ship. They must simply
1871−assert their presence, and they are all considered children of \~zod.
1872−This is the underworld of Urbit, where anonymity reigns supreme.
1873−
1874−### `++what:ames`, logical destroyer identity
1875−
1876−```hoon
1877− ++ what :: logical identity
1878− $% [%anon ~] :: anonymous
1879− [%lady p=whom] :: female person ()
1880− [%lord p=whom] :: male person []
1881− [%punk p=sect q=@t] :: opaque handle ""
1882− == ::
1883−```
1884−
1885−This is the logical identity of a destroyer.
1886−
1887−A `%anon` is a completely anonymous destroyer. The difference between
1888−this and a submarine is that a submarine is ephemeral while a `%anon`
1889−destroyer is not. Thus, we may not know who \~hoclur-bicrel is, but we
1890−do know that it's always the same person.
1891−
1892−A `%lady` is a female person. The name used here should be a real name.
1893−
1894−A `%lord` is a male person. The name used here should be a real name.
1895−
1896−A `%punk` is a person who is identified only by a handle.
1897−
1898−### `++whom:ames`, real person
1899−
1900−```hoon
1901− ++ whom ,[p=@ud q=govt r=sect s=name] :: year/govt/id
1902−```
1903−
1904−Ths is the information associated with a real person. It is mostly
1905−information that could be observed with the briefest of interactions.
1906−
1907−`p` is the birth year.
1908−
1909−`q` is the location of a user, usually of the form "country/zip".
1910−
1911−`r` is the sect of the user.
1912−
1913−`s` is the real name of the person.
1914−
1915−### `++govt:ames`
1916−
1917−```hoon
1918− ++ govt path :: country/postcode
1919−```
1920−
1921−This is the location of the user, usually of the form "country/zip".
1922−
1923−### `++sect:ames`
1924−
1925−```hoon
1926− ++ sect ?(%black %blue %red %orange %white) :: banner
1927−```
1928−
1929−XXX
1930−
1931−### `++name:ames`
1932−
1933−```hoon
1934− ++ name ,[p=@t q=(unit ,@t) r=(unit ,@t) s=@t] :: first mid/nick last
1935−```
1936−
1937−This is the given name, possible middle name/initial, possible nickname,
1938−and surname of a user.
tutorials/arvo/arvo.mdnew file+574
@@ -0,0 +1,574 @@
1++++
2+title = "Arvo"
3+weight = 1
4+template = "doc.html"
5+aliases = ["/docs/learn/arvo/arvo/"]
6++++
7+Arvo, also called Urbit OS, is our operating system.
8+
9+# Introduction
10+
11+## Overview
12+
13+This article is intended to provide a thorough summary of all of the most
14+important aspects of the Arvo kernel and how this functionality gives life to
15+the ambitions of the Urbit platform. We work on two levels: a conceptual level
16+that should be useful to anybody interested in how Arvo works, and a more
17+technical level intended for those that intend to write software for Urbit.
18+
19+The [Urbit white paper](https://media.urbit.org/whitepaper.pdf) is a good
20+companion to this document, and some segments are direct quotes or paraphrases, but it should be noted that some parts of it are now either out of date or not yet implemented.
21+
22+## Prerequisites
23+
24+The conceptual section titled [What is Arvo?](#what-is-arvo-) can be understood
25+without knowing Hoon, the Urbit programming language. The technical section
26+titled [The kernel](#the-kernel) will require Chapter One of the [Hoon
27+tutorial](@/docs/tutorials/hoon/_index.md) for full understanding, and some
28+material from Chapter Two will be helpful as well. At the bare minimum, we
29+presume that the reader has read through the [Technical
30+Overview](@/docs/tutorials/concepts/technical-overview.md).
31+
32+We also suggest to the reader to peruse the [glossary](@/docs/glossary/_index.md) before diving into this article. It will provide the initial scaffolding that you will be able to gradually fill in as you read this article and go deeper into the alternate universe of computing that is Urbit.
33+
34+
35+# Table of Contents
36+
37+- [What is Arvo?](#what-is-arvo)
38+ * [An operating function](#an-operating-function)
39+ + [Determinism](#determinism)
40+ + [Event log](#event-log)
41+ * [Solid state interpreter](#solid-state-interpreter)
42+ + [Over-the-air updates](#over-the-air-updates)
43+ + [ACID Database](#acid-database)
44+ + [Single-level store](#single-level-store)
45+ + [Non-preemptive](#non-preemptive)
46+- [The kernel](#the-kernel)
47+ * [Overall structure](#overall-structure)
48+ + [Formal interface](#formal-interface)
49+ + [Types](#types)
50+ + [Arvo cores](#arvo-cores)
51+ * [The state](#the-state)
52+ * [Vanes](#vanes)
53+
54+# What is Arvo?
55+
56+Arvo is a [non-preemptive](#non-preemptive)
57+operating system purposefully built to create a new, peer-to-peer internet
58+whereby users own and manage their own data. Despite being an operating system,
59+Arvo does not replace Windows, Mac OS, or Linux. It is better to think of the
60+user experience of Arvo as being closer to that of a web browser despite being a
61+fully fledged OS. As such, Arvo is generally run inside a virtual machine, though in theory it could be run on bare metal.
62+
63+Urbit is a “browser for the server side”; it replaces multiple developer-hosted web services on multiple foreign servers, with multiple self-hosted applications on one personal server. Every architectural decision for Arvo (and indeed, the entire Urbit stack) was made with this singular goal in mind. Throughout this document, we connect the various concepts underlying Arvo with this overarching goal.
64+
65+Arvo is designed to avoid the usual state of complex event networks: event spaghetti. We keep track of every event's cause so that we have a clear causal chain for every computation. At the bottom of every chain is a Unix I/O event, such as a network request, terminal input, file sync, or timer event. We push every step in the path the request takes onto the chain until we get to the terminal cause of the computation. Then we use this causal stack to route results back to the caller.
66+
67+Unlike any other popular operating system, it is possible for a single human to understand every aspect of Arvo due to its compact size. The entire Urbit stack is around 30,000 lines of code, while the Arvo kernel is only about 1,000 lines of code. We strive for a small codebase because the difficulty in administering a system is roughly proportional to the size of its code base.
68+
69+## An operating function
70+
71+Arvo is the world's first _purely functional_ operating system, and as such it may reasonably be called an _operating function_. The importance of understanding this design choice and its relevance to the overarching goal cannot be understated. If you knew only a single thing about Arvo, let it be this.
72+
73+This means two things: one is that the there is a notion of _state_ for the operating system, and that the current state is a pure function of the [event log](#event-log), which is a chronological record of every action the operating system has ever performed. A _pure function_ is a function that always produces the same output given the same input. Another way to put this is to say that Arvo is _deterministic_. Other operating systems are not deterministic for a number of reasons, but one simple reasons is because they allow programs to alter global variables that then affect the operation of other programs.
74+
75+In mathematical terms, one may think of Arvo as being given by a transition function _T_:
76+
77+```
78+T: (State, Input) -> (State, Output).
79+```
80+
81+In practice, _T_ is implemented by the `+poke` [arm](/docs/glossary/arm/) of the Arvo kernel, which is described in more detail in the [kernel section](#the-kernel). In theoretical terms, it may be more practical to think of Arvo as being defined by a _lifecycle function_ we denote here by _L_:
82+
83+```
84+L: History -> State.
85+```
86+
87+Which perspective is more fruitful depends on the problem being considered.
88+
89+### Determinism
90+
91+We consider Arvo to be deterministic at a high level. By that we mean that it is
92+stacked on top of a frozen instruction set known as Nock. Frozen instruction
93+sets are a new idea for an operating system, but not for computing in general.
94+For instance, the CPU instruction sets such as
95+[x86-64](https://en.wikipedia.org/wiki/X86-64v) are frozen at the level of the
96+chip. A given operating system may be adapted to run on more than one CPU
97+instruction set, we merely freeze the instruction set at a higher level in order
98+to enable deterministic computation.
99+
100+Arvo handles nondeterminism in an interesting way. Deciding whether or not to
101+halt a computation that could potentially last forever becomes a heuristic
102+decision that is akin to dropping a packet. Thus it behooves one to think of
103+Arvo as being a stateful packet transceiver rather than an ordinary computer - events
104+are never guaranteed to complete, even if one can prove that the computation
105+would eventually terminate. We elaborate on this in the [solid state
106+interpreter](#solid-state-intrepeter) section.
107+
108+Because Arvo is run on a VM, nondeterministic information such as the stack
109+trace of an infinite loop that was entered into may be obtained. This is
110+possible because while Arvo may be unable to obtain that information, the
111+interpreter beneath does and can inject that information back into the event log.
112+
113+Being deterministic at a high level enables many
114+things that are out of reach of any other operating system. For
115+instance, we are able to do [over-the-air](#over-the-air-updates) (OTA) updates,
116+which allows software updates to be implemented across the network without
117+needing to worry whether it won't work on someone's ship, since Arvo is an
118+[interpreter](#solid-state-intrepeter) that can accept source code to
119+update itself instead of requiring a pre-compiled binary. This essential
120+property is why Urbit is able to act as a personal server while only having the
121+the user experience is akin to that of a web browser.
122+
123+### Event log
124+
125+The formal state of an Arvo instance is an event history, as a linked list of [nouns](/docs/glossary/noun/) from first to last. The history starts with a bootstrap sequence that delivers Arvo itself, first as an inscrutable kernel, then as the self-compiling source for that kernel. After booting, we break symmetry by delivering identity and entropy. The rest of the log is actual input.
126+
127+The Arvo event log is a list of every action ever performed on your ship that
128+lead up to the current state. In principle, this event log is maintained by the
129+[Nock runtime environment](@/docs/tutorials/vere/_index.md), but in practice
130+event logs become too long over time to keep, as the event log has a size of
131+O(n) where n is the number of events. Thus it is our intention to
132+implement a feature whereby periodic snapshots of the state of Arvo are taken
133+and the log up to that state is pruned. This is currently unnecessary and thus
134+this feature has not been prioritized.
135+
136+The beginning of the event log starting from the very first time a ship is
137+booted up until the kernel is compiled and identity and entropy are created is a
138+special portion of the Arvo lifecycle known as the _larval stage_. We describe
139+the larval stage in more detail in the [larval stage](#larval-stage-core) section.
140+
141+More information on the structure of the Arvo event log and the Arvo state is given in the section on [the kernel](#the-kernel).
142+
143+
144+
145+## Solid state interpreter
146+
147+Arvo is a _solid state interpreter_. In this section we describe what is meant
148+by this new term, and how this behavior derives from the fact that Arvo is an [ACID database](#acid-database) and a [single-level store](#single-level-store).
149+
150+In computer science, an _interpreter_ is a program that directly executes
151+instructions written in some human-understandable programming or scripting
152+language, rather than requiring the code to first be compiled into a machine
153+language. Arvo is an interpreter, which is important for us since it allows us
154+to perform derministic [over-the-air updates](#over-the-air-updates) by the
155+direct transfer of raw source code.
156+
157+To understand what we mean by _solid state_ interpreter, consider the operation of a solid state hard drive when a computer shuts down or loses power. Data written to an SSD is permanent unless otherwise deleted - loss of power may leave some partially written data, but nothing is ever lost. Thus, the state of an SDD can be considered to be equivalent to the data that it contains. That is to say, you do not need to know anything about the system which is utilizing the SSD to know everything there is to know about the SSD. There is no notion of "rebooting" a SSD - it simply stores data, and when power is restored to it, it is in exactly the same state as it was when power was lost.
158+
159+Contrast this with other popular operating systems, such as Windows, Mac, or Linux. The state of the operating system is something that crucially depends on having a constant power supply because much of the state of the operating system is stored in RAM, which is volatile. When you reboot your computer or suddenly lose power, any information stored in RAM is lost. Modern operating systems do mitigate this loss of information to some extent. For instance, it may remember what applications you were running at the time power was lost and try to restore them. Particularly durable programs may go as far as writing their state to disk every few seconds so that only very minimal information can be lost in a power outage. However, this is not the default behavior, and indeed if it were then they would be so slow as to be unusable, as you would effectively be using your hard disk as the RAM.
160+
161+How Arvo handles loss of power is closer to that of an SSD. Since it is an [ACID database](#acid-database) and a [single-level store](#single-level-store), a sudden loss of power have no effect on the state of the operating system. When you boot your ship back up it will be exactly as it was before the failure. Your information can never be lost, and because it was designed from the ground up to behave in this fashion, it does not suffer significant slowdown by persisting all data in this manner as would be the case if your typical operating system utilized its hard disk as RAM.
162+
163+Another way to describe a solid state interpreter is to think of it as a
164+stateful packet transceiver. Imagine
165+it as a chip. Plug this chip into power and network; packets go in and
166+out, sometimes changing its state. The chip never loses data and has
167+no concept of a reboot; every packet is an [ACID transaction](#acid-database).
168+
169+
170+### Over-the-air updates
171+
172+Arvo can hotpatch any other semantics at any layer in the system (apps, vanes, Arvo or Hoon itself) with automatic over-the-air updates.
173+
174+Typically, updates to an operating system are given via a pre-compiled binary,
175+which is why some updates will work on some systems but not on others where the
176+hardware and environment may differ. This is not so on Arvo - because it is an
177+[interpreter](#solid-state-interpreter), Arvo may update itself by receiving
178+source code from your sponsor over [Ames](@/docs/tutorials/arvo/ames.md), our
179+network. As Hoon compiles down to Nock, which is an axiomatic representation of
180+a deterministic computer, this code is guaranteed to run identically on your machine as it
181+would on anybody else's.
182+
183+Some subtleties regarding types arise when handling OTA updates, since they can
184+potentially alter the type system. Put more concretely, the type of `type` may
185+be updated. In that case, the update is an untyped Nock formula from the
186+perspective of the old kernel, but ordinary typed Hoon code from the perspective of
187+the new kernel. Besides this one detail, the only functionality of the Arvo
188+kernel proper that is untyped are its interactions with the Unix runtime.
189+
190+### ACID Database
191+
192+In the client-server model, data is stored on the server and thus reliable and efficient databases are an integral part of server architecture. This is not quite so true for the client - a user may be expected to reboot their machine in the middle of a computation, alter or destroy their data, never make backups or perform version control, etc. In other words, client systems like your personal computer or smart phone are not well suited to act as databases.
193+
194+In order to dismantle the client-server model and build a peer-to-peer internet, we need the robustness of modern database servers in the hands of the users. Thus the Arvo operating system itself must have all of the properties of a reliable database.
195+
196+Database theory studies in precise terms the possible properties of anything that could be considered to be a database. In this context, Arvo has the properties of an [ACID database](https://en.wikipedia.org/wiki/ACID), and the Ames network could be thought of as network of such databases. ACID stands for _atomicity_, _consistency_, _isolation_, and _durability_. We review here how Arvo satisfies these properties.
197+
198+ - Atomicity: Events in Arvo are _atomic_, meaning that they either succeed completely or fail completely. In other words, there are no transient periods in which something like a power failure will leave the operating system in an invalid state. When an event occurs in Arvo, e.g. [the kernel](#the-kernel) is `poke`d, the effects of an event are computed, the event is [persisted](https://en.wikipedia.org/wiki/Persistence_(computer_science)) by writing it to the event log, and only then are the actual effects applied.
199+
200+ - Consistency: Every possible update to the database puts it into another valid state. Given that Arvo is purely functional, this is easier to accomplish than it would be in an imperative setting.
201+
202+ - Isolation: Transactions in databases often happen concurrently, and isolation
203+ ensures that the transactions occur as if they were performed sequentially,
204+ making it so that their effects are isolated from one another. Arvo ensures
205+ this simply by the fact that it only ever performs events sequentially. While
206+ Arvo
207+ transactions are sequential and performed by the daemon, persistence and effect application are performed
208+ in parallel by the worker; see [worker and
209+ daemon](@/docs/tutorials/vere/_index.md) for more detail.
210+
211+ - Durability: Completed transactions will survive permanently. In other words,
212+ since the event log is stored on disk, if power is lost you are guaranteed
213+ that no transactions will be reversed.
214+
215+It is easy to think that "completed transaction will survive permanently"
216+along with "the state of Arvo is pure function of its event log" implies that
217+nothing can ever be deleted. This is not quite true.
218+[Clay](@/docs/tutorials/arvo/clay.md) is our [referentially
219+transparency](https://en.wikipedia.org/wiki/Referential_transparency)
220+file system, which could naively be thought to mean that since data must be
221+immutable, files cannot be deleted. However, Clay can replace a file with a
222+"tombstone" that causes Clay to crash whenever it is accessed. Referential
223+transparency only guarantees that there won't be new data at a previously
224+accessed location - not that it will still be available.
225+
226+### Single-level store
227+
228+A kernel which presents the abstraction of a single layer of permanent state is also called a _single-level store_. One way to describe a single-level store is that it never reboots; a formal model of the system does not contain an operation which unpredictably erases half its brain.
229+
230+Today's operating systems utilize at least two types of memory: the hard disk and the RAM, and this split is responsible for the fact that data is lost whenever power is lost. Not every operating system in history was designed this way - in particular, [Multics](https://en.wikipedia.org/wiki/Multics) utilized only one store of memory. Arvo takes after Multics - all data is stored in one permanent location, and as a result no data is ever lost when power is lost.
231+
232+### Non-preemptive
233+
234+Most operating systems are preemptive, meaning that they regularly interrupt
235+tasks being performed with the intention of resuming that task at a later time,
236+without the task explicitly yielding control.
237+Arvo does not do this - tasks run until they are complete or are cancelled due
238+to some heuristic, such as taking too long or because the user pressed Ctrl-C.
239+This is known as
240+[non-preemptive](https://en.wikipedia.org/wiki/Cooperative_multitasking) or
241+cooperative multitasking.
242+
243+
244+# The kernel
245+
246+The Arvo kernel, stored in `sys/arvo.hoon`, is about 1k lines of Hoon whose primary purpose is to implement the transition function, `+poke`. In this section we point out the most important parts of `arvo.hoon` and describe their role in the greater system. We also give brief descriptions of Arvo's kernel modules, known as vanes, and how Arvo interfaces with them.
247+
248+This section requires an understanding of Hoon of at least the level of Chapter One of the [Hoon tutorial](@/docs/tutorials/hoon/_index.md).
249+
250+After concluding this section, the reader is encouraged to follow along with the
251+[move trace tutorial](@/docs/tutorials/arvo/move-trace.md),
252+which applies many of the concepts covered below.
253+
254+## Overall structure
255+
256+`arvo.hoon` contains five top level cores as well as a "formal interface" consisting of a single [gate](/docs/glossary/gate/) that implements the transition function. They are nested with the `=<` and `=>` runes like so, where items lower on the list are contained within items higher on the list:
257+ + Types
258+ + Section 3bE Arvo Core
259+ + Implementation core
260+ + Structural interface core, or adult core
261+ + Larval stage core
262+ + Formal interface
263+
264+See [Section 1.7](@/docs/tutorials/hoon/arms-and-cores.md#core-nesting) of the Hoon tutorial for further explanation of what is meant here by "nesting". We now describe the functionality of each of these components.
265+
266+### Formal interface
267+
268+The formal interface is a single gate that takes in the current time and a noun that encodes the input. This input, referred to as an _event_, is then put into action by the `+poke` arm, and a new noun denoting the current [state of Arvo](#the-state) is returned. In reality, you cannot feed the gate just any noun - it will end up being an `ovum` described below - but as this is the outermost interface of the kernel the types defined in the type core are not visible to the formal interface.
269+
270+```hoon
271+ :: Arvo formal interface
272+ ::
273+ :: this lifecycle wrapper makes the arvo door (multi-armed core)
274+ :: look like a gate (function or single-armed core), to fit
275+ :: urbit's formal lifecycle function. a practical interpreter
276+ :: can ignore it.
277+ ::
278+ |= [now=@da ovo=*]
279+ ^- *
280+ ~> %slog.[0 leaf+"arvo-event"]
281+ .(+> +:(poke now ovo))
282+```
283+
284+### Types
285+
286+This core contains the most basic types utilized in Arvo. We discuss a number of them here.
287+
288+#### `+duct`
289+
290+```hoon
291+++ duct (list wire) :: causal history
292+```
293+
294+Arvo is designed to avoid the usual state of complex event networks: event
295+spaghetti. We keep track of every event's cause so that we have a clear causal
296+chain for every computation. At the bottom of every chain is a Unix I/O event,
297+such as a network request, terminal input, file sync, or timer event. We push
298+every step in the path the request takes onto the chain until we get to the
299+terminal cause of the computation. Then we use this causal stack to route
300+results back to the caller.
301+
302+The Arvo causal stack is called a `duct`. This is represented simply as a list of paths, where each path represents a step in the causal chain. The first element in the path is the first letter of whichever vane handled that step in the computation, or the empty span for Unix.
303+
304+Here's a `duct` that was recently observed in the wild upon entering `-time ~s1`
305+into the dojo and pressing Enter, which sets a timer for one second that will
306+then produce a `@d` with the current time after the timer has elapsed:
307+
308+```
309+~[
310+ /g/a/~zod/4_shell_terminal/u/time
311+ /g/a/~zod/shell_terminal/u/child/4/main
312+ /g/a/~zod/terminal/u/txt
313+ /d/term-mess
314+ //term/1
315+]
316+```
317+
318+This is the `duct` that the timer vane, Behn, receives when the `time` sample app asks the Behn to set a timer. This is also the `duct` over which the response is produced at the specified time. Unix sent a terminal keystroke event (enter), and Arvo routed it to Dill (our terminal), which passed it on to the Gall app terminal, which sent it to shell, its child, which created a new child (with process id 4), which on startup asked Behn to set a timer.
319+
320+Behn saves this `duct`, so that when the specified time arrives and Unix sends a
321+wakeup event to the timer vane, it can produce the response on the same `duct`.
322+This response is routed to the place we popped off the top of the `duct`, i.e. the
323+time app. This app returns a `@d` which denotes the current time, which falls down to the shell,
324+which drops it through to the terminal. Terminal drops this down to Dill, which
325+converts it into an effect that Unix will recognize as a request to print the
326+current time to the screen. When Dill produces this, the last path in the `duct` has an
327+initial element of the empty span, so this is routed to Unix, which applies the effects.
328+
329+This is a call stack, with a crucial feature: the stack is a first-class citizen. You can respond over a `duct` zero, one, or many times. You can save `duct`s for later use. There are definitely parallels to Scheme-style continuations, but simpler and with more structure.
330+
331+
332+#### `wire`
333+
334+```hoon
335+++ wire path :: event pretext
336+```
337+
338+Synonym for `path`, used in `duct`s. These should be thought of as a list of symbols
339+representing a cause.
340+
341+#### `move`
342+
343+```hoon
344+++ move [p=duct q=arvo] :: arvo move
345+```
346+
347+If `duct`s are a call stack, then how do we make calls and produce results? Arvo
348+processes `move`s which are a combination of message data and metadata. There
349+are four types of `move`s: `%pass`, `%give`, `%slip`, and `%unix`.
350+
351+A `%pass` `move` is analogous to a call:
352+
353+```
354+[duct %pass return-path=path vane-name=@tD data=card]
355+```
356+
357+Arvo pushes the return path (preceded by the first letter of the vane name) onto
358+the `duct` and sends the given data, a `card`, to the vane we specified. Any response will come along the same `duct` with the `wire` `return-path`.
359+
360+A `%give` `move` is analogous to a return:
361+
362+```
363+[duct %give data=card]
364+```
365+
366+Arvo pops the top `wire` off the `duct` and sends the given `card` back to the caller.
367+
368+A `%slip` `move` is a cousin of `%pass`. Any `card` that can be `%pass`ed can also be
369+`%slip`ed, but while a `%pass` says to "push this `wire` onto the `duct` and
370+transfer control to the receiving vane", a `%slip` transfers control to the
371+receiving vane without altering the `duct`. Therefore, a `%give` in response to
372+a `%slip` will go to the caller of the vane that sent the `%slip` rather than
373+the vane that actually sent the `%slip`. `%slip`s are much more rare than
374+`%pass`es and `%give`s. In general, `%slip` and `%pass` `move`s are
375+both referred to as "passes" and it should be clear from the context if one
376+means to refer only to `%pass`es and not `%slip`s or vice versa. Lastly, we note
377+that `%slip` is a code smell and should nearly always be avoided. It can result
378+in unexpected behavior like receiving a gift from a vane you never passed a note to.
379+
380+Lastly, a `%unix` `move` is how Arvo represents communication from Unix, such as a
381+network request or terminal input.
382+
383+#### `card`s and `curd`s
384+
385+`card`s are the vane-specific portion of a `move`, while `curd`s are typeless
386+`card`s utilized at the level of the kernel. `card`s are not actually defined in
387+`arvo.hoon`, rather they are given by `+note-arvo` and `+sign-arvo` in the
388+standard library `zuse`
389+(which then refer to `+task` and `+gift` in each of the vane cores), but they are closely
390+connected to `curd`s so we speak of them in the same breath.
391+
392+Each vane defines a protocol for interacting with other vanes (via Arvo) by defining four types of `card`s: `task`s, `gift`s, `note`s, and `sign`s.
393+
394+When one vane is `%pass`ed a `card` in its `task` (defined in `zuse`), Arvo activates the `+call` gate with the `card` as its argument. To produce a result, the vane `%give`s one of the `card`s defined in its `gift`. If the vane needs to request something of another vane, it `%pass`es it a `note` `card`. When that other vane returns a result, Arvo activates the `+take` gate of the initial vane with one of the `card`s defined in its `sign`.
395+
396+In other words, there are only four ways of seeing a `move`: (1) as a request seen by the caller, which is a `note`. (2) that same request as seen by the callee, a `task`. (3) the response to that first request as seen by the callee, a `gift`. (4) the response to the first request as seen by the caller, a `sign`.
397+
398+When a `task` `card` is `%pass`ed to a vane, Arvo calls its `+call` gate,
399+passing it both the `card` and its `duct`. This gate must be defined in every vane.
400+It produces two things in the following order: a list of `move`s and a possibly
401+modified copy of its context. The `move`s are used to interact with other vanes,
402+while the new context allows the vane to save its state. The next time Arvo
403+activates the vane it will have this context as its subject.
404+
405+This cycle of `%pass`ing a `note` to `%pass`ing a `task` to `%give`ing a `gift`
406+to `%give`ing a `%sign` is summarized in the following diagram:
407+
408+<div style="text-align:center">
409+<img class="mv5 w-150" src="https://media.urbit.org/docs/arvo/cycle.png">
410+</div>
411+
412+Note that `%pass`ing a `note` doesn't _always_ result in a return - this diagram
413+just
414+shows the complete cycle. However, `%give`ing a `gift` is always in response to being
415+`%pass`ed some `task`. Since the Arvo kernel acts as a middleman between all `move`s in Arvo, in diagrams we will
416+generally represent the intermediate steps of a vane `%pass`ing a `note` to the kernel addressed to
417+another vane followed by the kernel `%pass`ing a `task` to the
418+addressed vane as a single arrow from one vane to the other to make the diagrams
419+less cluttered.
420+
421+This overview has detailed how to pass a `card` to a particular vane. To see the `card`s each vane can be `%pass`ed as a `task` or return as a `gift` (as well as the semantics tied to them), each vane's public interface is explained in detail in its respective overview.
422+
423+#### `ovum`
424+
425+This mold is used to represent both steps and actions.
426+
427+A pair of a `wire` and a `curd`, with a `curd` being like a typeless `card`. The
428+reason for a typeless `card` is that this is the data structure which Arvo uses
429+to communicate with the runtime, and Unix events have no type. Additionally,
430+upgrading the kernel may alter the type system and thus may not be able to be
431+described within the current type system. Then the `wire` here is the default Unix `wire`, namely `//`. In particular, it is not a `duct` because `ovum`s come from the runtime rather than from within Arvo.
432+
433+### Arvo cores
434+
435+`arvo.hoon` has four additional cores that encode the functionality of Arvo. The [larval core](#larval-stage-core), [structural interface core](#structural-interface-core), and [implementation core](#implementation-core) each have five arms, called `+come`, `+load`, `+peek`, `+poke`, and `+wish`. Of these five arms, only `+poke` affects the [Arvo state](#the-state), while the rest leave the state invariant. Thus `+poke` is the aforementioned transition function that sends Arvo from one state to the next.
436+
437+A short summary of the purpose of each these arms are as follows:
438+
439+ - `+poke` is the transition function that `move`s Arvo from one state to the
440+ next. It is the most fundamental arm in the entire system. It is a typed
441+ transactional message that is processed at most once. If the `+poke` causes
442+ Arvo to send an message over [Ames](@/docs/tutorials/arvo/ames.md) Ames
443+ guarantees that the message will be delivered exactly once. This is sometimes said
444+ to be impossible, and it is for standard operating systems, but that is not the case for single-level stores engaged in
445+ a permanent session, as is the case among Arvo ships.
446+ - `+peek` is an arm used for inspecting things outside of the kernel. It grants
447+ read-only access to `scry` Arvo's global referentially transparent namespace.
448+ It takes in a `path` and returns a `unit (unit)`. If the product is `~`, the
449+ path is unknown and its value cannot be produced synchronously. If its
450+ product is `[~ ~]` the `path` is known to be unbound and can never become
451+ bound. Otherwise the product is a `mark` and a noun.
452+ - `+wish` is a function that takes in a core and then parses and compiles it
453+ with the standard library, `zuse`. It is useful from the outside if you ever
454+ want to run code within. One particular way in which it is used is by the
455+ runtime to read out the version of `zuse` so that it knows if it is
456+ compatible with this particular version of the kernel.
457+ - `+load` is used when upgrading the kernel. It is only ever called by Arvo
458+ itself, never by the runtime. If upgrading to a kernel where types are
459+ compatible, `+load` is used, otherwise `+come` is used.
460+ - `+come` is used when the new kernel has incompatible types, but ultimately
461+ reduces to a series of `+load` calls.
462+
463+ The [Section 3bE core](#section-3be-core) does not follow this pattern.
464+
465+#### Section 3bE core
466+
467+This core defines helper functions that are called in the larval and adult cores. These helper functions are placed here for safety so that they do not have access to the entire [state of Arvo](#the-state), which is contained in the structural interface core. One reason this core is required is that the Arvo interface has only five arms and additional arms are required to perform everything the kernel needs to do in a clean manner, so they must be segregated from the other three cores that stick to the five-arm paradigm.
468+
469+#### Implementation core
470+
471+This core is where the real legwork of the Arvo kernel is performed during the adult stage. It does not communicate with Unix directly, rather it is called by the structural interface core.
472+
473+#### Structural interface core
474+
475+This core could be thought of as the primary "adult core" - the one that is in operation for the majority of its lifecycle and the one that contains the [Arvo state](#the-state). This core should be thought of as an interface - that is, the amount of work the code does here is minimal as its main purpose is to be the core that communicates with Unix, and Unix should not be able to access deeper functions stored in the implementation core and 3bE core on its own. Thus, arms in this core are there primarily to call arms in the implementation core and 3bE core.
476+
477+#### Larval stage core
478+
479+This core is in use only during the larval stage of Arvo, which is after the Arvo kernel has compiled itself but before it has "broken symmetry" by acquiring identity and entropy, the point at which the larval stage has concluded. We call this breaking symmetry because prior to this point, every Urbit is completely identical. The larval stage performs the following steps in order:
480+
481+ + The standard library, `zuse`, is installed.
482+ + Entropy is added
483+ + Identity is added
484+ + Metamorph into the next stage of Arvo
485+
486+Once the larval stage has passed its functionality will never be used again.
487+
488+## The state
489+
490+As we follow functional programming paradigms, the state of Arvo is considered
491+to be the entire Arvo kernel core currently in operation (whether it be the larval
492+stage or adult stage). Thus when `+poke` is performed, a new core with the
493+updated state is produced, rather than modifying the existing core as would be
494+expected to happen in an imperative setting.
495+
496+Thus besides the battery of the Arvo core, we have the [payload](/docs/glossary/payload/) which is as
497+follows.
498+
499+```hoon
500+:: persistent arvo state
501+::
502+=/ pit=vase !>(..is) ::
503+=/ vil=vile (viol p.pit) :: cached reflexives
504+=| $: lac=_& :: laconic bit
505+ eny=@ :: entropy
506+ our=ship :: identity
507+ bud=vase :: %zuse
508+ vanes=(list [label=@tas =vane]) :: modules
509+ == ::
510+```
511+
512+Let's investigate the state piece by piece.
513+
514+```hoon
515+=/ pit=vase !>(..is) ::
516+```
517+This `vase` is part of the state but does not get directly migrated when `+poke`
518+is called. `!>(..is)` consists of the code in `arvo.hoon` written above this core contained in
519+a `vase`. Thus this part of the state changes only when that code changes in an
520+update.
521+
522+```hoon
523+=/ vil=vile (viol p.pit) :: cached reflexives
524+
525+```
526+This is a cache of specific types that are of fundamental importance to Arvo -
527+namely `type`s, `duct`s, `path`s, and `vase`s. This is kept because it is
528+unnecessarily wasteful to recompile these fundamental types on a regular basis.
529+Again, this part of the state is never updated directly by `+poke`.
530+
531+```hoon
532+=| $: lac=_& :: laconic bit
533+ eny=@ :: entropy
534+ our=ship :: identity
535+ bud=vase :: %zuse
536+ vanes=(list [label=@tas =vane]) :: modules
537+ ==
538+```
539+This is where the real state of the Arvo kernel is kept. `lac` detemines whether
540+Arvo's output is verbose, which can be set using the `|verb` command in the
541+dojo. `eny` is the current entropy. `our` is the ship, which is permanently
542+frozen during the larval stage. `bud` is the standard library. Lastly, `vanes`
543+is of course the list of vanes, which have their own internal states.
544+
545+As you can see, the state of Arvo itself is quite simple. Its primary role is that of
546+a traffic cop, and most of the interesting part of the state lies in `vanes`.
547+
548+
549+## Vanes
550+
551+The Arvo kernel can do very little on its own. Its functionality is extended in a careful and controlled way with vanes, also known as kernel modules.
552+
553+As described above, we use Arvo proper to route and control the flow of `move`s.
554+However, Arvo proper is rarely directly responsible for processing the event
555+data that directly causes the desired outcome of a `move`. This event data is contained within a `card`. Instead, Arvo proper passes the `card` off to one of its vanes, which each present an interface to clients for a particular well-defined, stable, and general-purpose piece of functionality.
556+
557+As of this writing, we have nine vanes, which each provide the following services:
558+
559+- [Ames](@/docs/tutorials/arvo/ames.md): the name of both our network and the vane that communicates over it.
560+- [Behn](@/docs/tutorials/arvo/behn.md): a simple timer.
561+- [Clay](@/docs/tutorials/arvo/clay.md): our version-controlled, referentially- transparent, and global filesystem.
562+- [Dill](@/docs/tutorials/arvo/dill.md): a terminal driver. Unix sends keyboard events to `%dill` from the console, and `%dill` produces terminal output.
563+- [Eyre](@/docs/tutorials/arvo/eyre.md): an http server. Unix sends http messages to `%eyre`, and `%eyre` produces http messages in response.
564+- [Ford](@/docs/tutorials/arvo/ford.md): a build system also utilized for marks
565+ (file types) and debugging.
566+- [Gall](@/docs/tutorials/arvo/gall.md): manages our userspace applications. `%gall` keeps state and manages subscribers.
567+- `Iris`: an http client.
568+- `Jael`: storage for Azimuth information.
569+
570+#### Applying your knowledge
571+
572+Now that you've learned about the nuts and bolts of the Arvo kernel, why not
573+check it out in action? An in-depth "move trace" tutorial for running a timer app
574+is available [here](@/docs/tutorials/arvo/move-trace.md).
tutorials/arvo/behn.md+1−1
@@ -1,6 +1,6 @@
1+++
1+++
2title = "Behn"
2title = "Behn"
3−weight = 2
3+weight = 3
4template = "doc.html"
4template = "doc.html"
5+++
5+++
6Our simple timer.
6Our simple timer.
tutorials/arvo/clay.md+5−5
@@ -1,6 +1,6 @@
1+++
1+++
2title = "Clay"
2title = "Clay"
3−weight = 3
3+weight = 4
4template = "doc.html"
4template = "doc.html"
5aliases = ["/docs/learn/arvo/clay/"]
5aliases = ["/docs/learn/arvo/clay/"]
6+++
6+++
@@ -24,7 +24,7 @@ foreign ships.
24## Architecture
24## Architecture
25
25
26Clay is the primary filesystem for the arvo operating system,
26Clay is the primary filesystem for the arvo operating system,
27−which is the core of an urbit. The architecture of clay is
27+which is the [core](/docs/glossary/core/) of an urbit. The architecture of clay is
28intrinsically connected with arvo, but we assume no knowledge of
28intrinsically connected with arvo, but we assume no knowledge of
29either arvo or urbit. We will point out only those features of
29either arvo or urbit. We will point out only those features of
30arvo that are necessary for an understanding of clay, and we will
30arvo that are necessary for an understanding of clay, and we will
@@ -207,7 +207,7 @@ convert back to `%txt`. The diff, patch, and merge algorithms are
207fairly straightforward for json, though they're very different
207fairly straightforward for json, though they're very different
208from the text ones.
208from the text ones.
209
209
210−More formally, a mark is a core with three arms, `++grab`,
210+More formally, a mark is a core with three [arms](/docs/glossary/arm/), `++grab`,
211`++grow`, and `++grad`. In `++grab` is a series of functions to
211`++grow`, and `++grad`. In `++grab` is a series of functions to
212convert from other marks to the given mark. In `++grow` is a
212convert from other marks to the given mark. In `++grow` is a
213series of functions to convert from the given mark to other
213series of functions to convert from the given mark to other
@@ -922,7 +922,7 @@ very limited usefulness, and is not used at the moment.
922which is your classic diff. We, however, will work on any list of data.
922which is your classic diff. We, however, will work on any list of data.
923
923
924`%d` refers to changes in a tree of data. This is general enough to
924`%d` refers to changes in a tree of data. This is general enough to
925−describe changes to any hoon noun, but often more special-purpose delta
925+describe changes to any hoon [noun](/docs/glossary/noun/), but often more special-purpose delta
926should be created for different content types. This is not used at the
926should be created for different content types. This is not used at the
927moment, and may in fact be unimplemented.
927moment, and may in fact be unimplemented.
928
928
@@ -2442,7 +2442,7 @@ We'll examine `++knit` and `++wake`, in that order.
2442 ==
2442 ==
2443```
2443```
2444
2444
2445−This is kind of a long gate, but don't worry, it's not bad at all.
2445+This is kind of a long [gate](/docs/glossary/gate/), but don't worry, it's not bad at all.
2446
2446
2447First, we assert that we're not a domestic desk. That wouldn't make any
2447First, we assert that we're not a domestic desk. That wouldn't make any
2448sense at all.
2448sense at all.
tutorials/arvo/dill.md+1−1
@@ -1,6 +1,6 @@
1+++
1+++
2title = "Dill"
2title = "Dill"
3−weight = 4
3+weight = 5
4template = "doc.html"
4template = "doc.html"
5aliases = ["/docs/learn/arvo/dill/"]
5aliases = ["/docs/learn/arvo/dill/"]
6+++
6+++
tutorials/arvo/eyre.md+5−5
@@ -1,6 +1,6 @@
1+++
1+++
2title = "Eyre"
2title = "Eyre"
3−weight = 5
3+weight = 6
4template = "doc.html"
4template = "doc.html"
5aliases = ["/docs/learn/arvo/eyre/"]
5aliases = ["/docs/learn/arvo/eyre/"]
6+++
6+++
@@ -57,7 +57,7 @@ From arvo, requests enter `++call`, which after some type reification are passed
57along to `++apex:ye`. In the case of a `%this` task, its components are
57along to `++apex:ye`. In the case of a `%this` task, its components are
58parsed(see `++zest:epur`, `++eat-headers`) and handed off to `++handle`, wrapped
58parsed(see `++zest:epur`, `++eat-headers`) and handed off to `++handle`, wrapped
59in `++emule` to produce a `++fail` page in case of error. `++apex:handle` will
59in `++emule` to produce a `++fail` page in case of error. `++apex:handle` will
60−`++process` the request to a `pest` or a `++done` core, and in the former case
60+`++process` the request to a `pest` or a `++done` [core](/docs/glossary/core/), and in the former case
61`++resolve` the pest into an outgoing card.
61`++resolve` the pest into an outgoing card.
62
62
63XX it also seems to affect the current ship, test that serving ship name is consistently correct
63XX it also seems to affect the current ship, test that serving ship name is consistently correct
@@ -95,7 +95,7 @@ XX `%cast %mime` used to be in ford-get-beam, is there a reason it was removed?
95## Back into the breach, or: auxilary requests
95## Back into the breach, or: auxilary requests
96
96
97Now, it was mentioned that this result is self-refreshing: the `%urb`
97Now, it was mentioned that this result is self-refreshing: the `%urb`
98−translation door injects a `;script@"/~/on/{deps}.js"` into every page, `deps`
98+translation [door](/docs/glossary/door/) injects a `;script@"/~/on/{deps}.js"` into every page, `deps`
99is a ford-readable hash of the set of resources that page construction depended
99is a ford-readable hash of the set of resources that page construction depended
100on.
100on.
101
101
@@ -409,7 +409,7 @@ To this object, `/main/lib/urb.js` adds helpers:
409- `send({data,mark?='json',app?=urb.app,ship?}, cb?)` delivers messages
409- `send({data,mark?='json',app?=urb.app,ship?}, cb?)` delivers messages
410- `bind({path,app?=urb.app}, cb)` subscribes by path
410- `bind({path,app?=urb.app}, cb)` subscribes by path
411- `drop({path,app?=urb.app}, cb?)` pulls the subscription
411- `drop({path,app?=urb.app}, cb?)` pulls the subscription
412−- `util` is an object containing methods for converting between JavaScript types and Hoon atom odors.
412+- `util` is an object containing methods for converting between JavaScript types and Hoon [atom](/docs/glossary/atom/) odors.
413
413
414## 3. Requests
414## 3. Requests
415
415
@@ -538,7 +538,7 @@ Signs a `%writ` upon change.
538
538
539### 5.4 `[%f %exec (unit silk)]`, functional transformations
539### 5.4 `[%f %exec (unit silk)]`, functional transformations
540
540
541−The `%f` interface converts nouns from one form to another. An empty unit represents cancellation.
541+The `%f` interface converts [nouns](/docs/glossary/noun/) from one form to another. An empty unit represents cancellation.
542
542
543Signs a `%made` containing the computation result.
543Signs a `%made` containing the computation result.
544
544
tutorials/arvo/ford.md+4−4
@@ -1,6 +1,6 @@
1+++
1+++
2title = "Ford"
2title = "Ford"
3−weight = 6
3+weight = 7
4template = "doc.html"
4template = "doc.html"
5aliases = ["/docs/learn/arvo/ford/"]
5aliases = ["/docs/learn/arvo/ford/"]
6+++
6+++
@@ -93,7 +93,7 @@ functionality. We don't usually have naked hoods outside ford.
93
93
94### `%reef`
94### `%reef`
95
95
96−Produces a core containing the entirety of Zuse and Hoon, suitable for
96+Produces a [core](/docs/glossary/core/) containing the entirety of Zuse and Hoon, suitable for
97running arbitrary code against. The mark is `%noun`.
97running arbitrary code against. The mark is `%noun`.
98
98
99### `%ride`
99### `%ride`
@@ -402,7 +402,7 @@ Wide-form unfiltered `/_` doesn't need a delimiter: `/= kids /_/hoon/`
402### `/_` filtered: run a horn on each file in the directory matching an aura
402### `/_` filtered: run a horn on each file in the directory matching an aura
403
403
404Filtered `/_` takes an aura and a horn, and filters the list of files in the
404Filtered `/_` takes an aura and a horn, and filters the list of files in the
405−current directory by whether their filenames can be parsed to an atom of that
405+current directory by whether their filenames can be parsed to an [atom](/docs/glossary/atom/) of that
406aura. It then produces a map where each key is the filename after parsing into
406aura. It then produces a map where each key is the filename after parsing into
407that atom type, and each value is the result of running the horn on the
407that atom type, and each value is the result of running the horn on the
408contents of that file.
408contents of that file.
@@ -420,7 +420,7 @@ Wide-form filtered `/_` uses `_` as a delimiter: `/= timed-posts /_@da_/md/`
420
420
421### `/;` "fasmic"
421### `/;` "fasmic"
422
422
423−`/;` takes a twig and a horn. The twig should evaluate to a gate, which is then slammed
423+`/;` takes a twig and a horn. The twig should evaluate to a [gate](/docs/glossary/gate/), which is then slammed
424with the result of the horn as its sample.
424with the result of the horn as its sample.
425
425
426Example:
426Example:
tutorials/arvo/gall.md+14−21
@@ -1,6 +1,6 @@
1+++
1+++
2title = "Gall Apps"
2title = "Gall Apps"
3−weight = 6
3+weight = 8
4template = "doc.html"
4template = "doc.html"
5aliases = ["/docs/learn/arvo/gall/"]
5aliases = ["/docs/learn/arvo/gall/"]
6+++
6+++
@@ -61,7 +61,7 @@ definable in a regular recursive data type).
61
61
62## Specification
62## Specification
63
63
64−An agent is defined as a core with a set of arms to handle various
64+An agent is defined as a [core](/docs/glossary/core/) with a set of [arms](/docs/glossary/arm/) to handle various
65events. These handlers usually produce a list of effects and the next
65events. These handlers usually produce a list of effects and the next
66state of the agent. The interface definition can be found in
66state of the agent. The interface definition can be found in
67`sys/zuse.hoon`, which at the time of writing is:
67`sys/zuse.hoon`, which at the time of writing is:
@@ -153,17 +153,12 @@ Here's a skeleton example of an implementation:
153::
153::
154++ on-load
154++ on-load
155 |= =old-state=vase
155 |= =old-state=vase
156− =/ old-state !<(@ old-state-vase)
156+ `this(state !<(@ old-state-vase))
157− ?~ old-state
158− ~& %prep-lost
159− `this
160− ~& %prep-found
161− `this(state u.old-state)
162::
157::
163++ on-poke
158++ on-poke
164 |= [=mark =vase]
159 |= [=mark =vase]
165− ~& state=state
160+ ~& > state=state
166− ~& got-poked-with-data=mark]
161+ ~& got-poked-with-data=mark
167 =. state +(state)
162 =. state +(state)
168 `this
163 `this
169::
164::
@@ -203,7 +198,7 @@ implemented as:
203=| state=@
198=| state=@
204|_ =bowl:gall
199|_ =bowl:gall
205+* this .
200+* this .
206− default ~(. (default-agent %|) bowl)
201+ default ~(. (default-agent this %|) bowl)
207::
202::
208++ on-init on-init:default
203++ on-init on-init:default
209++ on-save on-save:default
204++ on-save on-save:default
@@ -281,9 +276,9 @@ An agent may pass `note`s to either Arvo or another agent. If the `note` is
281to another agent, then it should usually be one of these:
276to another agent, then it should usually be one of these:
282
277
283```hoon
278```hoon
284−[%pass /my/wire %agent our.bowl agent-name %watch /a/path]
279+[%pass /my/wire %agent [our.bowl agent-name] %watch /a/path]
285−[%pass /my/wire %agent our.bowl agent-name %leave ~]
280+[%pass /my/wire %agent [our.bowl agent-name] %leave ~]
286−[%pass /my/wire %agent our.bowl agent-name %poke %foo-mark !>(poke-data)]
281+[%pass /my/wire %agent [our.bowl agent-name] %poke %foo-mark !>(poke-data)]
287```
282```
288
283
289Note that to unsubscribe to a `path`, you must send the unsubscription on
284Note that to unsubscribe to a `path`, you must send the unsubscription on
@@ -361,19 +356,17 @@ the subscription.
361### Vases and cages
356### Vases and cages
362
357
363A `vase` is a piece of dynamic data. Structurally, it's a pair of an
358A `vase` is a piece of dynamic data. Structurally, it's a pair of an
364−explicit reification of a type and an untyped noun. This lets us
359+explicit reification of a type and an untyped [noun](/docs/glossary/noun/). This lets us
365represent a value which has a type that isn't known at compile time. A
360represent a value which has a type that isn't known at compile time. A
366vase has three operations:
361vase has three operations:
367
362
368- `!>` is a unary rune that lifts a statically typed value to a
363- `!>` is a unary rune that lifts a statically typed value to a
369− dynamically-typed `vase`. For example, `!>('hi')` gives `[[%atom %t ~]
364+ dynamically-typed `vase`. For example, `!>('hi')` gives `[#t/@t q=26.984]`.
370− 26.984']`, which has type `[type *]`.
371
365
372- `!<` is a binary rune that takes a mold and a dynamically typed `vase`
366- `!<` is a binary rune that takes a mold and a dynamically typed `vase`
373 and reduces it to a statically typed value. If the `vase` does not in
367 and reduces it to a statically typed value. If the `vase` does not in
374− fact have the type of the mold you give it, then it produces `~`, else
368+ fact have the type of the mold you give it, then it nest-fails, else
375− it produces `[~ value]`. For example, `!<(@t !>('hi'))` produces `[~
369+ it produces `value`. For example, `!<(@t !>('hi'))` produces `'hi'` while `!<(^ !>('hi'))` causes a nest fail..
376− 'hi']` while `!<(^ !>('hi'))` produces `~`.
377
370
378- The compiler takes text and converts it to a `vase` of the compiled
371- The compiler takes text and converts it to a `vase` of the compiled
379 code. Agents shouldn't need this directly, but Gall uses this to
372 code. Agents shouldn't need this directly, but Gall uses this to
@@ -535,7 +528,7 @@ whether there is or will be data at the given `path`.
535
528
536### +on-agent
529### +on-agent
537
530
538−This arm is called to handle responses to `%pass` moves to other agents.
531+This arm is called to handle responses to `%give` moves to other agents.
539It will be one of the following types of response:
532It will be one of the following types of response:
540
533
541- `%poke-ack`: acknowledgment (positive or negative) of a poke. If the
534- `%poke-ack`: acknowledgment (positive or negative) of a poke. If the
tutorials/arvo/move-trace.mdnew file+381
@@ -0,0 +1,381 @@
1++++
2+title = "Move trace"
3+weight = 12
4+template = "doc.html"
5++++
6+
7+
8+## Move trace tutorial
9+
10+In this tutorial we will run a simple "move trace" and use the output to get a
11+picture of what the Arvo kernel proper does during the routine task of setting a
12+timer. Some level of familiarity with the kernel is required for this section,
13+which can be obtained in our [Arvo kernel tutorial](@/docs/tutorials/arvo/arvo.md#the-kernel).
14+
15+### Running a move trace
16+
17+Ultimately, everything that happens in Arvo is reduced to Unix events, and the
18+Arvo kernel acts as a sort of traffic cop for vanes and apps to talk to one
19+another. Here we look at how a simple command, `-time ~s1`, goes from pressing
20+Enter on your keyboard in Dojo towards returning a notification that one second
21+has elapsed.
22+
23+To follow along yourself, boot up a fake `~zod` and enter `|verb` into the dojo
24+and press Enter to enable verbose mode (this is tracked by the laconic bit
25+introduced in the section on [the
26+state](@/docs/tutorials/arvo/arvo.md#the-state)) in the kernel documentation, followed by `-time ~s1`
27+followed by Enter. Your terminal should pretty print a series of `move`s that looks something like this:
28+
29+```
30+["" %unix p=%belt //term/1 ~2020.1.14..19.01.25..7556]
31+["|" %pass [%d %g] [[%deal [~zod ~zod] %hood %poke] /] [i=//term/1 t=~]]
32+["||" %pass [%g %g] [[%deal [~zod ~zod] %dojo %poke] /use/hood/~zod/out/~zod/dojo/drum/phat/~zod/dojo] [i=/d t=~[//term/1]]]
33+["|||" %give %g [%unto %fact] [i=/g/use/hood/~zod/out/~zod/dojo/drum/phat/~zod/dojo t=~[/d //term/1]]]
34+["||||" %give %g [%unto %fact] [i=/d t=~[//term/1]]]
35+["|||||" %give %d %blit [i=//term/1 t=~]]
36+["|||" %pass [%g %f] [%build /use/dojo/~zod/drum/hand] [i=/d t=~[//term/1]]]
37+["||||" %give %f %made [i=/g/use/dojo/~zod/drum/hand t=~[/d //term/1]]]
38+["|||||" %pass [%g %g] [[%deal [~zod ~zod] %spider %watch] /use/dojo/~zod/out/~zod/spider/drum/wool] [i=/d t=~[//term/1]]]
39+["||||||" %give %g [%unto %watch-ack] [i=/g/use/dojo/~zod/out/~zod/spider/drum/wool t=~[/d //term/1]]]
40+["|||||" %pass [%g %g] [[%deal [~zod ~zod] %spider %poke] /use/dojo/~zod/out/~zod/spider/drum/wool] [i=/d t=~[//term/1]]]
41+//term/1]]]
42+["||||||" %pass [%g %f] [%build /use/spider/~zod/find/~.dojo_0v6.210tt.1sme1.ev3qm.qgv2e.a754u] [i=/d t=~[//term/1]]]
43+["|||||||" %give %f %made [i=/g/use/spider/~zod/find/~.dojo_0v6.210tt.1sme1.ev3qm.qgv2e.a754u t=~[/d //term/1]]]
44+["||||||||" %pass [%g %f] [%build /use/spider/~zod/build/~.dojo_0v6.210tt.1sme1.ev3qm.qgv2e.a754u] [i=/d t=~[//term/1]]]
45+["|||||||||" %give %f %made [i=/g/use/spider/~zod/build/~.dojo_0v6.210tt.1sme1.ev3qm.qgv2e.a754u t=~[/d //term/1]]]
46+["||||||||||" %pass [%g %b] [%wait /use/spider/~zod/thread/~.dojo_0v6.210tt.1sme1.ev3qm.qgv2e.a754u/wait/~2020.1.14..19.01.26..7556] [i=/d t=~[//term/1]]]
47+["|||||||||||" %give %b %doze [i=//behn/0v1p.sn2s7 t=~]]
48+> -time ~s1
49+```
50+followed by a pause of one second, then
51+```
52+["" %unix p=%wake //behn ~2020.1.14..19.01.26..755d]
53+["|" %give %b %doze [i=//behn/0v1p.sn2s7 t=~]]
54+["|" %give %b %wake [i=/g/use/spider/~zod/thread/~.dojo_0v6.210tt.1sme1.ev3qm.qgv2e.a754u/wait/~2020.1.14..19.01.26..7556 t=~[/d //term/1]]]
55+["||" %give %g [%unto %fact] [i=/g/use/dojo/~zod/out/~zod/spider/drum/wool t=~[/d //term/1]]]
56+["|||" %give %g [%unto %fact] [i=/g/use/hood/~zod/out/~zod/dojo/drum/phat/~zod/dojo t=~[/d //term/1]]]
57+["||||" %give %g [%unto %fact] [i=/d t=~[//term/1]]]
58+["|||||" %give %d %blit [i=//term/1 t=~]]
59+["||" %give %g [%unto %kick] [i=/g/use/dojo/~zod/out/~zod/spider/drum/wool t=~[/d //term/1]]]
60+~s1..0007
61+```
62+This gives us a move trace that is a list of `move`s and some
63+associated metadata. Some of the `move`s are a bit of a distraction from what's
64+going on overall such as acknowledgements that a `poke` was received
65+(`%poke-ack`s), so we've omitted them for clarity. Furthermore, two `move`s (the
66+`%blit` `card`s) is not printed even in verbose mode because it occurs so
67+frequently, but there are only two of them here and so we have added it in.
68+
69+The main process that is occurring here is a sequence of `%pass` `move`s initiated
70+by pressing Enter in the terminal that goes on to be handled by Dill, then Gall,
71+and finally Behn. After the timer has elapsed, a sequence of `%give` `move`s is
72+begun by Behn, which then passes through Gall and ultimately ends up back at the
73+terminal. Any `move`s besides `%pass` in the first segment of the move trace is a
74+secondary process utilized for book-keeping, spawning processes, interpreting
75+commands, etc. All of this will be explained in detail below.
76+
77+
78+It is important to note that this move trace should be thought of
79+as being from the "point of view" of the kernel - each line represents the
80+kernel taking in a message from one source and passing it along to its
81+destination. It is then processed at that destination (which could be a vane or
82+an app), and the return of that process is sent back to Arvo in the form of
83+another `move` to perform and the loop begins again. Thus this move trace does
84+not display information about what is going on inside of the vane or app such as
85+private function calls, only what the kernel itself sees.
86+
87+### Interpreting the move trace
88+
89+In this section we will go over the move trace line-by-line, explaining how the
90+move trace is printed, what each line means (including some things not found in
91+the move trace), and a particular focus on what code is being activated in the
92+first few lines that should equip you well enough to unravel the rest of the
93+move trace in as much detail as you desire.
94+
95+
96+#### The call
97+
98+Let's put the first part of the move trace into a diagram to make following
99+along a little easier.
100+
101+<div style="text-align:center">
102+<img src="https://media.urbit.org/docs/arvo/move-trace-with-key.png">
103+</div>
104+
105+Here, each arrow represents the passing of some information, with most of it
106+being from vane to vane. Here, when Vane A has an arrow to a card and then an
107+arrow to Vane B, this represents either a `%pass` `note/task` sequence or a
108+`%give` `gift/sign` sequence that actually has the Arvo kernel in the middle.
109+That is to say, Vane A `%pass`es a `note` to the Arvo kernel addressed to Vane
110+B, and the Arvo kernel then `%pass`es a `task` to Vane B. For more information,
111+see the [Arvo kernel tutorial](@/docs/tutorials/arvo/arvo.md#the-kernel).
112+
113+This simple action ends up involving four vanes - Dill, Gall, Behn, and Ford -
114+as well as four applications - hood, spider, dojo, and time.
115+
116+Now let's go through each line one by one.
117+```
118+["" %unix p=%belt //term/1 ~2020.1.14..19.01.25..7556]
119+```
120+This tells us that Unix has sent a `%belt` `card`, which corresponds to
121+terminal input (the Enter keystroke) at time `~2020.1.14..19.01.25..7556`
122+
123+Here is the line of code in `arvo.hoon`, found in the [section
124+3bE core](@/docs/tutorials/arvo/arvo.md#section-3be-core), that generated the output:
125+
126+```hoon
127+ ~? !lac ["" %unix -.q.ovo p.ovo now]
128+```
129+First we note that this line is executed only if the laconic bit is set to true,
130+as we did when we input `|verb`. Here, `ovo` is the input `ovum`. Knowing that an `ovum` is a `[p=wire q=curd]`,
131+we can then say that this is a `%unix` `move` tagged with `%belt` whose cause is a `wire` given by `//term/1`,
132+where the empty span `//` represents Unix and `term/1` represents the terminal
133+in Unix. Here we have a `wire` instead of a `duct` (i.e. a list of `wire`s)
134+since Unix I/O events are always the beginning and end of the Arvo event loop,
135+thus only a single `wire` is ever required at this initial stage.
136+
137+The `""` here is a metadatum that keeps track of how many steps deep in the
138+causal chain the event is. An event
139+with `n` `|`'s was caused by the most recent previous event with `n-1` `|`'s. In
140+this case, Unix events are an "original cause" and thus represented by an empty
141+string.
142+
143+At this point in time, Dill has received the `move` and then processes it. The
144+`%belt` `task` in `dill.hoon` is `+call`ed, which is processed using the `+send`
145+arm:
146+
147+```hoon
148+ ++ send :: send action
149+ |= bet/dill-belt
150+ ^+ +>
151+ ?^ tem
152+ +>(tem `[bet u.tem])
153+ (deal / [%poke [%dill-belt -:!>(bet) bet]])
154+```
155+
156+Dill has taken in the command and in response it `%pass`es a `task` `card` with
157+instructions to `%poke` hood, which is a Gall app
158+primarily used for interfacing with Dill. Here, `+deal` is an arm for
159+`%pass`ing a `card` to Gall to ask it to create a `%deal` `task`:
160+
161+
162+```hoon
163+ ++ deal :: pass to %gall
164+ |= [=wire =deal:gall]
165+ (pass wire [%g %deal [our our] ram deal])
166+```
167+
168+Next in our move trace we have this:
169+```
170+["|" %pass [%d %g] [[%deal [~zod ~zod] %hood %poke] /] [i=//term/1 t=~]]
171+```
172+Here, Dill `%pass`es a `task` `card` saying to `%poke` Gall's hood app (with the
173+Enter keystroke).
174+
175+Let's glance at part of the `+jack` arm in `arvo.hoon`, located in the [section 3bE
176+core](@/docs/tutorials/arvo/arvo.md#section-3be-core). This arm is what the Arvo kernel uses to send `card`s,
177+and here we look at the segment that includes `%pass` `move`s.
178+
179+```hoon
180+ ++ jack :: dispatch card
181+ |= [lac=? gum=muse]
182+ ^- [[p=(list ovum) q=(list muse)] _vanes]
183+ ~| %failed-jack
184+ :: =. lac |(lac ?=(?(%g %f) p.gum))
185+ :: =. lac &(lac !?=($b p.gum))
186+ %^ fire
187+ p.gum
188+ s.gum
189+ ?- -.r.gum
190+ $pass
191+ ~? &(!lac !=(%$ p.gum))
192+ :- (runt [s.gum '|'] "")
193+ :^ %pass [p.gum p.q.r.gum]
194+ ?: ?=(?(%deal %deal-gall) +>-.q.q.r.gum)
195+ :- :- +>-.q.q.r.gum
196+ (,[[ship ship] term term] [+>+< +>+>- +>+>+<]:q.q.r.gum)
197+ p.r.gum
198+ [(symp +>-.q.q.r.gum) p.r.gum]
199+ q.gum
200+ [p.q.r.gum ~ [[p.gum p.r.gum] q.gum] q.q.r.gum]
201+```
202+
203+Code for writing traces can be a bit tricky, but let's try not to get too
204+distracted by the lark expressions and such. By paying attention to the lines
205+concerning the laconic bit (following `!lac`) we can mostly determine what is being told to us.
206+
207+From the initial input event, Arvo has generated a `card` that it is now
208+`%pass`ing from Dill (represented by `%d`) to Gall (represented by `%g`). The
209+`card` is a `%deal` `task`, asking Gall to `%poke` hood using data that has
210+originated from the terminal `//term/1`, namely that the Enter key was pressed. The line `:- (runt [s.gum '|'] "")`
211+displays the causal chain length metadatum mentioned above. Lastly, `[~zod ~zod]` tells us that
212+`~zod` is both the sending and receiving ship.
213+
214+From here on our explanations will be more brief. We include some information
215+that cannot be directly read from the move trace in [brackets]. Onto the next line:
216+
217+```
218+["||" %pass [%g %g] [[%deal [~zod ~zod] %dojo %poke] /use/hood/~zod/out/~zod/dojo/drum/phat/~zod/dojo] [i=/d t=~[//term/1]]]
219+```
220+
221+Here is another `%pass` `move`, this time from Gall to iself as denoted by `[%g
222+%g]`. Gall's hood has received the `%deal` `card` from Dill, and in response it is
223+`%poke`ing dojo with the information [that Enter was pressed].
224+
225+```
226+["|||" %give %g [%unto %fact] [i=/g/use/hood/~zod/out/~zod/dojo/drum/phat/~zod/dojo t=~[/d //term/1]]]
227+```
228+
229+Gall's dojo `%give`s a `gift` with a `%fact` (subscription update) to Gall's hood, [saying to clear
230+the terminal prompt].
231+
232+```
233+["||||" %give %g [%unto %fact] [i=/d t=~[//term/1]]]
234+```
235+Gall's hood `%give`s a `gift` with a `%fact` to Dill [saying to replace the current terminal line with `~zod:dojo>`]
236+
237+Next is the `move` that is not actually printed in the move trace mentioned
238+above:
239+
240+```
241+["|||||" %give %d %blit [i=//term/1 t=~]]
242+```
243+
244+Dill `%give`s a `%blit` (terminal output) event to Unix [saying to replace the current terminal line with `~zod:dojo>`].
245+
246+```
247+["|||" %pass [%g %f] [%build /use/dojo/~zod/drum/hand] [i=/d t=~[//term/1]]]
248+```
249+
250+Gall's dojo also `%pass`es a `%build` request to Ford [asking to run "~s1" against the subject we use in the dojo].
251+
252+```
253+["||||" %give %f %made [i=/g/use/dojo/~zod/drum/hand t=~[/d //term/1]]]
254+```
255+
256+Ford `%give`s a result back to dojo [with the value `~s1`]
257+
258+```
259+["|||||" %pass [%g %g] [[%deal [~zod ~zod] %spider %watch] /use/dojo/~zod/out/~zod/spider/drum/wool] [i=/d t=~[//term/1]]]
260+```
261+
262+Gall's dojo `%pass`es a `%watch` to Gall's spider app [to start listening for the result of the thread it's about to start].
263+
264+```
265+["||||||" %give %g [%unto %watch-ack] [i=/g/use/dojo/~zod/out/~zod/spider/drum/wool t=~[/d //term/1]]]
266+```
267+
268+Gall's spider acknowledges the subscription from dojo.
269+
270+```
271+["|||||" %pass [%g %g] [[%deal [~zod ~zod] %spider %poke] /use/dojo/~zod/out/~zod/spider/drum/wool] [i=/d t=~[//term/1]]]
272+```
273+
274+Gall's dojo also `%pass`es a `%poke` to Gall's spider [asking it start the thread "-time" with argument `~s1`].
275+
276+```
277+["||||||" %pass [%g %f] [%build /use/spider/~zod/find/~.dojo_0v6.210tt.1sme1.ev3qm.qgv2e.a754u] [i=/d t=~[//term/1]]]
278+```
279+
280+Gall's spider `%pass`es a `%build` request to Ford [asking it to find the path in `/ted` where the "time" thread is].
281+
282+```
283+["|||||||" %give %f %made [i=/g/use/spider/~zod/find/~.dojo_0v6.210tt.1sme1.ev3qm.qgv2e.a754u t=~[/d //term/1]]]
284+```
285+
286+Ford `%give`s a result back to Gall's spider [saying it's in `/ted/time.hoon`].
287+
288+```
289+["||||||||" %pass [%g %f] [%build /use/spider/~zod/build/~.dojo_0v6.210tt.1sme1.ev3qm.qgv2e.a754u] [i=/d t=~[//term/1]]]
290+```
291+
292+Gall's spider `%pass`es a `%build` request to Ford [asking it to compile the file `/ted/time.hoon`].
293+
294+```
295+["|||||||||" %give %f %made [i=/g/use/spider/~zod/build/~.dojo_0v6.210tt.1sme1.ev3qm.qgv2e.a754u t=~[/d //term/1]]]
296+```
297+
298+Ford `%give`s a result back to Gall's spider [with the compiled thread].
299+
300+```
301+["||||||||||" %pass [%g %b] [%wait /use/spider/~zod/thread/~.dojo_0v6.210tt.1sme1.ev3qm.qgv2e.a754u/wait/~2020.1.14..19.01.26..7556] [i=/d t=~[//term/1]]]
302+```
303+
304+Gall's spider's thread with id `~.dojo_0v6.210tt.1sme1.ev3qm.qgv2e.a754u` asks Behn to set a timer [for one second].
305+
306+```
307+["|||||||||||" %give %b %doze [i=//behn/0v1p.sn2s7 t=~]]
308+```
309+
310+Behn `%give`s a `%doze` `card` to Unix, asking it to set a timer [for one second from
311+now]. At this point Arvo may rest.
312+
313+#### The return
314+
315+Now Unix sets a timer for one second, waits one second, and then informs Behn that a second has
316+passed, leading to a chain of `%give` `move`s that ultimately prints
317+`~s1..0007`.
318+
319+Let's throw the move trace into a table:
320+
321+| length | move | vane(s) | card | duct |
322+|--------|---------|---------|-----------------|------------------------------------------------------------------------------------------------------------------|
323+| 0 | `%unix` | | `%wake` | `//behn` |
324+| 1 | `%give` | `%b` | `%doze` | `//behn/0v1p.sn2s7` |
325+| 1 | `%give` | `%b` | `%wake` | `/g/use/spider/~zod/thread/~.dojo_0v6.210tt.1sme1.ev3qm.qgv2e.a754u/wait/~2020.1.14..19.01.26..7556 /d //term/1` |
326+| 2 | `%give` | `%g` | `[%unto %fact]` | `/g/use/dojo/~zod/out/~zod/spider/drum/wool /d //term/1` |
327+| 3 | `%give` | `%g` | `[%unto %fact]` | `/g/use/hood/~zod/out/~zod/dojo/drum/phat/~zod/dojo /d //term/1` |
328+| 4 | `%give` | `%g` | `[%unto %fact]` | `/d //term/1` |
329+| 5 | `%give` | `%d` | `%blit` | `//term/1` |
330+| 2 | `%give` | `%g` | `[%unto %kick]` | `/g/use/dojo/~zod/out/~zod/spider/drum/wool /d //term/1` |
331+
332+Now we follow it line-by-line:
333+
334+```
335+["" %unix p=%wake //behn ~2020.1.14..19.01.26..755d]
336+```
337+
338+Unix sends a `%wake` (timer fire) `card` at time `~2020.1.14..19.01.26..755d`.
339+
340+```
341+["|" %give %b %doze [i=//behn/0v1p.sn2s7 t=~]]
342+```
343+
344+Behn `%give`s a `%doze` `card` to Unix, asking it to set a timer [for whatever next timer it has in its queue].
345+
346+```
347+["|" %give %b %wake [i=/g/use/spider/~zod/thread/~.dojo_0v6.210tt.1sme1.ev3qm.qgv2e.a754u/wait/~2020.1.14..19.01.26..7556 t=~[/d //term/1]]]
348+```
349+
350+Behn `%give`s a `%wake` to Gall's spider's thread with id `~.dojo_0v6.210tt.1sme1.ev3qm.qgv2e.a754u`.
351+
352+```
353+["||" %give %g [%unto %fact] [i=/g/use/dojo/~zod/out/~zod/spider/drum/wool t=~[/d //term/1]]]
354+```
355+
356+Gall's spider `%give`s a `%fact` (subscription update) to dojo [saying that the thread completed successfully and produced value `~s1.0007`].
357+
358+```
359+["|||" %give %g [%unto %fact] [i=/g/use/hood/~zod/out/~zod/dojo/drum/phat/~zod/dojo t=~[/d //term/1]]]
360+```
361+
362+Gall's dojo `%give`s a `%fact` to hood [saying to output `~s1..0007`].
363+
364+```
365+["||||" %give %g [%unto %fact] [i=/d t=~[//term/1]]]
366+```
367+
368+Gall's hood `%give`s a `%fact` to Dill [saying to output `~s1..0007`].
369+
370+```
371+["|||||" %give %d %blit [i=//term/1 t=~]]
372+```
373+
374+Dill `%give`s a `%blit` (terminal output) event to Unix [saying to print a new line with output `~s1..0007`].
375+
376+```
377+["||" %give %g [%unto %kick] [i=/g/use/dojo/~zod/out/~zod/spider/drum/wool t=~[/d //term/1]]]
378+```
379+
380+Gall's spider also closes the subscription from dojo [since the thread has completed].
381+
tutorials/concepts/technical-overview.md+3−2
@@ -2,6 +2,7 @@
2title = "Technical overview"
2title = "Technical overview"
3weight = 1
3weight = 1
4template = "doc.html"
4template = "doc.html"
5+aliases = ["/understanding-urbit/technical-overview"]
5+++
6+++
6
7
7Urbit is a clean-slate software stack designed to implement an encrypted P2P
8Urbit is a clean-slate software stack designed to implement an encrypted P2P
@@ -121,8 +122,8 @@ and Nock are two layers: Hoon, the practical layer, compiles itself to Nock, the
121simple layer. Your urbit runs in Vere, which includes a Nock interpreter, so it
122simple layer. Your urbit runs in Vere, which includes a Nock interpreter, so it
122can upgrade Hoon over the network without downtime.
123can upgrade Hoon over the network without downtime.
123
124
124−The Nock data model is quite simple. Every piece of data is a 'noun'. A noun
125+The Nock data model is quite simple. Every piece of data is a 'noun'. A [noun](/docs/glossary/noun/)
125−is an atom or a cell. An atom is any unsigned integer. A cell is an ordered
126+is an [atom](/docs/glossary/atom/) or a cell. An atom is any unsigned integer. A cell is an ordered
126pair of nouns. Nouns are acyclic and expose no pointer equality test.
127pair of nouns. Nouns are acyclic and expose no pointer equality test.
127
128
128### Vere
129### Vere
tutorials/creating-an-invite-pool.md+5−5
@@ -4,13 +4,13 @@ weight = 9
4template = "doc.html"
4template = "doc.html"
5+++
5+++
6
6
7−If you’re a star owner, you have the ability to create **invite pools**. These invite pools let you give your friends a piece of the network in the form of planets. This document will give you an explanation of how to create an invite pool and how to share it with your friends using our tool [Bridge](https://bridge.urbit.org).
7+If you're a star owner, you have the ability to create **invite pools**. These invite pools let you give your friends a piece of the network in the form of planets. This document will give you an explanation of how to create an invite pool and how to share it with your friends using our tool [Bridge](https://bridge.urbit.org).
8
8
9For more general tips on using your star, check out the [Star and Galaxy Operations page](https://urbit.org/using/operations/stars-and-galaxies/).
9For more general tips on using your star, check out the [Star and Galaxy Operations page](https://urbit.org/using/operations/stars-and-galaxies/).
10
10
11## Anatomy of an Invite Pool
11## Anatomy of an Invite Pool
12
12
13−An invite pool is a set of planet invites that can be distributed via email; each invite is worth one planet when redeemed. An invite pool can be as big as you’d like, providing that you have enough planets left to spawn. All invite pools must be created by a star, but they must be given to a planet. If you’re interested in how this works technically, take a look at the [DelegatedSending.sol contract](https://github.com/urbit/azimuth/blob/master/contracts/DelegatedSending.sol).
13+An invite pool is a set of planet invites that can be distributed via email; each invite is worth one planet when redeemed. An invite pool can be as big as you'd like, providing that you have enough planets left to spawn. All invite pools must be created by a star, but they must be given to a planet. If you're interested in how this works technically, take a look at the [DelegatedSending.sol contract](https://github.com/urbit/azimuth/blob/master/contracts/DelegatedSending.sol).
14
14
15Keep in mind that all planets will have access to the invite pool until the invite pool is exhausted.
15Keep in mind that all planets will have access to the invite pool until the invite pool is exhausted.
16
16
@@ -24,15 +24,15 @@ Giving your friends a piece of Urbit only takes a few minutes: send an invite po
24
24
252. Get the name (like `~poldec-tonteg`) of the planet to whom you'd like to give invites, it can be one you control or a friend's.
252. Get the name (like `~poldec-tonteg`) of the planet to whom you'd like to give invites, it can be one you control or a friend's.
26
26
27−3. Click “Manage Invite Pools” to assign an invite pool to the planet. You may receive a notification that you need to assign your spawn proxy to the address of the Delegated Sending contract. This is so that the contract can send invites on your behalf when the recipient claims them.
27+3. Click "Manage Invite Pools" to assign an invite pool to the planet. You may receive a notification that you need to assign your spawn proxy to the address of the Delegated Sending contract. This is so that the contract can send invites on your behalf when the recipient claims them.
28
28
29![](https://media.urbit.org/docs/invite-pool/browser-point.png)
29![](https://media.urbit.org/docs/invite-pool/browser-point.png)
30
30
31−4. Enter the planet name and the number of invites you’d like to assign them.
31+4. Enter the planet name and the number of invites you'd like to assign them.
32
32
33![](https://media.urbit.org/docs/invite-pool/browser-create-pool.png)
33![](https://media.urbit.org/docs/invite-pool/browser-create-pool.png)
34
34
35−5. If you control the planet that you gave the invite pool to, it should be accessible from the Bridge homepage. Click the Planet, then “Invite” to create invites for your friends.
35+5. If you control the planet that you gave the invite pool to, it should be accessible from the Bridge homepage. Click the Planet, then "Invite" to create invites for your friends.
36
36
37![](https://media.urbit.org/docs/invite-pool/browser-invite.png)
37![](https://media.urbit.org/docs/invite-pool/browser-invite.png)
38
38
tutorials/guide-to-breaches.md+23−5
@@ -4,26 +4,44 @@ weight = 10
4template = "doc.html"
4template = "doc.html"
5+++
5+++
6
6
7−An important concept on the Arvo network is that of continuity. Continuity refers to how ships remember the order of their own network messages and the network messages of others -- these messages are numbered, starting from zero. A _breach_ is when ships on the network agree to forget about this sequence and treat one or more ships like they are brand new.
7+An important concept on the [Ames](@/docs/tutorials/arvo/ames.md) network is that of continuity. Continuity refers to how ships remember the order of their own network messages and the network messages of others -- these messages are numbered, starting from zero. A _breach_ is when ships on the network agree to forget about this sequence and treat one or more ships like they are brand new.
8
8
9There are two kinds of breaches: **personal breaches** and **network breaches**.
9There are two kinds of breaches: **personal breaches** and **network breaches**.
10
10
11## Personal Breaches
11## Personal Breaches
12
12
13−Ships on the Arvo network sometimes need to reset their continuity. A personal breach is when an individual ship announces to the network: "I forgot who I am, let's start over from scratch." That is, it clears its own event log and sends an announcement to the network, asking all ships that have communicated with it to reset its networking information in their state. This makes it as though the ship was just started for the first time again, since everyone has network has forgotten about it.
13+Ships on the Ames network sometimes need to reset their continuity. A personal breach is when an individual ship announces to the network: "I forgot who I am, let's start over from scratch." That is, it clears its own event log and sends an announcement to the network, asking all ships that have communicated with it to reset its networking information in their state. This makes it as though the ship was just started for the first time again, since everyone on the network has forgotten about it.
14
14
15−Personal breaches often fix connectivity issues, but should only be used as a last resort. Before performing a personal breach, look at alternative fixes in the [Ship Troubleshooting](../ship-troubleshooting) guide. Also reach out for help in `~dopzod/urbit-help`, or, failing that, in the #ship-starting-support channel in our [Discord server](https://discord.gg/n9xhMdz) to see if there is another option.
15+Personal breaches often fix connectivity issues, but should only be used as a last resort. Before performing a personal breach, look at alternative fixes in the [Ship Troubleshooting](../ship-troubleshooting) guide. Also reach out for help in `~/~dopzod/urbit-help`, or, failing that, in the `#ship-starting-support` channel in our [Discord server](https://discord.gg/n9xhMdz) to see if there is another option.
16
16
17To perform a personal breach, follow the steps below.
17To perform a personal breach, follow the steps below.
18
18
19- Go to [bridge.urbit.org](https://bridge.urbit.org) and log into your identity.
19- Go to [bridge.urbit.org](https://bridge.urbit.org) and log into your identity.
20−- Go to the `Admin` section. Then go to `Edit Permisions`, then `Networking Keys`.
20+- Click on `OS: Urbit OS Settings` at the bottom, then click `Reset Networking Keys`.
21−- Check the `Breach Continuity` box. Click `Reset Networking Keys`, and then click `Send Transaction`.
21+- Check the `Breach Continuity` box. Click `Reset Networking Keys`, and then click `Send Transaction` and wait for the progress bar to appear.
22- Click `Download Arvo Keyfile`.
22- Click `Download Arvo Keyfile`.
23- Delete or archive your old pier.
23- Delete or archive your old pier.
24- Create a new pier by booting your ship with your new keyfile.
24- Create a new pier by booting your ship with your new keyfile.
25- Rejoin your favorite chat channels and subscriptions.
25- Rejoin your favorite chat channels and subscriptions.
26
26
27+There are two types of personal breaches: changing private keys, and changing
28+the Ethereum address that holds the Urbit ID.
29+
30+Performing a personal breach on your ship increments an integer value called
31+your ship's _life_ by one, which refers to your ship's [Azimuth](@/docs/tutorials/concepts/azimuth.md) _key
32+revision number_. This value is utilized by
33+Ames and Jael to ensure that you are
34+communicating with a ship created using its most recent set of keys. Your
35+ship's life is written at the end of the name of its keyfile, e.g.
36+`sampel-palnet-4.key`. Changing the Etherum address that holds the Urbit ID,
37+called _reticketing_, also increments a number called the ship's _rift_ by one.
38+Rift refers to your ship's Azimuth _continuity number_.
39+
40+You can check your current life and rift number by running the
41+`+keys our` generator in Dojo. You can inspect another ship's life and rift can be checked by
42+running `+keys ~sampel-palnet`.
43+
44+
27## Network Breaches
45## Network Breaches
28
46
29A network breach is an event where all ships on the network are required to update to a new continuity era. Network breaches happen when an Arvo update is released that is too large to release over the air. The current continuity era is given by a value in Ames, our networking vane, that is incremented when a network breaches; only ships with the same such value are able to communicate with one another.
47A network breach is an event where all ships on the network are required to update to a new continuity era. Network breaches happen when an Arvo update is released that is too large to release over the air. The current continuity era is given by a value in Ames, our networking vane, that is incremented when a network breaches; only ships with the same such value are able to communicate with one another.
reference/hoon-errors.md → tutorials/hoon-errors.mdrenamed+44−35
@@ -1,13 +1,16 @@
1+++
1+++
2title = "Hoon Errors"
2title = "Hoon Errors"
3−weight = 6
3+weight = 12
4template = "doc.html"
4template = "doc.html"
5+++
5+++
6−Ideally your Hoon works perfectly the first time. But...
6+
7+In this section we explore strategies for debugging and understanding what your
8+Hoon code is doing. We cover common errors that Dojo may spit out, how to turn
9+on debugging and verbose mode, and how to use debugging printfs.
7
10
8## Syntax errors
11## Syntax errors
9
12
10−When you get a syntax error, you'll see a message like
13+When you get a syntax error, you'll see a message like:
11
14
12```
15```
13syntax error at [10 12]
16syntax error at [10 12]
@@ -15,12 +18,12 @@ syntax error at [10 12]
15
18
16This is a line and column number; more exactly, the line and
19This is a line and column number; more exactly, the line and
17column of the first byte the parser couldn't interpret as part of
20column of the first byte the parser couldn't interpret as part of
18−a correct Hoon file. These values are always correct.
21+a correct Hoon file. These values are always correct.
19
22
20Usually, the line and column tell you everything you need to
23Usually, the line and column tell you everything you need to
21−know. But the worst-case scenario for a syntax error is that,
24+know. But the worst-case scenario for a syntax error is that,
22somewhere above, you've confused Hoon's tall form by using the
25somewhere above, you've confused Hoon's tall form by using the
23−wrong fanout for a rune. For example, `%+` ([**cenlus**](@/docs/reference/hoon-expressions/rune/cen.md#cenlus),
26+wrong fanout for a rune. For example, `%+` ([**cenlus**](@/docs/reference/hoon-expressions/rune/cen.md#cenlus),
24a function call whose sample is a cell) has three subhoons:
27a function call whose sample is a cell) has three subhoons:
25
28
26```hoon
29```hoon
@@ -29,19 +32,19 @@ a function call whose sample is a cell) has three subhoons:
29baz
32baz
30```
33```
31
34
32−But if you make a mistake and write
35+But if you make a mistake and write ...
33
36
34```hoon
37```hoon
35%+ foo
38%+ foo
36bar
39bar
37```
40```
38
41
39−the parser will eat the next reference below and try to treat it as a
42+... the parser will eat the next reference below and try to treat it as a
40−part of the `%+`. This can cause a cascading error somewhere
43+part of the `%+`. This can cause a cascading error somewhere
41below, usually stopped by a `==` or `--`.
44below, usually stopped by a `==` or `--`.
42
45
43−When this happens, don't panic! Binary search actually works
46+When this happens, don't panic! Binary search actually works
44−quite well. Any reference can be stubbed out as `!!`. Find the
47+quite well. Any reference can be stubbed out as `!!`. Find the
45prefix of your file that compiles, then work forward until
48prefix of your file that compiles, then work forward until
46the actual error appears.
49the actual error appears.
47
50
@@ -49,20 +52,24 @@ the actual error appears.
49
52
50Now your code parses but doesn't compile.
53Now your code parses but doesn't compile.
51
54
52−### Turn on debugging
55+### Turn on debugging or verbose mode
53
56
54Your first step should be to put a `!:` ("zapcol") rune at the
57Your first step should be to put a `!:` ("zapcol") rune at the
55−top of the file. This is like calling the C compiler with `-g`;
58+top of the file. This is like calling the C compiler with `-g`;
56it tells the Hoon compiler to generate tracing references.
59it tells the Hoon compiler to generate tracing references.
57
60
58−Bear in mind that `!:` breaks tail-call optimization. This is a
61+Bear in mind that `!:` breaks tail-call optimization. This is a
59−bug, but a relatively low-priority bug. `!.` turns off `!:`.
62+bug, but a relatively low-priority bug. `!.` turns off `!:`.
60Note that `!:` and `!.` are reference-level, not file-level; you can
63Note that `!:` and `!.` are reference-level, not file-level; you can
61wrap any reference in either.
64wrap any reference in either.
62
65
66+You may also find it helpful to turn on verbose mode by entering `|verb` into Dojo, which prints (almost)
67+everything happening in the kernel to the console. This is useful for performing
68+stack trace. An extensive stack trace tutorial is [below](#stack-trace-tutorial).
69+
63### Error trace
70### Error trace
64
71
65−If you have `!:` on, you'll see an error trace, like
72+If you have `!:` on, you'll see an error trace, like:
66
73
67```
74```
68/~zod/home/0/gen/hello:<[7 3].[11 21]>
75/~zod/home/0/gen/hello:<[7 3].[11 21]>
@@ -78,31 +85,31 @@ The bottom of this trace is the line and column of the reference which
78failed to compile, then the cause of the error (`nest-fail`).
85failed to compile, then the cause of the error (`nest-fail`).
79
86
80Hoon does not believe in inundating you with possibly irrelevant
87Hoon does not believe in inundating you with possibly irrelevant
81−debugging information. Your first resort is always to just look
88+debugging information. Your first resort is always to just look
82−at the code and try to figure out what's wrong. This practice
89+at the code and try to figure out what's wrong. This practice
83strengthens your Hoon muscles.
90strengthens your Hoon muscles.
84
91
85(Consider the opposite extreme; imagine if you had a magic bot
92(Consider the opposite extreme; imagine if you had a magic bot
86−that always fixed your compiler errors for you. Pro: no time
93+that always fixed your compiler errors for you. Pro: no time
87−wasted on compiler errors. Con: you never learn Hoon.)
94+wasted on compiler errors. Con: you never learn Hoon.)
88
95
89## Common errors
96## Common errors
90
97
91Moral fiber is all very well and good, but sometimes you're
98Moral fiber is all very well and good, but sometimes you're
92−stumped. Couldn't the compiler help a little? These messages do
99+stumped. Couldn't the compiler help a little? These messages do
93−mean something. Here are the three most common:
100+mean something. Here are the three most common:
94
101
95### `nest-fail`
102### `nest-fail`
96
103
97−This is a type mismatch (`nest` is the Hoon typechecker). It
104+This is a type mismatch (`nest` is the Hoon typechecker). It
98means you tried to pound a square peg into a round hole.
105means you tried to pound a square peg into a round hole.
99
106
100−What was the peg and what was the hole? Hoon doesn't tell you by
107+What was the peg and what was the hole? Hoon doesn't tell you by
101default, because moral fiber, and also because in too many cases
108default, because moral fiber, and also because in too many cases
102−trivial errors lead to large intimidating dumps. However, you
109+trivial errors lead to large intimidating dumps. However, you
103can use the `~!` rune ([**sigzap**](@/docs/reference/hoon-expressions/rune/sig.md#sigzap)) to print the type of any hoon in your stack trace.
110can use the `~!` rune ([**sigzap**](@/docs/reference/hoon-expressions/rune/sig.md#sigzap)) to print the type of any hoon in your stack trace.
104
111
105−For instance, you wrote `(foo bar)` and got a `nest-fail`. Change
112+For instance, you wrote `(foo bar)` and got a `nest-fail`. Change
106your code to be:
113your code to be:
107
114
108```hoon
115```hoon
@@ -117,10 +124,10 @@ You'll get the same `nest-fail`, but this will show the type of
117### `find.foo`
124### `find.foo`
118
125
119A `find.foo` error means limb `foo` wasn't found in the subject.
126A `find.foo` error means limb `foo` wasn't found in the subject.
120−In other words, "undeclared variable."
127+In other words, "undeclared variable".
121
128
122The most common subspecies of `find` error is `find.$`, meaning
129The most common subspecies of `find` error is `find.$`, meaning
123−the empty name `$` was not found. This often happens when you
130+the empty name `$` was not found. This often happens when you
124use a reference that does not produce a gate/mold, as a gate/mold. For
131use a reference that does not produce a gate/mold, as a gate/mold. For
125instance, `(foo bar)` will give `find.$` if `foo` is not actually a
132instance, `(foo bar)` will give `find.$` if `foo` is not actually a
126function.
133function.
@@ -128,17 +135,17 @@ function.
128### `mint-vain` and `mint-lost`
135### `mint-vain` and `mint-lost`
129
136
130These are errors caused by type inference in pattern matching.
137These are errors caused by type inference in pattern matching.
131−`mint-vain` means this hoon is never executed. `mint-lost` means there's a case in a `?-` ([**wuthep**](@/docs/reference/hoon-expressions/rune/wut.md#wuthep)) that isn't handled.
138+`mint-vain` means this hoon is never executed. `mint-lost` means there's a case in a `?-` ([**wuthep**](@/docs/reference/hoon-expressions/rune/wut.md#wuthep)) that isn't handled.
132
139
133## Runtime crashes
140## Runtime crashes
134
141
135If your code crashes at runtime or overflows the stack, you'll
142If your code crashes at runtime or overflows the stack, you'll
136−see a stack trace that looks just like the trace above. Don't
143+see a stack trace that looks just like the trace above. Don't
137confuse runtime crashes with compilation errors, though.
144confuse runtime crashes with compilation errors, though.
138
145
139If your code goes into an infinite loop, kill it with `ctrl-c` (you'll
146If your code goes into an infinite loop, kill it with `ctrl-c` (you'll
140need to be developing on the local console; otherwise, the
147need to be developing on the local console; otherwise, the
141−infinite loop will time out either too slowly or too fast). The
148+infinite loop will time out either too slowly or too fast). The
142stack trace will show what your code was doing when interrupted.
149stack trace will show what your code was doing when interrupted.
143
150
144The counterpart of `~!` for runtime crashes is `~|`
151The counterpart of `~!` for runtime crashes is `~|`
@@ -150,12 +157,12 @@ The counterpart of `~!` for runtime crashes is `~|`
150```
157```
151
158
152If `(foo bar)` crashes, the value of `foo` is printed in the
159If `(foo bar)` crashes, the value of `foo` is printed in the
153−stack trace. Otherwise, the `~|` has no effect.
160+stack trace. Otherwise, the `~|` has no effect.
154
161
155## Debugging printfs
162## Debugging printfs
156
163
157The worst possibility, of course, is that your code runs but does
164The worst possibility, of course, is that your code runs but does
158−the wrong thing. This is relatively unusual in a typed
165+the wrong thing. This is relatively unusual in a typed
159functional language, but it still happens.
166functional language, but it still happens.
160
167
161`~&` ([**sigpam**](@/docs/reference/hoon-expressions/rune/sig.md#sigpam)) is Hoon's debugging printf.
168`~&` ([**sigpam**](@/docs/reference/hoon-expressions/rune/sig.md#sigpam)) is Hoon's debugging printf.
@@ -166,7 +173,7 @@ This pretty-prints its argument:
166(foo bar)
173(foo bar)
167```
174```
168
175
169−will always print `foo` every time it executes. A variant is
176+will always print `foo` every time it executes. A variant is
170`~?` ([**sigwut**](@/docs/reference/hoon-expressions/rune/sig.md#sigwut)), which prints only if a condition is
177`~?` ([**sigwut**](@/docs/reference/hoon-expressions/rune/sig.md#sigwut)), which prints only if a condition is
171true:
178true:
172
179
@@ -176,5 +183,7 @@ true:
176```
183```
177
184
178For now, you need to be on the local console to see these debug
185For now, you need to be on the local console to see these debug
179−printfs (which are implemented by interpreter hints). This is a
186+printfs (which are implemented by interpreter hints). This is a
180bug and, like all bugs, will be fixed at some point.
187bug and, like all bugs, will be fixed at some point.
188+
189+
tutorials/hoon/_index.md+5−55
@@ -2,66 +2,16 @@
2title = "Hoon"
2title = "Hoon"
3weight = 1
3weight = 1
4sort_by = "weight"
4sort_by = "weight"
5−template = "sections/docs/chapters.html"
5+template = "sections/docs/hoon.html"
6aliases = ["/docs/byte/0/", "/docs/byte", "/docs/learn/hoon/hoon-tutorial/"]
6aliases = ["/docs/byte/0/", "/docs/byte", "/docs/learn/hoon/hoon-tutorial/"]
7+++
7+++
8
8
9−This series is designed to teach you Hoon without assuming you have an extensive programming background. In fact, you should be able to follow much of it even if you have no programming experience at all, though of course experience helps. We strongly encourage you to try out all the examples of each lesson. These lessons are meant for the beginner but they aren't meant to be skimmed. Each lesson falls into one of two categories: **readings**, which are prose-heavy explanations of Hoon fundamentals, and **walkthroughs**, which are line-by-line explanations of example programs. Walkthroughs are found between readings, offering a practical implementation of the concepts taught in the reading before.
9+This series is designed to teach you Hoon without assuming you have an extensive programming background. In fact, you should be able to follow much of it even if you have no programming experience at all, though of course experience helps. We strongly encourage you to try out all the examples of each lesson. These lessons are meant for the beginner but they aren't meant to be skimmed. Each lesson falls into one of two categories: **readings**, which are prose-heavy explanations of Hoon fundamentals, and **walkthroughs**, which are line-by-line explanations of example programs. Walkthroughs are found between readings, offering a practical implementation of the concepts taught in the reading before.
10+
11+Before you start, we recommend reading [Why Hoon?](https://urbit.org/blog/why-hoon/), a blog post by a Tlon engineer that justifies the existence and use of this peculiar language. This explainer gives useful context to all types of learners, but those new to programming will need to use Google frequently for the jargon.
10
12
11Chapter 1 introduces and explains the fundamental concepts you need in order to understand Hoon's semantics.
13Chapter 1 introduces and explains the fundamental concepts you need in order to understand Hoon's semantics.
12
14
13−Hoon is a 'subject-oriented' programming language -- every expression of Hoon is evaluated relative to a **subject**. The subject is a piece of data that represents the environment, or the context, of an expression. After reading Chapter 1 you should understand what the subject is and how to refer to its various parts. In this chapter you'll also learn about **cores**, which are an important data structure in Hoon. Once you get the hang of cores you'll be able to write your own functions in Hoon.
15+Hoon is a "subject-oriented" programming language -- every expression of Hoon is evaluated relative to a **subject**. The subject is a piece of data that represents the environment, or the context, of an expression. After reading Chapter 1 you should understand what the subject is and how to refer to its various parts. In this chapter you'll also learn about **[cores](/docs/glossary/core/)**, which are an important data structure in Hoon. Once you get the hang of [cores](/docs/glossary/core/) you'll be able to write your own functions in Hoon.
14
16
15Chapter 2 covers the type system, and writing apps, and the workings of the Arvo kernel.
17Chapter 2 covers the type system, and writing apps, and the workings of the Arvo kernel.
16−
17−
18−## Lessons
19−
20−### Chapter 1
21−
22−- [1.1 Setup](setup)
23−- [1.1.1 Walkthrough: List of Numbers](list-of-numbers)
24−- [1.2 Nouns](nouns)
25−- [1.3 Hoon Syntax](hoon-syntax)
26−- [1.3.1 Walkthrough: Conditionals](conditionals)
27−- [1.4 Gates (Hoon Functions)](gates)
28−- [1.4.1 Walkthrough: Recursion](recursion)
29−- [1.5 Lists](lists)
30−- [1.5.1 Walkthrough: Fibonacci Sequence](fibonacci)
31−- [1.6 The Subject and Its Legs](the-subject-and-its-legs)
32−- [1.6.1 Walkthrough: Ackermann Function](ackermann)
33−- [1.7 Arms and Cores](arms-and-cores)
34−- [1.7.1 Walkthrough: Caesar Cipher](caesar)
35−- [1.8 Doors](doors)
36−- [1.8.1 Walkthough: Bank Account](bank-account)
37−- [1.9 Generators](generators)
38−
39−### Chapter 2
40−
41−- [2.1 Atoms, Auras, and Simple Cell Types](atoms-auras-and-simple-cell-types)
42−- [2.2 Type Checking and Type Inference](type-checking-and-type-inference)
43−- [2.3 Structures and Complex Types](structures-and-complex-types)
44−- [2.3.1 Walkthrough: Libraries](libraries)
45−- [2.4 Standard Library: Trees, Sets, and Maps](trees-sets-and-maps)
46−- [2.5 Type Polymorphism](type-polymorphism)
47−- [2.5.1 Walkthrough: Iron Polymorphism](iron-polymorphism)
48−- [2.5.2 Walkthrough: Lead Polymorphism](lead-polymorphism)
49−- [2.6 Behn](behn)
50−- [2.7 Gall](gall)
51−- [2.7.1 Gall Walkthrough: Egg Timer](egg-timer)
52−- [2.7.2 Gall: Async Monad](async-monad)
53−- [2.8 Ford](ford)
54−- [2.8.1 Walkthrough Ford Testing Suite Walkthrough](test-sets)
55−- [2.9.1 Walkthrough: Landscape Tile](landscape-tile)
56−
57−
58−## Other Resources
59−
60−Want to know how to style your code? Check out the [style guide](style).
61−
62−Consult the [standard library documentation](@/docs/reference/library/_index.md) or [rune reference](@/docs/reference/hoon-expressions/_index.md) to look up any unknown rune or standard library function you don't understand.
63−
64−As you work your way through these lessons you may want to work on example problems from the [Hoon Workbook](@/docs/tutorials/hoon/workbook/_index.md) for practice. Once you finish the lessons here you may want to write more versatile Hoon programs which can make use of more of your urbit's environment, in which case you'll want to check out the [Generators](@/docs/tutorials/hoon/generators.md) documentation. Learn about [Udon and Sail](@/docs/tutorials/sail-and-udon.md), Urbit's stripped-down version of Markdown, and a subset of Hoon used for generating XML nodes respectively.
65−
66−
67−> Last major revision of this section: November 2019
tutorials/hoon/ackermann.md+1−1
@@ -7,7 +7,7 @@ aliases = ["docs/learn/hoon/hoon-tutorial/ackermann/"]
7
7
8The Ackermann function is one of the earliest examples of a function that is both totally computable -- meaning that it can be solved -- and not primitively recursive -- meaning it can not be rewritten in an iterative fashion.
8The Ackermann function is one of the earliest examples of a function that is both totally computable -- meaning that it can be solved -- and not primitively recursive -- meaning it can not be rewritten in an iterative fashion.
9
9
10−In this lesson, we will write a gate that computes the [Ackermann function](https://en.wikipedia.org/wiki/Ackermann_function)
10+In this lesson, we will write a [gate](/docs/glossary/gate/) that computes the [Ackermann function](https://en.wikipedia.org/wiki/Ackermann_function)
11
11
12``` hoon
12``` hoon
13|= [m=@ n=@]
13|= [m=@ n=@]
tutorials/hoon/aqua.mdnew file+80
@@ -0,0 +1,80 @@
1++++
2+title = "Writing Aqua Tests"
3+weight = 37
4+template = "doc.html"
5++++
6+
7+# Concepts
8+
9+Aqua (short for "aquarium", alluding to the idea that you're running
10+multiple ships in a safe, artificial environment and watching them
11+carefully) is an app that lets you run one or more virtual ships from
12+within a single host.
13+
14+pH is a library of functions designed to make it easy to write
15+integration tests using Aqua.
16+
17+# First test
18+
19+To run your first pH test, run the following commands:
20+
21+```
22+|start %aqua
23+:aqua +solid
24+-ph-add
25+```
26+
27+This will start Aqua, compile a new kernel for it, and then compile and
28+run /ted/ph/add.hoon. Here are the contents of that file:
29+
30+```
31+/- spider
32+/+ *ph-io
33+=, strand=strand:spider
34+^- thread:spider
35+|= [=bowl:spider args=vase]
36+=/ m (strand ,vase)
37+;< ~ bind:m start-simple
38+;< ~ bind:m (raw-ship ~bud ~)
39+;< ~ bind:m (dojo ~bud "[%test-result (add 2 3)]")
40+;< ~ bind:m (wait-for-output ~bud "[%test-result 5]")
41+;< ~ bind:m end-simple
42+(pure:m *vase)
43+```
44+
45+There's a few lines of boilerplate, with three important lines defining
46+the test.
47+
48+```
49+;< ~ bind:m (raw-ship ~bud ~)
50+;< ~ bind:m (dojo ~bud "[%test-result (add 2 3)]")
51+;< ~ bind:m (wait-for-output ~bud "[%test-result 5]")
52+```
53+
54+We boot a ship with `+raw-ship`. In this case the ship we are booting will be `~bud`. These ships exist in a virtual environment so you could use any valid `@p`.
55+
56+Next we enter some commands with `+dojo`, and then we wait until we get a line that includes some expected output. Each of these commands we need to specify the ship we want to run on.
57+
58+Many tests can be created with nothing more than these simple tools.
59+Try starting two ships and having one send a `|hi` to the other, and
60+check that it arrives.
61+
62+Many more complex tests can be created, including file changes, personal
63+breaches, mock http clients or servers, or anything you can imagine.
64+Check out `/lib/ph/io.hoon` for other available functions, and look at
65+other tests in `/ted/ph/` for inspiration.
66+
67+# Reference
68+
69+Aqua has the following commands:
70+
71+`:aqua +solid` Compiles a "pill" (kernel) for the guest ships and loads it into Aqua.
72+
73+`:aqua [%swap-files ~]` modifies the pill to use the files you have in
74+your filesystem without rebuilding the whole pill. For example, if you
75+change an app and you want to test the new version, you must install it
76+in the pill. This command will do that.
77+
78+`:aqua [%swap-vanes ~[%a]]` Modifies the pill to load a new version of a
79+vane (`%a` == Ames in this example, but it can be any list of vanes).
80+This is faster than running `:aqua +solid`.
tutorials/hoon/arms-and-cores.md+4−4
@@ -4,7 +4,7 @@ weight = 15
4template = "doc.html"
4template = "doc.html"
5aliases = ["/docs/learn/hoon/hoon-tutorial/arms-and-cores/"]
5aliases = ["/docs/learn/hoon/hoon-tutorial/arms-and-cores/"]
6+++
6+++
7−The Hoon subject is a noun. Each fragment of this noun is either an arm or a leg. In the previous lesson you learned what a leg is, and how to return legs of the subject by various means. In this lesson you'll learn what an arm is. Arms are a bit more complex than legs -- a full understanding of them requires a bit more background knowledge. Accordingly, in this lesson we must also introduce an important Hoon data structure: a 'core'.
7+The Hoon subject is a [noun](/docs/glossary/noun/). Each fragment of this [noun](/docs/glossary/noun/) is either an [arm](/docs/glossary/arm/) or a leg. In the previous lesson you learned what a leg is, and how to return legs of the subject by various means. In this lesson you'll learn what an [arm](/docs/glossary/arm/) is. Arms are a bit more complex than legs -- a full understanding of them requires a bit more background knowledge. Accordingly, in this lesson we must also introduce an important Hoon data structure: a '[core](/docs/glossary/core/)'.
8
8
9After arms are defined and explained we review wing expressions, this time focusing on wing resolution to arms.
9After arms are defined and explained we review wing expressions, this time focusing on wing resolution to arms.
10
10
@@ -14,9 +14,9 @@ Arms and legs are limbs of the subject, i.e., noun fragments of the subject. In
14
14
15An **arm** is some expression of Hoon encoded as a noun. (By 'encoded as a noun' we literally mean: 'compiled to a Nock formula'. But you don't need to know anything about Nock to understand Hoon.) You virtually never need to treat an arm as raw data, even though technically you can -- it's just a noun like any other. You virtually always want to think of an arm simply as a way of running some Hoon code.
15An **arm** is some expression of Hoon encoded as a noun. (By 'encoded as a noun' we literally mean: 'compiled to a Nock formula'. But you don't need to know anything about Nock to understand Hoon.) You virtually never need to treat an arm as raw data, even though technically you can -- it's just a noun like any other. You virtually always want to think of an arm simply as a way of running some Hoon code.
16
16
17−Every expression of Hoon is evaluated relative to a subject. What subject is the arm to be evaluated against? Answer: the parent core of that arm.
17+Every expression of Hoon is evaluated relative to a subject. What subject is the arm to be evaluated against? Answer: the parent [core](/docs/glossary/core/) of that arm.
18
18
19−So in order to understand fully what an arm is, you must understand what a core is. Briefly, a **core** is a cell of `[battery payload]`. The **battery** is a collection of one or more arms, and the **payload** is the data needed by the arms to evaluate correctly. (The battery is code and the payload is data for that code.) A given core is the **parent core** of all of the arms in its battery.
19+So in order to understand fully what an arm is, you must understand what a core is. Briefly, a **core** is a cell of `[battery payload]`. The **battery** is a collection of one or more arms, and the **payload** is the data needed by the arms to evaluate correctly. (The battery is code and the [payload](/docs/glossary/payload/) is data for that code.) A given core is the **parent core** of all of the arms in its battery.
20
20
21## Your First Core
21## Your First Core
22
22
@@ -110,7 +110,7 @@ Now use the following multi-line expression to bind `c` to a core. As before, f
110
110
111Note: binding `c` to the core created by the `|%` expression will fail unless you have already bound `a` and `b` to the relevant values, as we did above. Our having already bound them is what lets us use them in the `|%` expression.
111Note: binding `c` to the core created by the `|%` expression will fail unless you have already bound `a` and `b` to the relevant values, as we did above. Our having already bound them is what lets us use them in the `|%` expression.
112
112
113−The `|%` expression above creates a core with four arms. The first, named `two`, evaluates to the constant `2`. The second arm, `inc`, adds `1` to `a`. `double` returns double the value of `a`, and `sum` returns the sum of the two atoms in `b`. The computations defined by these arms are pretty simple (and in the case of `two`, trivial), but a good starting point for learning about cores.
113+The `|%` expression above creates a core with four arms. The first, named `two`, evaluates to the constant `2`. The second arm, `inc`, adds `1` to `a`. `double` returns double the value of `a`, and `sum` returns the sum of the two [atoms](/docs/glossary/atom/) in `b`. The computations defined by these arms are pretty simple (and in the case of `two`, trivial), but a good starting point for learning about cores.
114
114
115Let's run the arm names in the dojo:
115Let's run the arm names in the dojo:
116
116
tutorials/hoon/async-monad.md+2−2
@@ -158,7 +158,7 @@ The following code is from `app/example-tapp-fetch.hoon` Much of this file shoul
158--
158--
159```
159```
160
160
161−As indicated by the comments, `handle-poke` is the main arm of our Gall app. This is equivalent to the `poke` arms in a standard Gall app, but will not differentiate by mark. Let's look at the first part of this gate.
161+As indicated by the comments, `handle-poke` is the main [arm](/docs/glossary/arm/) of our Gall app. This is equivalent to the `poke` arms in a standard Gall app, but will not differentiate by mark. Let's look at the first part of this [gate](/docs/glossary/gate/).
162
162
163```hoon
163```hoon
164++ handle-poke
164++ handle-poke
@@ -212,4 +212,4 @@ In a number of cases `D` here is going to be another `;<` rune. This is how you
212
212
213Continuing on, here is a use of `fetch-json` with the `;<` that is an example worth reading. `fetch-json` takes a `tape` and produces a `form:(async ,json)` which can be processed to obtain the data we want.
213Continuing on, here is a use of `fetch-json` with the `;<` that is an example worth reading. `fetch-json` takes a `tape` and produces a `form:(async ,json)` which can be processed to obtain the data we want.
214
214
215−Armed with an understanding of `;<`, the rest of `handle-poke` should be quite readable though you may need to consult the `dejs-soft:format` core to get a firm grasp on how JSON parsing works. Hopefully, you now have an understanding of the basic use of the `tapp` library. This style of Gall app can result in code that, while potentially less flexible, is easier to read and reason about than a traditional Gall app.
215+Armed with an understanding of `;<`, the rest of `handle-poke` should be quite readable though you may need to consult the `dejs-soft:format` [core](/docs/glossary/core/) to get a firm grasp on how JSON parsing works. Hopefully, you now have an understanding of the basic use of the `tapp` library. This style of Gall app can result in code that, while potentially less flexible, is easier to read and reason about than a traditional Gall app.
tutorials/hoon/atoms-auras-and-simple-cell-types.md+2−2
@@ -6,7 +6,7 @@ aliases = ["/docs/learn/hoon/hoon-tutorial/atoms-auras-and-simple-cell-types/"]
6+++
6+++
7Like most modern high-level programming languages, Hoon has a type system. Because Hoon is a functional programming language, its type system differs somewhat from those of non-functional languages. In the next few lessons we'll go over Hoon's type system and point out some of its distinctive features. Certain advanced topics (e.g. type [polymorphism](https://en.wikipedia.org/wiki/Polymorphism_%28computer_science%29)) won't be addressed until a later chapter.
7Like most modern high-level programming languages, Hoon has a type system. Because Hoon is a functional programming language, its type system differs somewhat from those of non-functional languages. In the next few lessons we'll go over Hoon's type system and point out some of its distinctive features. Certain advanced topics (e.g. type [polymorphism](https://en.wikipedia.org/wiki/Polymorphism_%28computer_science%29)) won't be addressed until a later chapter.
8
8
9−A type is ordinarily understood to be a set of values. Examples: the set of all atoms is a type, the set of all cells is a type, and so on.
9+A type is ordinarily understood to be a set of values. Examples: the set of all [atoms](/docs/glossary/atom/) is a type, the set of all cells is a type, and so on.
10
10
11Type systems provide type safety, in part by making sure functions produce values of the correct type. When you write a function whose product is intended to be an atom, it would be nice to know that the function is guaranteed to produce an atom. Hoon's type system provides such guarantees with **type checking** and **type inference**.
11Type systems provide type safety, in part by making sure functions produce values of the correct type. When you write a function whose product is intended to be an atom, it would be nice to know that the function is guaranteed to produce an atom. Hoon's type system provides such guarantees with **type checking** and **type inference**.
12
12
@@ -52,7 +52,7 @@ Let's try one in the dojo. For the expression to be assessed we'll use `15` aga
5215
5215
53```
53```
54
54
55−Because `@ud` is the inferred type of `15`, the cast succeeds. Notice that the `^-` expression never does anything to modify the underlying noun of the second subexpression. It's used simply to mandate a type-check on that expression. This check occurs at compile-time (i.e., when the expression is compiled to Nock).
55+Because `@ud` is the inferred type of `15`, the cast succeeds. Notice that the `^-` expression never does anything to modify the underlying [noun](/docs/glossary/noun/) of the second subexpression. It's used simply to mandate a type-check on that expression. This check occurs at compile-time (i.e., when the expression is compiled to Nock).
56
56
57What about when the inferred type doesn't fit under the cast type? You get a `nest-fail` crash at compile-time:
57What about when the inferred type doesn't fit under the cast type? You get a `nest-fail` crash at compile-time:
58
58
tutorials/hoon/bank-account.md+5−5
@@ -5,7 +5,7 @@ template = "doc.html"
5aliases = ["/docs/learn/hoon/hoon-tutorial/bank-account/"]
5aliases = ["/docs/learn/hoon/hoon-tutorial/bank-account/"]
6+++
6+++
7
7
8−In this lesson, we will write a door that can act as a bank account with the ability to withdraw, deposit, and check the account's balance.
8+In this lesson, we will write a [door](/docs/glossary/door/) that can act as a bank account with the ability to withdraw, deposit, and check the account's balance.
9
9
10```hoon
10```hoon
11:- %say
11:- %say
@@ -38,7 +38,7 @@ We start with the three lines we have in every `%say` generator:
38:- %noun
38:- %noun
39```
39```
40
40
41−In the above code chunk, we're creating a cell. The head of this cell is `%say`. The tail is a gate (`|= *`) that produces another cell (`:- %noun`) with a head of the mark of a the kind of data we are going to produce, a noun; the tail of the second cell is the rest of the program.
41+In the above code chunk, we're creating a cell. The head of this cell is `%say`. The tail is a [gate](/docs/glossary/gate/) (`|= *`) that produces another cell (`:- %noun`) with a head of the mark of a the kind of data we are going to produce, a [noun](/docs/glossary/noun/); the tail of the second cell is the rest of the program.
42
42
43```hoon
43```hoon
44=< =~ new-account
44=< =~ new-account
@@ -51,7 +51,7 @@ In the above code chunk, we're creating a cell. The head of this cell is `%say`.
51
51
52In this code above, we're going to compose two runes using `=<`, which has inverted arguments. We use this rune to keep the heaviest twig to the bottom of the code.
52In this code above, we're going to compose two runes using `=<`, which has inverted arguments. We use this rune to keep the heaviest twig to the bottom of the code.
53
53
54−`=~` is a rune that composes multiple expressions. We take `new-account` and use that as the subject for the call to `deposit`. `deposit` and `withdraw` both produce a new version of the door that's used in subsequent calls, which is why we are able to chain them in this fashion. The final reference is to `balance`, which is the account balance contained in the core we that that we examine below.
54+`=~` is a rune that composes multiple expressions. We take `new-account` and use that as the subject for the call to `deposit`. `deposit` and `withdraw` both produce a new version of the door that's used in subsequent calls, which is why we are able to chain them in this fashion. The final reference is to `balance`, which is the account balance contained in the [core](/docs/glossary/core/) we that that we examine below.
55
55
56```hoon
56```hoon
57|%
57|%
@@ -67,7 +67,7 @@ In this code above, we're going to compose two runes using `=<`, which has inver
67--
67--
68```
68```
69
69
70−We've chosen here to wrap our door in its own core to emulate the style of programming that is used when creating libraries. `new-account` is the name of our door. Recall that a door is a core with one or more arms that has a sample. Here, our door has a sample of one `@ud` with the face `balance` and two arms, `deposit` and `withdraw`.
70+We've chosen here to wrap our door in its own core to emulate the style of programming that is used when creating libraries. `new-account` is the name of our door. Recall that a door is a core with one or more [arms](/docs/glossary/arm/) that has a sample. Here, our door has a sample of one `@ud` with the face `balance` and two arms `deposit` and `withdraw`.
71
71
72Each of these arms produces a gate which takes an `@ud` argument. Each of these gates has a similar bit of code inside:
72Each of these arms produces a gate which takes an `@ud` argument. Each of these gates has a similar bit of code inside:
73
73
@@ -75,6 +75,6 @@ Each of these arms produces a gate which takes an `@ud` argument. Each of these
75+>.$(balance (add balance amount))
75+>.$(balance (add balance amount))
76```
76```
77
77
78−`+>` is [wing syntax](@/docs/reference/hoon-expressions/limb/wing.md). This particularly wing construction looks for the the tail of the tail (the third element) in `$`, the subject of the gate we are in, which is the entire `new-account` door. We change `balance` to be the result of adding `balance` and `amount` and produce the door as the result. `withdraw` functions the same way only doing subtraction instead of addition.
78+`+>` is [wing syntax](@/docs/reference/hoon-expressions/limb/wing.md). This particular wing construction looks for the tail of the tail (the third element) in `$`, the subject of the gate we are in. The `withdraw` and `deposit` arms create gates with the entire `new-account` door as the context in their cores' `[battery sample context]`, in the "tail of the tail" slot. We change `balance` to be the result of adding `balance` and `amount` and produce the door as the result. `withdraw` functions the same way only doing subtraction instead of addition.
79
79
80It's important to notice that the sample, `balance`, is stored as part of the door rather than existing outside of it.
80It's important to notice that the sample, `balance`, is stored as part of the door rather than existing outside of it.
tutorials/hoon/behn.md+2−2
@@ -1,6 +1,6 @@
1+++
1+++
2title = "2.6 Behn"
2title = "2.6 Behn"
3−weight = 33
3+weight = 34
4template = "doc.html"
4template = "doc.html"
5+++
5+++
6
6
@@ -20,7 +20,7 @@ Notably, vanes are _not_ something that a user ever interacts with directly. The
20
20
21## Behn
21## Behn
22
22
23−In this section we introduce the simplest Arvo vane, Behn. This is not exhaustive, but just enough to know what is going on inside of Behn when we make a system call to it in the egg timer app. We discuss relevant types, some arms that are only called internally, and arms that may be called by another vane via a `move`.
23+In this section we introduce the simplest Arvo vane, Behn. This is not exhaustive, but just enough to know what is going on inside of Behn when we make a system call to it in the egg timer app. We discuss relevant types, some [arms](/docs/glossary/arm/) that are only called internally, and arms that may be called by another vane via a `move`.
24
24
25Behn is an Arvo vane that acts as a simple timer. It allows vanes and applications to set timer events, which are managed in a simple priority queue.
25Behn is an Arvo vane that acts as a simple timer. It allows vanes and applications to set timer events, which are managed in a simple priority queue.
26
26
tutorials/hoon/caesar.md+6−6
@@ -122,16 +122,16 @@ itself before reading the explanation.
122The `!:` in the first line of the above code enables a full stack trace in the
122The `!:` in the first line of the above code enables a full stack trace in the
123event of an error.
123event of an error.
124
124
125−`|= [msg=tape key=@ud]` creates a gate that takes a cell. The head of this cell
125+`|= [msg=tape key=@ud]` creates a [gate](/docs/glossary/gate/) that takes a cell. The head of this cell
126is a `tape`, which is a string type that's a list of `cord`s. Tapes are represented
126is a `tape`, which is a string type that's a list of `cord`s. Tapes are represented
127as text surrounded by double-quotes, such as this: `"a tape"`. We give this input
127as text surrounded by double-quotes, such as this: `"a tape"`. We give this input
128−tape the face `msg`. The tail of our cell is a `@ud` -- an unsigned decimal atom
128+tape the face `msg`. The tail of our cell is a `@ud` -- an unsigned decimal [atom](/docs/glossary/atom/)
129-- that we give the face `key`.
129-- that we give the face `key`.
130
130
131`=<` is the rune that evaluates its first child expression with respect to its
131`=<` is the rune that evaluates its first child expression with respect to its
132second child expression as the subject. In this case, we evaluate the
132second child expression as the subject. In this case, we evaluate the
133−expressions in the code chunk below against the core declared later, which
133+expressions in the code chunk below against the [core](/docs/glossary/core/) declared later, which
134−allows us reference the core's contained arms before they are defined. Without
134+allows us reference the core's contained [arms](/docs/glossary/arm/) before they are defined. Without
135`=<`, we would need to put the code chunk below at the bottom of our program.
135`=<`, we would need to put the code chunk below at the bottom of our program.
136
136
137```hoon
137```hoon
@@ -209,13 +209,13 @@ value. A `map` is a type equivalent to a dictionary in other languages: it's a
209data structure that associates a key with a value. If, for example, we wanted
209data structure that associates a key with a value. If, for example, we wanted
210to have an association between `a` and 1 and `b` and 2, we could use a `map`.
210to have an association between `a` and 1 and `b` and 2, we could use a `map`.
211
211
212−`=| chart=(map @t @t)` adds a noun to the subject with the default value of
212+`=| chart=(map @t @t)` adds a [noun](/docs/glossary/noun/) to the subject with the default value of
213the `(map @t @t)` type, and gives that noun the face `chart`.
213the `(map @t @t)` type, and gives that noun the face `chart`.
214
214
215`?. =((lent a) (lent b))` checks if the two tapes are the same length. If not,
215`?. =((lent a) (lent b))` checks if the two tapes are the same length. If not,
216the program crashes.
216the program crashes.
217
217
218−`|-` creates a trap, a gate that is called immediately.
218+`|-` creates a [trap](/docs/glossary/trap/), a gate that is called immediately.
219
219
220`?: |(?=(~ a) ?=(~ b))` checks if either tape is empty. If this is true, we
220`?: |(?=(~ a) ?=(~ b))` checks if either tape is empty. If this is true, we
221the program is finished and can return `chart`, the the `map` that we have been
221the program is finished and can return `chart`, the the `map` that we have been
tutorials/hoon/conditionals.md+23−15
@@ -5,7 +5,7 @@ template = "doc.html"
5aliases = ["/docs/learn/hoon/hoon-tutorial/conditionals/"]
5aliases = ["/docs/learn/hoon/hoon-tutorial/conditionals/"]
6+++
6+++
7
7
8−In this lesson, we will write a generator that takes an integer and checks if it is an even number between 1 and 100. This will help demonstrate how boolean (true or false) conditional expressions work in Hoon.
8+In this lesson, we will write a generator that takes an integer and checks if it is an even number between `1` and `100`. This will help demonstrate how boolean (`true` or `false`) conditional expressions work in Hoon.
9
9
10```hoon
10```hoon
11:- %say
11:- %say
@@ -18,60 +18,67 @@ In this lesson, we will write a generator that takes an integer and checks if it
18==
18==
19```
19```
20
20
21−On the very first line, with `:- %say` we are beginning to create a generator of the `%say` variety. The result of a `%say` generator is a cell with a head of `%say` and tail that is a gate, itself producing a `cask`, a pair of a `mark` and some data. It's not important for understanding conditionals; this is just template code. For more information about `%say` generators, see the [Generators](@/docs/tutorials/hoon/generators.md) documentation.
21+On the very first line, with `:- %say` we are beginning to create a generator of the `%say` variety. The result of a `%say` generator is a cell with a head of `%say` and tail that is a [gate](/docs/glossary/gate/), itself producing a `cask`, a pair of a `mark` and some data. It's not important for understanding conditionals; this is just template code. For more information about `%say` generators, see the [Generators](@/docs/tutorials/hoon/generators.md) documentation.
22
22
23```hoon
23```hoon
24|= [* [n=@ud ~] ~]
24|= [* [n=@ud ~] ~]
25```
25```
26
26
27−The code above builds a gate. The gate's first argument is a cell provided by Dojo that contains some system information we're not going to use, so we use `*` to indicate "any noun." The next cell is our arguments provided to the generator upon invocation at the `dojo`. Here we only want one `@ud` with the face `n`.
27+The code above builds a gate. The gate's first argument is a cell provided by Dojo that contains some system information we're not going to use, so we use `*` to indicate "any [noun](/docs/glossary/noun/)". The next cell is our arguments provided to the generator upon invocation at the Dojo. Here we only want one `@ud` with the face `n`.
28
28
29```hoon
29```hoon
30:- %noun
30:- %noun
31```
31```
32
32
33−This code is the third line of the `%say` "boilerplate," and it produces a `cask` with the head of `%noun`. We could use any `mark` here, but `%noun` is the most generic type, able to fit any data.
33+This code is the third line of the `%say` "boilerplate", and it produces a `cask` with the head of `%noun`. We could use any `mark` here, but `%noun` is the most generic type, able to fit any data.
34
34
35```hoon
35```hoon
36^- ?
36^- ?
37```
37```
38−This line casts the output as a `flag`, which is a type whose values are `%.y` and `%.n` representing "yes" and "no". These behave as boolean values.
39
38
39+This line casts the output as a `flag`, which is a type whose values are `%.y` and `%.n` representing "yes" and "no". These behave as boolean values (`true` or `false`).
40+
40−Let's look at the conditional.
41+Let's look at the conditional:
41
42
42```hoon
43```hoon
43?& (gte n 1)
44?& (gte n 1)
44```
45```
45
46
46−`?&` (pronounced "wut-pam") takes in a list of Hoon expressions, terminated by `==`, that evaluate to a `flag` and returns the logical "AND" of these `flag`s. Most runes take a fixed number of children, but the handful that do not (such as `?&`) end their list of children with a terminating rune. In our context, that means that if the product of each of the children of `?&` is `%.y`, then the product of the entire `?&` expression is `%.y` as well. Otherwise, the product of the conditional `?&` is `%.n`.
47+`?&` (pronounced "wut-pam") takes in a list of Hoon expressions, terminated by `==`, that evaluate to a `flag` and returns the logical "AND" of these flags. Most runes take a fixed number of children, but the handful that do not (such as `?&`) end their list of children with a terminating rune. In our context, that means that if the product of each of the children of `?&` is `%.y`, then the product of the entire `?&` expression is `%.y` as well. Otherwise, the product of the conditional `?&` is `%.n`.
47
48
48−The first child of `?&` is `(gte n 1)`. It is good practice to put the first boolean test of a conditional on the same line as the conditional as we have done here. This utilizes the standard library function `gte` which stands for "greater than or equal to". `(gte a b)` returns `%.y` if `a` is greater than or equal to `b`, and `%.n` otherwise.
49+The first child of `?&` is `(gte n 1)`. It is good practice to put the first boolean test of a conditional on the same line as the conditional, as we have done here. This utilizes the standard library function `gte` which stands for "greater than or equal to". `(gte a b)` returns `%.y` if `a` is greater than or equal to `b`, and `%.n` otherwise.
49
50
50Next we have:
51Next we have:
52+
51```hoon
53```hoon
52 (lte n 100)
54 (lte n 100)
53```
55```
56+
54`lte` is the standard library function for "less than or equal to". `(lte a b)` returns `%.y` if `a` is less than `b`, and `%.n` otherwise.
57`lte` is the standard library function for "less than or equal to". `(lte a b)` returns `%.y` if `a` is less than `b`, and `%.n` otherwise.
55
58
56−The last boolean test we have is
59+The last boolean test we have is:
60+
57```hoon
61```hoon
58 =(0 (mod n 2))
62 =(0 (mod n 2))
59```
63```
64+
60−This checks to see if `0` is equal to `(mod n 2)` - in other words, checking if `n` is even. It produces `%.y` if `n` is even and `%.n` if `n` is odd.
65+This checks to see if `0` is equal to `(mod n 2)` -- in other words, checking if `n` is even. It produces `%.y` if `n` is even and `%.n` if `n` is odd.
61
66
62It is good practice in Hoon to put "lighter" lines at the top and "heavier" lines at the bottom, which is why we have put `=(0 (mod n 2))` last in the list of conditionals.
67It is good practice in Hoon to put "lighter" lines at the top and "heavier" lines at the bottom, which is why we have put `=(0 (mod n 2))` last in the list of conditionals.
63
68
64−Finally we have a terminator.
69+Finally we have a terminator:
70+
65```hoon
71```hoon
66==
72==
67```
73```
74+
68This marks the end of the list of children of `?&`.
75This marks the end of the list of children of `?&`.
69
76
70### Other Runes
77### Other Runes
71
78
72We only utilized one "wut" rune in our walkthrough, but there are many others. Here are a few more examples:
79We only utilized one "wut" rune in our walkthrough, but there are many others. Here are a few more examples:
73
80
74−- `?:` (pronounced "wut-pam") is the simplest "wut" rune. It takes three children, also called sub-expressions. The first child is a boolean test, so it looks for a `%.y` or a `%.n`. The second child is a yes-branch, which is what we arrive at if the aforementioned boolean test evaluates to `%.y`. The third child is a no-branch, which we arrive at if the boolean test evaluates to `%.n`. These branches can contain any sort of Hoon expression, including further conditional expressions. Instead of the `?&` expression in our `%say` generator above, we could have written
81+- `?:` (pronounced "wut-col") is the simplest "wut" rune. It takes three children, also called subexpressions. The first child is a boolean test, so it looks for a `%.y` or a `%.n`. The second child is a yes-branch, which is what we arrive at if the aforementioned boolean test evaluates to `%.y`. The third child is a no-branch, which we arrive at if the boolean test evaluates to `%.n`. These branches can contain any sort of Hoon expression, including further conditional expressions. Instead of the `?&` expression in our `%say` generator above, we could have written:
75
82
76```hoon
83```hoon
77?: ?& (gte n 1)
84?: ?& (gte n 1)
@@ -81,11 +88,12 @@ We only utilized one "wut" rune in our walkthrough, but there are many others. H
81 %.y
88 %.y
82%.n
89%.n
83```
90```
84−Of course, doing so would be needlessly obfuscating - we mention this only to illustrate that these two Hoon expressions have the same product.
85
91
92+Of course, doing so would be needlessly obfuscating -- we mention this only to illustrate that these two Hoon expressions have the same product.
93+
86−- `?!` ("wut-zup") is the logical "NOT" operator, which inverts the truth value of its single child. Instead of `(lte n 100)` in our `%say` generator above, we could have written `?! (gth n 100)`. Again, this would be bad practice, we only present this as an example.
94+- `?!` ("wut-zap") is the logical "NOT" operator, which inverts the truth value of its single child. Instead of `(lte n 100)` in our `%say` generator above, we could have written `?! (gth n 100)`. Again, this would be bad practice, we only present this as an example.
87
95
88−- `?@` takes three children. It branches on whether its first child is an atom.
96+- `?@` takes three children. It branches on whether its first child is an [atom](/docs/glossary/atom/).
89
97
90- `?^` takes three children. It branches on whether its first child is a cell.
98- `?^` takes three children. It branches on whether its first child is a cell.
91
99
tutorials/hoon/doors.md+6−6
@@ -5,7 +5,7 @@ template = "doc.html"
5aliases = ["/docs/learn/hoon/hoon-tutorial/doors/"]
5aliases = ["/docs/learn/hoon/hoon-tutorial/doors/"]
6+++
6+++
7
7
8−It's useful to have cores whose arms evaluate to make gates. The use of such cores is common in Hoon; that's how the functions of the Hoon standard library are stored in the subject. Learning about such cores will also deepen the reader's understanding of Hoon semantics, and for that reason alone is worthwhile.
8+It's useful to have [cores](/docs/glossary/core/) whose [arms](/docs/glossary/arm/) evaluate to make [gates](/docs/glossary/gate/). The use of such cores is common in Hoon; that's how the functions of the Hoon standard library are stored in the subject. Learning about such cores will also deepen the reader's understanding of Hoon semantics, and for that reason alone is worthwhile.
9
9
10In this lesson you'll also learn about a new kind of core, called a 'door'.
10In this lesson you'll also learn about a new kind of core, called a 'door'.
11
11
@@ -79,7 +79,7 @@ Let's try out these arms, using them for function calls:
7930
7930
80```
80```
81
81
82−Notice that each arm in core `c` is able to call the other arms of `c` -- `add-two` uses the `inc` arm to increment a number twice. As a reminder, each arm is evaluated with is parent core as the subject. In the case of `add-two` the parent core is `c`, which has `inc` in it.
82+Notice that each arm in core `c` is able to call the other arms of `c` -- `add-two` uses the `inc` arm to increment a number twice. As a reminder, each arm is evaluated with its parent core as the subject. In the case of `add-two` the parent core is `c`, which has `inc` in it.
83
83
84### Mutating a Gate
84### Mutating a Gate
85
85
@@ -210,9 +210,9 @@ Here are some of the other gates that can be generated from this core in the Hoo
210
210
211## Doors
211## Doors
212
212
213−A brief review: A core is a cell of battery and payload: `[battery payload]`. The battery is code and the payload is data. The battery contains a series of arms, and the payload contains all the data necessary to run those arms correctly.
213+A brief review: A core is a cell of battery and [payload](/docs/glossary/payload/): `[battery payload]`. The battery is code and the payload is data. The battery contains a series of arms, and the payload contains all the data necessary to run those arms correctly.
214
214
215−New material: A **door** is a core with a sample. That is, a door is a core whose payload is a cell of sample and context: `[sample context]`.
215+New material: A **door** is a core with a sample. That is, a [door](/docs/glossary/door/) is a core whose payload is a cell of sample and context: `[sample context]`.
216
216
217```
217```
218 Door
218 Door
@@ -250,7 +250,7 @@ The first subexpression after the `|_` rune defines the door's sample. (This is
250
250
251#### Back to the Example
251#### Back to the Example
252
252
253−For the door defined above, `c`, the sample is defined as an atom, `@`, and given the face `b`. The `plus` arm defines a gate that takes a single atom as its argument, `a`, and which returns the sum of `a` and `b`. The `times` arm defines a gate that takes a single atom, `a`, and returns `a` times `b`. The `greater` arm defines a gate that takes a single atom, `a`, and if `a` is greater than `b` returns `%.y`; otherwise `%.n`.
253+For the door defined above, `c`, the sample is defined as an [atom](/docs/glossary/atom/), `@`, and given the face `b`. The `plus` arm defines a gate that takes a single [atom](/docs/glossary/atom/) as its argument, `a`, and which returns the sum of `a` and `b`. The `times` arm defines a gate that takes a single [atom](/docs/glossary/atom/), `a`, and returns `a` times `b`. The `greater` arm defines a gate that takes a single [atom](/docs/glossary/atom/), `a`, and if `a` is greater than `b` returns `%.y`; otherwise `%.n`.
254
254
255Let's try out the arms of `c` with ordinary function calls:
255Let's try out the arms of `c` with ordinary function calls:
256
256
@@ -470,4 +470,4 @@ Can we mutate the `rs` door so that its sample is `%u`? Let's try it:
470
470
471Oops! Why didn't this work? Remember, `rs` isn't itself a door; it's an arm that produces a door. The `rs` in `rs(r %u)` resolves to the nameless parent core of `rs`, and the search for `r` commences there. But that face can't be found in that parent core -- it's not where we want to look.
471Oops! Why didn't this work? Remember, `rs` isn't itself a door; it's an arm that produces a door. The `rs` in `rs(r %u)` resolves to the nameless parent core of `rs`, and the search for `r` commences there. But that face can't be found in that parent core -- it's not where we want to look.
472
472
473−It's better simply to use the `~(arm rs arg)` syntax to replace the value of the `rs` door sample with `arg`.
473+It's better simply to use the `~(arm rs arg)` syntax to replace the value of the `rs` door sample with `arg`.
tutorials/hoon/egg-timer.md+99−59
@@ -5,115 +5,155 @@ template = "doc.html"
5aliases = ["/docs/learn/hoon/hoon-tutorial/egg-timer/"]
5aliases = ["/docs/learn/hoon/hoon-tutorial/egg-timer/"]
6+++
6+++
7
7
8−The Arvo operating system is divided up into modules called vanes. Gall is the vane responsible for providing an API for building stateful applications in Urbit. Gall is a complex system that takes a lot of getting used to, so let's dip our toes in with a simple egg-timer app.
8+The Arvo operating system is divided up into modules called vanes. Gall is the vane responsible for providing an API for building stateful applications in Urbit. Gall is a complex system that takes a lot of getting used to, so let's dip our toes in with a simple egg-timer app.
9
9
10+The following code sample should be saved as `/home/app/egg-timer.hoon`
11+After committing: `|start %egg-timer` and poke with `:egg-timer ~s10`
10
12
11```hoon
13```hoon
14+/+ default-agent
12|%
15|%
13−+$ move (pair bone card)
16++$ card card:agent:gall
14−+$ card [%wait path @da]
15--
17--
18+::
19+^- agent:gall
16−|_ [bowl:gall ~]
20+|_ =bowl:gall
21++* this .
22+ def ~(. (default-agent this %.n) bowl)
23+::
17−++ poke-noun
24+++ on-poke
25+ |= [=mark =vase]
26+ ^- (quip card _this)
18− |= t=@dr
27+ =/ t !<(@dr vase)
19− ^+ [*(list move) +>.$]
28+ :_ this
20− :_ +>.$ :_ ~
21− [ost %wait /egg-timer (add now t)]
29+ [%pass /egg-timer %arvo %b %wait (add now.bowl t)]~
22−++ wake
30+::
23− |= [=wire error=(unit tang)]
31+++ on-arvo
24− ^+ [*(list move) +>.$]
32+ ^+ on-arvo:*agent:gall
33+ |= [=wire =sign-arvo]
34+ ^- (quip card _this)
25 ~& "Timer went off!"
35 ~& "Timer went off!"
26− [~ +>.$]
36+ [~ this]
37+::
38+++ on-init on-init:def
39+++ on-save on-save:def
40+++ on-load on-load:def
41+++ on-watch on-watch:def
42+++ on-leave on-leave:def
43+++ on-peek on-peek:def
44+++ on-agent on-agent:def
45+++ on-fail on-fail:def
27--
46--
28```
47```
29
48
30−The first thing to notice is that we are creating a `core` (`|%`) and a `door` (`|_`). This is a typical style of Gall programming where your types are defined in the first `core` and your application is defined in the following `door`.
49+The first thing to notice is that we are creating a core (`|%`) and a door (`|_`). This is a typical style for Gall programming wherein types are defined in the first core and your application is defined in the following door.
50+Our door will have type `agent:gall` as specified in `sys/zuse.hoon`
31
51
32```hoon
52```hoon
33|%
53|%
34−+$ move (pair bone card)
54++$ card card:agent:gall
35−+$ card [%wait path @da]
36--
55--
37```
56```
38
57
58+The core here defines only one type: `card`.
39−The `core` here defines two types: `move` and `card`. A `move` is a `pair` of `bone` and `card`. A `bone` is a Gall-only type that identifies app event chains by mapping atoms to them. We define `card` to be a request to Arvo to do something for us. In this case, the only valid `card` will be `%wait` which we'll discuss in a bit.
59+A `card` is a request to Arvo to do something for us. In this case, the only card used will be a `%wait` request to Behn which we'll discuss later.
40
60
41−It's important to note that the names `move` and `card` are technically arbitrary; you can call them whatever you'd like. By convention, however, you will see them called `move` and `card` practically everywhere.
61+It's important to note that the name `card` is technically arbitrary. By convention, however, you will see it called `card` practically everywhere.
42
62
43−The sample of the `door` is:
63+The sample of the door(`|_`) is:
44
64
45```hoon
65```hoon
46−[bowl:gall ~]
66+=bowl:gall
47```
67```
48
68
49−You can find the full definition of `bowl` in `sys/zuse.hoon`, but for now it's enough to know that this is the default app state and includes various faces for information. Below are some important such faces:
69+You can find the full definition of `bowl` in `sys/zuse.hoon`, but for now it's enough to know that includes contextual data used by Gall with particular faces. Below are some important such faces:
50
70
51- `our` The ship this code is running on
71- `our` The ship this code is running on
52- `src` The ship the current event originated from
72- `src` The ship the current event originated from
53−- `ost` A reference to the current chain of events
54- `eny` Guaranteed-fresh entropy
73- `eny` Guaranteed-fresh entropy
55- `now` The current time
74- `now` The current time
56
75
57−The `door` we've made has two arms `poke-noun` and `wake`. Gall is capable of dispatching `pokes`, or requests, to an app based on the mark of the data given along with that poke. These are sent to the arm with the name that matches the mark of the data. Here we use the generic `noun` mark:
76+We give `bowl:gall` the face `bowl`.
77+Additionally, we use `+*` to create two structures for future use:
58
78
59```hoon
79```hoon
60−++ poke-noun
80++* this .
61− |= t=@dr
81+ def ~(. (default-agent this %.n) bowl)
62− ^+ [*(list move) +>.$]
63− :_ +>.$ :_ ~
64− [ost %wait /egg-timer (add now t)]
65```
82```
83+`this` is our current context(the door).
84+`def` uses `default-agent` to produce a standard `gall:agent` door, from which we will instance default definitions for our unused arms.
66
85
67−In the above code, we create a gate that takes a single `@dr` argument. `@dr` is an aura for a 128-bit relative date. Here are a few examples.
86+All Gall agents have a fixed set of 10 arms. In this trivial case, we will specify only two and use the default definitions from `default-agent` for the remaining arms.
68−
69−- `~s17` 17 seconds
70−- `~m20` 20 minutes
71−- `~d42` 42 days
72−
73−As a matter of good type hygiene, we explicitly cast the output of this gate with `^+` to ensure we are producing the correct thing for Gall to handle. `^+` is the rune for casting by example. Our example is a cell: `list` of `move`, which we `bunt` with `*`, is the head; `+>.$`, the enclosing core which is our `door`, is the tail.
74−
75−Next we're going to use the `:_` rune which is just the inverted form a `:-` the cell construction rune. We use it twice so the actual data will end up looking something like:
76
87
77```hoon
88```hoon
89+++ on-poke
90+ |= [=mark =vase]
91+ ^- (quip card _this)
92+ =/ t !<(@dr vase)
93+ :_ this
78−[[[ost %wait /egg-timer (add now t)] ~] +>.$]
94+ [%pass /egg-timer %arvo %b %wait (add now.bowl t)]~
79```
95```
80
96
81−`ost` is the `bone`, the opaque reference to a chain of events, that comes from `bowl`, so we're going to continue to use it here. `%wait` is the name of the `move`, in this case a request to the Behn vain to start a timer for us.
97+The `++on-poke` arm evaluates to a gate which takes a sample `[mark vase]`. `mark` is a type specification and `vase` is a cell of `[specification value]`
98+Note: since `++on-poke` may take many different samples, it would be prudent to add a `%noun` mark check here.
99+In this example, we assume that our sample will contain a `@dr` and pull it from the `vase` with `=/ t !<(@dr vase)`
100+`@dr` is an aura for a 128-bit relative date. Here are a few examples.
82
101
83−After `%wait`, we have the `path`, a `list` of `cords` that serves as the unique identifier for this `move`:
102+- `~s17` 17 seconds
103+- `~m20` 20 minutes
104+- `~m13s37` 13 minutes, 37 seconds
105+- `~d42` 42 days
84
106
85−```
107+As a matter of good type hygiene, we explicitly cast the output of this gate with `^-` to ensure we are producing the correct structure for Gall to handle.
86−/egg-timer
108+Our specification is `(quip card _this)` which produces a type, `[(list card) _this]`. Note that `_this` is irregular form of `$_(this)` which normalizes to the type of `this`, our door.
87−```
88−
89−The `/` here is an irregular syntax to make a `path`.
90
109
91−The final part of this `move` is:
110+Next we use the `:_` rune which is the inverted form of `:-`, the cell construction rune.
92
111
112+```hoon
113+:_ this
114+ [%pass /egg-timer %arvo %b %wait (add now.bowl t)]~
93```
115```
94−(add now t)
116+Our card should follow the basic form `[%pass /my/wire a-note]`
95−```
117+In this case, our card will ask Arvo to `%pass` a note along the wire `/egg-timer` to Behn(`%b`) containing a `%wait` request.
118+Behn will start a timer for us, and will respond along our wire, `/egg-timer`.
96
119
97−`now` is the current time of type `@da`, and `t` was declared as `@dr`. Because they are both atoms, we can add `now` and `t` these two to get an atom that is `t` units of time into the future from `now`. That produced atom can be interpreted as a `@da`.
120+`now.bowl` is the current time of type `@da`, and `t` was declared as `@dr`. Because they are both atoms, we can add `now` and `t` to produce an atom that is `t` units of time into the future from `now`. That produced atom can be interpreted as a `@da`.
121+The calculated time will be passed via Arvo to Behn with instruction to `%wait @da`, i.e., to set a timer.
98
122
99−That's all for our `poke-noun` arm. But what about when the timer goes off? Behn will create a `gift`, a similar construct to how we created a `card`, only this time it will end up being dispatched back to us via Gall in the `++wake` arm. Any app that wants to use a timer trigger needs to have an arm called `++wake`.
123+That's all for our `++on-poke` arm. But what about when the timer goes off? Behn will create a `gift`, a similar construct to our `card` which will be dispatched back to us via Gall in the `++on-arvo` arm.
100
124
101```hoon
125```hoon
102−++ wake
126+++ on-arvo
103− |= [=wire error=(unit tang)]
127+ ^+ on-arvo:*agent:gall
104− ^+ [*(list move) +>.$]
128+ |= [=wire =sign-arvo]
129+ ^- (quip card _this)
105 ~& "Timer went off!"
130 ~& "Timer went off!"
106− [~ +>.$]
131+ [~ this]
107```
132```
133+`++on-arvo` evaluates to a gate whose sample is a cell of `wire` and `sign-arvo` here given default faces. The syntax of `=wire` is a shortcut for `wire=wire`; it's a common pattern to shadow the name of a type when you only have one instance of the type and are not going to refer to the type itself.
134+A `wire` is an alias for a path. Our `wire` will be the path we provided in our `++on-poke` card. If we needed to do something particular depending on which request triggered this Arvo card, we could use the wire to do so.
108
135
109−`wake` is a `gate` that has two arguments: a `wire`, and a `(unit tang)` with the face `error`. The syntax of `=wire` is a shortcut for `wire=wire`; it's a common pattern to shadow the name of a type when you only have one instance of the type and are not going to refer to the type itself. A `wire` is just an alias for `path`. Our `wire` will be the `path` that we gave original `move`. If we needed to do something based on which request caused this gate to be called, we could use the wire to do so. In this case, we don't do perform such a dispatch.
136+Note: since multiple vanes can send many sorts of cards via `++on-arvo`, it would be prudent to check if `sign-arvo` is `[%b %wake *]`. Since our trivial example assumes the card is `%wake` from Behn, we will forgo that better practice here.
110−
111−Next we have the same cast we used in `++poke-noun` to make sure we are producing the correct thing for Gall. These casts are not strictly necessary, as the type system can infer what the type will be, but they can be very useful both for debugging our own code and for someone else trying to determine what our code should be producing.
112
137
138+Next we have the same cast we used in `++on-poke` to make sure we produce the correct type for Gall. `(quip card _this)` resolves to a type `[(list card) _this]`
113```
139```
114~& "Timer went off!"
140~& "Timer went off!"
115```
141```
116
142
117−`~&` is the debugging printf rune. Here we're using it to output a message. We could, however, modify this line of code to do any other computation we would want to happen when `++wait` gets called.
143+`~&` is the debugging printf rune. Here we're using it to output a message. We could, however, modify this line of code to do any other computation when `++on-arvo` is called.
144+
145+We need to produce a noun of type `(quip card _this)` i.e., `[(list card) _this]`.
146+In this case, we will not produce any card or change application state. Therefore we simply produce a cell of a null list and our original context, `[~ this]`.
118
147
119−Finally, we need to produce our `move`. Here the effect is simply `[~ +>.$]`, since we have no `move` to make and we are not changing the state of our app. We just use the `door` without changing its sample.
148+```hoon
149+++ on-init on-init:def
150+++ on-save on-save:def
151+++ on-load on-load:def
152+++ on-watch on-watch:def
153+++ on-leave on-leave:def
154+++ on-peek on-peek:def
155+++ on-agent on-agent:def
156+++ on-fail on-fail:def
157+--
158+```
159+Finally, we define the remaining 8 unused but required Gall Agent armsas instances of the default arms provided in `/lib/default-agent.hoon`.
tutorials/hoon/fibonacci.md+7−7
@@ -5,7 +5,7 @@ template = "doc.html"
5aliases = ["/docs/learn/hoon/hoon-tutorial/fibonacci/"]
5aliases = ["/docs/learn/hoon/hoon-tutorial/fibonacci/"]
6+++
6+++
7
7
8−In this example, we will write a generator that produces a list of Fibonacci numbers up to `n`.
8+In this example, we will write a generator that produces a list of [Fibonacci numbers](https://en.wikipedia.org/wiki/Fibonacci_number) up to `n`.
9
9
10```hoon
10```hoon
11|= n=@ud
11|= n=@ud
@@ -21,21 +21,21 @@ In this example, we will write a generator that produces a list of Fibonacci num
21==
21==
22```
22```
23
23
24−On the first line, we use `|=` to produce a gate which takes an `@ud` that's stored in the face `n`. This `n` sample that we give our gate determines how long our Fibonacci sequence is. When the list that our program builds has `n` members, the program ends.
24+On the first line, we use `|=` to produce a [gate](/docs/glossary/gate/) which takes an `@ud` that's stored in the face `n`. This `n` sample that we give our [gate](/docs/glossary/gate/) determines how long our Fibonacci sequence is. When the list that our program builds has `n` items, the program ends.
25
25
26```hoon
26```hoon
27%- flop
27%- flop
28```
28```
29
29
30−In the line above, we use `flop` on the output of the rest of the program. `flop` is a standard library function to reverse a list.
30+In the line above, we use `flop` on the output of the rest of the program. `flop` is a [standard library](https://urbit.org/docs/reference/library/) function to reverse a list.
31
31
32−Why are we using this instead of just producing the list in the order we want it in the first place? Because with lists, adding an element to the end is a computationally expensive operation that gets more expensive the longer the list is, due to the fact that you need to traverse to the end of the tree. Adding an element to the front, however, is cheap. [In Big-O Notation](https://en.wikipedia.org/wiki/Big_O_notation), adding to the end of a list is O(n) and the front is O(1).
32+Why are we using this instead of just producing the list in the order we want it in the first place? Because with lists, adding an element to the end is a computationally expensive operation that gets more expensive the longer the list is, due to the fact that you need to traverse to the end of the tree. Adding an element to the front, however, is cheap. [In Big-O notation](https://en.wikipedia.org/wiki/Big_O_notation), adding to the end of a list is O(n) and the front is O(1).
33
33
34```hoon
34```hoon
35=+ [i=0 p=0 q=1 r=*(list @ud)]
35=+ [i=0 p=0 q=1 r=*(list @ud)]
36```
36```
37
37
38−Here we declare several values that we are going to use the execution of our program. The only one of these that is noteworthy is `r`: we're using `*` to bunt, or get the default value for, the mold `(list @ud)`.
38+Here we declare several values that we are going to use during the execution of our program. The only one that is noteworthy is `r`: we're using `*` to bunt, or get the default value for, the mold `(list @ud)`.
39
39
40```hoon
40```hoon
41|- ^+ r
41|- ^+ r
@@ -47,7 +47,7 @@ With this code, we define `|-`, the _trap_ that acts as a recursion point and co
47?: =(i n) r
47?: =(i n) r
48```
48```
49
49
50−In the code above, `?:` checks whether the first child, `=(i n)`, our terminating case, is true or false. If it is true, it branches to `r` and the program ends. If it is false, the program continues to the code below.
50+In the code above, `?:` checks whether the first child, `=(i n)` (our terminating case), is `true` or `false`. If it is `true`, it branches to `r` and the program ends. If it is `false`, the program continues to the code below.
51
51
52```hoon
52```hoon
53%= $
53%= $
@@ -58,4 +58,4 @@ In the code above, `?:` checks whether the first child, `=(i n)`, our terminatin
58==
58==
59```
59```
60
60
61−The final expression in our program calls the `$` arm of the trap we are but makes some changes: we increment `i`, set `p` to be `q` and `q` becomes the sum of `p` and `q`. `r` becomes a cell of `q` and whatever `r` was previously. The list built from this is the one that will get `flop`ped to produce the result at the end of the computation.
61+The final expression in our program calls the `$` [arm](/docs/glossary/arm/) of the [trap](/docs/glossary/trap/) we are in but makes some changes: we increment `i`, set `p` to be `q` and `q` becomes the sum of `p` and `q`. `r` becomes a cell of `q` and whatever `r` was previously. The list built from this is the one that will get `flop`ped to produce the result at the end of the computation.
tutorials/hoon/ford.md+3−3
@@ -91,7 +91,7 @@ It is important for us to note that Ford is _not_ used to build vanes. Vanes are
91
91
92## Using Ford
92## Using Ford
93
93
94−Having covered the distinctive features of Ford, we now dive into some of the specifics on how these features are implemented. Let us first cover some of most important types of data we will run into, and then discuss the most frequently used arms.
94+Having covered the distinctive features of Ford, we now dive into some of the specifics on how these features are implemented. Let us first cover some of most important types of data we will run into, and then discuss the most frequently used [arms](/docs/glossary/arm/).
95
95
96### Data types
96### Data types
97
97
@@ -113,8 +113,8 @@ A `schematic`, found in `zuse.hoon`, is a set of build instruction for Ford. It
113
113
114Some examples of subtypes include:
114Some examples of subtypes include:
115 - `%list` - a list of schematics to build.
115 - `%list` - a list of schematics to build.
116− - `%core` - a Clay path to a Hoon source file to build.
116+ - `%[core](/docs/glossary/core/)` - a Clay path to a Hoon source file to build.
117− - `%call` - a schematic consisting of two sub-schematics, one of which produces a gate and a second that produces a sample. It then runs the gate on the sample, producing a vase of the result, tagged with the mark `%noun`.
117+ - `%call` - a schematic consisting of two sub-schematics, one of which produces a [gate](/docs/glossary/gate/) and a second that produces a sample. It then runs the [gate](/docs/glossary/gate/) on the sample, producing a vase of the result, tagged with the mark `%noun`.
118 - `%scry` - look up a value from the Urbit namespace.
118 - `%scry` - look up a value from the Urbit namespace.
119
119
120 Schematics are only ever sent to Ford by another vane. Userspace apps do not directly create schematics.
120 Schematics are only ever sent to Ford by another vane. Userspace apps do not directly create schematics.
tutorials/hoon/gall.md+6−4
@@ -5,13 +5,15 @@ template = "doc.html"
5aliases = ["/docs/learn/hoon/hoon-tutorial/gall/"]
5aliases = ["/docs/learn/hoon/hoon-tutorial/gall/"]
6+++
6+++
7
7
8+> Note: This guide is outdated. For an updated explanation of Gall, take a look at [/tutorial/arvo/gall](/docs/tutorials/arvo/gall)
9+
8Gall is the Arvo vane responsible for handling user space applications. When writing a Gall application there are several things you will need to understand.
10Gall is the Arvo vane responsible for handling user space applications. When writing a Gall application there are several things you will need to understand.
9
11
10## bowl and moves
12## bowl and moves
11
13
12−The core of a gall app is a door which has two parts of its subject, the first a `bowl:gall` which contains a lot of standard things used by gall apps, the second a type containing app state information.
14+The [core](/docs/glossary/core/) of a gall app is a [door](/docs/glossary/door/) which has two parts of its subject, the first a `bowl:gall` which contains a lot of standard things used by gall apps, the second a type containing app state information.
13
15
14−Vanes in Arvo communicate by means of `moves`. When a move is produced by an arm in a gall app, it's dispatched by Arvo to the correct handler for the request, be it another application or another vane. A `move` is pair of `bone` and `card`. These are essential components to understand when learning to use gall.
16+Vanes in Arvo communicate by means of `moves`. When a move is produced by an [arm](/docs/glossary/arm/) in a gall app, it's dispatched by Arvo to the correct handler for the request, be it another application or another vane. A `move` is pair of `bone` and `card`. These are essential components to understand when learning to use gall.
15
17
16A `bone` is an opaque cause that initiates a request. When constructing a `move` you can often use `ost.bowl` and when responding to an incoming `move` you can use the `bone` in that `move` to construct your response.
18A `bone` is an opaque cause that initiates a request. When constructing a `move` you can often use `ost.bowl` and when responding to an incoming `move` you can use the `bone` in that `move` to construct your response.
17
19
@@ -26,7 +28,7 @@ A `card` is the effect or event that is being requested. Each application should
26 ==
28 ==
27```
29```
28
30
29−Each `card` is a pair of a tag and a noun. The tag indicates what the event being triggered is and the noun is any data required for that event.
31+Each `card` is a pair of a tag and a [noun](/docs/glossary/noun/). The tag indicates what the event being triggered is and the [noun](/docs/glossary/noun/) is any data required for that event.
30
32
31## Arms
33## Arms
32
34
@@ -34,7 +36,7 @@ Gall applications can have a number of arms that get called depending on the inf
34
36
35### ++prep
37### ++prep
36
38
37−`++prep` is the arm that is called when an application is first started or when it's updated. This arm should be a gate that takes a `unit` of a noun and provides a way, if necessary, to make any changes to the application's data required by an upgrade. As a reminder, a `unit` is a type that may contain another type or it might contain `~`. They are used when there may or may not be some data available.
39+`++prep` is the arm that is called when an application is first started or when it's updated. This arm should be a [gate](/docs/glossary/gate/) that takes a `unit` of a noun and provides a way, if necessary, to make any changes to the application's data required by an upgrade. As a reminder, a `unit` is a type that may contain another type or it might contain `~`. They are used when there may or may not be some data available.
38
40
39Often when developing an application you will not initially care about the data. Here is a sample `++prep` arm that will simply throw away the previous application state.
41Often when developing an application you will not initially care about the data. Here is a sample `++prep` arm that will simply throw away the previous application state.
40
42
tutorials/hoon/gates.md+37−36
@@ -4,17 +4,18 @@ weight = 6
4template = "doc.html"
4template = "doc.html"
5aliases = ["/docs/learn/hoon/hoon-tutorial/gates/"]
5aliases = ["/docs/learn/hoon/hoon-tutorial/gates/"]
6+++
6+++
7+
7In this lesson you're going to learn about Hoon functions.
8In this lesson you're going to learn about Hoon functions.
8
9
9## What is a Function?
10## What is a Function?
10
11
11−The word 'function' is used in various ways, but let's start by talking about them in the [mathematical sense](https://en.wikipedia.org/wiki/Function_%28mathematics%29). Roughly put, a function takes one or more arguments (i.e., input values) and returns a value. The return value depends solely on the argument(s), and nothing else. For example, we can understand multiplication as a function: it takes two numbers and returns another number. It doesn't matter where you ask, when you ask, or what kind of hat you're wearing when you ask. If you pass the same two numbers (e.g., `3` and `4`), you get the same answer returned every time (`12`).
12+The word "function" is used in various ways, but let's start by talking about them in the [mathematical sense](https://en.wikipedia.org/wiki/Function_%28mathematics%29). Roughly put, a function takes one or more arguments (i.e., input values) and returns a value. The return value depends solely on the argument(s), and nothing else. For example, we can understand multiplication as a function: it takes two numbers and returns another number. It doesn't matter where you ask, when you ask, or what kind of hat you're wearing when you ask. If you pass the same two numbers (e.g., `3` and `4`), you get the same answer returned every time (`12`).
12
13
13−That output value depends solely upon input value(s) is an important property of functions. This property is called [referential transparency](https://en.wikipedia.org/wiki/Referential_transparency), and we make use of it throughout the Urbit software stack.
14+That output value depends solely upon input value(s) is an important property of functions. This property is called [referential transparency](https://en.wikipedia.org/wiki/Referential_transparency), and we make use of it throughout the Urbit software stack.
14
15
15−Functions are implemented in Hoon with a special kind of core called a **gate**. In this lesson you'll learn what a gate is and how a gate represents a function. Along the way you'll build some example gates of your own.
16+Functions are implemented in Hoon with a special kind of [core](/docs/glossary/core/) called a **gate**. In this lesson you'll learn what a [gate](/docs/glossary/gate/) is and how a gate represents a function. Along the way you'll build some example gates of your own.
16
17
17−You've already used two functions from the Hoon standard library: `add` and `mul`. These are implemented with gates, and you call them from the dojo in the following way:
18+You've already used two functions from the Hoon standard library: `add` and `mul`. These are implemented with gates, and you call them from the Dojo in the following way:
18
19
19```
20```
20> (add 2 3)
21> (add 2 3)
@@ -28,7 +29,7 @@ You've already used two functions from the Hoon standard library: `add` and `mul
28
29
29A core is a cell: `[battery payload]`.
30A core is a cell: `[battery payload]`.
30
31
31−A gate is a core with two distinctive properties: (1) the battery of a gate contains exactly one arm, which has the special name `$`. The `$` arm contains the instructions for the function in question. And (2), the payload of a gate consists of a cell of `[sample context]`. The sample is the part of the payload that stores the 'argument' (i.e., input value) of the function call. The context contains all other data that is needed for computing the `$` arm of the gate correctly.
32+A gate is a core with two distinctive properties: (1) the battery of a gate contains exactly one [arm](/docs/glossary/arm/), which has the special name `$`. The `$` [arm](/docs/glossary/arm/) contains the instructions for the function in question. And (2), the payload of a gate consists of a cell of `[sample context]`. The sample is the part of the payload that stores the "argument" (i.e., input value) of the function call. The context contains all other data that is needed for computing the `$` [arm](/docs/glossary/arm/) of the gate correctly.
32
33
33```
34```
34Gate: [$ [Sample Context]]
35Gate: [$ [Sample Context]]
@@ -44,11 +45,11 @@ As a tree, a gate looks like the following:
44 Sample Context
45 Sample Context
45```
46```
46
47
47−Like all arms, `$` is computed with its parent core as the subject. When `$` is computed, the resulting value is called the 'product' of the gate. No other data is used to calculate the product other than the data in the gate itself.
48+Like all arms, `$` is computed with its parent core as the subject. When `$` is computed, the resulting value is called the "product" of the gate. No other data is used to calculate the product other than the data in the gate itself.
48
49
49## Creating Your First Gate
50## Creating Your First Gate
50
51
51−Let's make a gate that takes any unsigned integer (i.e., an atom) as its sample and returns that value plus one as the product. To do this we'll use the `|=` rune. We'll bind this gate to the face `inc` for 'increment':
52+Let's make a gate that takes any unsigned integer (i.e., an [atom](/docs/glossary/atom/)) as its sample and returns that value plus one as the product. To do this we'll use the `|=` rune. We'll bind this gate to the face `inc` for "increment":
52
53
53```
54```
54> =inc |=(a=@ (add 1 a))
55> =inc |=(a=@ (add 1 a))
@@ -63,21 +64,21 @@ Let's make a gate that takes any unsigned integer (i.e., an atom) as its sample
63124
64124
64```
65```
65
66
66−The gate works as promised -- it takes any number `n` and returns `n + 1`. Let's take a closer look at what the `|=` is doing.
67+The gate works as promised -- it takes any number `n` and returns `n+1`. Let's take a closer look at what the `|=` is doing.
67
68
68### The `|=` Rune
69### The `|=` Rune
69
70
70−We typically use the `|=` rune to create a gate. In the expression above the `|=` is immediately followed by a set of parentheses containing two subexpressions: `a=@` and `(add 1 a)`. The first defines the gate's sample (input value type), and the second defines the gate's product (value).
71+We typically use the `|=` rune to create a gate. In the expression above the `|=` is immediately followed by a set of parentheses containing two subexpressions: `a=@` and `(add 1 a)`. The first defines the gate's sample (input value type), and the second defines the gate's product (value).
71
72
72−In the example gate above, `inc`, the sample is defined by `a=@`. This means that the sample is defined as an atom, `@`, meaning that the gate will take as input anything of that type. The sample is given the face `a`. With the face it's easier to refer to the sample in later code, if desired.
73+In the example gate above, `inc`, the sample is defined by `a=@`. This means that the sample is defined as an atom, `@`, meaning that the gate will take as input anything of that type. The sample is given the face `a`. With the face it's easier to refer to the sample in later code, if desired.
73
74
74−In `inc`, the product is defined by `(add 1 a)`. There's not much to it -- it returns the value of `a + 1`!
75+In `inc`, the product is defined by `(add 1 a)`. There's not much to it -- it returns the value of `a+1`!
75
76
76−The second subexpression after the `|=` rune is used to build the gate's `$` arm. That's where all the computations go.
77+The second subexpression after the `|=` rune is used to build the gate's `$` arm. That's where all the computations go.
77
78
78## Anatomy of a Gate
79## Anatomy of a Gate
79
80
80−A gate is a one-armed core with a sample: `[$ [Sample Context]]`. Let's go over these parts a little more carefully, using `inc` as our example.
81+A gate is a one-armed core with a sample: `[$ [Sample Context]]`. Let's go over these parts a little more carefully, using `inc` as our example.
81
82
82```
83```
83> inc
84> inc
@@ -93,27 +94,27 @@ A gate is a one-armed core with a sample: `[$ [Sample Context]]`. Let's go over
93
94
94The arm of a gate encodes the instructions for the Hoon function in question.
95The arm of a gate encodes the instructions for the Hoon function in question.
95
96
96−The pretty printer represents the `$` arm of `inc` as `1.jgn`. To see the actual noun of the `$` arm, enter `+2:inc` into the dojo:
97+The pretty printer represents the `$` arm of `inc` as `1.jgn`. To see the actual [noun](/docs/glossary/noun/) of the `$` arm, enter `+2:inc` into the Dojo:
97
98
98```
99```
99> +2:inc
100> +2:inc
100[8 [9 8 0 4.095] 9 2 [0 4] [[7 [0 3] 1 1] 0 14] 0 11]
101[8 [9 8 0 4.095] 9 2 [0 4] [[7 [0 3] 1 1] 0 14] 0 11]
101```
102```
102
103
103−This is un-computed Nock. You don't need to understand any of this.
104+This is un-computed Nock. You don't need to understand any of this.
104
105
105−It's worth pointing out that the arm name, `$`, can be used like any other name. We can compute `$` directly with `$:inc` in the dojo:
106+It's worth pointing out that the arm name, `$`, can be used like any other name. We can compute `$` directly with `$:inc` in the Dojo:
106
107
107```
108```
108> $:inc
109> $:inc
1091
1101
110```
111```
111
112
112−This result may seem a bit strange. We didn't call `inc` or in any other way pass it a number. Yet using `$` to evaluate `inc`'s arm seems to work -- sort of, anyway. Why is it giving us `1` as the return value? We can answer this question after we understand gate samples a little better.
113+This result may seem a bit strange. We didn't call `inc` or in any other way pass it a number. Yet using `$` to evaluate `inc`'s arm seems to work -- sort of, anyway. Why is it giving us `1` as the return value? We can answer this question after we understand gate samples a little better.
113
114
114### The Sample
115### The Sample
115
116
116−The sample of a gate is the address reserved for storing the argument(s) to the Hoon function. The sample is always at the head of the gate's tail, i.e., `+6`.
117+The sample of a gate is the address reserved for storing the argument(s) to the Hoon function. The sample is always at the head of the gate's tail, i.e., `+6`.
117
118
118Let's look at the gate for `inc` again, paying particular attention to its sample:
119Let's look at the gate for `inc` again, paying particular attention to its sample:
119
120
@@ -127,27 +128,27 @@ Let's look at the gate for `inc` again, paying particular attention to its sampl
127>
128>
128```
129```
129
130
130−We see `a/@`. This may not be totally clear, but it should make _some_ sense. This is the pretty-printer's way of indicating an atom with the face `a`. Let's take a closer look:
131+We see `a/@`. This may not be totally clear, but it should make _some_ sense. This is the pretty-printer's way of indicating an atom with the face `a`. Let's take a closer look:
131
132
132```
133```
133> +6:inc
134> +6:inc
134a=0
135a=0
135```
136```
136
137
137−We see now that the sample of `inc` is the value `0`, and has `a` as a face. This is a placeholder value for the function argument. If you evaluate the `$` arm of `inc` without passing it an argument the placeholder value is used for the computation, and the return value will thus be `0 + 1`:
138+We see now that the sample of `inc` is the value `0`, and has `a` as a face. This is a placeholder value for the function argument. If you evaluate the `$` arm of `inc` without passing it an argument the placeholder value is used for the computation, and the return value will thus be `0+1`:
138
139
139```
140```
140> $:inc
141> $:inc
1411
1421
142```
143```
143
144
144−The placeholder value is sometimes called a **bunt** value. The bunt value is determined by the input type; for atoms, `@`, the bunt value is `0`.
145+The placeholder value is sometimes called a **bunt** value. The bunt value is determined by the input type; for atoms, `@`, the bunt value is `0`.
145
146
146−The face value of `a` comes from the way we defined the gate above: `|=(a=@ (add 1 a))`. It was so we could use `a` to refer to the sample to generate the product with `(add 1 a)`.
147+The face value of `a` comes from the way we defined the gate above: `|=(a=@ (add 1 a))`. It was so we could use `a` to refer to the sample to generate the product with `(add 1 a)`.
147
148
148### The Context
149### The Context
149
150
150−The context of a gate contains other data that may be necessary for the `$` arm to evaluate correctly. The context always located at the tail of the tail of the gate, i.e., `+7` of the gate. There is no requirement that the context have any particular arrangement, though often it does.
151+The context of a gate contains other data that may be necessary for the `$` arm to evaluate correctly. The context is always located at the tail of the tail of the gate, i.e., `+7` of the gate. There is no requirement for the context to have any particular arrangement, though often it does.
151
152
152Let's look at the context of `inc`:
153Let's look at the context of `inc`:
153
154
@@ -164,28 +165,28 @@ Let's look at the context of `inc`:
164]
165]
165```
166```
166
167
167−This is exactly the default dojo subject, from before we put `inc` into the subject. The `|=` expression defines the context as whatever the subject is. This guarantees that the context has all the information it needs to have for the `$` arm to work correctly.
168+This is exactly the default Dojo subject, from before we put `inc` into the subject. The `|=` expression defines the context as whatever the subject is. This guarantees that the context has all the information it needs to have for the `$` arm to work correctly.
168
169
169### Exercise 1.4.1a
170### Exercise 1.4.1a
170
171
171−Write a gate that takes an atom, `a=@`, and which returns double the value of `a`. Bind this gate to `double` and test it in the dojo. A solution is given at the end of this lesson.
172+Write a gate that takes an atom, `a=@`, and which returns double the value of `a`. Bind this gate to `double` and test it in the Dojo. A solution is given at the end of this lesson.
172
173
173## Gates Define Functions of the Sample
174## Gates Define Functions of the Sample
174
175
175−The value of a function's output depends solely upon the input value. This is one of the features that make functions desirable in many programming contexts. It's worth going over how Hoon function calls implement this feature.
176+The value of a function's output depends solely upon the input value. This is one of the features that make functions desirable in many programming contexts. It's worth going over how Hoon function calls implement this feature.
176
177
177−In Hoon one can use `(gate arg)` syntax to make a function call. For example,
178+In Hoon, one can use `(gate arg)` syntax to make a function call. For example:
178
179
179```
180```
180> (inc 234)
181> (inc 234)
181235
182235
182```
183```
183
184
184−The name of the gate is `inc`. How is the `$` arm of `inc` evaluated? When a function call occurs, a copy of the `inc` gate is created, but with one modification; the sample is replaced with the function argument. Then the `$` arm is computed against this modified version of the `inc` gate.
185+The name of the gate is `inc`. How is the `$` arm of `inc` evaluated? When a function call occurs, a copy of the `inc` gate is created, but with one modification; the sample is replaced with the function argument. Then the `$` arm is computed against this modified version of the `inc` gate.
185
186
186−Remember that the default or 'bunt' value of the sample of `inc` is `0`. In the function call above, a copy of the `inc` gate is made but with a sample value of `234`. When `$` is computed against this modified core, the product is `235`.
187+Remember that the default or "bunt" value of the sample of `inc` is `0`. In the function call above, a copy of the `inc` gate is made but with a sample value of `234`. When `$` is computed against this modified core, the product is `235`.
187
188
188−Notice that neither the arm nor the context is modified before the arm is evaluated. That means that the only part of the gate that changes before the arm evaluation is the sample. Hence, we may understand each gate as defining a function whose argument is the sample. If you call a gate with the same sample, you'll get the same value returned to you every time.
189+Notice that neither the arm nor the context is modified before the arm is evaluated. That means that the only part of the gate that changes before the arm evaluation is the sample. Hence, we may understand each gate as defining a function whose argument is the sample. If you call a gate with the same sample, you'll get the same value returned to you every time.
189
190
190Let's unbind `inc` to keep the subject tidy:
191Let's unbind `inc` to keep the subject tidy:
191
192
@@ -198,7 +199,7 @@ Let's unbind `inc` to keep the subject tidy:
198
199
199### Modifying the Context of a Gate
200### Modifying the Context of a Gate
200
201
201−It _is_ possible to modify the context of a gate when you make a function call; or, to be more precise, it's possible to call a mutant copy of the gate in which the context is modified. To illustrate this let's use another example gate. Let's write a gate which uses a value from the context to generate the product. Bind `b` to the value `10`:
202+It _is_ possible to modify the context of a gate when you make a function call; or, to be more precise, it's possible to call a mutant copy of the gate in which the context is modified. To illustrate this let's use another example gate. Let's write a gate which uses a value from the context to generate the product. Bind `b` to the value `10`:
202
203
203```
204```
204> =b 10
205> =b 10
@@ -222,7 +223,7 @@ Now let's write a gate called `ten` that adds `b` to the input value:
22235
22335
223```
224```
224
225
225−We can unbind `b` from the dojo subject, and `ten` works just as well because it's using a copy of `b` stored its context:
226+We can unbind `b` from the Dojo subject, and `ten` works just as well because it's using a copy of `b` stored its context:
226
227
227```
228```
228> =b
229> =b
@@ -233,11 +234,11 @@ We can unbind `b` from the dojo subject, and `ten` works just as well because it
233> (ten 35)
234> (ten 35)
23445
23545
235
236
236−> b.+7.ten
237+> b.+14.ten
23710
23810
238```
239```
239
240
240−We can use `ten(b 25)` to produce a variant of `ten`. Calling this mutant version of `ten` causes a different value to be returned than we'd get with a normal `ten` call:
241+We can use `ten(b 25)` to produce a variant of `ten`. Calling this mutant version of `ten` causes a different value to be returned than we'd get with a normal `ten` call:
241
242
242```
243```
243> (ten(b 25) 10)
244> (ten(b 25) 10)
@@ -256,9 +257,9 @@ Before finishing the lesson let's unbind `ten`:
256> =ten
257> =ten
257```
258```
258
259
259−## Exercise 1.4.1a Solution
260+## Exercise 1.4.1a: Answer
260
261
261−Write a gate that takes an atom, `a=@`, and which returns double the value of `a`. Bind this gate to `double` and test it in the dojo.
262+Write a gate that takes an atom, `a=@`, and which returns double the value of `a`. Bind this gate to `double` and test it in the Dojo.
262
263
263```
264```
264> =double |=(a=@ (mul 2 a))
265> =double |=(a=@ (mul 2 a))
tutorials/hoon/generators.md+8−151
@@ -11,12 +11,12 @@ input and produce an output, then disappear. Generators might make sense for
11listing directory contents, or running unit tests, or fetching the contents of a
11listing directory contents, or running unit tests, or fetching the contents of a
12URL.
12URL.
13
13
14−There are four kinds of generators: naked, `%say`, `%get`, and `%ask`.
14+There are three kinds of generators: naked, `%say`, and `%ask`. There also used to be a fourth type of generator, `%get`, but this kind is no longer in use.
15
15
16### Naked Generators
16### Naked Generators
17
17
18A naked generator is simply a `gate`; that is, it is an anonymous function that
18A naked generator is simply a `gate`; that is, it is an anonymous function that
19−takes a `sample` (argument) and produces a noun. All you need to do is write a
19+takes a `sample` (argument) and produces a [noun](/docs/glossary/noun/). All you need to do is write a
20`gate` and put it into a file in the `/gen` directory. Let's take a look at a
20`gate` and put it into a file in the `/gen` directory. Let's take a look at a
21very simple one:
21very simple one:
22
22
@@ -49,7 +49,7 @@ an `aura` is type metadata and does other things, too.
49
49
50In the example above, we didn't specify an `aura`, leaving the printer to fend
50In the example above, we didn't specify an `aura`, leaving the printer to fend
51for itself. `"asdf"` is a `tape`, a type that is simply a `list` of `cords`. A
51for itself. `"asdf"` is a `tape`, a type that is simply a `list` of `cords`. A
52−`cord` is itself an atom represented as a string of UTF-8 characters. When used
52+`cord` is itself an [atom](/docs/glossary/atom/) represented as a string of UTF-8 characters. When used
53as part of a `tape`, the `cord` is only a single character. So each atom in the
53as part of a `tape`, the `cord` is only a single character. So each atom in the
54`[97 115 100 102 0]` output corresponds to a component of the `tape`: 97 is
54`[97 115 100 102 0]` output corresponds to a component of the `tape`: 97 is
55`a`, 115 is `s`, 100 is `d`, 102 is `f`, and `0` is the "null" that every list
55`a`, 115 is `s`, 100 is `d`, 102 is `f`, and `0` is the "null" that every list
@@ -141,7 +141,7 @@ the `|= *` expression on the line that follows.
141(add 40 2)
141(add 40 2)
142```
142```
143
143
144−`|= *` constructs a gate that takes a noun. This gate will itself produce a
144+`|= *` constructs a [gate](/docs/glossary/gate/) that takes a noun. This [gate](/docs/glossary/gate/) will itself produce a
145`cask`, which is cell formed by the prepending `:-`. The head of that `cask` is
145`cask`, which is cell formed by the prepending `:-`. The head of that `cask` is
146`%noun` and the tail is the rest of the program, `(add 40 2)`. The tail of the
146`%noun` and the tail is the rest of the program, `(add 40 2)`. The tail of the
147`cask` will be our actual data produced by the body of the program: in this
147`cask` will be our actual data produced by the body of the program: in this
@@ -230,8 +230,8 @@ In the code, our sample specifies faces on all of the Arvo data, meaning that we
230can easily access them. We also require the argument `[n=@ud ~]`, and allow the
230can easily access them. We also require the argument `[n=@ud ~]`, and allow the
231_optional_ argument `[bet=@ud ~]`.
231_optional_ argument `[bet=@ud ~]`.
232
232
233−But there's something new: `(~(rad og eny) n)`. This code pulls the `rad` arm
233+But there's something new: `(~(rad og eny) n)`. This code pulls the `rad` [arm](/docs/glossary/arm/)
234−out of the `og` core with the subject of `eny`. Recall that `eny` is our entropy
234+out of the `og` [core](/docs/glossary/core/) with the subject of `eny`. Recall that `eny` is our entropy
235value, so this is used to seed the generator. The `rad` arm will give us a
235value, so this is used to seed the generator. The `rad` arm will give us a
236pseudorandom number between 0 and `n`. Then we form a cell with the result and
236pseudorandom number between 0 and `n`. Then we form a cell with the result and
237`bet`, the optional named argument specified previously.
237`bet`, the optional named argument specified previously.
@@ -454,151 +454,8 @@ This is a [known issue](https://github.com/urbit/arvo/issues/840) to be resolved
454
454
455### `%get` generators
455### `%get` generators
456
456
457−`%get` generators are used for making HTTP requests through `eyre`. For this
457+`%get` generators no longer exist. They were once used for making HTTP requests through `eyre`. Such functionality is no longer supported with generators.
458−section we'll assume knowledge of generators covered in previous sections, so
459−we can jump in with an example:
460−
461−```hoon
462−/- sole
463−/+ generators
464−=, generators
465−:- %get
466−|= [* [url=tape ~] ~]
467−^- (sole-request:sole (cask json))
468−%+ curl (scan url auri:de-purl:html)
469−|= hit/httr:eyre
470−?~ r.hit !!
471−=/ my-json (de-json:html q.u.r.hit)
472−?~ my-json !!
473−=, dejs:format
474−%+ produce %json
475−%. %title
476−%~ got by
477−%- (om same)
478−u.my-json
479−```
480−
481−The above generator was written with the
482−[Studio Ghibli API](https://ghibliapi.herokuapp.com/). It uses this API to
483−print the title of a Studio Ghibli film.
484−
485−```hoon
486−/- sole
487−/+ generators
488−=, generators
489−```
490−
491−Here we import types from `/sur/sole.hoon` and gates from
492−`/lib/generators.hoon`. We also use `=,` to expose the namespace of
493−`generators` that we just imported.
494−
495−```hoon
496−:- %get
497−|= [* [url=tape ~] ~]
498−```
499−
500−Like with `%say` and `%ask` generators, we must include the "boilerplate":
501−code that produces a generator-specific `cell`. The head of that cell is `%get`,
502−and the tail is a gate that takes a `tape` of the URL that we are trying
503−to access.
504−
505−```hoon
506−^- (sole-request:sole (cask json))
507−```
508−
509−Here we make sure our gate is producing a `sole-request` which contains a `cask`
510−of the type `json`.
511−
512−
513−```hoon
514−%+ curl (scan url auri:de-purl:html)
515−|= hit/httr:eyre
516−```
517−
518−Here we can see the call to `curl`, the sample of which will parse our url and
519−make sure it's in the proper format.
520−
521−The second part of the `curl` call is the `gate` that will get called with the
522−result provided by the actual HTTP request.
523−
524−```hoon
525−?~ r.hit !!
526−```
527−
528−Here we verify that the `r` face of our response is not null before
529−continuing. If it is null, the generator will crash, as there is nothing left to
530−do.
531−
532−```hoon
533−=/ my-json (de-json:html q.u.r.hit)
534−```
535−
536−Here we verify that data was returned to us in the `json` Hoon type.
537−`q.u.r.hit` is the actual data we care about as a `cord`. `hit` is actually an
538−entire response object, including headers, which we don't care about for this
539−example. `de-json` out of `html` will parse the `cord` and produce a `json` type
540−for us that we can then use to inspect the data.
541−
542−```hoon
543−?~ my-json !!
544−=, dejs:format
545−```
546−
547−After parsing the JSON structure we want to make sure we got back a valid `json`
548−type. To do that, we test for null and crash if that test passes. If it doesn't
549−pass, we use `=,` on the `dejs:format` core so that we can more easily pull arms
550−out of it.
551−
552−```hoon
553−%+ produce %json
554−%. %title
555−%~ got by
556−```
557−
558−Now we come to our `produce` call. Recall that `produce` is used in all the
559−non-naked generators to output the final result. Here we want to produce a
560−`cask` of `json`, so we use the mark `%json` to indicate that.
561−
562−Next we have what may be an unfamiliar rune: `%.`. This rune is simply `%-` with
563−the argument order reversed. `%title` is the argument passed to the next gate
564−that is called. `by` is the core that is the `map` engine. A Hoon `map` is a
565−key-value pair structure, sometimes referred to as a dictionary in other
566−languages. `got` is the arm in `by` that will produce a gate that we can call to
567−access members of a given `map`.
568−
569−> The idiomatic way to write Hoon is to have the
570− "heaviest" code paths lowest in the program, which is why `%.`
571− is preferred in this case over `%-`. Use of this style is recommended, as it
572− results in code that is much easier to read.
573−
574−At the moment, however, we do not have a `map`, but instead have a `json` type.
575−
576−```hoon
577−%- (om same)
578−u.my-json
579−```
580−
581−Here we use `om`, which is an arm in `dejs:format` that will take a `json` and
582−return a `map`. `same` is a wet gate from the standard library that takes an
583−argument of any type and returns it as that type. We could use any other gate to
584−modify the data if that were useful for the particular data we are going to be
585−processing, but here we want the data exactly as it is.
586−
587−Since `my-json` is a `unit` of `json`, the actual data we are looking for is in
588−`u.my-json`. We take this and give it to the gate produced by the call to `om`.
589−This gate is going to transform our data by taking in the `json` structure and
590−producing a `map`. Then we can look up keys in this map using `got` from
591−the `by` core.
592−
593−`%.` performs the same function as `%-`, the rune used to call a function,
594−except with the arguments reversed so that the function is last and
595−the arguments of that function come first. It's used here to keep with the
596−principle that heaviest, or most complex, expressions should go to the bottom.
597−
598−The key we are looking up in our new `map` we've created from `my-json` is
599−`%title`, which is an element in the original source, to produce the final
600−result of the generator.
601
458
602## Conclusion
459## Conclusion
603
460
604−You've now reached the end of Chapter 1 of the Hoon tutorial. Ideally you should have a fair understanding of the fundamental concepts of subject-oriented programming: limbs, legs, faces, wings, arms, cores, gates, and doors. If you can master these concepts you should have little or no trouble learning to write substantial Hoon programs.
461+You've now reached the end of Chapter 1 of the Hoon tutorial. Ideally you should have a fair understanding of the fundamental concepts of subject-oriented programming: limbs, legs, faces, wings, arms, cores, gates, and [doors](/docs/glossary/door/). If you can master these concepts you should have little or no trouble learning to write substantial Hoon programs.
tutorials/hoon/hoon-syntax.md+55−55
@@ -7,22 +7,22 @@ aliases = ["/docs/learn/hoon/hoon-tutorial/hoon-syntax/"]
7
7
8The study of Hoon can be divided into two parts: syntax and semantics.
8The study of Hoon can be divided into two parts: syntax and semantics.
9
9
10−The [syntax](https://en.wikipedia.org/wiki/Syntax_%28programming_languages%29 ) of a programming language is the set of rules that determine what counts as admissible code in that language. It determines which characters may be used in the source, and also how these characters may be assembled to constitute a program. Attempting to run a program that doesn't follow these rules will result in a syntax error.
10+The [syntax](https://en.wikipedia.org/wiki/Syntax_%28programming_languages%29 ) of a programming language is the set of rules that determine what counts as admissible code in that language. It determines which characters may be used in the source, and also how these characters may be assembled to constitute a program. Attempting to run a program that doesn’t follow these rules will result in a syntax error.
11
11
12−The [semantics](https://en.wikipedia.org/wiki/Semantics_%28computer_science%29 ) of a programming language concerns the meaning of the various parts of that language's code.
12+The [semantics](https://en.wikipedia.org/wiki/Semantics_%28computer_science%29 ) of a programming language concerns the meaning of the various parts of that language’s code.
13
13
14−In this lesson we will give a general overview of Hoon's syntax. By the end of it, you should be familiar with all the basic elements of Hoon code.
14+In this lesson we will give a general overview of Hoon’s syntax. By the end of it, you should be familiar with all the basic elements of Hoon code.
15
15
16## Hoon Characters
16## Hoon Characters
17
17
18−Hoon source files are composed almost entirely of the [printable ASCII characters](https://en.wikipedia.org/wiki/ASCII%23Printable_characters). Hoon does not accept any other characters in source files except for [UTF-8](https://en.wikipedia.org/wiki/UTF-8) in quoted strings. Hard tab characters are illegal; use two spaces instead.
18+Hoon source files are composed almost entirely of the [printable ASCII characters](https://en.wikipedia.org/wiki/ASCII%23Printable_characters). Hoon does not accept any other characters in source files except for [UTF-8](https://en.wikipedia.org/wiki/UTF-8) in quoted strings. Hard tab characters are illegal; use two spaces instead.
19
19
20```
20```
21> "You can put ½ in quotes, but not elsewhere!"
21> "You can put ½ in quotes, but not elsewhere!"
22"You can put ½ in quotes, but not elsewhere!"
22"You can put ½ in quotes, but not elsewhere!"
23
23
24−> 'You can put ½ in single quotes too.'
24+> 'You can put ½ in single quotes, too.'
25−'You can put ½ in single quotes too.'
25+'You can put ½ in single quotes, too.'
26
26
27> "Some UTF-8: ἄλφα"
27> "Some UTF-8: ἄλφα"
28"Some UTF-8: ἄλφα"
28"Some UTF-8: ἄλφα"
@@ -30,7 +30,7 @@ Hoon source files are composed almost entirely of the [printable ASCII character
30
30
31### Reading Hoon Aloud
31### Reading Hoon Aloud
32
32
33−Hoon code makes heavy use of non-alphanumeric symbols. Reading off code aloud using the proper names of ASCII symbols is tedious, so we've mapped syllables to symbols:
33+Hoon code makes heavy use of non-alphanumeric symbols. Reading off code aloud using the proper names of ASCII symbols is tedious, so we’ve mapped syllables to symbols:
34
34
35```
35```
36ace [1 space] gap [>1 space, nl] pat @
36ace [1 space] gap [>1 space, nl] pat @
@@ -47,25 +47,25 @@ fas / pam &
47gal < par )
47gal < par )
48```
48```
49
49
50−Learning and using these names of non-alphanumeric symbols is entirely optional; you can become an expert Hoon programmer without them. Many Hoon programmers find them helpful, however, particularly when talking to someone else who knows them.
50+Learning and using these names of non-alphanumeric symbols is entirely optional; you can become an expert Hoon programmer without them. Many Hoon programmers find them helpful, however, particularly when talking to someone else who knows them.
51
51
52−Note that the list includes two separate whitespace forms: `ace` for a single space; `gap` is either 2+ spaces or a newline. In Hoon, the only whitespace significance is the distinction between `ace` and `gap` -- i.e., the distinction between one space and more than one.
52+Note that the list includes two separate whitespace forms: `ace` for a single space; `gap` is either 2+ spaces or a newline. In Hoon, the only whitespace significance is the distinction between `ace` and `gap` -- i.e., the distinction between one space and more than one.
53
53
54## Expressions of Hoon
54## Expressions of Hoon
55
55
56−An [expression](https://en.wikipedia.org/wiki/Expression_%28computer_science%29 ) is a combination of characters that the language interprets and evaluates as producing a value. Hoon programs are made up entirely of expressions.
56+An [expression](https://en.wikipedia.org/wiki/Expression_%28computer_science%29 ) is a combination of characters that the language interprets and evaluates as producing a value. Hoon programs are made up entirely of expressions.
57
57
58−Hoon expressions can be either basic or complex. Basic expressions of Hoon are fundamental, meaning that they can't be broken down into smaller expressions. Complex expressions are made up of smaller expressions (which are called **subexpressions**).
58+Hoon expressions can be either basic or complex. Basic expressions of Hoon are fundamental, meaning that they can’t be broken down into smaller expressions. Complex expressions are made up of smaller expressions (which are called **subexpressions**).
59
59
60−There are many categories of Hoon expressions: noun literals, wing expressions, type expressions, and rune expressions. Let's go over each.
60+There are many categories of Hoon expressions: [noun](/docs/glossary/noun/) literals, wing expressions, type expressions, and rune expressions. Let’s go over each.
61
61
62### Noun Literals
62### Noun Literals
63
63
64−A noun is either an atom or a cell. An atom is an unsigned integer and a cell is a pair of nouns.
64+A noun is either an [atom](/docs/glossary/atom/) or a cell. An [atom](/docs/glossary/atom/) is an unsigned integer and a cell is a pair of nouns.
65
65
66−There are [literal](https://en.wikipedia.org/wiki/Literal_%28computer_programming%29 ) expressions for each kind of noun. A noun literal is just a notation for representing a fixed noun value.
66+There are [literal](https://en.wikipedia.org/wiki/Literal_%28computer_programming%29 ) expressions for each kind of noun. A noun literal is just a notation for representing a fixed noun value.
67
67
68−We start with atom literals. Each of these is a basic expression of Hoon that evaluates to itself. Examples:
68+We start with atom literals. Each of these is a basic expression of Hoon that evaluates to itself. Examples:
69
69
70```
70```
71> 1
71> 1
@@ -84,9 +84,9 @@ We start with atom literals. Each of these is a basic expression of Hoon that e
84~zod
84~zod
85```
85```
86
86
87−Recall from [Lesson 1.2](@/docs/tutorials/hoon/nouns.md) that even though atoms are unsigned integers, they can be pretty-printed in different ways. The way an atom is to be represented depends on its aura. The literal syntax for each of the hard-coded auras will be explained further in [Lesson 2.1](@/docs/tutorials/hoon/atoms-auras-and-simple-cell-types.md).
87+Recall from [Lesson 1.2](@/docs/tutorials/hoon/nouns.md) that even though atoms are unsigned integers, they can be pretty-printed in different ways. The way an atom is to be represented depends on its aura. The literal syntax for each of the hard-coded auras will be explained further in [Lesson 2.1](@/docs/tutorials/hoon/atoms-auras-and-simple-cell-types.md).
88
88
89−Cell literals can be written in Hoon using `[ ]`. Cell literals are complex, because other expressions are put inside the square brackets. Examples:
89+Cell literals can be written in Hoon using `[ ]`. Cell literals are complex, because other expressions are put inside the square brackets. Examples:
90
90
91```
91```
92> [6 7]
92> [6 7]
@@ -102,7 +102,7 @@ Cell literals can be written in Hoon using `[ ]`. Cell literals are complex, be
102[123 [~zod ~ten] .1.2837]
102[123 [~zod ~ten] .1.2837]
103```
103```
104
104
105−You can also put complex expressions inside square brackets to make a cell. These are valid expressions but they aren't cell literals, naturally:
105+You can also put complex expressions inside square brackets to make a cell. These are valid expressions but they aren’t cell literals, naturally:
106
106
107```
107```
108> [(add 22 33) (mul 22 33)]
108> [(add 22 33) (mul 22 33)]
@@ -111,9 +111,9 @@ You can also put complex expressions inside square brackets to make a cell. The
111
111
112### Wings
112### Wings
113
113
114−A wing expression is a series of limb expressions separated by `.`. A deeper explanation can be found on the [wing](@/docs/reference/hoon-expressions/limb/wing.md) and [limb](@/docs/reference/hoon-expressions/limb/limb.md) reference pages.
114+A wing expression is a series of limb expressions separated by `.`. A deeper explanation can be found on the [wing](@/docs/reference/hoon-expressions/limb/wing.md) and [limb](@/docs/reference/hoon-expressions/limb/limb.md) reference pages.
115
115
116−Let's start with the base case: a single limb. A limb expression is a trivial wing expression -- there is only one limb in the series. Some one-limb wings:
116+Let’s start with the base case: a single limb. A limb expression is a trivial wing expression -- there is only one limb in the series. Some one-limb wings:
117
117
118- `+2`
118- `+2`
119- `-`
119- `-`
@@ -124,9 +124,9 @@ Let's start with the base case: a single limb. A limb expression is a trivial w
124- `add`
124- `add`
125- `mul`
125- `mul`
126
126
127−As a special limb we also have `$`. This is the name of the arm in special one-armed cores called "gates". (We'll cover the role of `$` in [Lesson 1.4](@/docs/tutorials/hoon/gates.md).)
127+As a special limb we also have `$`. This is the name of the [arm](/docs/glossary/arm/) in special one-armed [cores](/docs/glossary/core/) called “gates”. (We’ll cover the role of `$` in [Lesson 1.4](@/docs/tutorials/hoon/gates.md).)
128
128
129−Wing expressions with multiple limbs are complex expressions. Examples:
129+Wing expressions with multiple limbs are complex expressions. Examples:
130
130
131- `+2.+3.+4`
131- `+2.+3.+4`
132- `-.+.+`
132- `-.+.+`
@@ -139,29 +139,29 @@ Wing expressions with multiple limbs are complex expressions. Examples:
139
139
140### Type Expressions
140### Type Expressions
141
141
142−Hoon is a statically typed language. You'll learn more about the type system later in the chapter. For now, just know that Hoon's type system uses special symbols to indicate certain fundamental types: `~` (null), `*` (noun), `@` (atom), `^` (cell), and `?` (flag). Each of these symbols can be used as a stand-alone expression of Hoon. In the case of `@` there may be a series of letters following it, to indicate an atom aura; e.g., `@s`, `@rs`, `@tas`, and `@tD`.
142+Hoon is a statically typed language. You’ll learn more about the type system later in the chapter. For now, just know that Hoon’s type system uses special symbols to indicate certain fundamental types: `~` (null), `*` (noun), `@` (atom), `^` (cell), and `?` (flag). Each of these symbols can be used as a stand-alone expression of Hoon. In the case of `@` there may be a series of letters following it, to indicate an atom aura; e.g., `@s`, `@rs`, `@tas`, and `@tD`.
143
143
144−They may also be put in brackets to indicate compound types, e.g., `[@ ^]`, `[@ud @sb]`, `[[? *] ^]`. (Technically these expressions don't _always_ indicate compound types. In certain contexts they're interpreted in a different way. We'll address this variation of meaning in [Lesson 2.3](@/docs/tutorials/hoon/structures-and-complex-types.md).)
144+They may also be put in brackets to indicate compound types, e.g., `[@ ^]`, `[@ud @sb]`, `[[? *] ^]`. (Technically these expressions don’t _always_ indicate compound types. In certain contexts they’re interpreted in a different way. We’ll address this variation of meaning in [Lesson 2.3](@/docs/tutorials/hoon/structures-and-complex-types.md).)
145
145
146### Rune Expressions
146### Rune Expressions
147
147
148−A **rune** is just a pair of ASCII characters (a digraph). You've already seen some runes in Chapter 1: `|=`,`|%`, and `|_`. We usually pronounce runes by combining their characters' names, e.g.: 'ket-hep' for `^-`, 'bar-tis' for `|=`, and 'bar-cen' for `|%`. As stated previously, these names are entirely optional.
148+A **rune** is just a pair of ASCII characters (a digraph). You’ve already seen some runes in Chapter 1: `|=`,`|%`, and `|_`. We usually pronounce runes by combining their characters’ names, e.g.: “ket-hep” for `^-`, “bar-tis” for `|=`, and “bar-cen” for `|%`. As stated previously, these names are entirely optional.
149
149
150−Expressions with a rune at the beginning are rune expressions. Most runes are used at the beginning of a complex expression, but there are exceptions. For example, the runes `--` and `==` are used at the end of certain expressions.
150+Expressions with a rune at the beginning are rune expressions. Most runes are used at the beginning of a complex expression, but there are exceptions. For example, the runes `--` and `==` are used at the end of certain expressions.
151
151
152−Runes are classified by family (with the exceptions of `--` and `==`). The first of the two symbols indicates the family -- e.g., the `^-` rune is in the `^` family of runes, and the `|=` and `|%` runes are in the `|` family. The runes of particular family usually have related meanings. Two simple examples: the runes in the `|` family are all used to create cores, and the runes in the `:` family are all used to create cells.
152+Runes are classified by family (with the exceptions of `--` and `==`). The first of the two symbols indicates the family -- e.g., the `^-` rune is in the `^` family of runes, and the `|=` and `|%` runes are in the `|` family. The runes of particular family usually have related meanings. Two simple examples: the runes in the `|` family are all used to create cores, and the runes in the `:` family are all used to create cells.
153
153
154−Rune expressions are usually complex, which means they usually have one or more subexpressions. The appropriate syntax varies from rune to rune; after all, they're used for different purposes. To see the syntax rules for a particular rune, consult the [rune reference](@/docs/reference/hoon-expressions/rune/_index.md). Nevertheless, there are some general principles that hold of all rune expressions.
154+Rune expressions are usually complex, which means they usually have one or more subexpressions. The appropriate syntax varies from rune to rune; after all, they’re used for different purposes. To see the syntax rules for a particular rune, consult the [rune reference](@/docs/reference/hoon-expressions/rune/_index.md). Nevertheless, there are some general principles that hold of all rune expressions.
155
155
156−Runes generally do not need to be closed. In other languages you'll see an abundance of terminators, such as opening and closing parentheses, and this way of doing this is largely absent from Urbit. That's because all runes take a fixed number of children. Children can themselves be runes (with more children), and Hoon programs work by chaining through these series of children until a value -- not another rune -- is arrived at. This makes Hoon code nice and neat to look at.
156+Runes generally do not need to be closed. In other languages you’ll see an abundance of terminators, such as opening and closing parentheses, and this way of doing this is largely absent from Urbit. That’s because all runes take a fixed number of children. Children can themselves be runes (with more children), and Hoon programs work by chaining through these series of children until a value -- not another rune -- is arrived at. This makes Hoon code nice and neat to look at.
157
157
158−#### Tall and Flat Forms
158+#### Tall and Wide Forms
159
159
160−There are two rune syntax forms: **tall** and **flat**. Tall form is usually used for multi-line expressions, and flat form is used for one-line expressions. Most runes can be used in either of tall or flat forms. Tall form expressions may contain flat form subexpressions, but flat form expressions may not contain tall form.
160+There are two rune syntax forms: **tall** and **wide**. Tall form is usually used for multi-line expressions, and wide form is used for one-line expressions. Most runes can be used in either of tall or wide forms. Tall form expressions may contain wide form subexpressions, but wide form expressions may not contain tall form.
161
161
162−The spacing rules differ in the two forms. In tall form, each rune and subexpression must be separated from the others by a `gap` -- that is, by two or more spaces, or a line break. In flat form the rune is immediately followed by parentheses `( )`, and the various subexpressions inside the parentheses must be separated from the others by an `ace` -- that is, by a single space.
162+The spacing rules differ in the two forms. In tall form, each rune and subexpression must be separated from the others by a `gap` -- that is, by two or more spaces, or a line break. In wide form the rune is immediately followed by parentheses `( )`, and the various subexpressions inside the parentheses must be separated from the others by an `ace` -- that is, by a single space.
163
163
164−Seeing an example will help you understand the difference. The `:-` rune is used to produce a cell. Accordingly, it is followed by two subexpressions: the first defines the head of the cell, and the second defines the tail. Here are three different ways to write a `:-` expression in tall form:
164+Seeing an example will help you understand the difference. The `:-` rune is used to produce a cell. Accordingly, it is followed by two subexpressions: the first defines the head of the cell, and the second defines the tail. Here are three different ways to write a `:-` expression in tall form:
165
165
166```
166```
167> :- 11 22
167> :- 11 22
@@ -177,22 +177,22 @@ Seeing an example will help you understand the difference. The `:-` rune is use
177[11 22]
177[11 22]
178```
178```
179
179
180−These all do the same thing. The first example shows that, if you want to, you can write 'tall' form code on a single line. Notice that there are two spaces between the `:-` rune and `11`, and also between `11` and `22`. This is the minimum spacing necessary between the various parts of a tall form expression -- any fewer will result in a syntax error.
180+These all do the same thing. The first example shows that, if you want to, you can write tall form code on a single line. Notice that there are two spaces between the `:-` rune and `11`, and also between `11` and `22`. This is the minimum spacing necessary between the various parts of a tall form expression -- any fewer will result in a syntax error.
181
181
182−Usually one or more line breaks are used to break up a tall form expression. This is especially useful when the subexpressions are themselves long stretches of code. The same `:-` expression in flat-form is:
182+Usually one or more line breaks are used to break up a tall form expression. This is especially useful when the subexpressions are themselves long stretches of code. The same `:-` expression in wide form is:
183
183
184```
184```
185> :-(11 22)
185> :-(11 22)
186[11 22]
186[11 22]
187```
187```
188
188
189−This is the preferred way to write an expression on a single line. The rune itself is followed by a set of parentheses, and the subexpressions inside are separated by a single space. Any more spacing than that results in a syntax error.
189+This is the preferred way to write an expression on a single line. The rune itself is followed by a set of parentheses, and the subexpressions inside are separated by a single space. Any more spacing than that results in a syntax error.
190
190
191−Nearly all rune expressions can be written in either form, but there are exceptions. `|%` and `|_` expressions, for example, can only be written in tall form. (Those are a bit too complicated to fit comfortably on one line anyway.)
191+Nearly all rune expressions can be written in either form, but there are exceptions. `|%` and `|_` expressions, for example, can only be written in tall form. (Those are a bit too complicated to fit comfortably on one line anyway.)
192
192
193#### Nesting Runes
193#### Nesting Runes
194
194
195−Since runes take a fixed number of children, one can visualize how Hoon expressions are built by thinking of each rune being followed by a series of boxes to be filled - one for each of its children. Let us illustrate this with the `:-` rune.
195+Since runes take a fixed number of children, one can visualize how Hoon expressions are built by thinking of each rune being followed by a series of boxes to be filled -- one for each of its children. Let us illustrate this with the `:-` rune.
196
196
197![](https://media.urbit.org/docs/hoon-syntax/cell1.png)
197![](https://media.urbit.org/docs/hoon-syntax/cell1.png)
198
198
@@ -204,7 +204,7 @@ This, of course, evaluates to the cell `[2 3]`. This next figure corresponds to
204
204
205![](https://media.urbit.org/docs/hoon-syntax/cell3.png)
205![](https://media.urbit.org/docs/hoon-syntax/cell3.png)
206
206
207−This evaluates to `[[2 3] 4]`, and we can think of the second `:-` as being "nested" inside of the first `:-`.
207+This evaluates to `[[2 3] 4]`, and we can think of the second `:-` as being “nested” inside of the first `:-`.
208
208
209What Hoon expression does the following figure correspond to, and what does it evaluate to?
209What Hoon expression does the following figure correspond to, and what does it evaluate to?
210
210
@@ -213,17 +213,17 @@ What Hoon expression does the following figure correspond to, and what does it e
213Right. This represents the Hoon expression `:- 2 :- 3 4`,
213Right. This represents the Hoon expression `:- 2 :- 3 4`,
214and evaluates to `[2 [3 4]]`. Remember, though, that if you input this into dojo it will print as `[2 3 4]`.
214and evaluates to `[2 [3 4]]`. Remember, though, that if you input this into dojo it will print as `[2 3 4]`.
215
215
216−Thinking in terms of these "LEGO block" diagrams, as well as the more literal binary tree diagrams utilized in [Lesson 1.2](@/docs/tutorials/hoon/nouns.md), can be a helpful learning and debugging tactic.
216+Thinking in terms of these “LEGO block” diagrams, as well as the more literal binary tree diagrams utilized in [Lesson 1.2](@/docs/tutorials/hoon/nouns.md), can be a helpful learning and debugging tactic.
217
217
218−##### Exercise 1.3.a.
218+##### Exercise 1.3a
219
219
220Draw binary trees corresponding to the above figures. Determine a one-to-one correspondence between linearly ordered nested boxes (i.e. what is depicted in the above figures) and binary trees. You will need to make use of the convention `[a [b c]] = [a b c]`.
220Draw binary trees corresponding to the above figures. Determine a one-to-one correspondence between linearly ordered nested boxes (i.e. what is depicted in the above figures) and binary trees. You will need to make use of the convention `[a [b c]] = [a b c]`.
221
221
222#### Irregular Forms
222#### Irregular Forms
223
223
224−Some runes are used so frequently that they have irregular counterparts that are easier to write and which mean precisely the same thing. Irregular rune syntax is hence a form of [syntactic sugar](https://en.wikipedia.org/wiki/Syntactic_sugar). All irregular rune syntax is flat. (It follows from this that all tall form expressions are regular.)
224+Some runes are used so frequently that they have irregular counterparts that are easier to write and which mean precisely the same thing. Irregular rune syntax is hence a form of [syntactic sugar](https://en.wikipedia.org/wiki/Syntactic_sugar). All irregular rune syntax is wide. (It follows from this that all tall form expressions are regular.)
225
225
226−Let's look at another example. The `.=` rune takes two subexpressions, evaluates them, and tests the results for equality. If they're equal it produces `%.y` for 'yes'; otherwise `%.n` for 'no'. In tall form:
226+Let’s look at another example. The `.=` rune takes two subexpressions, evaluates them, and tests the results for equality. If they’re equal it produces `%.y` for “yes”; otherwise `%.n` for “no”. In tall form:
227
227
228```
228```
229> .= 22 11
229> .= 22 11
@@ -234,7 +234,7 @@ Let's look at another example. The `.=` rune takes two subexpressions, evaluate
234%.y
234%.y
235```
235```
236
236
237−And in flat form:
237+And in wide form:
238
238
239```
239```
240> .=(22 11)
240> .=(22 11)
@@ -254,7 +254,7 @@ The irregular form of the `.=` rune is just `=( )`:
254%.y
254%.y
255```
255```
256
256
257−The examples above have another irregular form: `(add 11 11)`. This is the irregular form of `%+`, which calls a gate (i.e., a Hoon function) with two arguments for the sample.
257+The examples above have another irregular form: `(add 11 11)`. This is the irregular form of `%+`, which calls a [gate](/docs/glossary/gate/) (i.e., a Hoon function) with two arguments for the sample.
258
258
259```
259```
260> %+ add 11 11
260> %+ add 11 11
@@ -283,7 +283,7 @@ You can find other irregular forms in the irregular expression [reference docume
283
283
284### Expressions That Are Only Irregular
284### Expressions That Are Only Irregular
285
285
286−There are certain irregular expressions that aren't syntactic sugar for regular form equivalents -- they're solely irregular. There isn't much in general that can be said about these because they're all different, but we can look at some examples.
286+There are certain irregular expressions that aren’t syntactic sugar for regular form equivalents -- they’re solely irregular. There isn’t much in general that can be said about these because they’re all different, but we can look at some examples.
287
287
288Below we use the `` ` `` symbol to create a cell whose head is null, `~`.
288Below we use the `` ` `` symbol to create a cell whose head is null, `~`.
289
289
@@ -319,9 +319,9 @@ To see other irregular expressions, check the irregular expression [reference do
319
319
320## The Standard Library
320## The Standard Library
321
321
322−The Hoon standard library is a compilation of generally useful Hoon gates (functions). You've seen these already: in expressions like `(add 11 11)`, `add` is a function from the standard library.
322+The Hoon standard library is a compilation of generally useful Hoon gates (functions). You’ve seen these already: in expressions like `(add 11 11)`, `add` is a function from the standard library.
323
323
324−It's important to know about standard library functions, because they make certain tasks much easier, and spare you from having to write the code itself. If you did not use the `add` library function, for example, you would have to write out code like this every time you wanted to find the sum of two numbers:
324+It’s important to know about standard library functions, because they make certain tasks much easier, and spare you from having to write the code itself. If you did not use the `add` library function, for example, you would have to write out code like this every time you wanted to find the sum of two numbers:
325
325
326```hoon
326```hoon
327++ add
327++ add
@@ -336,21 +336,21 @@ Standard library functions are often built with other standard library functions
336
336
337## Reference Materials
337## Reference Materials
338
338
339−The Hoon syntax can be intimidating for the uninitiated, so it's good to remember where you can look up expressions can be found. The [reference section](@/docs/reference/_index.md) itself is a good place to find the reference materials that you need. These children sections are likely to be useful:
339+The Hoon syntax can be intimidating for the uninitiated, so it’s good to remember where you can look up expressions. The [Reference](@/docs/reference/_index.md) section itself is a good place to find the materials that you need. These children sections are likely to be useful:
340
340
341- The [Runes](@/docs/reference/hoon-expressions/rune/_index.md) page will show you how to use any Hoon rune.
341- The [Runes](@/docs/reference/hoon-expressions/rune/_index.md) page will show you how to use any Hoon rune.
342−- The [Cheat sheet](@/docs/reference/cheat-sheet.md) is a more compact place to look up rune expressions.
342+- The [Cheat Sheet](@/docs/reference/cheat-sheet.md) is a more compact place to look up rune expressions.
343−- The [Standard library](@/docs/reference/library/table-of-contents.md) section has its sub-pages arranged by category. So arithmetic functions, for example, are all found on the same page.
343+- The [Standard Library](@/docs/reference/library/table-of-contents.md) section has its sub-pages arranged by category. So arithmetic functions, for example, are all found on the same page.
344−- The [Hoon Style Guide](@/docs/tutorials/hoon/style.md) will show you how to write your Hoon code so that it's idiomatic and easily understood by others.
344+- The [Hoon Style Guide](@/docs/tutorials/hoon/style.md) will show you how to write your Hoon code so that it’s idiomatic and easily understood by others.
345
345
346### Debugging
346### Debugging
347
347
348−When you have an error in your Hoon code, one of two things can happen. Either the code does not run at all and you get an error (such as `nest-fail`), or your code _does_ run but produces the wrong results. The [Troubleshooting](@/docs/reference/hoon-errors.md) page is a good resource for figuring out how to debug your code.
348+When you have an error in your Hoon code, one of two things can happen. Either the code does not run at all and you get an error (such as `nest-fail`), or your code _does_ run but produces the wrong results. The [Troubleshooting](@/docs/tutorials/hoon-errors.md) page is a good resource for figuring out how to debug your code.
349
349
350There are a couple useful runes associated with debugging:
350There are a couple useful runes associated with debugging:
351
351
352−`!:` (zapcol), if written at the top of a Hoon file, turns on a full debugging stack-trace. It's good practice to use whenever you're learning.
352+`!:` (zapcol), if written at the top of a Hoon file, turns on a full debugging stack-trace. It’s good practice to use whenever you’re learning.
353
353
354`~&` (sigpam) is used to print its argument every time that argument executes. So, if you wanted to see how many times your program executed `foo`, you would write `foo bar`. Then, when your program runs, it will print `foo` on a new line of output every time the program comes across it by recursion.
354`~&` (sigpam) is used to print its argument every time that argument executes. So, if you wanted to see how many times your program executed `foo`, you would write `foo bar`. Then, when your program runs, it will print `foo` on a new line of output every time the program comes across it by recursion.
355
355
356−But there are more. Check out the aforementioned [troubleshooting](@/docs/reference/hoon-errors.md) page to see other handy debugging runes and how to use them.
356+But there are more. Check out the aforementioned [Troubleshooting](@/docs/tutorials/hoon-errors.md) page to see other handy debugging runes and how to use them.
tutorials/hoon/iron-polymorphism.md+3−3
@@ -5,11 +5,11 @@ template = "doc.html"
5aliases = ["/docs/learn/hoon/hoon-tutorial/iron-polymorphism/"]
5aliases = ["/docs/learn/hoon/hoon-tutorial/iron-polymorphism/"]
6+++
6+++
7
7
8−Polymorphism is a programming concept that allows a a piece of code to use different types at different times. It's a common technique in most languages to make code that can be reused for many different situations, and Hoon is no exception. Let's take a look at a gate from the Hoon standard library as an example; we'll be passing a few different types in. The code below is an excerpt from `hoon.hoon` and, as such, will not run as-is by itself.
8+Polymorphism is a programming concept that allows a a piece of code to use different types at different times. It's a common technique in most languages to make code that can be reused for many different situations, and Hoon is no exception. Let's take a look at a [gate](/docs/glossary/gate/) from the Hoon standard library as an example; we'll be passing a few different types in. The code below is an excerpt from `hoon.hoon` and, as such, will not run as-is by itself.
9
9
10`fold` is a _wet_ gate that takes two arguments and produces a _dry_ gate. But what are wet and dry gates?
10`fold` is a _wet_ gate that takes two arguments and produces a _dry_ gate. But what are wet and dry gates?
11
11
12−A dry gate (also simply a _gate_) is the kind that you're already familiar with by now: a one-armed core with a sample. A wet gate is also a one-armed core with a sample, but there is a difference. With a dry gate, when you pass in an argument and the code gets compiled, the type system will try to cast to the type specified by the gate; if you pass something that does not fit in the specified type, for example a `cord` instead of a `cell` you will get a nest failure. On the other hand, when you pass arguments to a wet gate, their types are preserved and type analysis is done at the definition site of the gate -- in our case, `fold` in `hoon.hoon` -- rather than the call site.
12+A dry gate (also simply a _gate_) is the kind that you're already familiar with by now: a one-armed [core](/docs/glossary/core/) with a sample. A wet gate is also a one-armed [core](/docs/glossary/core/) with a sample, but there is a difference. With a dry gate, when you pass in an argument and the code gets compiled, the type system will try to cast to the type specified by the gate; if you pass something that does not fit in the specified type, for example a `cord` instead of a `cell` you will get a nest failure. On the other hand, when you pass arguments to a wet gate, their types are preserved and type analysis is done at the definition site of the gate -- in our case, `fold` in `hoon.hoon` -- rather than the call site.
13
13
14```hoon
14```hoon
15++ fold
15++ fold
@@ -21,7 +21,7 @@ A dry gate (also simply a _gate_) is the kind that you're already familiar with
21 $(xs t.xs, st (f st i.xs))
21 $(xs t.xs, st (f st i.xs))
22```
22```
23
23
24−On the first line of the arm, we use `|*` to create a wet gate, with two arguments: `state` and `elem`. These arguments are both `mold`s; that is to say, they are type definitions. We use this to define the types used in the dry gate.
24+On the first line of the [arm](/docs/glossary/arm/), we use `|*` to create a wet gate, with two arguments: `state` and `elem`. These arguments are both `mold`s; that is to say, they are type definitions. We use this to define the types used in the dry gate.
25
25
26```hoon
26```hoon
27|= [[st=state xs=(list elem)] f=$-([state elem] state)]
27|= [[st=state xs=(list elem)] f=$-([state elem] state)]
tutorials/hoon/landscape-tile.md+4−4
@@ -23,7 +23,7 @@ Once you've cloned the repo, `cd` into the newly downloaded folder and run `npm
23
23
24The wizard prompts you with three questions.
24The wizard prompts you with three questions.
25- For the purposes of this walkthrough, choose `testing` as the name of your file; your answer determines the name of a Hoon file and the name of directory containing the `tile.js` file that the Hoon file references.
25- For the purposes of this walkthrough, choose `testing` as the name of your file; your answer determines the name of a Hoon file and the name of directory containing the `tile.js` file that the Hoon file references.
26−- When prompted to choose between a title and a full application, answer `tile`.
26+- When prompted to choose between a tile and a full application, answer `tile`.
27- For the final question, simply give the full path to your ship's pier and the desired desk (such as `/home`). This links your ship to this repo.
27- For the final question, simply give the full path to your ship's pier and the desired desk (such as `/home`). This links your ship to this repo.
28
28
29### Testing the Default App
29### Testing the Default App
@@ -220,7 +220,7 @@ window.testingTile = testingTile;
220
220
221### Default Code Components
221### Default Code Components
222
222
223−Parts of the `testing.hoon` code shown above is the "scaffolding" that was automatically built for us by the default Hoon file from the `create-landscape-app` repo. We'll give a general overview of those arms here.
223+Parts of the `testing.hoon` code shown above is the "scaffolding" that was automatically built for us by the default Hoon file from the `create-landscape-app` repo. We'll give a general overview of those [arms](/docs/glossary/arm/) here.
224
224
225As with other gall apps, `card` and `move` define the types that can be produced by the app, `card` specifically defines which type of requests can be made to other parts of the system.
225As with other gall apps, `card` and `move` define the types that can be produced by the app, `card` specifically defines which type of requests can be made to other parts of the system.
226
226
@@ -257,11 +257,11 @@ Now that we've glanced at the default components of the program, lets take a clo
257 ==
257 ==
258```
258```
259
259
260−`++poke-json` is going to accept a `json` and produce a `quip`. A `quip` is a pair of: a list of `moves` (in this case), and some state which is the same type as the core we are building. To be clear, a `json` in Hoon is not the same thing as something in the more general JSON format. It is rather a parsed data structure.
260+`++poke-json` is going to accept a `json` and produce a `quip`. A `quip` is a pair of: a list of `moves` (in this case), and some state which is the same type as the [core](/docs/glossary/core/) we are building. To be clear, a `json` in Hoon is not the same thing as something in the more general JSON format. It is rather a parsed data structure.
261
261
262There are several uses of the `~&` rune. These are simply debugging printfs that we can skip over.
262There are several uses of the `~&` rune. These are simply debugging printfs that we can skip over.
263
263
264−`(om:dejs:format same)` builds a gate that converts a `json` into a `map`.
264+`(om:dejs:format same)` builds a [gate](/docs/glossary/gate/) that converts a `json` into a `map`.
265
265
266`++so:dejs:format` formats some piece of data out of the `json` map, in this case the value of `%ship`. `sthu` is transformed by [`slaw`](@/docs/reference/library/4m.md#slaw) into an actual `@p` to verify that we didn't get sent nonsense. If we did, `need` will cause the gate to crash.
266`++so:dejs:format` formats some piece of data out of the `json` map, in this case the value of `%ship`. `sthu` is transformed by [`slaw`](@/docs/reference/library/4m.md#slaw) into an actual `@p` to verify that we didn't get sent nonsense. If we did, `need` will cause the gate to crash.
267
267
tutorials/hoon/lead-polymorphism.md+5−5
@@ -5,9 +5,9 @@ template = "doc.html"
5aliases = ["/docs/learn/hoon/hoon-tutorial/lead-polymorphism/"]
5aliases = ["/docs/learn/hoon/hoon-tutorial/lead-polymorphism/"]
6+++
6+++
7
7
8−There are four kinds of cores: gold, iron, zinc, and lead. You are able to use core-variance rules to create programs which take other programs as arguments. Which particular rules depends on which kind of core your program needs to complete.
8+There are four kinds of [cores](/docs/glossary/core/): gold, iron, zinc, and lead. You are able to use core-variance rules to create programs which take other programs as arguments. Which particular rules depends on which kind of core your program needs to complete.
9
9
10−Lead cores have opaque payloads. That is, the payload can not be written to or read from. Below is an example of using lead cores. The program produces a list populated by the first 10 elements of `fib`.
10+Lead cores have opaque [payloads](/docs/glossary/payload/). That is, the payload can not be written to or read from. Below is an example of using lead cores. The program produces a list populated by the first 10 elements of `fib`.
11
11
12```hoon
12```hoon
13=< (to-list (take fib 10))
13=< (to-list (take fib 10))
@@ -57,7 +57,7 @@ Lead cores have opaque payloads. That is, the payload can not be written to or r
57--
57--
58```
58```
59
59
60−There are five arms in this core: `stream`, `stream-type`, `to-list`, `take`, and `fib`.
60+There are five [arms](/docs/glossary/arm/) in this core: `stream`, `stream-type`, `to-list`, `take`, and `fib`.
61
61
62
62
63```hoon
63```hoon
@@ -68,11 +68,11 @@ There are five arms in this core: `stream`, `stream-type`, `to-list`, `take`, an
68 ~
68 ~
69```
69```
70
70
71−`stream` is a mold-builder. It's a wet gate that takes one argument, `of`, which is a `mold`, and produces a trap -- a function with no argument.
71+`stream` is a mold-builder. It's a wet gate that takes one argument, `of`, which is a `mold`, and produces a [trap](/docs/glossary/trap/) -- a function with no argument.
72
72
73`$_` is a rune that produces a type from an example; `^?` converts (casts) a core to lead; `|.` forms the trap. So to follow this sequence we read it backwards: we create a trap, convert it to a lead trap (making its payload inaccessible), and then use that lead trap as an example to produce a type from.
73`$_` is a rune that produces a type from an example; `^?` converts (casts) a core to lead; `|.` forms the trap. So to follow this sequence we read it backwards: we create a trap, convert it to a lead trap (making its payload inaccessible), and then use that lead trap as an example to produce a type from.
74
74
75−With the line `^- $@(~ [item=of more=^$])`, the output of the trap will be cast into a new type. `$@` is the rune to describe a data structure that can either be an atom or a cell. The first part describes the atom, which here is going to be `~`. The second part describes a cell, which we define to have the head of type `of` with the face `item`, and a tail with a face of `more`. The expression `^$` is not a rune, but rather a reference to the enclosing wet gate, so the tail of this cell will be of the same type produced by this wet gate.
75+With the line `^- $@(~ [item=of more=^$])`, the output of the trap will be cast into a new type. `$@` is the rune to describe a data structure that can either be an [atom](/docs/glossary/atom/) or a cell. The first part describes the [atom](/docs/glossary/atom/), which here is going to be `~`. The second part describes a cell, which we define to have the head of type `of` with the face `item`, and a tail with a face of `more`. The expression `^$` is not a rune, but rather a reference to the enclosing wet [gate](/docs/glossary/gate/), so the tail of this cell will be of the same type produced by this wet [gate](/docs/glossary/gate/).
76
76
77The final `~` here is used as the type produced when initially calling this wet gate. This is valid because it nests within the type we defined on the previous line.
77The final `~` here is used as the type produced when initially calling this wet gate. This is valid because it nests within the type we defined on the previous line.
78
78
tutorials/hoon/libraries.md+7−7
@@ -5,7 +5,7 @@ template = "doc.html"
5aliases = ["/docs/learn/hoon/hoon-tutorial/libraries/"]
5aliases = ["/docs/learn/hoon/hoon-tutorial/libraries/"]
6+++
6+++
7
7
8−In Hoon, like in other languages, it's often useful to create a library for other code to access. In this example, we look at one example of a library that can be used to represent a deck of 52 playing cards. The core below builds such a library, and can be accessed by programs.
8+In Hoon, like in other languages, it's often useful to create a library for other code to access. In this example, we look at one example of a library that can be used to represent a deck of 52 playing cards. The [core](/docs/glossary/core/) below builds such a library, and can be accessed by programs.
9
9
10```hoon
10```hoon
11|%
11|%
@@ -62,7 +62,7 @@ In Hoon, like in other languages, it's often useful to create a library for othe
62
62
63On the very first line, we create a core with `|%`. This core contains all of our library code, and is closed by the `--` on the final line.
63On the very first line, we create a core with `|%`. This core contains all of our library code, and is closed by the `--` on the final line.
64
64
65−To create three types we're going to need, we use `+$`, which is an arm used to define a type.
65+To create three types we're going to need, we use `+$`, which is an [arm](/docs/glossary/arm/) used to define a type.
66
66
67
67
68```hoon
68```hoon
@@ -91,7 +91,7 @@ One way to get a feel for how a library works is to skim the `++` arm-names befo
91 ==
91 ==
92```
92```
93
93
94−We can see this is a gate that takes a single `@ud` and produces a `suit`.
94+We can see this is a [gate](/docs/glossary/gate/) that takes a single `@ud` and produces a `suit`.
95
95
96The `?+` rune is the rune to switch against a value with a default. The default here is to crash with `!!`. Then we have the four options of 1 through 4, based on the value of `val`, which each resulting in a different suit.
96The `?+` rune is the rune to switch against a value with a default. The default here is to crash with `!!`. Then we have the four options of 1 through 4, based on the value of `val`, which each resulting in a different suit.
97
97
@@ -103,9 +103,9 @@ The `?+` rune is the rune to switch against a value with a default. The default
103 |-
103 |-
104 ?: (gth i 4)
104 ?: (gth i 4)
105 mydeck
105 mydeck
106− =/ j 1
106+ =/ j 2
107 |-
107 |-
108− ?. (lte j 13)
108+ ?. (lte j 14)
109 ^$(i +(i))
109 ^$(i +(i))
110 %= $
110 %= $
111 j +(j)
111 j +(j)
@@ -153,9 +153,9 @@ Next, with `=/ random ~(. og entropy)`, we feed the `og` core the entropy it n
153
153
154`?: =(remaining 1)` checks if have only one card remaining. If that's true, we produce a cell of `shuffled` and the one card left in `unshuffled`. We use the `:_` rune here, so that the "heavier" hoon is at the bottom of the expression.
154`?: =(remaining 1)` checks if have only one card remaining. If that's true, we produce a cell of `shuffled` and the one card left in `unshuffled`. We use the `:_` rune here, so that the "heavier" hoon is at the bottom of the expression.
155
155
156−If the above conditional evaluates to false, we are going to do a little work. `=^` is a rune that pins the head of a pair and changes the leg with a tail. It's useful for interacting with the `og` core arms, as many of them produce a pair of a random numbers and the next state of the core. We're going to put the random number in the subject with the face `index` and change `random` to be the next core.
156+If the above conditional evaluates to false, we are going to do a little work. `=^` is a rune that pins the head of a pair and changes a leg in the subject with the tail. It's useful for interacting with the `og` core arms, as many of them produce a pair of a random numbers and the next state of the core. We're going to put the random number in the subject with the face `index` and change `random` to be the next core.
157
157
158−With completed, we use `%^` to call `$` to recurse back up to `|-` with a few changes.
158+With completed, we use `%=` to call `$` to recurse back up to `|-` with a few changes.
159
159
160`shuffled` gets the `darc` from `unshuffled` at `index` added to the front of it.
160`shuffled` gets the `darc` from `unshuffled` at `index` added to the front of it.
161
161
tutorials/hoon/list-of-numbers.md+13−13
@@ -20,11 +20,11 @@ Below is a simple Hoon program that takes a single number `n` from the user as i
20$(count (add 1 count)) :: 8
20$(count (add 1 count)) :: 8
21```
21```
22
22
23−As we mentioned in the previous lesson, the easiest way to use such a program is to run it as a _generator_. Mount your desk `|mount %` (if you didn't do it before), saving a file in the `/home/gen` directory of your ship and commiting these changes `|commit %home` allows you to run it from your ship's Dojo (command line) as a generator. Save the above code there as `list.hoon`. Now you can run it in the Dojo as so:
23+As we mentioned in the previous lesson, the easiest way to use such a program is to run it as a _generator_. Mount your desk `|mount %` (if you didn't do it before), saving a file in the `/home/gen` directory of your ship and commiting these changes `|commit %home` allows you to run it from your ship's Dojo (command line) as a generator. Save the above code there as `list.hoon`. Now you can run it in the Dojo with the command below (remember, without the `>`):
24
24
25−`~your-ship:> +list 5`
25+`> +list 5`
26
26
27−Try it! You can choose any natural number to put after `+list`, but it can't be zero or blank. The `+` lets the Dojo know that it's looking for a generator with the name that follows. You don't write out the `.hoon` part of the file name when running it in the Dojo.
27+Try it! You can choose any natural number to put after `+list`, but it can't be `0` or blank. The `+` lets the Dojo know that it's looking for a generator with the name that follows. You don't write out the `.hoon` part of the file name when running it in the Dojo.
28
28
29But what do all these squiggly symbols in the program _do_? It probably isn't immediately clear. Let's go through each component of this code.
29But what do all these squiggly symbols in the program _do_? It probably isn't immediately clear. Let's go through each component of this code.
30
30
@@ -42,11 +42,11 @@ In our example program, we use comments with line numbers for convenient referen
42
42
43There's a few things going on in our first line. The first part of it, `|=`, is a kind of **rune**. Runes are the building blocks of all Hoon code, represented as a pair of non-alphanumeric ASCII characters. Runes form expressions; runes are used how keywords are used in other languages. In other words, all computations in Hoon ultimately require runes. Runes and other Hoon expressions are all separated from one another by either two spaces or a line break.
43There's a few things going on in our first line. The first part of it, `|=`, is a kind of **rune**. Runes are the building blocks of all Hoon code, represented as a pair of non-alphanumeric ASCII characters. Runes form expressions; runes are used how keywords are used in other languages. In other words, all computations in Hoon ultimately require runes. Runes and other Hoon expressions are all separated from one another by either two spaces or a line break.
44
44
45−All runes take a fixed number of "children." Children can themselves be runes with children, and Hoon programs work by chaining through these until a value -- not another rune -- is arrived at. For this reason, we very rarely need to close expressions. Keep this scheme in mind when examining Hoon code.
45+All runes take a fixed number of "children". Children can themselves be runes with children, and Hoon programs work by chaining through these until a value -- not another rune -- is arrived at. For this reason, we very rarely need to close expressions. Keep this scheme in mind when examining Hoon code.
46
46
47−The specific purpose of the `|=` rune is to create a **gate**. A gate is what would be called a function in other languages: it takes an input, performs a specified computation, and then produces an output.
47+The specific purpose of the `|=` rune is to create a **gate**. A [gate](/docs/glossary/gate/) is what would be called a function in other languages: it takes an input, performs a specified computation, and then produces an output.
48
48
49−Because we're only on line 1, all we're doing with the gate is creating it, and then specifying what kind of input the gate takes with that rune's first child: `end=@`. The `end` part of our code is simply a name that we give to the user's input so that we can use the number later. `=@` means that we restrict the kind of input that our gate accepts to the **atom** type, or `@` for short. An atom is a natural number.
49+Because we're only on line 1, all we're doing with the gate is creating it, and then specifying what kind of input the gate takes with that rune's first child: `end=@`. The `end` part of our code is simply a name that we give to the user's input so that we can use the number later. `=@` means that we restrict the kind of input that our gate accepts to the **atom** type, or `@` for short. An [atom](/docs/glossary/atom/) is a natural number.
50
50
51Our program is simple, so the _entire program_ is the gate that's being created here. The rest of our lines of code are part of the second child of our gate, and they determine how our gate produces an output.
51Our program is simple, so the _entire program_ is the gate that's being created here. The rest of our lines of code are part of the second child of our gate, and they determine how our gate produces an output.
52
52
@@ -58,7 +58,7 @@ Our program is simple, so the _entire program_ is the gate that's being created
58
58
59This line begins with the `=/` rune, which stores a value with a name and specifies its type. It takes three children.
59This line begins with the `=/` rune, which stores a value with a name and specifies its type. It takes three children.
60
60
61−`count=@` (the first child) stores `1` (the second child) as `count` and as specifies that has the `@` type.
61+`count=@` (the first child) stores `1` (the second child) as `count` and specifies that it has the `@` type.
62
62
63We're using `count` to keep track of what numbers we're including in the list we're building. We'll use it later in the program.
63We're using `count` to keep track of what numbers we're including in the list we're building. We'll use it later in the program.
64
64
@@ -87,11 +87,11 @@ In this case, the rune specifies that our gate's output must be `(list @)` -- th
87 ~
87 ~
88```
88```
89
89
90−`?:` is a rune that evaluates whether its first child is true or false. If that child is true, the program branches to the second child. If it's false, it branches to the third child. `?:` takes three children.
90+`?:` is a rune that evaluates whether its first child is `true` or `false`. If that child is `true`, the program branches to the second child. If it's `false`, it branches to the third child. `?:` takes three children.
91
91
92−`=(end count)` checks if the user's input equals to the `count` value that we're incrementing to build the list. If these values are equal, we want to end the program, because our list has been built out to where it needs to be. Note that this expression is, in fact, a rune expression, just written a different way than you've seen so far. `=(end count)` is an _irregular form_ of `.= end count`, different in looks but identical in operation. `.=` is a rune that checks for the equality of its two children, and produces a "true" or "false" based on what it finds.
92+`=(end count)` checks if the user's input equals to the `count` value that we're incrementing to build the list. If these values are equal, we want to end the program, because our list has been built out to where it needs to be. Note that this expression is, in fact, a rune expression, just written a different way than you've seen so far. `=(end count)` is an _irregular form_ of `.= end count`, different in looks but identical in operation. `.=` is a rune that checks for the equality of its two children, and produces a `true` or `false` based on what it finds.
93
93
94−`~` simply represents the "null" value. The program branches here if on line 5 it finds that `end` equals `count`. Lists in Hoon always end with `~`, so we need this to be the last thing we put in our list.
94+`~` simply represents the `null` value. The program branches here if on line 5 it finds that `end` equals `count`. Lists in Hoon always end with `~`, so we need this to be the last thing we put in our list.
95
95
96## Line 7
96## Line 7
97
97
@@ -105,15 +105,15 @@ In our case, `:- count` creates a cell out of whatever value is stored in `coun
105$(count (add 1 count))
105$(count (add 1 count))
106```
106```
107
107
108−The above code is, once again, a compact way of writing a rune expression. All you need to know is that this line of code restarts the program at `|-`, except with the value stored in `count` incremented by 1. The construction of `(count (add 1 count))` tells the computer, "replace the value of count with count+1".
108+The above code is, once again, a compact way of writing a rune expression. All you need to know is that this line of code restarts the program at `|-`, except with the value stored in `count` incremented by `1`. The construction of `(count (add 1 count))` tells the computer, "replace the value of `count` with `count+1`".
109
109
110−You'll notice that we use an unfamiliar word here: `add`. Unlike `count` and `end`, `add` is not defined anywhere in our program. That's because it's a gate that's predefined in the Hoon **standard library**. The standard library is filled with pre-defined gates that are generally useful, and these gates can be used just like something that you defined in your own program. You can see this gate, and other mathematical operators, in [section 1a](@/docs/reference/library/1a.md) of the standard-library documentation.
110+You'll notice that we use an unfamiliar word here: `add`. Unlike `count` and `end`, `add` is not defined anywhere in our program. That's because it's a gate that's predefined in the Hoon **standard library**. The standard library is filled with pre-defined gates that are generally useful, and these gates can be used just like something that you defined in your own program. You can see this gate, and other mathematical operators, in [section 1a](@/docs/reference/library/1a.md) of the standard library documentation.
111
111
112## Explanation
112## Explanation
113
113
114If you aren't clear on how the program is building the list, that's okay.
114If you aren't clear on how the program is building the list, that's okay.
115
115
116−Our program works by having each iteration of the list creating a cell. In each of these cells, the head -- the cell's first position -- is filled with the current-iteration value of `count`. The tail of the cell, its second position, is filled with _the product of a new iteration of our code_ that starts at `|-`. This iteration will itself create another cell, the head of which will be filled by the incremented value of `count`, and the tail of which will start another iteration. This process continues until `?:` branches to `~` (null). When that happens, the list is terminated and the program doesn't have anything else to do, so it ends. So, a built-out list of nested cells can be visualized like this:
116+Our program works by having each iteration of the list creating a cell. In each of these cells, the head -- the cell's first position -- is filled with the current-iteration value of `count`. The tail of the cell, its second position, is filled with _the product of a new iteration of our code_ that starts at `|-`. This iteration will itself create another cell, the head of which will be filled by the incremented value of `count`, and the tail of which will start another iteration. This process continues until `?:` branches to `~` (`null`). When that happens, the list is terminated and the program doesn't have anything else to do, so it ends. So, a built-out list of nested cells can be visualized like this:
117
117
118```
118```
119 [1 [2 [3 [4 ~]]]]
119 [1 [2 [3 [4 ~]]]]
tutorials/hoon/lists.md+55−38
@@ -5,15 +5,13 @@ template = "doc.html"
5aliases = ["/docs/learn/hoon/hoon-tutorial/lists/"]
5aliases = ["/docs/learn/hoon/hoon-tutorial/lists/"]
6+++
6+++
7
7
8−# Lists
8+A **list** is a type of [noun](/docs/glossary/noun/) that you'll frequently encounter when reading and writing Hoon. A list can be thought of as an ordered arrangement of zero or more elements terminated by a `~` (null).
9
9
10−A **list** is a type of noun that you'll frequently encounter when reading and writing Hoon. A list can be thought of as an ordered arrangement of zero or more elements terminated by a `~` (null).
11−
12−So a list can be either null or non-null. When the list contains only `~` and no items, it's the null list. Most lists are, however, non-null lists, which have items preceding the `~`. Non-null lists, called _lests_, are cells in which the head is the first list item, and the tail is the rest of the list. The tail is itself a list, and if such a list is also non-null, the head of this sub-list is the second item in the greater list, and so on. To illustrate, let's look at a list `[1 2 3 4 ~]` with the cell-delineating brackets left in:
10+So a list can be either null or non-null. When the list contains only `~` and no items, it's the null list. Most lists are, however, non-null lists, which have items preceding the `~`. Non-null lists, called _lests_, are cells in which the head is the first list item, and the tail is the rest of the list. The tail is itself a list, and if such a list is also non-null, the head of this sublist is the second item in the greater list, and so on. To illustrate, let's look at a list `[1 2 3 4 ~]` with the cell-delineating brackets left in:
13
11
14`[1 [2 [3 [4 ~]]]]`
12`[1 [2 [3 [4 ~]]]]`
15
13
16−It's easy to see where the heads are and where the nesting tails are. The head of the above list is the atom `1` and the tail is the list `[2 [3 [4 ~]]]`, (or `[2 3 4 ~]`). Recall that whenever cell brackets are omitted so that visually there appears to be more than two child nouns, it is implicitly understood that the right-most nouns constitute a cell.
14+It's easy to see where the heads are and where the nesting tails are. The head of the above list is the [atom](/docs/glossary/atom/) `1` and the tail is the list `[2 [3 [4 ~]]]`, (or `[2 3 4 ~]`). Recall that whenever cell brackets are omitted so that visually there appears to be more than two child nouns, it is implicitly understood that the right-most nouns constitute a cell.
17
15
18To make a list, let's cast nouns to the `(list @)` ("list of atoms") type.
16To make a list, let's cast nouns to the `(list @)` ("list of atoms") type.
19
17
@@ -44,7 +42,7 @@ Let's make a list whose items are of the `@t` string type:
44<|Urbit will rescue the internet|>
42<|Urbit will rescue the internet|>
45```
43```
46
44
47−The head of a list has the face `i` and the tail has the face `t`. (For the sake of neatness, these faces aren't shown by the Hoon pretty printer.) To use the `i` and `t` faces of a list, you must first prove that the list is non-null by using the conditional family of runes, `?`:
45+The head of a list has the face `i` and the tail has the face `t`. (For the sake of neatness, these faces aren't shown by the Hoon pretty printer.) To use the `i` and `t` faces of a list, you must first prove that the list is non-null by using the conditional family of runes, `?`:
48
46
49```
47```
50> =>(b=`(list @)`[1 2 3 4 5 ~] i.b)
48> =>(b=`(list @)`[1 2 3 4 5 ~] i.b)
@@ -58,15 +56,15 @@ find-fork-d
58~[2 3 4 5]
56~[2 3 4 5]
59```
57```
60
58
61−It's important to note that performing tests like `?~ mylist` will actually transform `mylist` into a `lest`, a non-null list. Because `lest` is a different type than `list`, performing such tests can come back to bite you later in non-obvious ways when you try to use some standard library functions meant for `list`s.
59+It's important to note that performing tests like `?~ mylist` will actually transform `mylist` into a `lest`, a non-null list. Because `lest` is a different type than `list`, performing such tests can come back to bite you later in non-obvious ways when you try to use some standard library functions meant for lists.
62
60
63−You can construct lists of any type. `(list @)` indicates a list of atoms, `(list ^)` indicates a list of cells, `(list [@ ?])` indicates a list of cells whose head is an atom and whose tail is a flag, etc.
61+You can construct lists of any type. `(list @)` indicates a list of atoms, `(list ^)` indicates a list of cells, `(list [@ ?])` indicates a list of cells whose head is an atom and whose tail is a flag, etc.
64
62
65−## Tapes
63+## Tapes and Cords
66
64
67−While a list can be of any type, there are some special types of lists that are built into Hoon. The tape is the most common example.
65+While a list can be of any type, there are some special types of lists that are built into Hoon. The `tape` is the most common example.
68
66
69−Hoon has two kinds of strings: cords and tapes. Cords are atoms with aura `@t`, and they're pretty-printed between `''` marks.
67+Hoon has two kinds of strings: cords and tapes. Cords are atoms with aura `@t`, and they're pretty-printed between `''` marks.
70
68
71```
69```
72> 'this is a cord'
70> 'this is a cord'
@@ -98,9 +96,9 @@ You can also use the words `cord` and `tape` for casting:
98
96
99## List Functions in the Hoon Standard Library
97## List Functions in the Hoon Standard Library
100
98
101−Lists are a commonly used data structure. Accordingly, there are several functions in the [Hoon standard library](/docs/reference/library/) intended to make lists easier to use.
99+Lists are a commonly used data structure. Accordingly, there are several functions in the [Hoon standard library](/docs/reference/library/) intended to make lists easier to use.
102
100
103−For a complete list of these functions, check out the standard library reference for lists [here](/docs/reference/library/2b/). Here we'll look at a few of these functions.
101+For a complete list of these functions, check out the standard library reference for lists [here](/docs/reference/library/2b/). Here we'll look at a few of these functions.
104
102
105### `flop`
103### `flop`
106
104
@@ -119,18 +117,18 @@ The `flop` function takes a list and returns it in reverse order:
119
117
120#### `flop` Exercise 1.5a
118#### `flop` Exercise 1.5a
121
119
122−Without using `flop`, write a gate that takes a `(list @)` and returns it in reverse order. There is a solution at the bottom of this lesson.
120+Without using `flop`, write a [gate](/docs/glossary/gate/) that takes a `(list @)` and returns it in reverse order. There is a solution at the bottom of this lesson.
123
121
124### `sort`
122### `sort`
125
123
126−The `sort` function uses the 'quicksort' algorithm to sort a list. It takes a list to sort and a gate that serves as a comparator. For example, if you want to sort the list `~[37 62 49 921 123]` from least to greatest, you would pass that list along with the `lth` gate (for 'less than'):
124+The `sort` function uses the "quicksort" algorithm to sort a list. It takes a list to sort and a gate that serves as a comparator. For example, if you want to sort the list `~[37 62 49 921 123]` from least to greatest, you would pass that list along with the `lth` gate (for "less than"):
127
125
128```
126```
129> (sort ~[37 62 49 921 123] lth)
127> (sort ~[37 62 49 921 123] lth)
130~[37 49 62 123 921]
128~[37 49 62 123 921]
131```
129```
132
130
133−To sort the list from greatest to least, use the `gth` gate ('greater than') as the basis of comparison instead:
131+To sort the list from greatest to least, use the `gth` gate ("greater than") as the basis of comparison instead:
134
132
135```
133```
136> (sort ~[37 62 49 921 123] gth)
134> (sort ~[37 62 49 921 123] gth)
@@ -160,7 +158,7 @@ The `weld` function takes two lists of the same type and concatenates them:
160
158
161#### `weld` Exercise 1.5b
159#### `weld` Exercise 1.5b
162
160
163−Without using `weld`, write a gate that takes a `[(list @) (list @)]` who product is the concatenation of these two lists. There is a solution at the bottom of this lesson.
161+Without using `weld`, write a gate that takes a `[(list @) (list @)]` of which the product is the concatenation of these two lists. There is a solution at the bottom of this lesson.
164
162
165### `snag`
163### `snag`
166
164
@@ -186,7 +184,7 @@ The `snag` function takes an atom `n` and a list, and returns the `n`th item of
186'!'
184'!'
187```
185```
188
186
189−Note: there is currently a type system issue that causes some of these functions to fail when passed a list `b` after some type inference has been performed on `b`. For an illustration of the bug, let's set `b` to be a `(list @)` of `~[11 22 33 44]` in the dojo:
187+Note: there is currently a type system issue that causes some of these functions to fail when passed a list `b` after some type inference has been performed on `b`. For an illustration of the bug, let's set `b` to be a `(list @)` of `~[11 22 33 44]` in the Dojo:
190
188
191```
189```
192> =b `(list @)`~[11 22 33 44]
190> =b `(list @)`~[11 22 33 44]
@@ -213,7 +211,7 @@ You can cast `b` to `(list)` to work around this:
213
211
214#### `snag` Exercise 1.5c
212#### `snag` Exercise 1.5c
215
213
216−Without using `snag`, write a gate that returns the `n`th item of a list. There is a solution at the bottom of this lesson.
214+Without using `snag`, write a gate that returns the `n`th item of a list. There is a solution at the bottom of this lesson.
217
215
218### `oust`
216### `oust`
219
217
@@ -251,7 +249,7 @@ Without using `lent`, write a gate that takes a list and returns the number of i
251
249
252### `roll`
250### `roll`
253
251
254−The `roll` function takes a list and a gate, and accumulates a value of the list items using that gate. For example, if you want to add or multiply all the items in a list of atoms, you would use `roll`:
252+The `roll` function takes a list and a gate, and accumulates a value of the list items using that gate. For example, if you want to add or multiply all the items in a list of atoms, you would use `roll`:
255
253
256```
254```
257> (roll `(list @)`~[11 22 33 44 55] add)
255> (roll `(list @)`~[11 22 33 44 55] add)
@@ -263,7 +261,7 @@ The `roll` function takes a list and a gate, and accumulates a value of the list
263
261
264### `turn`
262### `turn`
265
263
266−The `turn` function takes a list and a gate, and returns a list of the products of applying each item of the input list to the gate. For example, to add `1` to each item in a list of atoms:
264+The `turn` function takes a list and a gate, and returns a list of the products of applying each item of the input list to the gate. For example, to add `1` to each item in a list of atoms:
267
265
268```
266```
269> (turn `(list @)`~[11 22 33 44] |=(a=@ +(a)))
267> (turn `(list @)`~[11 22 33 44] |=(a=@ +(a)))
@@ -279,7 +277,7 @@ Or to double each item in a list of atoms:
279
277
280`turn` is Hoon's version of Haskell's `map`.
278`turn` is Hoon's version of Haskell's `map`.
281
279
282−We can rewrite the Caesar cipher program using `turn`:
280+We can rewrite the [Caesar cipher](https://en.wikipedia.org/wiki/Caesar_cipher) program using `turn`:
283
281
284```hoon
282```hoon
285|= [a=@ b=tape]
283|= [a=@ b=tape]
@@ -301,49 +299,60 @@ c
301
299
302## Using `hoon.hoon` to Learn Hoon
300## Using `hoon.hoon` to Learn Hoon
303
301
304−The Hoon standard library and compiler are written in Hoon. At this point, you know enough Hoon to be able to explore the standard library portions of `hoon.hoon` and find more functions relevant to lists. [Look around in section `2b` (and elsewhere)](/docs/reference/library/2b/)
302+The Hoon standard library and compiler are written in Hoon. At this point, you know enough Hoon to be able to explore the standard library portions of `hoon.hoon` and find more functions relevant to lists. Look around in [section 2b](/docs/reference/library/2b/) (and elsewhere).
305
303
306## Additional Exercises
304## Additional Exercises
307
305
308#### Exercise 1.5e
306#### Exercise 1.5e
307+
309−Without entering these expressions into the dojo, what are the products of the following expressions?
308+Without entering these expressions into the Dojo, what are the products of the following expressions?
309+
310```
310```
311> (lent ~[1 2 3 4 5])
311> (lent ~[1 2 3 4 5])
312```
312```
313+
313```
314```
314> (lent ~[~[1 2] ~[1 2 3] ~[2 3 4]])
315> (lent ~[~[1 2] ~[1 2 3] ~[2 3 4]])
315```
316```
317+
316```
318```
317> (lent ~[1 2 (weld ~[1 2 3] ~[4 5 6])])
319> (lent ~[1 2 (weld ~[1 2 3] ~[4 5 6])])
318```
320```
319
321
320#### Exercise 1.5f
322#### Exercise 1.5f
323+
321First, bind these faces.
324First, bind these faces.
325+
322```
326```
323> =b ~['moon' 'planet' 'star' 'galaxy']
327> =b ~['moon' 'planet' 'star' 'galaxy']
324> =c ~[1 2 3]
328> =c ~[1 2 3]
325```
329```
330+
326−Then determine whether the following dojo expressions are valid, and if so, what they evaluate to.
331+Then determine whether the following Dojo expressions are valid, and if so, what they evaluate to.
332+
327```
333```
328> (weld b b)
334> (weld b b)
329```
335```
336+
330```
337```
331> (weld b c)
338> (weld b c)
332```
339```
340+
333```
341```
334> (lent (weld b c))
342> (lent (weld b c))
335```
343```
344+
336```
345```
337> (add (lent b) (lent c))
346> (add (lent b) (lent c))
338```
347```
339
348
340#### Exercise 1.5g
349#### Exercise 1.5g
341−Write a gate that takes in a list `a` and returns `%.y` if `a` is a palindrome and `%.n` otherwise. You may make use of the `flop` function.
342
350
351+Write a gate that takes in a list `a` and returns `%.y` if `a` is a palindrome and `%.n` otherwise. You may make use of the `flop` function.
343
352
344## Exercise Solutions
353## Exercise Solutions
345
354
346−#### `flop` 1.5a
355+#### 1.5a `flop`
347
356
348```hoon
357```hoon
349:: flop.hoon
358:: flop.hoon
@@ -355,14 +364,15 @@ Write a gate that takes in a list `a` and returns `%.y` if `a` is a palindrome a
355$(b [i.a b], a t.a)
364$(b [i.a b], a t.a)
356```
365```
357
366
358−Run in dojo:
367+Run in Dojo:
359
368
360```
369```
361> +flop ~[11 22 33 44]
370> +flop ~[11 22 33 44]
362~[44 33 22 11]
371~[44 33 22 11]
363```
372```
364
373
365−#### `weld` 1.5b
374+#### 1.5b `weld`
375+
366```hoon
376```hoon
367:: weld.hoon
377:: weld.hoon
368::
378::
@@ -372,14 +382,14 @@ Run in dojo:
372[i.a $(a t.a)]
382[i.a $(a t.a)]
373```
383```
374
384
375−Run in dojo:
385+Run in Dojo:
376
386
377```
387```
378> +weld [~[1 2 3] ~[3 4 5 6]]
388> +weld [~[1 2 3] ~[3 4 5 6]]
379~[1 2 3 3 4 5 6]
389~[1 2 3 3 4 5 6]
380```
390```
381
391
382−#### `snag` 1.5c
392+#### 1.5c `snag`
383
393
384```hoon
394```hoon
385:: snag.hoon
395:: snag.hoon
@@ -390,7 +400,7 @@ Run in dojo:
390$(a (dec a), b t.b)
400$(a (dec a), b t.b)
391```
401```
392
402
393−Run in dojo:
403+Run in Dojo:
394
404
395```
405```
396> +snag [0 ~[11 22 33 44]]
406> +snag [0 ~[11 22 33 44]]
@@ -400,7 +410,7 @@ Run in dojo:
40033
41033
401```
411```
402
412
403−#### `lent` 1.5d
413+#### 1.5d `lent`
404
414
405```hoon
415```hoon
406:: lent.hoon
416:: lent.hoon
@@ -413,7 +423,7 @@ Run in dojo:
413$(a t.a, b +(b))
423$(a t.a, b +(b))
414```
424```
415
425
416−Run in dojo:
426+Run in Dojo:
417
427
418```
428```
419> +lent ~[1 2 3 4 5]
429> +lent ~[1 2 3 4 5]
@@ -424,7 +434,7 @@ Run in dojo:
424
434
425#### 1.5e
435#### 1.5e
426
436
427−Run in dojo:
437+Run in Dojo:
428
438
429```
439```
430> (lent ~[1 2 3 4 5])
440> (lent ~[1 2 3 4 5])
@@ -437,27 +447,34 @@ Run in dojo:
437
447
438#### 1.5f
448#### 1.5f
439
449
440−Run in dojo:
450+Run in Dojo:
441
451
442```
452```
443> (weld b b)
453> (weld b b)
444<|moon planet star galaxy moon planet star galaxy|>
454<|moon planet star galaxy moon planet star galaxy|>
445```
455```
456+
446```
457```
447> (weld b c)
458> (weld b c)
448```
459```
460+
449This will not run because `weld` expects the elements of both lists to be of the same type.
461This will not run because `weld` expects the elements of both lists to be of the same type.
462+
450```
463```
451> (lent (weld b c))
464> (lent (weld b c))
452```
465```
466+
453This also fails for the same reason, but it is important to note that in some languages that are more lazily evaluated, such an expression would still work since it would only look at the length of `b` and `c` and not worry about what the elements were. In that case, it would return `7`.
467This also fails for the same reason, but it is important to note that in some languages that are more lazily evaluated, such an expression would still work since it would only look at the length of `b` and `c` and not worry about what the elements were. In that case, it would return `7`.
468+
454```
469```
455> (add (lent b) (lent c))
470> (add (lent b) (lent c))
4567
4717
457```
472```
473+
458We see here the correct way to find the sum of the length of two lists of unknown type.
474We see here the correct way to find the sum of the length of two lists of unknown type.
459
475
460#### 1.5g
476#### 1.5g
477+
461```hoon
478```hoon
462:: palindrome.hoon
479:: palindrome.hoon
463::
480::
@@ -465,11 +482,11 @@ We see here the correct way to find the sum of the length of two lists of unknow
465=(a (flop a))
482=(a (flop a))
466```
483```
467
484
468−Run in dojo:
485+Run in Dojo:
469
486
470```
487```
471> +palindrome "urbit"
488> +palindrome "urbit"
472%.n
489%.n
473> +palindrome "racecar"
490> +palindrome "racecar"
474%.y
491%.y
475−```
492+```
tutorials/hoon/molds.md+2−2
@@ -5,7 +5,7 @@ template = "doc.html"
5aliases = ["/docs/learn/hoon/hoon-tutorial/molds/"]
5aliases = ["/docs/learn/hoon/hoon-tutorial/molds/"]
6+++
6+++
7
7
8−A mold is a function that coerces a noun to a type or crashes.
8+A mold is a function that coerces a [noun](/docs/glossary/noun/) to a type or crashes.
9
9
10Let's take some examples from `hoon.hoon`. `|$` is a new rune as of the writing of this document so you may see this spelled in slightly different way if you don't have the latest version of `hoon.hoon`. `|$` is the mold builder rune which takes a list of molds and produces a mold.
10Let's take some examples from `hoon.hoon`. `|$` is a new rune as of the writing of this document so you may see this spelled in slightly different way if you don't have the latest version of `hoon.hoon`. `|$` is the mold builder rune which takes a list of molds and produces a mold.
11
11
@@ -32,7 +32,7 @@ Here is a very simple mold builder. It takes two molds and produces a mold that
32 |$ [item]
32 |$ [item]
33 $@(~ [i=item t=(list item)])
33 $@(~ [i=item t=(list item)])
34```
34```
35−Here is a mold builder you've used previously. `$@` is a rune that will match the first thing if its sample is an atom and the second if the sample is a cell. You should be familiar at this point that a `list` is either `~` or a pair of an item and a list of item.
35+Here is a mold builder you've used previously. `$@` is a rune that will match the first thing if its sample is an [atom](/docs/glossary/atom/) and the second if the sample is a cell. You should be familiar at this point that a `list` is either `~` or a pair of an item and a list of item.
36
36
37
37
38```hoon
38```hoon
tutorials/hoon/nouns.md+52−45
@@ -5,11 +5,11 @@ template = "doc.html"
5aliases = ["/docs/learn/hoon/hoon-tutorial/nouns/"]
5aliases = ["/docs/learn/hoon/hoon-tutorial/nouns/"]
6+++
6+++
7
7
8−In Urbit, every piece of data is a noun. In order to understand Hoon, one must first understand nouns.
8+In Urbit, every piece of data is a [noun](/docs/glossary/noun/). In order to understand Hoon, one must first understand nouns.
9
9
10## Noun Definition
10## Noun Definition
11
11
12−A **noun** is either an atom or a cell. An **atom** is a natural number ("unsigned integer" in computer lingo) of any size, including zero. A **cell** is an [ordered pair](https://en.wikipedia.org/wiki/Ordered_pair) of nouns, usually indicated with square brackets around the nouns in question; i.e., `[a b]`, where `a` and `b` are nouns.
12+A **noun** is either an [atom](/docs/glossary/atom/) or a cell. An **atom** is a natural number ("unsigned integer" in computer lingo) of any size, including zero. A **cell** is an [ordered pair](https://en.wikipedia.org/wiki/Ordered_pair) of nouns, usually indicated with square brackets around the nouns in question; i.e., `[a b]`, where `a` and `b` are nouns.
13
13
14Here are some atoms:
14Here are some atoms:
15
15
@@ -28,7 +28,7 @@ All of the above are nouns.
28
28
29### Nouns as Binary Trees
29### Nouns as Binary Trees
30
30
31−A [binary tree](https://en.wikipedia.org/wiki/Binary_tree) has a single base node, and each node of the tree may have up to two child nodes (but it need not have any). A node without children is a 'leaf'. You can think of a noun as a binary tree whose leaves are atoms, i.e., unsigned integers. All non-leaf nodes are cells. To visualize this, consider the following representation of the noun: `[12 [17 45]]`:
31+A [binary tree](https://en.wikipedia.org/wiki/Binary_tree) has a single base node, and each node of the tree may have up to two child nodes (but it need not have any). A node without children is a "leaf". You can think of a noun as a binary tree whose leaves are atoms, i.e., unsigned integers. All non-leaf nodes are cells. To visualize this, consider the following representation of the noun: `[12 [17 45]]`:
32
32
33```
33```
34[12 [17 45]]
34[12 [17 45]]
@@ -39,7 +39,7 @@ A [binary tree](https://en.wikipedia.org/wiki/Binary_tree) has a single base nod
39 17 45
39 17 45
40```
40```
41
41
42−Each number is an atom; each dot is a cell. Let's look at another example, this time of `[[7 13] [87 65]]`, with the cell nodes shown explicitly:
42+Each number is an atom; each dot is a cell. Let's look at another example, this time of `[[7 13] [87 65]]`, with the cell nodes shown explicitly:
43
43
44```
44```
45 [[7 13] [87 65]]
45 [[7 13] [87 65]]
@@ -55,9 +55,9 @@ An atom is a trivial tree of just one node; e.g., `17`.
55
55
56## Atoms
56## Atoms
57
57
58−Atoms are unsigned integers. These are often represented by the dojo as unsigned integers in decimal notation, e.g., `17`.
58+Atoms are unsigned integers. These are often represented by the Dojo as unsigned integers in decimal notation, e.g., `17`.
59
59
60−To be sure we understand Hoon's atom notation, let's enter some atoms into the dojo:
60+To be sure we understand Hoon's atom notation, let's enter some atoms into the Dojo:
61
61
62```
62```
63> 3
63> 3
@@ -84,9 +84,9 @@ Can we add another zero?
84> 320
84> 320
85```
85```
86
86
87−It didn't work! When you tried to type that next zero and turn `320` into `3200`, the dojo actually _deleted the `0` and beeped at you_.
87+It didn't work! When you tried to type that next zero and turn `320` into `3200`, the Dojo actually _deleted the `0` and beeped at you_.
88
88
89−Isn't an atom an unsigned integer of any size? It is. But the way to represent the four-digit number `3200` is actually `3.200`:
89+Isn't an atom an unsigned integer of any size? It is. But the way to represent the four-digit number `3200` is actually `3.200`:
90
90
91```
91```
92> 3.200
92> 3.200
@@ -98,21 +98,21 @@ Isn't an atom an unsigned integer of any size? It is. But the way to represent
98
98
99Just think of it as "3,200", written the German way with a dot.
99Just think of it as "3,200", written the German way with a dot.
100
100
101−Why? Long numbers are difficult to read. We know this, so we group digits in threes. For some reason most programming languages don't use this marvelous innovation. Hoon does.
101+Why? Long numbers are difficult to read. We know this, so we group digits in threes. For some reason, most programming languages don't use this marvelous innovation. Hoon does.
102
102
103−English notation for decimals is more common than German notation. Unfortunately, dots are URL-safe and commas aren't. For reasons to be discussed in a later lesson, it's nice to have a regular syntax for atoms that's URL-safe.
103+English notation for decimals is more common than German notation. Unfortunately, dots are URL-safe and commas aren't. For reasons to be discussed in a later lesson, it's nice to have a regular syntax for atoms that's URL-safe.
104
104
105−As for why the dojo deleted your zero: it parses the command line as you type, and rejects any characters after the parser stops. This prevents you from entering commands or expressions that aren't well-formed.
105+As for why the Dojo deleted your zero: it parses the command line as you type, and rejects any characters after the parser stops. This prevents you from entering commands or expressions that aren't well-formed.
106
106
107### Atom Auras
107### Atom Auras
108
108
109−Atoms are nothing more than unsigned integers -- natural numbers -- but it's often useful to represent an atom in a different way. This is done with an **aura**. The aura of an atom is type meta-data used by Hoon to determine how to interpret that atom. It answers the question: What type of information is this atom?
109+Atoms are nothing more than unsigned integers -- natural numbers -- but it's often useful to represent an atom in a different way. This is done with an **aura**. The aura of an atom is type meta-data used by Hoon to determine how to interpret that atom. It answers the question: What type of information is this atom?
110
110
111−We use auras because data isn't always represented as a positive decimal number. Sometimes we want to represent data as binary, as text, or as a negative number. Auras allow us to to use such types of data _without changing the underlying atom_.
111+We use auras because data isn't always represented as a positive decimal number. Sometimes we want to represent data as binary, as text, or as a negative number. Auras allow us to use such types of data _without changing the underlying atom_.
112
112
113−We won't fully explain auras and their various uses yet. Auras will be covered more comprehensively in a later lesson. For now let's just look at the various kinds of [literal syntax](https://en.wikipedia.org/wiki/Literal_%28computer_programming%29) associated with a few atom auras.
113+We won't fully explain auras and their various uses yet. Auras will be covered more comprehensively in a later lesson. For now let's just look at the various kinds of [literal syntax](https://en.wikipedia.org/wiki/Literal_%28computer_programming%29) associated with a few atom auras.
114
114
115−In computer science, a 'literal' is an expression that represents and evaluates to a fixed value. The default syntax of an atom literal is the German-style decimal notation, as seen above. Let's look at some other atom literal syntaxes: unsigned binary, unsigned hexadecimal, signed decimal, signed binary and hexadecimal.
115+In computer science, a "literal" is an expression that represents and evaluates to a fixed value. The default syntax of an atom literal is the German-style decimal notation, as seen above. Let's look at some other atom literal syntaxes: unsigned binary, unsigned hexadecimal, signed decimal, signed binary, and signed hexadecimal.
116
116
117```
117```
118> 0b1001
118> 0b1001
@@ -140,7 +140,7 @@ In computer science, a 'literal' is an expression that represents and evaluates
140-0x9d
140-0x9d
141```
141```
142
142
143−All of the above are atoms. The underlying noun of each is just an unsigned integer, but each is written in a special syntax indicating to Hoon that the atom is to be represented in a different way. To see their values in the default atom notation, you can tell Hoon to throw away the aura information. Do this by preceding each expression above with `` `@` ``.
143+All of the above are atoms. The underlying noun of each is just an unsigned integer, but each is written in a special syntax indicating to Hoon that the atom is to be represented in a different way. To see their values in the default atom notation, you can tell Hoon to throw away the aura information. Do this by preceding each expression above with `` `@` ``.
144
144
145```
145```
146> `@`0b1001
146> `@`0b1001
@@ -168,7 +168,7 @@ All of the above are atoms. The underlying noun of each is just an unsigned int
168313
168313
169```
169```
170
170
171−The `` `@` `` syntax is used to 'cast' a value to a raw atom, i.e., an atom without an aura. Don't worry about exactly what `` `@` `` means just yet. Casts will be explained in more detail in a later lesson. For now all you need to know is that a cast doesn't change the underlying value of the noun; it's used here only to change how the value is printed in the dojo output.
171+The `` `@` `` syntax is used to "cast" a value to a raw atom, i.e., an atom without an aura. Don't worry about exactly what `` `@` `` means just yet. Casts will be explained in more detail in a later lesson. For now all you need to know is that a cast doesn't change the underlying value of the noun; it's used here only to change how the value is printed in the Dojo output.
172
172
173#### Identities, Cords, and Terms
173#### Identities, Cords, and Terms
174
174
@@ -194,7 +194,7 @@ Urbit identities such as `~zod` and `~sorreg-namtyv` are also atoms, but of the
194~sorreg-namtyv
194~sorreg-namtyv
195```
195```
196
196
197−Hoon permits the use of atoms as strings. Strings that are encoded as atoms are called **cords**. Cords are of the aura `@t`. The literal syntax of a cord is text inside a pair of single-quotes, e.g., `'Hello world!'`.
197+Hoon permits the use of atoms as strings. Strings that are encoded as atoms are called **cords**. Cords are of the aura `@t`. The literal syntax of a cord is text inside a pair of single-quotes, e.g., `'Hello world!'`.
198
198
199```
199```
200> 'Howdy!'
200> 'Howdy!'
@@ -210,7 +210,7 @@ Hoon permits the use of atoms as strings. Strings that are encoded as atoms are
21010.334.410.032.606.748.633.331.426.632
21010.334.410.032.606.748.633.331.426.632
211```
211```
212
212
213−Hoon also has **terms**, of the aura `@tas`. Terms are constant values that are used to tag data using the type system. These are strings preceded with a `%` and made up of lower-case letters, numbers, and hyphens, i.e., 'kebab case'. The first character after the `%` must be a letter. For example, `%a`, `%hello`, `%this-is-kebab-case123`.
213+Hoon also has **terms**, of the aura `@tas`. Terms are constant values that are used to tag data using the type system. These are strings preceded with a `%` and made up of lowercase letters, numbers, and hyphens, i.e., "kebab case". The first character after the `%` must be a letter. For example, `%a`, `%hello`, `%this-is-kebab-case123`.
214
214
215```
215```
216> %howdy
216> %howdy
@@ -281,20 +281,20 @@ You can force Hoon to interpret an atom differently by using the aura symbols in
2810x9d
2810x9d
282```
282```
283
283
284−The atoms in the examples above are all exactly the same value. Only they're interpreted and printed differently, depending on the aura.
284+The atoms in the examples above are all exactly the same value. Only they're interpreted and printed differently, depending on the aura.
285
285
286You'll learn more about atoms and auras in [Lesson 2.1](@docs/tutorials/hoon/atoms-auras-and-simple-cell-types.md).
286You'll learn more about atoms and auras in [Lesson 2.1](@docs/tutorials/hoon/atoms-auras-and-simple-cell-types.md).
287
287
288## Cells
288## Cells
289
289
290−There's not much mystery about cells. The left of a cell is called the **head**, and the right is called the **tail**. Cells are typically represented in Hoon with square brackets around a pair of nouns.
290+There's not much mystery about cells. The left of a cell is called the **head**, and the right is called the **tail**. Cells are typically represented in Hoon with square brackets around a pair of nouns.
291
291
292```
292```
293> [32 320]
293> [32 320]
294[32 320]
294[32 320]
295```
295```
296
296
297−In this cell `32` is the head and `320` is the tail. Cells can contain cells, and atoms of other auras as well:
297+In this cell `32` is the head and `320` is the tail. Cells can contain cells, and atoms of other auras as well:
298
298
299```
299```
300> [%hello 'world!']
300> [%hello 'world!']
@@ -304,7 +304,7 @@ In this cell `32` is the head and `320` is the tail. Cells can contain cells, a
304[[%in 0xa] 'cell']
304[[%in 0xa] 'cell']
305```
305```
306
306
307−I said there isn't _much_ mystery about cells, but there is a little. So far whenever we've entered a cell into the dojo, it not only returned the same cell; the cell was printed in the same way it was entered. This doesn't always happen. The dojo is obligated to evaluate the input and return the correct answer, but it doesn't have to show the result in exactly the same way:
307+I said there isn't _much_ mystery about cells, but there is a little. So far whenever we've entered a cell into the Dojo, it not only returned the same cell; the cell was printed in the same way it was entered. This doesn't always happen. The Dojo is obligated to evaluate the input and return the correct answer, but it doesn't have to show the result in exactly the same way:
308
308
309```
309```
310> [6 [62 620]]
310> [6 [62 620]]
@@ -317,11 +317,11 @@ I said there isn't _much_ mystery about cells, but there is a little. So far wh
317[[6 62] 620]
317[[6 62] 620]
318```
318```
319
319
320−In the first example, the inner pair of square brackets is dropped. Why did this happen? Why is `[6 62 620]` accepted as a cell despite apparently having more than two atoms in it?
320+In the first example, the inner pair of square brackets is dropped. Why did this happen? Why is `[6 62 620]` accepted as a cell despite apparently having more than two atoms in it?
321
321
322−In fact, `[6 [62 620]]` and `[6 62 620]` are considered equivalent in Hoon. A cell _must_ be a pair, which means there are always exactly two nouns in it. Whenever cell brackets are omitted so that visually there appears to be more than two child nouns, it is implicitly understood that the right-most nouns constitute a cell. That is, the tail of the whole cell is assumed to be a cell of the right-most nouns.
322+In fact, `[6 [62 620]]` and `[6 62 620]` are considered equivalent in Hoon. A cell _must_ be a pair, which means there are always exactly two nouns in it. Whenever cell brackets are omitted so that visually there appears to be more than two child nouns, it is implicitly understood that the right-most nouns constitute a cell. That is, the tail of the whole cell is assumed to be a cell of the right-most nouns.
323
323
324−This is why `[6 [62 620]]` and `[6 62 620]` are equivalent. `[6 [62 620]]` and `[[6 62] 620]`, on the other hand, are not equivalent. If you look at them as binary trees you can see the difference:
324+This is why `[6 [62 620]]` and `[6 62 620]` are equivalent. `[6 [62 620]]` and `[[6 62] 620]`, on the other hand, are not equivalent. If you look at them as binary trees you can see the difference:
325
325
326```
326```
327 [6 [62 620]] [[6 62] 620]
327 [6 [62 620]] [[6 62] 620]
@@ -332,7 +332,7 @@ This is why `[6 [62 620]]` and `[6 62 620]` are equivalent. `[6 [62 620]]` and
332 62 620 6 62
332 62 620 6 62
333```
333```
334
334
335−When the dojo pretty-prints a cell it always removes superfluous cell brackets:
335+When the Dojo pretty-prints a cell it always removes superfluous cell brackets:
336
336
337```
337```
338> [[12 13] [[14 15] [16 17]]]
338> [[12 13] [[14 15] [16 17]]]
@@ -343,7 +343,7 @@ However, you should always remember that though cells can be presented as lists
343
343
344### Exercise 1.2a
344### Exercise 1.2a
345
345
346−Without using the dojo, assess whether each of the following pairs of nouns is equivalent. (Answers are at the bottom of the page.)
346+Without using the Dojo, assess whether each of the following pairs of nouns is equivalent. (Answers are at the bottom of the page.)
347
347
348```
348```
3491. [[1 3] [6 2]] [1 3 [6 2]]
3491. [[1 3] [6 2]] [1 3 [6 2]]
@@ -355,15 +355,15 @@ Without using the dojo, assess whether each of the following pairs of nouns is e
355
355
356## Noun Addresses
356## Noun Addresses
357
357
358−Nouns have a regular structure that can be exploited to give a unique **address** to each of its 'sub-nouns'. A sub-noun is a part of a noun that is itself a noun; e.g., `[6 2]` is a sub-noun of `[[1 3] [6 2]]`. We can also call these 'noun fragments'.
358+Nouns have a regular structure that can be exploited to give a unique **address** to each of its "sub-nouns". A sub-noun is a part of a noun that is itself a noun; e.g., `[6 2]` is a sub-noun of `[[1 3] [6 2]]`. We can also call these "noun fragments".
359
359
360−What if you want to refer to a noun fragment, and not the whole thing? For example, what if you want to refer to the `[6 2]` part of `[[1 3] [6 2]]`? One way is to use the unique address of that noun fragment.
360+What if you want to refer to a noun fragment, and not the whole thing? For example, what if you want to refer to the `[6 2]` part of `[[1 3] [6 2]]`? One way is to use the unique address of that noun fragment.
361
361
362−To define noun addresses we'll use recursion. The base case is trivial: address `1` of a noun is the entire noun. The generating case: if the noun at address `n` is a cell, then its head is at address `2n` and its tail is at address `2n + 1`. For example, if address `5` of some noun is a cell, then its head is at address `10` and its tail address `11`.
362+To define noun addresses we'll use recursion. The base case is trivial: address `1` of a noun is the entire noun. The generating case: if the noun at address `n` is a cell, then its head is at address `2n` and its tail is at address `2n + 1`. For example, if address `5` of some noun is a cell, then its head is at address `10` and its tail address `11`.
363
363
364−Address 1 of the noun `[[1 3] [6 2]]` is the whole noun: `[[1 3] [6 2]]`. The head of the noun at address `1`, `[1 3]`, is at address `2 x 1`, i.e., `2`. The tail of the noun at address `1`, `[6 2]`, is at address `(2 x 1) + 1`, i.e., `3`.
364+Address 1 of the noun `[[1 3] [6 2]]` is the whole noun: `[[1 3] [6 2]]`. The head of the noun at address `1`, `[1 3]`, is at address `2 x 1`, i.e., `2`. The tail of the noun at address `1`, `[6 2]`, is at address `(2 x 1) + 1`, i.e., `3`.
365
365
366−If the way this works isn't immediately clear, remember that each noun can be understood as a binary tree. The following diagram shows the address of several nodes of the tree:
366+If the way this works isn't immediately clear, remember that each noun can be understood as a binary tree. The following diagram shows the address of several nodes of the tree:
367
367
368```
368```
369 1
369 1
@@ -375,7 +375,7 @@ If the way this works isn't immediately clear, remember that each noun can be un
375 14 15
375 14 15
376```
376```
377
377
378−Let's do some examples in the dojo. We're going to use the `slot` operator, `+`, to return fragments of a noun. For any unsigned integer `n`, `+n` evaluates to the fragment at address `n`.
378+Let's do some examples in the Dojo. We're going to use the `slot` operator, `+`, to return fragments of a noun. For any unsigned integer `n`, `+n` evaluates to the fragment at address `n`.
379
379
380```
380```
381> +1:[22 [33 44]]
381> +1:[22 [33 44]]
@@ -394,7 +394,7 @@ Let's do some examples in the dojo. We're going to use the `slot` operator, `+`
39444
39444
395```
395```
396
396
397−You'll notice that we use the `:` symbol between the slot syntax and the noun. Don't worry about what this means yet; we'll explain it in another lesson. For now you can read it as the word "of": `+7:[22 [33 44]]` is "slot `7` of `[22 [33 44]]`".
397+You'll notice that we use the `:` symbol between the slot syntax and the noun. Don't worry about what this means yet; we'll explain it in another lesson. For now you can read it as the word "of": `+7:[22 [33 44]]` is "slot `7` of `[22 [33 44]]`".
398
398
399What happens if you ask for a fragment that doesn't exist?
399What happens if you ask for a fragment that doesn't exist?
400
400
@@ -422,7 +422,8 @@ Let's do a few more examples:
422%six
422%six
423```
423```
424
424
425−For those who prefer to think in terms of binary numbers and binary trees, there is another (equivalent) way to understand noun addressing. When the noun address is expressed as a binary number, you can think of the the number as indicating a tree path from the top node.
425+For those who prefer to think in terms of binary numbers and binary trees, there is another (equivalent) way to understand noun addressing. When the noun address is expressed as a binary number, you can think of the number as indicating a tree path from the top node.
426+
426
427
427As before, the root of the binary tree (i.e., the whole noun) is at address `1`. For the node of a tree at any address `b`, where `b` is a binary number, you get the address of its head by concatenating a `0` to the end of `b`; and to get its tail, concatenate a `1` to the end. For example, the head of the node at binary address `111` is at `1110`, and the tail is at `1111`.
428As before, the root of the binary tree (i.e., the whole noun) is at address `1`. For the node of a tree at any address `b`, where `b` is a binary number, you get the address of its head by concatenating a `0` to the end of `b`; and to get its tail, concatenate a `1` to the end. For example, the head of the node at binary address `111` is at `1110`, and the tail is at `1111`.
428
429
@@ -430,7 +431,7 @@ Address `1110` indicates "the head of the tail of the tail of the noun".
430
431
431### Exercise 1.2b
432### Exercise 1.2b
432
433
433−Without using the dojo, evaluate the following expressions. (Answers are at the bottom of the page.)
434+Without using the Dojo, evaluate the following expressions. (Answers are at the bottom of the page.)
434
435
435```
436```
4361. +6:[[34 54] [86 48]]
4371. +6:[[34 54] [86 48]]
@@ -442,7 +443,7 @@ Without using the dojo, evaluate the following expressions. (Answers are at the
442
443
443### Exercise 1.2c
444### Exercise 1.2c
444
445
445−Without using the dojo, for each fragment below provide the address relative to the noun `[51 52 53 54 55]`. (Answers are at the bottom of the page.)
446+Without using the Dojo, for each fragment below provide the address relative to the noun `[51 52 53 54 55]`. (Answers are at the bottom of the page.)
446
447
447```
448```
4481. 51
4491. 51
@@ -452,11 +453,11 @@ Without using the dojo, for each fragment below provide the address relative to
4525. 55
4535. 55
453```
454```
454
455
455−That's it for our basic introduction to nouns. Hit `ctrl-d` to exit your ship, or else move on to the next lesson.
456+That's it for our basic introduction to nouns. Hit `ctrl-d` to exit your ship, or else move on to the next lesson.
456
457
457### Exercise 1.2d
458### Exercise 1.2d
458
459
459−Draw out a binary tree diagram for each of the following nouns. Try to do this without using the dojo to simplify the expressions.
460+Draw out a binary tree diagram for each of the following nouns. Try to do this without using the Dojo to simplify the expressions.
460
461
461```
462```
4621. [[2 3] 4 [5 6 7]]
4631. [[2 3] 4 [5 6 7]]
@@ -508,12 +509,15 @@ Write the following binary tree as a noun.
508
509
509### 1.2d
510### 1.2d
510
511
511−1. Dojo simplifies the expression
512+1. Dojo simplifies the expression ...
513+
512```
514```
513> [[2 3] 4 [5 6 7]]
515> [[2 3] 4 [5 6 7]]
514[[2 3] 4 5 6 7]
516[[2 3] 4 5 6 7]
515```
517```
518+
516−which has the following tree:
519+... which has the following tree:
520+
517```
521```
518 .
522 .
519 / \
523 / \
@@ -527,13 +531,15 @@ which has the following tree:
527 6 7
531 6 7
528```
532```
529
533
530−2. Dojo simplifies the expression
534+2. Dojo simplifies the expression ...
531
535
532```
536```
533> [[[5 6 7] 8 9] 10 11 [12 13]]
537> [[[5 6 7] 8 9] 10 11 [12 13]]
534[[[5 6 7] 8 9] 10 11 12 13]
538[[[5 6 7] 8 9] 10 11 12 13]
535```
539```
540+
536−which has the following tree:
541+... which has the following tree:
542+
537```
543```
538 .
544 .
539 /\
545 /\
@@ -551,6 +557,7 @@ which has the following tree:
551```
557```
552
558
553### 1.2e
559### 1.2e
560+
554```
561```
555[[[1 2] 3] 4 [5 6] 7]
562[[[1 2] 3] 4 [5 6] 7]
556−```
563+```
tutorials/hoon/recursion.md+10−10
@@ -8,7 +8,7 @@ aliases = ["/docs/learn/hoon/hoon-tutorial/recursion/"]
8[Recursion](.) is a common pattern for solving certain problems in most programming
8[Recursion](.) is a common pattern for solving certain problems in most programming
9languages, and Hoon is no exception. One of the classically recursive problems
9languages, and Hoon is no exception. One of the classically recursive problems
10is that of factorial. The factorial of _n_ is the product of all positive
10is that of factorial. The factorial of _n_ is the product of all positive
11−integers less than or equal to N. Thus the factorial of 5, denoted as _5!_,
11+integers less than or equal to _n_. Thus the factorial of 5, denoted as _5!_,
12would be:
12would be:
13
13
14```
14```
@@ -37,11 +37,11 @@ Next we check to see if `n` is `1`. If so, the result is just `1`, since
37
37
38If, however, `n` is _not_ `1`, then we branch to the final line of the code,
38If, however, `n` is _not_ `1`, then we branch to the final line of the code,
39`(mul n $(n (dec n)))`, where the recursion logic lives. Here, we multiply `n`
39`(mul n $(n (dec n)))`, where the recursion logic lives. Here, we multiply `n`
40−by the recursion of `n` minus `1`. `$` initiates recursion: it calls the gate
40+by the recursion of `n` minus `1`. `$` initiates recursion: it calls the [gate](/docs/glossary/gate/)
41that we're already in, but replaces its sample.
41that we're already in, but replaces its sample.
42
42
43In our example, we multiply `n` with the product of this _entire gate
43In our example, we multiply `n` with the product of this _entire gate
44−all over again_ with `$(n (dec n))`, except when that new gate has its sample
44+all over again_ with `$(n (dec n))`, except when that new gate has its sample
45decremented by one. This works recursively because each new gate will, of
45decremented by one. This works recursively because each new gate will, of
46course, itself contain the code to call a further-decremented gate. Gates will
46course, itself contain the code to call a further-decremented gate. Gates will
47continue to call new, further-decremented gates until `n` is `1`, and that `1`
47continue to call new, further-decremented gates until `n` is `1`, and that `1`
@@ -80,7 +80,7 @@ into the `mul` functions behind them.
80
80
81#### Tail-Call Optimization
81#### Tail-Call Optimization
82
82
83−Our last example isn't a very efficient use computing resources. The
83+Our last example isn't a very efficient use of computing resources. The
84pyramid-shaped illustration approximates what's happening on the **call stack**, a
84pyramid-shaped illustration approximates what's happening on the **call stack**, a
85memory structure that tracks the instructions of the program. In our example
85memory structure that tracks the instructions of the program. In our example
86code, every time a parent gate calls another gate, the gate being called is
86code, every time a parent gate calls another gate, the gate being called is
@@ -111,7 +111,7 @@ function every time.
111To reiterate: if you have to manipulate the result of a recursion as the last
111To reiterate: if you have to manipulate the result of a recursion as the last
112expression of your gate, as we did in our example, the function is not
112expression of your gate, as we did in our example, the function is not
113tail-recursive, and therefore not very efficient with memory. A problem arises
113tail-recursive, and therefore not very efficient with memory. A problem arises
114−when we try to recurse more times that we have space on the stack. This will
114+when we try to recurse more times than we have space on the stack. This will
115result in our computation failing and producing a stack overflow. If we tried
115result in our computation failing and producing a stack overflow. If we tried
116to find the factorial of `5.000.000`, for example, we would almost certainly
116to find the factorial of `5.000.000`, for example, we would almost certainly
117run out of stack space.
117run out of stack space.
@@ -138,11 +138,11 @@ $(n (dec n), t (mul t n))
138The above code should look familiar. We are still building a gate that
138The above code should look familiar. We are still building a gate that
139takes one argument `n`. This time, however, we are also putting a face on a
139takes one argument `n`. This time, however, we are also putting a face on a
140`@ud` and setting its initial value to 1. The `|-` here is used to create a new
140`@ud` and setting its initial value to 1. The `|-` here is used to create a new
141−gate with one arm `$` and immediately call it. Think of `|-` as the recursion
141+gate with one [arm](/docs/glossary/arm/) `$` and immediately call it. Think of `|-` as the recursion
142point.
142point.
143
143
144−We then evaluate `n` to see if it is 1. If it is we return the value of `t`. In
144+We then evaluate `n` to see if it is 1. If it is, we return the value of `t`.
145−the case that `n` is anything other than 1, we perform our recursion:
145+In case that `n` is anything other than 1, we perform our recursion:
146
146
147```hoon
147```hoon
148$(n (dec n), t (mul t n))
148$(n (dec n), t (mul t n))
@@ -153,7 +153,7 @@ and `t`. `t` is used as an accumulator variable that we use to keep a running
153total for the factorial computation.
153total for the factorial computation.
154
154
155Let's use pseudo-Hoon to illustrate how the stack is working in this example for
155Let's use pseudo-Hoon to illustrate how the stack is working in this example for
156−factorial 5.
156+the factorial of 5.
157
157
158```
158```
159(factorial 5)
159(factorial 5)
@@ -175,7 +175,7 @@ each iteration can be replaced instead of held in memory.
175#### A Note on `$`
175#### A Note on `$`
176
176
177`$` (pronounced "buc") is, in its use with recursion, a reference to the gate that we are inside
177`$` (pronounced "buc") is, in its use with recursion, a reference to the gate that we are inside
178−of. That's because a gate is just a core with a single arm named `$`. The
178+of. That's because a gate is just a [core](/docs/glossary/core/) with a single arm named `$`. The
179subject is searched depth-first, head before tail, with faces skipped, and
179subject is searched depth-first, head before tail, with faces skipped, and
180stopping on the first result. In other words, the first match found in the head
180stopping on the first result. In other words, the first match found in the head
181will be returned. If you wished to refer to the outer `$` in this context, the
181will be returned. If you wished to refer to the outer `$` in this context, the
tutorials/hoon/setup.md+9−11
@@ -9,20 +9,19 @@ Before we begin working on Hoon, you should first (1) have Urbit installed and (
9
9
10## What is an urbit?
10## What is an urbit?
11
11
12−An **urbit** is an Urbit virtual computer with persistent state that can connect to the Urbit network. (Note the lowercase 'u' here. 'Urbit' is the entire software stack, whereas 'an urbit' is a local instance.) Each urbit is associated with a unique number that plays three distinct roles: (1) it's an address on the Urbit network, (2) it's a cryptographic identity, and (3) it's (in principle) a human memorable name. Normally an urbit's name is represented as a string starting with `~`, as in `~zod` or `~taglux-nidsep`.
12+An **urbit** is an Urbit virtual computer with persistent state that can connect to the Urbit network. (Note the lowercase `u` here. "Urbit" is the entire software stack, whereas "an urbit" is a local instance.) Each urbit is associated with a unique number that plays three distinct roles: (1) it's an address on the Urbit network, (2) it's a cryptographic identity, and (3) it's (in principle) a human memorable name. Normally an urbit's name is represented as a string starting with `~`, as in `~zod` or `~taglux-nidsep`.
13
13
14−These may not look like numbers, but they are. Each urbit name is written in a base-256 format, where each 'digit' is a syllable. Imagine your phone number as a pronounceable string which sounds like a name in a foreign language. An ordinary user-level urbit is a 'planet', and it's named by a 32-bit number. The latter is represented as a four-syllable string; e.g., the planet name `~taglux-nidsep` is the number 6,095,360.
14+These may not look like numbers, but they are. Each urbit name is written in a base-256 format, where each "digit" is a syllable. Imagine your phone number as a pronounceable string which sounds like a name in a foreign language. An ordinary user-level urbit is a "planet", and it's named by a 32-bit number. The latter is represented as a four-syllable string; e.g., the planet name `~taglux-nidsep` is the number 6,095,360.
15
15
16## Installing Urbit
16## Installing Urbit
17
17
18−You can install Urbit on any Mac or Unix machine; if you're just trying out Urbit or creating a development ship, you can follow the steps for creating a development ship [here](@/using/develop.md#creating-a-development-ship). On Windows, make a virtual Linux machine using VirtualBox or a similar tool.
18+You can install Urbit on any Mac or Unix machine; if you're just trying out Urbit or creating a development ship, you can follow the steps for creating a development ship [here](@/using/develop.md#creating-a-development-ship). On Windows, make a virtual Linux machine using VirtualBox or a similar tool.
19−
20
19
21Once you're finished, you can [boot your very own ship](@/using/install.md#booting-your-ship). While you can develop in Hoon on your own ship on the live network, we strongly suggest developing on a development ship first.
20Once you're finished, you can [boot your very own ship](@/using/install.md#booting-your-ship). While you can develop in Hoon on your own ship on the live network, we strongly suggest developing on a development ship first.
22
21
23## Getting started
22## Getting started
24
23
25−Once you've created your development ship, let's try a basic command. Type `(add 2 2)` at the prompt and hit return. Your screen now shows:
24+Once you've created your development ship, let's try a basic command. Type `(add 2 2)` at the prompt and hit return. Your screen now shows:
26
25
27```
26```
28fake: ~zod
27fake: ~zod
@@ -34,7 +33,7 @@ http: live (insecure, loopback) on 12321
34~zod:dojo>
33~zod:dojo>
35```
34```
36
35
37−You just used a function from the Hoon standard library, `add`. Next, quit Urbit with `ctrl-d`:
36+You just used a function from the Hoon standard library, `add`. Next, quit Urbit with `ctrl-d`:
38
37
39```
38```
40> (add 2 2)
39> (add 2 2)
@@ -51,9 +50,9 @@ urbit zod
51
50
52## Another Noun
51## Another Noun
53
52
54−You've already used a standard library function to produce one value, in the dojo. Now that your ship is running again, let's try another. Enter the number `17`.
53+You've already used a standard library function to produce one value, in the Dojo. Now that your ship is running again, let's try another. Enter the number `17`.
55
54
56−> We won't show the `~zod:dojo> ` prompt from here on out. We'll just show the echoed command along with its result.
55+> We won't show the `~zod:dojo> ` prompt from here on out. We'll just show the echoed command along with its result.
57
56
58You'll see:
57You'll see:
59
58
@@ -62,13 +61,13 @@ You'll see:
6217
6117
63```
62```
64
63
65−You asked dojo to evaluate `17` and it echoed the number back at you. This value is a 'noun'. We'll talk more about nouns in [Lesson 1.2](@/docs/tutorials/hoon/nouns.md), but first let's write a very basic program.
64+You asked Dojo to evaluate `17` and it echoed the number back at you. This value is a "noun". We'll talk more about [nouns](/docs/glossary/noun/) in [Lesson 1.2](@/docs/tutorials/hoon/nouns.md), but first let's write a very basic program.
66
65
67## Generators
66## Generators
68
67
69Generators are the most straightforward way to write Hoon programs. They are a concept in Arvo, and involve saving Hoon code in a `.hoon` text file. While they aren't strictly part of the Hoon language, we'll be dealing with generators throughout this tutorial.
68Generators are the most straightforward way to write Hoon programs. They are a concept in Arvo, and involve saving Hoon code in a `.hoon` text file. While they aren't strictly part of the Hoon language, we'll be dealing with generators throughout this tutorial.
70
69
71−The simplest type of generator is the **naked generator**. All naked generators are `gates`: functions that take an argument and produce an output. Before creating generator you need to mount your `desk` to Unix, for So, to create a generator, all you need to do is write a `gate` and put it into a file in the `/home/gen` directory of your ship as a `.hoon` file. (Assuming you've already mounted with `|mount /=home=`.) After this, you need to run `|commit %home` in dojo and the new file will be recognized by your ship. To run a generator named `mygen.hoon`, you would type `+mygen <argument>` in your ship's Dojo.
70+The simplest type of generator is the **naked generator**. All naked generators are `gates`: functions that take an argument and produce an output. Before creating a generator you need to [mount](https://urbit.org/using/install/#the-dojo) your `desk` to Unix. To create a generator, all you need to do is write a `gate` and put it into a file in the `/home/gen/` directory of your ship as a `.hoon` file. (Assuming you've already mounted with `|mount /=home=`.) After this, you need to run `|commit %home` in Dojo and the new file will be recognized by your ship. To run a generator named `mygen.hoon`, you would type `+mygen <argument>` in your ship's Dojo.
72
71
73If this doesn't make sense yet, that's okay. In the [next lesson](@/docs/tutorials/hoon/list-of-numbers.md), we will walk you through an example `gate` that is run as a generator.
72If this doesn't make sense yet, that's okay. In the [next lesson](@/docs/tutorials/hoon/list-of-numbers.md), we will walk you through an example `gate` that is run as a generator.
74
73
@@ -104,4 +103,3 @@ Emacs is free and open-source and runs on all major operating systems. It is ava
104#### Vim
103#### Vim
105
104
106Vim is free and open-source and runs on all major operating systems. It is available [here](https://www.vim.org/). Hoon support is available with [hoon.vim](https://github.com/urbit/hoon.vim) and is maintained by Tlon.
105Vim is free and open-source and runs on all major operating systems. It is available [here](https://www.vim.org/). Hoon support is available with [hoon.vim](https://github.com/urbit/hoon.vim) and is maintained by Tlon.
107−
tutorials/hoon/structures-and-complex-types.md+3−3
@@ -36,7 +36,7 @@ Accordingly, the structures produced by the type subexpressions above aren't par
36
36
37### Type Example Values ('Bunt' Values)
37### Type Example Values ('Bunt' Values)
38
38
39−In other cases, structures _can_ have an effect on runtime semantics. For example, consider the expression `|=(a=@ 15)`. This produces a gate that takes any atom as its sample and returns `15`.
39+In other cases, structures _can_ have an effect on runtime semantics. For example, consider the expression `|=(a=@ 15)`. This produces a [gate](/docs/glossary/gate/) that takes any [atom](/docs/glossary/atom/) as its sample and returns `15`.
40
40
41The `@` subexpression of `|=(a=@ 15)` produces a structure at compile time. In the compiled program this structure is converted to a default value for the appropriate type, sometimes called an **example** value (or a **bunt** value).
41The `@` subexpression of `|=(a=@ 15)` produces a structure at compile time. In the compiled program this structure is converted to a default value for the appropriate type, sometimes called an **example** value (or a **bunt** value).
42
42
@@ -99,7 +99,7 @@ Structures can also become gates at runtime. To produce such a gate, use a type
99>
99>
100```
100```
101
101
102−In all three cases, the result of evaluation is a gate. For each, the head is a single arm, signified by `1.xxx`. The sample -- i.e., the head of the tail -- in each case is of the type `*`. These gates are sometimes called **molds**.
102+In all three cases, the result of evaluation is a gate. For each, the head is a single [arm](/docs/glossary/arm/), signified by `1.xxx`. The sample -- i.e., the head of the tail -- in each case is of the type `*`. These gates are sometimes called **molds**.
103
103
104Molds are gates with two special properties: (1) they are guaranteed to produce a value of the type indicated by the type expression, and (2) they are [idempotent](https://en.wikipedia.org/wiki/Idempotence). (A gate `i` is idempotent if and only if the result of applying `i` multiple times to a value produces the same result as applying it once. In other words, `(i val)` must produce the same result as `(i (i val))`.)
104Molds are gates with two special properties: (1) they are guaranteed to produce a value of the type indicated by the type expression, and (2) they are [idempotent](https://en.wikipedia.org/wiki/Idempotence). (A gate `i` is idempotent if and only if the result of applying `i` multiple times to a value produces the same result as applying it once. In other words, `(i val)` must produce the same result as `(i (i val))`.)
105
105
@@ -143,7 +143,7 @@ Let's review (1) and (2) briefly.
143
143
144### Basic Types
144### Basic Types
145
145
146−The basic types of Hoon are: `*` for nouns, `@` for atoms (possibly with aura information, e.g., `@ud` and `@sx`), `^` for cells, `?` for flags, and `~` for null. You can also make constant, one-value types by using `%` followed by a series of lowercase letters, the hyphen symbol `-`, and numbers. E.g., `%red`, `%2`, `%kebab-case123`. The lone values of these one-value types are sometimes called 'tags'.
146+The basic types of Hoon are: `*` for [nouns](/docs/glossary/noun/), `@` for atoms (possibly with aura information, e.g., `@ud` and `@sx`), `^` for cells, `?` for flags, and `~` for null. You can also make constant, one-value types by using `%` followed by a series of lowercase letters, the hyphen symbol `-`, and numbers. E.g., `%red`, `%2`, `%kebab-case123`. The lone values of these one-value types are sometimes called 'tags'.
147
147
148Let's illustrate with the irregular `\` \`` cast syntax:
148Let's illustrate with the irregular `\` \`` cast syntax:
149
149
tutorials/hoon/style.md+78−77
@@ -1,28 +1,29 @@
1+++
1+++
2−title = "Hoon Style Guide"
2+title = "Appendix: Hoon Style Guide"
3weight = 100
3weight = 100
4template = "doc.html"
4template = "doc.html"
5aliases = ["docs/learn/hoon/style/"]
5aliases = ["docs/learn/hoon/style/"]
6+++
6+++
7+
7−Welcome to the Hoon style guide. It's important to familiarize yourself with our way of writing Hoon code.
8+Welcome to the Hoon style guide. It’s important to familiarize yourself with our way of writing Hoon code.
8
9
9## Layout
10## Layout
10
11
11−Hoon's position on layout is: so long as your code is (a) correctly commented,
12+Hoon’s position on layout is: so long as your code is (a) correctly commented,
12−(b) free from blank or overlong lines, (c) parses, and (d) looks good, it's good
13+(b) free from blank or overlong lines, (c) parses, and (d) looks good, it’s good
13layout.
14layout.
14
15
15When a layout standard or other fundamental coding convention is
16When a layout standard or other fundamental coding convention is
16not perfectly rigid, code can develop some individual flavor.
17not perfectly rigid, code can develop some individual flavor.
17−But Hoon's layout rules, though not rigid, are still strict. The
18+But Hoon’s layout rules, though not rigid, are still strict. The
18flavor should never overwhelm the content.
19flavor should never overwhelm the content.
19
20
20### General outline of Hoon syntax
21### General outline of Hoon syntax
21
22
22−There are two forms of syntax in Hoon: wide and tall. Wide forms
23+There are two forms of syntax in Hoon: wide and tall. Wide forms
23fit on a single line, use single spaces to separate syntax, and
24fit on a single line, use single spaces to separate syntax, and
24generally use enclosing terminators (like parentheses to close an
25generally use enclosing terminators (like parentheses to close an
25−expression). Tall forms can use multiple lines, separate syntax
26+expression). Tall forms can use multiple lines, separate syntax
26with two spaces at minimum and arbitrary whitespace at maximum,
27with two spaces at minimum and arbitrary whitespace at maximum,
27and avoid terminators when the content has a fixed structure.
28and avoid terminators when the content has a fixed structure.
28
29
@@ -41,37 +42,37 @@ or
41```
42```
42
43
43These are regular forms -- every rune can be written this way.
44These are regular forms -- every rune can be written this way.
44−Hoon also has a variety of wide [irregular forms](@/docs/reference/hoon-expressions/irregular.md). All tall
45+Hoon also has a variety of wide [irregular forms](@/docs/reference/hoon-expressions/irregular.md). All tall
45−forms are regular. All code within a wide form is wide.
46+forms are regular. All code within a wide form is wide.
46Almost all code has both wide and tall forms, the exception
47Almost all code has both wide and tall forms, the exception
47−being named cores.
48+being named [cores](/docs/glossary/core/).
48
49
49The goal of wide/tall forms is to resemble the look of
50The goal of wide/tall forms is to resemble the look of
50procedural code, with its statement/expression distinction,
51procedural code, with its statement/expression distinction,
51−in a purely functional language. In particular, complex code in
52+in a purely functional language. In particular, complex code in
52functional languages tends to develop a diagonal shape, since
53functional languages tends to develop a diagonal shape, since
53child nodes in the syntax tree are indented right.
54child nodes in the syntax tree are indented right.
54
55
55### Tall layout conventions
56### Tall layout conventions
56
57
57In wide form, the parser allows no freedom of layout (and no
58In wide form, the parser allows no freedom of layout (and no
58−comments, either). In tall form, there is too much freedom, and so we need
59+comments, either). In tall form, there is too much freedom, and so we need
59−conventions. These conventions aren't absolute, but
60+conventions. These conventions aren’t absolute, but
60−you shouldn't defy them unless you have a good reason to do so.
61+you shouldn’t defy them unless you have a good reason to do so.
61
62
62Syntactically, there are three kinds of runes: fixed sequences,
63Syntactically, there are three kinds of runes: fixed sequences,
63−variable sequences, and cores/engines. Let's talk about each.
64+variable sequences, and cores/engines. Let’s talk about each.
64
65
65#### Fixed sequences and backstep indentation
66#### Fixed sequences and backstep indentation
66
67
67−A fixed sequence is a rune with a fixed number of children. Most
68+A fixed sequence is a rune with a fixed number of children. Most
68−runes are fixed sequences. In wide mode we terminate a fixed
69+runes are fixed sequences. In wide mode we terminate a fixed
69−sequence with a right-parenthesis (rit). In tall mode there is
70+sequence with a right-parenthesis (“rit”). In tall mode there is
70no terminator.
71no terminator.
71
72
72−With a fixed sequence, we typically use "backstep indentation."
73+With a fixed sequence, we typically use “backstep indentation.”
73The goal of a backstep is for the largest child node of the rune
74The goal of a backstep is for the largest child node of the rune
74−to end up on the same left margin as the rune itself. This
75+to end up on the same left margin as the rune itself. This
75design ensures that the body of the code flows down the page, not
76design ensures that the body of the code flows down the page, not
76across the page.
77across the page.
77
78
@@ -107,13 +108,13 @@ With four (the maximum rune fanout):
107```
108```
108
109
109It is sometimes acceptable to not backstep -- especially in tuple
110It is sometimes acceptable to not backstep -- especially in tuple
110−runes: `:-,` `:_`, `:+` and `+^`. But you should have a specific reason:
111+runes: `:-,` `:_`, `:+` and `+^`. But you should have a specific reason:
111for example: emphasizing symmetry in a tuple.
112for example: emphasizing symmetry in a tuple.
112
113
113#### Variable sequences
114#### Variable sequences
114
115
115Variable sequences can have an arbitrary number of elements, so
116Variable sequences can have an arbitrary number of elements, so
116−they can't self-terminate. They are terminated by a `==` marker.
117+they can’t self-terminate. They are terminated by a `==` marker.
117The sequence, or its variable part, is indented and vertical:
118The sequence, or its variable part, is indented and vertical:
118
119
119```hoon
120```hoon
@@ -123,7 +124,7 @@ The sequence, or its variable part, is indented and vertical:
123 ==
124 ==
124```
125```
125
126
126−Another representation wastes a line, but saves an indent. Use
127+Another representation wastes a line, but saves an indent. Use
127this only for very long sequences:
128this only for very long sequences:
128
129
129```hoon
130```hoon
@@ -135,8 +136,8 @@ this only for very long sequences:
135```
136```
136
137
137Some variable sequences are sequences of pairs; some of these
138Some variable sequences are sequences of pairs; some of these
138−start with fixed sequences of nodes. Pair sequences are in
139+start with fixed sequences of nodes. Pair sequences are in
139−either "kingside" or "queenside" convention, depending on what
140+either “kingside” or “queenside” convention, depending on what
140looks better for this particular code.
141looks better for this particular code.
141
142
142Kingside format:
143Kingside format:
@@ -172,7 +173,7 @@ It is also usually hard to read without linebreak comments,
172as demonstrated above.
173as demonstrated above.
173
174
174We sometimes end up with multiple terminators on separate lines,
175We sometimes end up with multiple terminators on separate lines,
175−two or more spaces apart. These lines can be collapsed:
176+two or more spaces apart. These lines can be collapsed:
176
177
177```hoon
178```hoon
178 ?+ x default
179 ?+ x default
@@ -191,10 +192,10 @@ Modern Hoon naming is **verbose**.
191**Never**: abbreviate a label; pack characters (try to reduce the
192**Never**: abbreviate a label; pack characters (try to reduce the
192length of labels, or make lengths match up between parallel
193length of labels, or make lengths match up between parallel
193labels); use intentionally vague and meaningless words; or use
194labels); use intentionally vague and meaningless words; or use
194−nonsense text that isn't a word.
195+nonsense text that isn’t a word.
195
196
196−It can't be repeated too often: **do not abbreviate words, unless
197+It can’t be repeated too often: **do not abbreviate words, unless
197−you would use the same abbreviations in written English**. To
198+you would use the same abbreviations in written English**. To
198save a trivial, one-time amount of work in typing, you are adding
199save a trivial, one-time amount of work in typing, you are adding
199a nontrivial amount of work and ambiguity in reading.
200a nontrivial amount of work and ambiguity in reading.
200
201
@@ -206,16 +207,16 @@ Hoon comments are 8-column lines which contain whitespace, then
206Blank lines are lines containing no characters, or only whitespace.
207Blank lines are lines containing no characters, or only whitespace.
207There must never be blank lines in a Hoon file.
208There must never be blank lines in a Hoon file.
208
209
209−Empty lines are lines containing `::` only. There must never be
210+Empty lines are lines containing `::` only. There must never be
210two empty lines in a row in a Hoon file.
211two empty lines in a row in a Hoon file.
211
212
212−Whitespace is semi-significant. The difference between a
213+Whitespace is semi-significant. The difference between a
213−space and a gap (more than one space) is significant. But two or
214+space and a gap (more than one space) is significant. But two or
214more spaces, newlines, or comments are one gap.
215more spaces, newlines, or comments are one gap.
215
216
216#### Comment conventions
217#### Comment conventions
217
218
218−Hoon suggests "breathing comments." There should always be an
219+Hoon suggests “breathing comments.” There should always be an
219empty comment line between a comment and the line **below** it:
220empty comment line between a comment and the line **below** it:
220
221
221```hoon
222```hoon
@@ -227,7 +228,7 @@ empty comment line between a comment and the line **below** it:
227 this.is.more.code
228 this.is.more.code
228```
229```
229
230
230−Sometimes dense code does need air on both sides. Also
231+Sometimes dense code does need air on both sides. Also
231legitimate:
232legitimate:
232
233
233```hoon
234```hoon
@@ -243,16 +244,16 @@ legitimate:
243But air on both sides is needed less often than you may think.
244But air on both sides is needed less often than you may think.
244
245
245Crowded comments are comments on lines which also contain code.
246Crowded comments are comments on lines which also contain code.
246−Older code has a lot of these, especially the "column 56"
247+Older code has a lot of these, especially the “column 56”
247standard.
248standard.
248
249
249−Crowded comments are considered harmful -- don't use them. Hoon,
250+Crowded comments are considered harmful -- don’t use them. Hoon,
250like any higher-order functional language, can be very dense and
251like any higher-order functional language, can be very dense and
251−powerful. We almost never want it to be **more** dense.
252+powerful. We almost never want it to be **more** dense.
252
253
253#### Megalithic comments
254#### Megalithic comments
254
255
255−In older code you'll also see attempts to produce large, visually
256+In older code you’ll also see attempts to produce large, visually
256salient geometries as separators, like:
257salient geometries as separators, like:
257
258
258```
259```
@@ -267,8 +268,8 @@ or
267 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
268 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
268```
269```
269
270
270−Please don't do this in new code. Normal conventions should be
271+Please don’t do this in new code. Normal conventions should be
271−legible. Use more deeply qualified positions if your code is
272+legible. Use more deeply qualified positions if your code is
272hard to navigate.
273hard to navigate.
273
274
274### Structure of all comments, formal and informal
275### Structure of all comments, formal and informal
@@ -285,10 +286,10 @@ development process).
285All kinds of formal comments have the same structure: simple or
286All kinds of formal comments have the same structure: simple or
286complex.
287complex.
287
288
288−A simple formal comment is a one-line headline. A headline is
289+A simple formal comment is a one-line headline. A headline is
289optional whitespace; then `::`; then two spaces; then a parsed
290optional whitespace; then `::`; then two spaces; then a parsed
290line of **lowercase** ASCII whose syntax depends on the comment
291line of **lowercase** ASCII whose syntax depends on the comment
291−type. Like this:
292+type. Like this:
292
293
293```hoon
294```hoon
294 :: $foo: the definition of a foo
295 :: $foo: the definition of a foo
@@ -301,23 +302,23 @@ four spaces, in ASCII mixed case:
301```hoon
302```hoon
302 :: $foo: the definition of a foo
303 :: $foo: the definition of a foo
303 ::
304 ::
304− :: The source of the word "foo" is lost in history. Some
305+ :: The source of the word “foo” is lost in history. Some
305− :: think it comes from the WWII military term "FUBAR,"
306+ :: think it comes from the WWII military term “FUBAR,”
306− :: in which "UBAR" stands for "up beyond all retrieval."
307+ :: in which “UBAR” stands for “up beyond all retrieval.”
307 ::
308 ::
308− :: Somehow "FUBAR" became "foobar." The rest is history.
309+ :: Somehow “FUBAR” became “foobar.” The rest is history.
309 ::
310 ::
310```
311```
311
312
312The point is: sometimes we want to see a deep explanation;
313The point is: sometimes we want to see a deep explanation;
313−sometimes we just want a summary. So we require you to either
314+sometimes we just want a summary. So we require you to either
314(a) provide a line-length explanation, or (b) a long screed
315(a) provide a line-length explanation, or (b) a long screed
315but with a line-length summary/headline.
316but with a line-length summary/headline.
316
317
317### Feature comments
318### Feature comments
318
319
319A feature headline is `::`, then two spaces, then a qualified
320A feature headline is `::`, then two spaces, then a qualified
320−location, then `:`, then a freeform string. Like:
321+location, then `:`, then a freeform string. Like:
321
322
322```hoon
323```hoon
323 :: $foo: a the definition of a foo
324 :: $foo: a the definition of a foo
@@ -326,8 +327,8 @@ location, then `:`, then a freeform string. Like:
326```
327```
327
328
328We find the feature `$foo` relative to the current location and
329We find the feature `$foo` relative to the current location and
329−move the comment there, as described above. In most cases it
330+move the comment there, as described above. In most cases it
330−becomes a product comment. For a `|chapter` (which does not
331+becomes a product comment. For a `|chapter` (which does not
331resolve to any data value) it becomes the chapter description.
332resolve to any data value) it becomes the chapter description.
332
333
333### Product comments
334### Product comments
@@ -348,22 +349,22 @@ Flow comments use a new commenting concept called **legends**.
348#### Legends
349#### Legends
349
350
350One of the problems with Hoon as a language is that it takes some
351One of the problems with Hoon as a language is that it takes some
351−time to learn to look at a tree of runes and "see the function."
352+time to learn to look at a tree of runes and “see the function.”
352−Seeing the function is beautiful and pleasant. But until the new
353+Seeing the function is beautiful and pleasant. But until the new
353Hoon student has put in a lot of practice, this experience is
354Hoon student has put in a lot of practice, this experience is
354−inaccessible. And tracing runes with a manual is hard.
355+inaccessible. And tracing runes with a manual is hard.
355
356
356Canonical flow comments are one way to ease this burden.
357Canonical flow comments are one way to ease this burden.
357−them, we first need to write descriptive names (not necessarily
358+We first need to write descriptive names (not necessarily
358−unique) for every leg of every rune case. Then, we introduce a
359+unique) for every leg of every rune case. Then, we introduce a
359narration of the code with these descriptions.
360narration of the code with these descriptions.
360
361
361−For example, let's fix `[%wtcl p=hoon q=hoon r=hoon]`. Let's
362+For example, let’s fix `[%wtcl p=hoon q=hoon r=hoon]`. Let’s
362−make it... `[%wtcl if=hoon then=hoon else=hoon]`. Then we
363+make it … `[%wtcl if=hoon then=hoon else=hoon]`. Then we
363could write flow comments as follows:
364could write flow comments as follows:
364
365
365```hoon
366```hoon
366− ?: :: if, it's it winter
367+ ?: :: if, it is winter
367 ::
368 ::
368 is-winter
369 is-winter
369 :: then, why not rome?
370 :: then, why not rome?
@@ -377,12 +378,12 @@ could write flow comments as follows:
377The headline of a flow comment uses a **legend**: the name of
378The headline of a flow comment uses a **legend**: the name of
378this leg in the parent rune, then a message,
379this leg in the parent rune, then a message,
379
380
380−For someone who doesn't know Hoon, these pseudo-keywords are
381+For someone who doesn’t know Hoon, these pseudo-keywords are
381−a lifesaver. For someone who does, they are not too annoying
382+a lifesaver. For someone who does, they are not too annoying
382and may still be helpful.
383and may still be helpful.
383
384
384−Of course, to use this we need to write useful "leg ends" for all
385+Of course, to use this we need to write useful “leg ends” for all
385−appropriate legs of all appropriate runes. But that will
386+appropriate legs of all appropriate runes. But that will
386probably help us document them, anyway.
387probably help us document them, anyway.
387
388
388#### Flow promotion
389#### Flow promotion
@@ -391,7 +392,7 @@ Sometimes, just for cosmetic reasons, we like to raise the
391comment on the first leg of a rune up above the parent:
392comment on the first leg of a rune up above the parent:
392
393
393```hoon
394```hoon
394− :: if, it's it winter
395+ :: if, it is winter
395 ::
396 ::
396 ?: is-winter
397 ?: is-winter
397 :: then, why not rome?
398 :: then, why not rome?
@@ -402,10 +403,10 @@ comment on the first leg of a rune up above the parent:
402 visit-holland
403 visit-holland
403```
404```
404
405
405−This can make flow comments collide, as in "else, if," below:
406+This can make flow comments collide, as in “else, if,” below:
406
407
407```hoon
408```hoon
408− :: if, it's winter
409+ :: if, it is winter
409 ::
410 ::
410 ?: is-winter
411 ?: is-winter
411 :: then, why not rome?
412 :: then, why not rome?
@@ -426,7 +427,7 @@ This can make flow comments collide, as in "else, if," below:
426
427
427Flow comments, because they describe what your code is doing, are
428Flow comments, because they describe what your code is doing, are
428embedded in the stack trace, using the same hint mechanism as
429embedded in the stack trace, using the same hint mechanism as
429−`~|`. A trace is an explanation of everything your code was
430+`~|`. A trace is an explanation of everything your code was
430doing when it crashed.
431doing when it crashed.
431
432
432And data interpolation, in `{}`, also works in flow comments.
433And data interpolation, in `{}`, also works in flow comments.
@@ -435,7 +436,7 @@ English, including data.
435
436
436## Grading
437## Grading
437
438
438−How do we define the superficial quality of Hoon code? (Setting
439+How do we define the superficial quality of Hoon code? (Setting
439aside, of course, the question of whether the code is computing
440aside, of course, the question of whether the code is computing
440the right thing in the right way.)
441the right thing in the right way.)
441
442
@@ -446,30 +447,30 @@ Any file that looks like code and opens in an editor gets an F.
446If it compiles, and it is Hoon, it gets a D.
447If it compiles, and it is Hoon, it gets a D.
447
448
448A Hoon file that follows the layout, structure, and naming
449A Hoon file that follows the layout, structure, and naming
449−conventions in this document has earned a C. Weird indents,
450+conventions in this document has earned a C. Weird indents,
450cryptic or abbreviated names, etc, etc, preclude an A or B
451cryptic or abbreviated names, etc, etc, preclude an A or B
451grade -- regardless of documentation.
452grade -- regardless of documentation.
452
453
453A Hoon file gets a B if and only if **every symbol in the file is
454A Hoon file gets a B if and only if **every symbol in the file is
454−defined, where introduced, by a formal comment**. You do not get
455+defined, where introduced, by a formal comment**. You do not get
455to make up a name without writing a one-line definition.
456to make up a name without writing a one-line definition.
456
457
457For an A, there are two criteria.
458For an A, there are two criteria.
458
459
459One: every symbol that needs an explanation (a multiline comment
460One: every symbol that needs an explanation (a multiline comment
460−after the definition) has an explanation. This is obviously a
461+after the definition) has an explanation. This is obviously a
461−judgment call, as a grade of A should always be. If a definition
462+judgment call, as a grade of A should always be. If a definition
462−doesn't call for any explanation, it must be dead obvious.
463+doesn’t call for any explanation, it must be dead obvious.
463
464
464Two: every `%constant` we use must be defined where it is used,
465Two: every `%constant` we use must be defined where it is used,
465−not just where it's declared.
466+not just where it’s declared.
466
467
467The advantage of a `%constant` over a classic `typedef`: there is no
468The advantage of a `%constant` over a classic `typedef`: there is no
468−need to search formally for a symbol. The disadvantage: there is
469+need to search formally for a symbol. The disadvantage: there is
469−no trivial way to find out what the symbol actually means. So
470+no trivial way to find out what the symbol actually means. So
470when I send some `%foobar` move, I should define what I think
471when I send some `%foobar` move, I should define what I think
471−`%foobar` means. Just copy and paste the original definition.
472+`%foobar` means. Just copy and paste the original definition.
472
473
473−Code shouldn't even try for an A until it is quite stable. The worst
474+Code shouldn’t even try for an A until it is quite stable. The worst
474thing in the world is code that changes without updating the documentation.
475thing in the world is code that changes without updating the documentation.
475Any **incorrect** comment in a file drops it all the way back to a D.
476Any **incorrect** comment in a file drops it all the way back to a D.
tutorials/hoon/test-sets.md+4−4
@@ -6,7 +6,7 @@ template = "doc.html"
6
6
7In this walkthrough we will show how to use Ford as a testing suite.
7In this walkthrough we will show how to use Ford as a testing suite.
8
8
9−First we will cover the essential molds, arms, and generators used for testing, followed by walking through the code that implements a series of tests for standard library sets, as described [here](@/docs/tutorials/hoon/trees-sets-and-maps.md).
9+First we will cover the essential molds, [arms](/docs/glossary/arm/), and generators used for testing, followed by walking through the code that implements a series of tests for standard library sets, as described [here](@/docs/tutorials/hoon/trees-sets-and-maps.md).
10
10
11## Running our first test
11## Running our first test
12
12
@@ -41,9 +41,9 @@ Here, we ran a generator called `+test` with a path argument `/sys/hoon/set`. Th
41::
41::
42|%
42|%
43```
43```
44−We note that the first line that isn't a comment is `/+ *test`, which from [the previous lesson](@/docs/tutorials/hoon/ford.md) you know means that we are importing the shared library `lib/test.hoon`. This is followed by a core which will contain arms that perform our tests, which we will see an example of shortly.
44+We note that the first line that isn't a comment is `/+ *test`, which from [the previous lesson](@/docs/tutorials/hoon/ford.md) you know means that we are importing the shared library `lib/test.hoon`. This is followed by a [core](/docs/glossary/core/) which will contain arms that perform our tests, which we will see an example of shortly.
45
45
46−In `lib/test.hoon`, we find a core with a few gates: `expect-eq`, `expect-fail`, and `category`. The source for `expect-eq` is:
46+In `lib/test.hoon`, we find a core with a few [gates](/docs/glossary/gate/): `expect-eq`, `expect-fail`, and `category`. The source for `expect-eq` is:
47```hoon
47```hoon
48++ expect-eq
48++ expect-eq
49 |= [expected=vase actual=vase]
49 |= [expected=vase actual=vase]
@@ -127,7 +127,7 @@ We see that this arm returns a `tang`, i.e. a pretty-printed message, and adds s
127 !> ~
127 !> ~
128 !> (~(int in s-nul) s-asc)
128 !> (~(int in s-nul) s-asc)
129```
129```
130−`%+` is used to call a gate with a cell sample. `expect-eq` is the gate, `!> ~` is the head of the sample, and `!> (~(int in s-nul) s-asc)` is the tail of the sample. `!>` is a rune used to wrap a noun in its type - in other words, it produces a `vase`. We've seen this rune before when we learned about the type spear `-:!>`. Thus, what this block of code is doing is checking whether the expected `vase` that is the product of `!> ~` is equal to the `vase` that is the product of `!> (~(int in s-nul) s-asc)`. `s-nul` is simply the empty set, and here we are taking the intersection of the empty set with `s-asc`, a non-empty set. This ought to produce the empty set of course, and so when this block of code runs, we compare the expected result `!> ~` (which is something we determined by hand) with the actual result `!> (~(int in s-nul) s-asc)`.
130+`%+` is used to call a gate with a cell sample. `expect-eq` is the gate, `!> ~` is the head of the sample, and `!> (~(int in s-nul) s-asc)` is the tail of the sample. `!>` is a rune used to wrap a [noun](/docs/glossary/noun/) in its type - in other words, it produces a `vase`. We've seen this rune before when we learned about the type spear `-:!>`. Thus, what this block of code is doing is checking whether the expected `vase` that is the product of `!> ~` is equal to the `vase` that is the product of `!> (~(int in s-nul) s-asc)`. `s-nul` is simply the empty set, and here we are taking the intersection of the empty set with `s-asc`, a non-empty set. This ought to produce the empty set of course, and so when this block of code runs, we compare the expected result `!> ~` (which is something we determined by hand) with the actual result `!> (~(int in s-nul) s-asc)`.
131```hoon
131```hoon
132 %+ expect-eq
132 %+ expect-eq
133 !> ~
133 !> ~
tutorials/hoon/the-subject-and-its-legs.md+4−4
@@ -9,7 +9,7 @@ Hoon isn't an object-oriented programming language; it's a "subject-oriented" pr
9
9
10## A Start
10## A Start
11
11
12−For now we can say three things about the subject: (1) every Hoon expression is evaluated relative to some subject; (2) roughly, the subject defines the environment in which a Hoon expression is evaluated; and (3) the subject is a noun.
12+For now we can say three things about the subject: (1) every Hoon expression is evaluated relative to some subject; (2) roughly, the subject defines the environment in which a Hoon expression is evaluated; and (3) the subject is a [noun](/docs/glossary/noun/).
13
13
14In fact, you already learned about the noun address system in [Lesson 1.2](@/docs/tutorials/hoon/nouns.md) when you used `+` to return a fragment of a noun:
14In fact, you already learned about the noun address system in [Lesson 1.2](@/docs/tutorials/hoon/nouns.md) when you used `+` to return a fragment of a noun:
15
15
@@ -54,7 +54,7 @@ Let's create a subject with some computations:
5455
5455
55```
55```
56
56
57−`add` and `mul` are functions of the Hoon standard library. `add` is used to add two atoms, and `mul` is used to multiply them.
57+`add` and `mul` are functions of the Hoon standard library. `add` is used to add two [atoms](/docs/glossary/atom/), and `mul` is used to multiply them.
58
58
59## Limbs of the Subject
59## Limbs of the Subject
60
60
@@ -73,7 +73,7 @@ The subject is a noun, just like any other piece of Hoon data. In Lesson 1.2 we
73
73
74Each fragment of a noun is itself a noun, and hence can be understood as a binary tree as well. Each fragment or 'subtree' sticks out of the original tree, like a **limb**. A 'limb' is a subtree of the subject.
74Each fragment of a noun is itself a noun, and hence can be understood as a binary tree as well. Each fragment or 'subtree' sticks out of the original tree, like a **limb**. A 'limb' is a subtree of the subject.
75
75
76−Sometimes a programmer simply wants to produce a value from the subject. In other cases more is desired -- programmers often want to carry out substantive computations on data in the subject. There are two kinds of limbs to accommodate these two cases: arms and legs.
76+Sometimes a programmer simply wants to produce a value from the subject. In other cases more is desired -- programmers often want to carry out substantive computations on data in the subject. There are two kinds of limbs to accommodate these two cases: [arms](/docs/glossary/arm/) and legs.
77
77
78**Arms** are limbs of the subject that are used for carrying out substantive computations. We'll talk about arms in the next lesson. **Legs** are limbs that store data. Any limb that isn't an arm is a leg. In this lesson we'll talk about various ways to access legs of the subject.
78**Arms** are limbs of the subject that are used for carrying out substantive computations. We'll talk about arms in the next lesson. **Legs** are limbs that store data. Any limb that isn't an arm is a leg. In this lesson we'll talk about various ways to access legs of the subject.
79
79
@@ -193,7 +193,7 @@ You can think of this sort of lark series -- e.g., `+>-<` -- as indicating a bin
193 / \
193 / \
194 6 7
194 6 7
195```
195```
196−2. Use a lark expression to obtain the value 9 in the following noun: `[[5 6] 7 [[8 9 10] 3] 2] 1]`.
196+2. Use a lark expression to obtain the value 9 in the following noun: `[[5 6] 7 [[8 9 10] 3] 2]`.
197
197
198Solutions to these exercises may be found at the bottom of this lesson.
198Solutions to these exercises may be found at the bottom of this lesson.
199
199
tutorials/hoon/trees-sets-and-maps.md+5−5
@@ -11,7 +11,7 @@ In this lesson we'll cover each.
11
11
12## Trees
12## Trees
13
13
14−We use `tree` to make a binary tree data structure in Hoon, e.g., `(tree @)` for a binary tree of atoms.
14+We use `tree` to make a binary tree data structure in Hoon, e.g., `(tree @)` for a binary tree of [atoms](/docs/glossary/atom/).
15
15
16There are two kinds of `tree` in Hoon: (1) the null tree, `~`, and (2) a non-null tree which is a cell with three parts. Part (i) is the node value, part (ii) is the left child of the node, and part (iii) is the right child of the node. Each child is itself a tree. The node value has the face `n`, the left child has the face `l`, and the right child has the face `r`. The following diagram provides an illustration of a `(tree @)` (without the faces):
16There are two kinds of `tree` in Hoon: (1) the null tree, `~`, and (2) a non-null tree which is a cell with three parts. Part (i) is the node value, part (ii) is the left child of the node, and part (iii) is the right child of the node. Each child is itself a tree. The node value has the face `n`, the left child has the face `l`, and the right child has the face `r`. The following diagram provides an illustration of a `(tree @)` (without the faces):
17
17
@@ -32,7 +32,7 @@ Hoon supports trees of any type that can be constructed in Hoon, e.g.: `(tree @)
32{4 8 12 14 16}
32{4 8 12 14 16}
33```
33```
34
34
35−Notice that we don't have to insert the faces manually; by casting the noun above to a `(tree @)` Hoon inserts the faces for us. Let's put this noun in the dojo subject with the face `b` and pull out the tree at the left child of the `12` node:
35+Notice that we don't have to insert the faces manually; by casting the [noun](/docs/glossary/noun/) above to a `(tree @)` Hoon inserts the faces for us. Let's put this noun in the dojo subject with the face `b` and pull out the tree at the left child of the `12` node:
36
36
37```
37```
38> =b `(tree @)`[12 [8 [4 ~ ~] ~] [14 ~ [16 ~ ~]]]
38> =b `(tree @)`[12 [8 [4 ~ ~] ~] [14 ~ [16 ~ ~]]]
@@ -88,11 +88,11 @@ $(hay r.hay)
88
88
89## Sets
89## Sets
90
90
91−Use `set` to create a data structure for a set of values, e.g., `(set @)` for a set of atoms. The `in` core in the Hoon standard library contains the various functions for operating on sets. See the standard library reference documentation for sets [here](@/docs/reference/library/2h.md).
91+Use `set` to create a data structure for a set of values, e.g., `(set @)` for a set of atoms. The `in` [core](/docs/glossary/core/) in the Hoon standard library contains the various functions for operating on sets. See the standard library reference documentation for sets [here](@/docs/reference/library/2h.md).
92
92
93As with `list`s and `tree`s, there are two categories of sets: null `~`, and non-null. Hoon implements sets using trees for the underlying noun.
93As with `list`s and `tree`s, there are two categories of sets: null `~`, and non-null. Hoon implements sets using trees for the underlying noun.
94
94
95−Two common methods for populating a set include (1) creating it from a list of values using the `sy` function, and (2) inserting items into a set using the `put` arm of the `in` core.
95+Two common methods for populating a set include (1) creating it from a list of values using the `sy` function, and (2) inserting items into a set using the `put` [arm](/docs/glossary/arm/) of the `in` core.
96
96
97Using `sy`:
97Using `sy`:
98
98
@@ -138,7 +138,7 @@ Check whether an item is in the set using `has` of `in`:
138%.n
138%.n
139```
139```
140
140
141−You can apply a gate to each item of a set using `run` of `in` and produce a new set from the products:
141+You can apply a [gate](/docs/glossary/gate/) to each item of a set using `run` of `in` and produce a new set from the products:
142
142
143```
143```
144> c
144> c
tutorials/hoon/type-checking-and-type-inference.md+4−4
@@ -62,7 +62,7 @@ nest-fail
62
62
63The `^+` rune takes two subexpressions. The first subexpression is evaluated and its type is inferred. The second subexpression is evaluated and its inferred type is compared against the type of the first. If the type of the second provably nests under the type of the first, the result of the `^+` expression is just the value of its second subexpression. Otherwise, the code fails to compile.
63The `^+` rune takes two subexpressions. The first subexpression is evaluated and its type is inferred. The second subexpression is evaluated and its inferred type is compared against the type of the first. If the type of the second provably nests under the type of the first, the result of the `^+` expression is just the value of its second subexpression. Otherwise, the code fails to compile.
64
64
65−This rune is useful for casting when you already have a noun -- or expression producing a noun -- whose type you may not know or be able to construct easily. If you want your output value to be of the same type, you can use `^+`.
65+This rune is useful for casting when you already have a [noun](/docs/glossary/noun/) -- or expression producing a [noun](/docs/glossary/noun/) -- whose type you may not know or be able to construct easily. If you want your output value to be of the same type, you can use `^+`.
66
66
67More examples:
67More examples:
68
68
@@ -98,7 +98,7 @@ You can evade the `.=` type-check by casting one of its subexpressions to a `*`,
98
98
99It isn't recommended that you evade the rules in this way, however.
99It isn't recommended that you evade the rules in this way, however.
100
100
101−The `.+` increment rune -- including its `+( )` irregular form -- does a type check to ensure that its subexpression must evaluate to an atom.
101+The `.+` increment rune -- including its `+( )` irregular form -- does a type check to ensure that its subexpression must evaluate to an [atom](/docs/glossary/atom/).
102
102
103```
103```
104> +(12)
104> +(12)
@@ -110,9 +110,9 @@ nest-fail
110
110
111### Arm Evaluation
111### Arm Evaluation
112
112
113−Whenever an arm is evaluated in Hoon it expects to have some version of its parent core as the subject. Specifically, a type check is performed to see whether the arm subject is of the appropriate **type**. We see this in action whenever a gate or a multi-arm door is called.
113+Whenever an [arm](/docs/glossary/arm/) is evaluated in Hoon it expects to have some version of its parent [core](/docs/glossary/core/) as the subject. Specifically, a type check is performed to see whether the [arm](/docs/glossary/arm/) subject is of the appropriate **type**. We see this in action whenever a [gate](/docs/glossary/gate/) or a multi-arm [door](/docs/glossary/door/) is called.
114
114
115−A gate is a one-armed core with a sample. When it is called, its `$` arm is evaluated with (a version of) the gate as the subject. The only part of the core that might change is the payload, including the sample. Of course, we want the sample to be able to change. The sample is where the argument(s) of the function call are placed. For example, when we call `add` the `$` arm of expects two atoms for the sample, i.e., the two numbers to be added. When the type check occurs, the payload must be of the appropriate type. If it isn't, the result is a `nest-fail` crash.
115+A gate is a one-armed core with a sample. When it is called, its `$` arm is evaluated with (a version of) the gate as the subject. The only part of the core that might change is the [payload](/docs/glossary/payload/), including the sample. Of course, we want the sample to be able to change. The sample is where the argument(s) of the function call are placed. For example, when we call `add` the `$` arm of expects two atoms for the sample, i.e., the two numbers to be added. When the type check occurs, the [payload](/docs/glossary/payload/) must be of the appropriate type. If it isn't, the result is a `nest-fail` crash.
116
116
117```
117```
118> (add 22 33)
118> (add 22 33)
tutorials/hoon/type-polymorphism.md+4−4
@@ -7,7 +7,7 @@ aliases = ["/docs/learn/hoon/hoon-tutorial/type-polymorphism/"]
7
7
8There are many cases in which one may want to write a function that accepts as input various different types of data. Such a function is said to be [polymorphic](https://en.wikipedia.org/wiki/Polymorphism_%28computer_science%29). ("Polymorphism" = "many forms"; so polymorphic functions accept many forms of data as input.)
8There are many cases in which one may want to write a function that accepts as input various different types of data. Such a function is said to be [polymorphic](https://en.wikipedia.org/wiki/Polymorphism_%28computer_science%29). ("Polymorphism" = "many forms"; so polymorphic functions accept many forms of data as input.)
9
9
10−One relatively trivial form of polymorphism involves sub-typing. A gate whose sample is a raw `noun` can accept any Hoon data structure as input -- it's just that the sample will only be treated as a raw noun. For example, consider the `copy` gate below:
10+One relatively trivial form of polymorphism involves sub-typing. A [gate](/docs/glossary/gate/) whose sample is a raw `noun` can accept any Hoon data structure as input -- it's just that the sample will only be treated as a raw [noun](/docs/glossary/noun/). For example, consider the `copy` gate below:
11
11
12```
12```
13> =copy |=(a=* [a a])
13> =copy |=(a=* [a a])
@@ -28,7 +28,7 @@ In this lesson we'll go over Hoon's support for more interesting polymorphic fun
28
28
29## Polymorphic Properties of Cores
29## Polymorphic Properties of Cores
30
30
31−Hoon supports type polymorphism at the core level. That is, each core has certain polymorphic properties that are tracked and maintained as metadata by Hoon's type system. (See `+$ type` of `hoon.hoon`.) These properties determine the extent to which a core can be used as an interface for values of various types.
31+Hoon supports type polymorphism at the [core](/docs/glossary/core/) level. That is, each core has certain polymorphic properties that are tracked and maintained as metadata by Hoon's type system. (See `+$ type` of `hoon.hoon`.) These properties determine the extent to which a core can be used as an interface for values of various types.
32
32
33This is rather vaguely put so far. We can clarify by talking more specifically about the kinds of polymorphism supported in Hoon. There are two kinds of type polymorphism for cores: [genericity](https://en.wikipedia.org/wiki/Generic_programming), to include certain kinds of [parametric polymorphism](https://en.wikipedia.org/wiki/Parametric_polymorphism); and [variance polymorphism](https://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29), which involves making use of special sub-typing rules for cores.
33This is rather vaguely put so far. We can clarify by talking more specifically about the kinds of polymorphism supported in Hoon. There are two kinds of type polymorphism for cores: [genericity](https://en.wikipedia.org/wiki/Generic_programming), to include certain kinds of [parametric polymorphism](https://en.wikipedia.org/wiki/Parametric_polymorphism); and [variance polymorphism](https://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29), which involves making use of special sub-typing rules for cores.
34
34
@@ -36,7 +36,7 @@ If you don't understand these very well, that's okay. We'll explain them. Let'
36
36
37## Dry vs. Wet Cores
37## Dry vs. Wet Cores
38
38
39−To review briefly, a **core** is a pair of `[battery payload]`. The **battery** contains the various arms of the core (code), and the **payload** contains all the data needed to evaluate those arms correctly (data). Every arm is evaluated with its parent core as the subject. A **gate** (i.e., a Hoon function) is a core with exactly one arm named `$` and with a payload of the form: `[sample context]`. The **sample** is reserved for the function's argument value, and the **context** is any other data needed to evaluate `$` correctly.
39+To review briefly, a **core** is a pair of `[battery payload]`. The **battery** contains the various [arms](/docs/glossary/arm/) of the core (code), and the **payload** contains all the data needed to evaluate those arms correctly (data). Every arm is evaluated with its parent core as the subject. A **gate** (i.e., a Hoon function) is a core with exactly one arm named `$` and with a [payload](/docs/glossary/payload/) of the form: `[sample context]`. The **sample** is reserved for the function's argument value, and the **context** is any other data needed to evaluate `$` correctly.
40
40
41There are two kinds of cores: **dry** and **wet**. Dry cores, which are more typical, _don't_ make use of **genericity**. Wet cores do. In order to understand generic functions in Hoon, you have to understand the difference between dry and wet cores.
41There are two kinds of cores: **dry** and **wet**. Dry cores, which are more typical, _don't_ make use of **genericity**. Wet cores do. In order to understand generic functions in Hoon, you have to understand the difference between dry and wet cores.
42
42
@@ -64,7 +64,7 @@ For illustration, consider the gate created by `add`, a function in the Hoon sta
64 sample context
64 sample context
65```
65```
66
66
67−The `add` code depends on the fact that there are two atoms in the sample: the numbers to be added together. Hence, it is appropriate that only a cell of atoms is permitted for the sample. We can look at the default sample of `add` at address `+6`:
67+The `add` code depends on the fact that there are two [atoms](/docs/glossary/atom/) in the sample: the numbers to be added together. Hence, it is appropriate that only a cell of atoms is permitted for the sample. We can look at the default sample of `add` at address `+6`:
68
68
69```
69```
70> +6:add
70> +6:add
tutorials/hoon/workbook/bomb.md+1−1
@@ -99,7 +99,7 @@ doing here.
99We call `defuse` and pass it `cuts`, the list of tapes we were provided with
99We call `defuse` and pass it `cuts`, the list of tapes we were provided with
100when the generator started.
100when the generator started.
101
101
102−Next is the core that has two arms, `defuse` and `rules`. Let's look at `rules`
102+Next is the [core](/docs/glossary/core/) that has two [arms](/docs/glossary/arm/), `defuse` and `rules`. Let's look at `rules`
103quickly.
103quickly.
104
104
105We can see that it is a `map` of `tape` to `list` of `tape`. For each of the
105We can see that it is a `map` of `tape` to `list` of `tape`. For each of the
tutorials/hoon/workbook/digits.md+1−1
@@ -33,7 +33,7 @@ need some "boilerplate" code in the format of `[%say [%noun "data"]]`:
33
33
34The head of this cell is the literal `%say`.
34The head of this cell is the literal `%say`.
35
35
36−In the tail is the gate and its sample: `|= [* [n=@ud ~] ~]`. This is
36+In the tail is the [gate](/docs/glossary/gate/) and its sample: `|= [* [n=@ud ~] ~]`. This is
37where we describe any arguments we are expecting to be passed in when the
37where we describe any arguments we are expecting to be passed in when the
38generator is called. We are expecting data of type `@ud`. We give the data the
38generator is called. We are expecting data of type `@ud`. We give the data the
39face `n` so that we can easily reference it later.
39face `n` so that we can easily reference it later.
tutorials/hoon/workbook/eightball.md+4−4
@@ -66,10 +66,10 @@ the template that is followed for all `%say` generators.
66`:- %say` creates a cell with `%say` as that cell's head to define
66`:- %say` creates a cell with `%say` as that cell's head to define
67the generator's format.
67the generator's format.
68
68
69−`|= [[* eny=@uv *] *]` is the tail of the cell, a gate, and that gate's first
69+`|= [[* eny=@uv *] *]` is the tail of the cell, a [gate](/docs/glossary/gate/), and that gate's first
70child, a sample. Because the only external data our program is interested in
70child, a sample. Because the only external data our program is interested in
71using is entropy to seed our random-number generator, that's the only one we
71using is entropy to seed our random-number generator, that's the only one we
72−will assign a face (`eny`). The `*` elements that you see represent any noun. We
72+will assign a face (`eny`). The `*` elements that you see represent any [noun](/docs/glossary/noun/). We
73use these as fillers: because we don't wish to use the data that's passed to
73use these as fillers: because we don't wish to use the data that's passed to
74those parts of the sample, we don't assign them faces.
74those parts of the sample, we don't assign them faces.
75
75
@@ -135,7 +135,7 @@ elements are the `tape`s that are selected as the 8-Ball's responses.
135
135
136The code above is our random-number engine.
136The code above is our random-number engine.
137
137
138−`og` is the core in the standard library that contains arms that perform
138+`og` is the [core](/docs/glossary/core/) in the standard library that contains [arms](/docs/glossary/arm/) that perform
139randomness-related operations. `=/ rng ~(. og eny)` passes `eny` to the
139randomness-related operations. `=/ rng ~(. og eny)` passes `eny` to the
140subject of `og`, and then stores the resulting core in a face called `rng`.
140subject of `og`, and then stores the resulting core in a face called `rng`.
141
141
@@ -149,7 +149,7 @@ store the random result in `val`.
149(snag val answers)
149(snag val answers)
150```
150```
151
151
152−`snag` is a standard-library arm that that takes two arguments: an atom and
152+`snag` is a standard-library arm that that takes two arguments: an [atom](/docs/glossary/atom/) and
153a `list`. It fetches the element in position `n` of the list, where `n` is the
153a `list`. It fetches the element in position `n` of the list, where `n` is the
154value of the atom it was passed. By using the randomized `val` as that position
154value of the atom it was passed. By using the randomized `val` as that position
155argument, we can pull a different response from `answers` every time the
155argument, we can pull a different response from `answers` every time the
tutorials/hoon/workbook/traffic-light.md+4−4
@@ -47,9 +47,9 @@ relevant to the functionality of our program.
47 --
47 --
48```
48```
49
49
50−`=+` adds a noun to the subject. In our case, the noun in question is the core
50+`=+` adds a [noun](/docs/glossary/noun/) to the subject. In our case, the [noun](/docs/glossary/noun/) in question is the [core](/docs/glossary/core/)
51that is opened with `|%` and closed with `--`. This core is used to store types,
51that is opened with `|%` and closed with `--`. This core is used to store types,
52−and does that with the arm that it contains.
52+and does that with the [arm](/docs/glossary/arm/) that it contains.
53
53
54`++ state` creates an arm called `state`, which will be used as the name of the
54`++ state` creates an arm called `state`, which will be used as the name of the
55new type that is created in the code that follows, `?(%red %yellow %green)`.
55new type that is created in the code that follows, `?(%red %yellow %green)`.
@@ -89,7 +89,7 @@ With `|%`, we are finally at the meat of the program. This core that we just
89named has two arms: `look`, which gives us the current state, defined later; and
89named has two arms: `look`, which gives us the current state, defined later; and
90`set`, which gives us a simple way to modify the value of `current-state`.
90`set`, which gives us a simple way to modify the value of `current-state`.
91
91
92−The gate we are producing with `|=` may look a bit strange, so let's break it
92+The [gate](/docs/glossary/gate/) we are producing with `|=` may look a bit strange, so let's break it
93down.
93down.
94
94
95`s=state` allows for an argument of type `state` and gives it a face `s`.
95`s=state` allows for an argument of type `state` and gives it a face `s`.
@@ -101,7 +101,7 @@ How does this work?
101Remember that `.` is [wing syntax](@/docs/reference/hoon-expressions/limb/wing.md) that
101Remember that `.` is [wing syntax](@/docs/reference/hoon-expressions/limb/wing.md) that
102applies the wing expression on the left of it to the noun to the right of it.
102applies the wing expression on the left of it to the noun to the right of it.
103`$` is the arm of the core. Then by using the wing expression `+>`, which means
103`$` is the arm of the core. Then by using the wing expression `+>`, which means
104−"return the head of the tail", we traverse the subject to the core to latch onto
104+"return the tail of the tail", we traverse the subject to the core to latch onto
105its parent core. where we defined the arms `look` and `set`. The `( )` then
105its parent core. where we defined the arms `look` and `set`. The `( )` then
106lists changes to the core we would like to make as we produce a new one. You
106lists changes to the core we would like to make as we produce a new one. You
107will often see `+>.$` used in this way.
107will often see `+>.$` used in this way.
tutorials/nock/definition.md+1−1
@@ -6,7 +6,7 @@ aliases = ["docs/learn/nock/definition/"]
6+++
6+++
7
7
8Nock is a Turing-complete function that maps a cell
8Nock is a Turing-complete function that maps a cell
9−`[subject formula]` to a noun `product`, where `subject` is the
9+`[subject formula]` to a [noun](/docs/glossary/noun/) `product`, where `subject` is the
10data, `formula` is the code, and `product` is the result.
10data, `formula` is the code, and `product` is the result.
11
11
12To program in Hoon, this is all you need to know about Nock.
12To program in Hoon, this is all you need to know about Nock.
tutorials/sail-and-udon.md+115−107
@@ -5,7 +5,7 @@ template = "doc.html"
5aliases = ["docs/using/sail-and-udon/"]
5aliases = ["docs/using/sail-and-udon/"]
6+++
6+++
7
7
8−Sail is Hoon markup that’s used to render a web page with XML. But what makes it special is that you can run arbitrary Hoon code within such a web page without using a separate markup language.
8+Sail is Hoon markup that's used to render a web page with XML. But what makes it special is that you can run arbitrary Hoon code within such a web page without using a separate markup language.
9
9
10Udon is a way to write content for the web. It's a minimalist markup language for creating and rendering text documents, with a Markdown-inspired syntax. It's integrated with our Hoon programming language, allowing it to be used as standalone prose in its own file or embedded inside a Hoon source file, in which case it will be parsed into a tree of HTML nodes using Sail.
10Udon is a way to write content for the web. It's a minimalist markup language for creating and rendering text documents, with a Markdown-inspired syntax. It's integrated with our Hoon programming language, allowing it to be used as standalone prose in its own file or embedded inside a Hoon source file, in which case it will be parsed into a tree of HTML nodes using Sail.
11
11
@@ -25,8 +25,8 @@ Before starting with either Sail or Udon, make sure that your ship is
25[mounted to Unix](@/using/install.md).
25[mounted to Unix](@/using/install.md).
26
26
27To host that output, your ship also has a web-server that can be found at
27To host that output, your ship also has a web-server that can be found at
28−`localhost` (default port 80) if it’s your first ship that’s running on the
28+`http://localhost/` (default port 80) if it's your first ship that's running on the
29−machine, `http://localhost:8081/` if it’s the second ship on that same machine,
29+machine, `http://localhost:8081/` if it's the second ship on that same machine,
30and so on. In the startup messages, a ship will tell you which HTTP port it's
30and so on. In the startup messages, a ship will tell you which HTTP port it's
31using.
31using.
32
32
@@ -44,14 +44,14 @@ Dojo:
44
44
45This command has three arguments:
45This command has three arguments:
46- The first is the URL we want to bind our site to. We chose `/test`, so the URL
46- The first is the URL we want to bind our site to. We chose `/test`, so the URL
47−we will find our site at is `localhost/test`.
47+we will find our site at is `http://localhost/test`.
48- The second is the desk we want to serve. We will be serving from `%home` in
48- The second is the desk we want to serve. We will be serving from `%home` in
49this tutorial.
49this tutorial.
50- The third is the file that we want to serve. In this tutorial, we will be
50- The third is the file that we want to serve. In this tutorial, we will be
51−using `/gen/frontpage/hoon`, which refers to `frontpage.hoon`.
51+using `/gen/frontpage/hoon`, which refers to `/gen/frontpage.hoon`.
52
52
53Run the command `|serve /test %home /gen/frontpage/hoon`. Now navigate to
53Run the command `|serve /test %home /gen/frontpage/hoon`. Now navigate to
54−`localhost/test` (or `localhost:8081/test` if your ship is on that port) in your
54+`http://localhost/test` (or `http://localhost:8081/test` if your ship is on that port) in your
55browser, and you should see the rendered Sail.
55browser, and you should see the rendered Sail.
56
56
57**Note:** Important to remember that every time you edit a file in your ship's
57**Note:** Important to remember that every time you edit a file in your ship's
@@ -60,7 +60,7 @@ to copy those changes to Urbit.
60
60
61## <a name="sail"></a>Sail: A Guide
61## <a name="sail"></a>Sail: A Guide
62
62
63−It’s easy to see how Sail can directly translate to HTML:
63+It's easy to see how Sail can directly translate to HTML:
64
64
65### Sail code
65### Sail code
66
66
@@ -89,7 +89,7 @@ It’s easy to see how Sail can directly translate to HTML:
89 <body>
89 <body>
90 <h1>Welcome!</h1>
90 <h1>Welcome!</h1>
91 Hello, world!
91 Hello, world!
92− We’re on the web.
92+ We're on the web.
93 <div></div>
93 <div></div>
94 <script src="http://unsafely.tracking.you/cookiemonster.js"></script>
94 <script src="http://unsafely.tracking.you/cookiemonster.js"></script>
95 </body>
95 </body>
@@ -99,7 +99,7 @@ It’s easy to see how Sail can directly translate to HTML:
99You can test above Sail code by placing it
99You can test above Sail code by placing it
100under `^- manx` in your `frontpage.hoon` file, and then running `|commit %home`
100under `^- manx` in your `frontpage.hoon` file, and then running `|commit %home`
101in the Dojo. If you've already run the `|serve` command code from the first
101in the Dojo. If you've already run the `|serve` command code from the first
102−section, the new content should appear at `localhost/test`.
102+section, the new content should appear at `http://localhost/test`.
103
103
104It shouldn't be hard to see the similarities between Sail and HTML. So let's go
104It shouldn't be hard to see the similarities between Sail and HTML. So let's go
105into more detail about what the differences are.
105into more detail about what the differences are.
@@ -108,7 +108,7 @@ into more detail about what the differences are.
108
108
109In Sail, tag heads are written with the tag name prepended by `;`. Unlike in
109In Sail, tag heads are written with the tag name prepended by `;`. Unlike in
110HTML, there are different ways on closing tags, depending on the needs of the
110HTML, there are different ways on closing tags, depending on the needs of the
111−tag. One of the nice things about Hoon is that you don’t have to be constantly
111+tag. One of the nice things about Hoon is that you don't have to be constantly
112closing expressions; Sail inherits this convenience.
112closing expressions; Sail inherits this convenience.
113
113
114#### Empty
114#### Empty
@@ -147,7 +147,7 @@ with `==`, because they expect a list of sub-tags. If we nest a line of plain
147text with no tag, a `<p>` is prepended.
147text with no tag, a `<p>` is prepended.
148
148
149Sail, like Hoon, is white-space sensitive. Unlike in Hoon, however, two spaces
149Sail, like Hoon, is white-space sensitive. Unlike in Hoon, however, two spaces
150−(called a "gap") is not necessarily equivalent to a line-break in Sail.
150+(called a `gap`) is not necessarily equivalent to a line-break in Sail.
151
151
152```
152```
153;body
153;body
@@ -160,12 +160,11 @@ Equals:
160
160
161```
161```
162<body>
162<body>
163− <h1>Blog title</h1>
163+ <h1>Blog title</h1>
164− <p>This is some good content.</p>
164+ <p>This is some good content.</p>
165</body>
165</body>
166```
166```
167
167
168−
169Conversely, if we want to write a string with no tag at all, then we can prepend
168Conversely, if we want to write a string with no tag at all, then we can prepend
170those untagged lines with `;`.
169those untagged lines with `;`.
171
170
@@ -173,7 +172,7 @@ those untagged lines with `;`.
173;body
172;body
174 ;h1: Welcome!
173 ;h1: Welcome!
175 ; Hello, world!
174 ; Hello, world!
176− ; We’re on the web.
175+ ; We're on the web.
177==
176==
178```
177```
179
178
@@ -183,27 +182,25 @@ Equals:
183<body>
182<body>
184 <h1>Welcome!</h1>
183 <h1>Welcome!</h1>
185 Hello, world!
184 Hello, world!
186− We’re on the web.
185+ We're on the web.
187</body>
186</body>
188```
187```
189
188
190−
191#### Attributes
189#### Attributes
192
190
193Attributes are key-value pairs that go into an HTML node.
191Attributes are key-value pairs that go into an HTML node.
194
192
195Adding attributes is simple: just add the desired attribute between parentheses,
193Adding attributes is simple: just add the desired attribute between parentheses,
196−right after the tag name without a space. We separate different attributes of
194+right after the tag name without a space. We separate different attributes of
197the same node by using `,`.
195the same node by using `,`.
198
196
199−Attributes can be used in two forms: flat, which uses one line; and tall, which
197+Attributes can be used in two forms: wide, which uses one line; and tall, which
200−uses multiple lines, when a single line would not be practical. Flat forms and
198+uses multiple lines, when a single line would not be practical. Wide forms and
201−flat forms are two syntaxes of semantically equivalent expressions.
199+tall forms are two syntaxes of semantically equivalent expressions.
202−
203
200
204#### Generic
201#### Generic
205
202
206−The code below produces a “Submit” button on the page.
203+The code below produces a "Submit" button on the page.
207
204
208Wide-form Sail:
205Wide-form Sail:
209
206
@@ -223,7 +220,7 @@ Tall-form Sail:
223Equals:
220Equals:
224
221
225```
222```
226−<input type="submit" value="Submit">`
223+<input type="submit" value="Submit">
227```
224```
228
225
229#### IDs
226#### IDs
@@ -242,27 +239,34 @@ Add `#` after tag name to add an ID.
242
239
243#### Classes
240#### Classes
244
241
242+`;h1.text-blue: Title`
243+
244+Equals:
245+
245−`;h1.text-blue: Title` equals `<h1 class="text-blue">Title</h1>`
246+`<h1 class="text-blue">Title</h1>`
246
247
247−Add `.` after tag name to add a class. However, if you want a class name that
248+Add `.` after tag name to add a class. However, if you want a class list that
248contains a space, you will need to use use the syntax of a generic attribute:
249contains a space, you will need to use use the syntax of a generic attribute:
249
250
250−`;div(class "logo inverse");` equals `<div class="logo inverse"></div>`
251+`;div(class "logo inverse");`
252+
253+Equals:
251
254
255+`<div class="logo inverse"></div>`
252
256
253#### Image
257#### Image
254
258
255`;img@"example.png";`
259`;img@"example.png";`
256
260
257−Equals
261+Equals:
258
262
259−`<img src="example.png"/>`
263+`<img src="example.png" />`
260
264
261Add `@` after the tag name to link your source.
265Add `@` after the tag name to link your source.
262
266
263To add attributes to the image, like size specifications, add the
267To add attributes to the image, like size specifications, add the
264−desired attribute after the `"` of the image name and before the final `;` of
268+desired attribute after the closing `"` of the image name and before the final
265−the `img` tag.
269+`;` of the `img` tag.
266
270
267For example:
271For example:
268
272
@@ -272,12 +276,20 @@ For example:
272
276
273`;a/"urbit.org": A link to Urbit.org`
277`;a/"urbit.org": A link to Urbit.org`
274
278
275−Equals
279+Equals:
276
280
277`<a href="urbit.org">A link to Urbit.org</a>`
281`<a href="urbit.org">A link to Urbit.org</a>`
278
282
279Add `/` after tag name to start an href.
283Add `/` after tag name to start an href.
280
284
285+To add attributes to the link, like target specifications, add the
286+desired attribute after the closing `"` of the link url and before the `:` of
287+the `a` tag.
288+
289+For example:
290+
291+`;a/"urbit.org"(target "_blank"): A link to Urbit.org`
292+
281### Hoon in Sail
293### Hoon in Sail
282
294
283Our first example is useful to understand how Sail syntax translates to HTML
295Our first example is useful to understand how Sail syntax translates to HTML
@@ -287,7 +299,7 @@ with Hoon code.
287One place where Sail diverges from HTML is that it supports string
299One place where Sail diverges from HTML is that it supports string
288interpolation. In Sail, the contents of all tags are a string type called `tape`
300interpolation. In Sail, the contents of all tags are a string type called `tape`
289unless otherwise designated. Tapes are delineated by the double quotes `""`.
301unless otherwise designated. Tapes are delineated by the double quotes `""`.
290−That’s important, because tapes can be interpolated with Hoon expressions,
302+That's important, because tapes can be interpolated with Hoon expressions,
291provided that those expressions produce something a tape as well. Interpolation
303provided that those expressions produce something a tape as well. Interpolation
292is done by wrapping the code to be inserted in `{}`. In your Dojo prompt, try
304is done by wrapping the code to be inserted in `{}`. In your Dojo prompt, try
293the command below (without the `>`):
305the command below (without the `>`):
@@ -310,7 +322,7 @@ following command in your Dojo:
31033
32233
311```
323```
312
324
313−This should work, producing `33`, an atom. That’s our problem. The
325+This should work, producing `33`, an atom. That's our problem. The
314interpolation expression expects a tape, but our first command tried to
326interpolation expression expects a tape, but our first command tried to
315interpolate with something that results in an atom. Try this now:
327interpolate with something that results in an atom. Try this now:
316
328
@@ -319,8 +331,8 @@ interpolate with something that results in an atom. Try this now:
319"33"
331"33"
320```
332```
321
333
322−We get a similar result, but we know that it’s a tape because it’s wrapped in
334+We get a similar result, but we know that it's a tape because it's wrapped in
323−`""`. Bingo! With this knowledge, let’s perform a successful interpolation:
335+`""`. Bingo! With this knowledge, let's perform a successful interpolation:
324
336
325```
337```
326> "I am a l{<(mul 3 11)>}t Urbit user."
338> "I am a l{<(mul 3 11)>}t Urbit user."
@@ -376,7 +388,7 @@ web-related operations.
376
388
377### A More Interesting Example
389### A More Interesting Example
378
390
379−Now let’s apply knowledge of string interpolation and the Sail subject in a Sail
391+Now let's apply knowledge of string interpolation and the Sail subject in a Sail
380source file. The following code produces more interesting things than the
392source file. The following code produces more interesting things than the
381example we saw before.
393example we saw before.
382
394
@@ -417,31 +429,31 @@ Save the above Sail code in to `home/web/pages/secondsail.hoon` and access the
417resulting page by navigating to `http://localhost:8080/pages/secondsail` in
429resulting page by navigating to `http://localhost:8080/pages/secondsail` in
418your browser.
430your browser.
419
431
420−There are some interesting things here. Let’s go through this code piece by
432+There are some interesting things here. Let's go through this code piece by
421piece.
433piece.
422
434
423```
435```
424/= gas /$ fuel:html
436/= gas /$ fuel:html
425```
437```
426
438
427−Later in this code we want produce the name of the ship is hosting it, something
439+Later in this code we want to produce the name of the ship which is hosting it,
428−that looks like ~lodleb-ritrul. In a generator, we could produce our ship name
440+something that looks like ~lodleb-ritrul. In a generator, we could produce our ship
429−by writing `our` -- try it in the Dojo. But remember that Sail is rendered
441+name by writing `our` -- try it in the Dojo. But remember that Sail is rendered
430against its own subject, `our` is not part of the default subject. To augment
442against its own subject, `our` is not part of the default subject. To augment
431our subject with the information that we need, we use `/= gas /$ fuel:html`.
443our subject with the information that we need, we use `/= gas /$ fuel:html`.
432
444
433The above expression uses two Ford runes, `/=` and `/$`, to add the relevant
445The above expression uses two Ford runes, `/=` and `/$`, to add the relevant
434−information to the current subject. We can pull the ship’s name out of this
446+information to the current subject. We can pull the ship's name out of this
435augmented subject later. It's important to note that these runes are not part of
447augmented subject later. It's important to note that these runes are not part of
436Hoon. They are part of Ford, our build system.
448Hoon. They are part of Ford, our build system.
437
449
438`/$` is used to get data from the environment, and `/=` adds that data to
450`/$` is used to get data from the environment, and `/=` adds that data to
439subject in the face `gas`. The
451subject in the face `gas`. The
440[Ford user manual](https://urbit.org/docs/arvo/internals/ford/runes/) has
452[Ford user manual](https://urbit.org/docs/arvo/internals/ford/runes/) has
441−details on these and other Ford runes, but understanding these runes isn’t
453+details on these and other Ford runes, but understanding these runes isn't
442necessary for the purposes of this tutorial.
454necessary for the purposes of this tutorial.
443
455
444−`fuel:html` gets extra data from your ship’s Eyre module, which handles all
456+`fuel:html` gets extra data from your ship's Eyre module, which handles all
445things HTTP, and sticks it in the subject when Eyre renders a page. This
457things HTTP, and sticks it in the subject when Eyre renders a page. This
446includes the name of the ship, which is what we look for in the next line, but
458includes the name of the ship, which is what we look for in the next line, but
447it includes much more.
459it includes much more.
@@ -473,7 +485,7 @@ the source code.
473 "comet"
485 "comet"
474```
486```
475
487
476−This code chunk is a series of conditionals that checks the host ship’s name to
488+This code chunk is a series of conditionals that checks the host ship's name to
477see what its value is.
489see what its value is.
478
490
479The first line, `=+ wid=(met 3 p.bem.gas)`, combines a new noun with the
491The first line, `=+ wid=(met 3 p.bem.gas)`, combines a new noun with the
@@ -505,7 +517,7 @@ perform less-than tests to see what kind of ship is running the web-server.
505Sail proper begins here. These four lines are four nodes. The `;html` node
517Sail proper begins here. These four lines are four nodes. The `;html` node
506indicates that the contained code should be rendered as HTML; this tag is closed
518indicates that the contained code should be rendered as HTML; this tag is closed
507on the final line. The `;head` node contains metadata, and is closed three lines
519on the final line. The `;head` node contains metadata, and is closed three lines
508−later. The `;meta` node sets the character set to UTF-8, and the `;title` node
520+later. The `;meta` node sets the character set to UTF-8, and the `;title` node
509sets the title of the page that shows up in the browser tab.
521sets the title of the page that shows up in the browser tab.
510
522
511```
523```
@@ -532,7 +544,7 @@ attributes, it continues the line without formatting. Following `;span:` with
532**two** spaces causes there to be single space following the produced `<span>`
544**two** spaces causes there to be single space following the produced `<span>`
533element, because one of those spaces is syntactically necessary.
545element, because one of those spaces is syntactically necessary.
534
546
535−In the following lines, we beginning to use some Hoon expressions again.
547+In the following lines, we begin to use some Hoon expressions again.
536
548
537```
549```
538 ;+ ?: show-list
550 ;+ ?: show-list
@@ -542,7 +554,7 @@ In the following lines, we beginning to use some Hoon expressions again.
542In the top line in the chunk above, we use the `;+` Sail rune, which
554In the top line in the chunk above, we use the `;+` Sail rune, which
543resolves an expression to a single node. That expression, in this case, is
555resolves an expression to a single node. That expression, in this case, is
544`?:`, which tests the truth value of `show-list`, which we assigned the value
556`?:`, which tests the truth value of `show-list`, which we assigned the value
545−`&` (meaning “true”) at the beginning of the program. It’s closed by the `==` on
557+`&` (meaning `true`) at the beginning of the program. It's closed by the `==` on
546the last line.
558the last line.
547
559
548Thus, this program resolves to the first child of `show-list`, the node `;ol`.
560Thus, this program resolves to the first child of `show-list`, the node `;ol`.
@@ -556,8 +568,8 @@ The line above is the only element of this list that does not use
556Hoon proper. The line renders as green, as interpreted by the browser,
568Hoon proper. The line renders as green, as interpreted by the browser,
557because of the Sail attribute.
569because of the Sail attribute.
558
570
559−The next items in the list use `{}`. Recall that these braces, pronounced “lob”
571+The next items in the list use `{}`. Recall that these braces, pronounced "lob"
560−and “rob” in Hoon-speak, allow for the interpolation of code within a string.
572+and "rob" in Hoon-speak, allow for the interpolation of code within a string.
561
573
562```
574```
563 ;li: We're pretty-printing this sum with Hoon: {<(add 50 50)>}.
575 ;li: We're pretty-printing this sum with Hoon: {<(add 50 50)>}.
@@ -567,17 +579,15 @@ The line above is interpolated with Hoon code that produces the sum of 50 plus
56750, which is wrapped in `<>` to put the product in double quotes to make it a
57950, which is wrapped in `<>` to put the product in double quotes to make it a
568tape, like the rest of the line.
580tape, like the rest of the line.
569
581
570−
571```
582```
572 ;li: The code above is shorthand for {(scow %ud (add 50 50))}.
583 ;li: The code above is shorthand for {(scow %ud (add 50 50))}.
573```
584```
574
585
575The `{(scow %ud (add 50 50)}` on this line is just a different way
586The `{(scow %ud (add 50 50)}` on this line is just a different way
576writing the `{<(add 50 50)>}` expression. `scow` is a Hoon function that turns a
587writing the `{<(add 50 50)>}` expression. `scow` is a Hoon function that turns a
577−noun into a `tape`, Hoon’s string type. `%ud` tells `scow` that its argument
588+noun into a `tape`, Hoon's string type. `%ud` tells `scow` that its argument
578should be displayed in the form of an unsigned decimal.
589should be displayed in the form of an unsigned decimal.
579
590
580−
581```
591```
582 ;li: I am {(trip '~lodleb-ritrul')}.
592 ;li: I am {(trip '~lodleb-ritrul')}.
583```
593```
@@ -594,10 +604,10 @@ tape that we are trying to insert it into without getting a type error.
594```
604```
595
605
596The line above has interpolated code that uses a wing expression to access the
606The line above has interpolated code that uses a wing expression to access the
597−name of the host ship, and then accesses the face `what-kind` contains a string
607+name of the host ship, and then accesses the face `what-kind` that contains a
598−describing what type of ship it is. We declared `gas` on the very first line so
608+string describing what type of ship it is. We declared `gas` on the very first
599−that we could add that sort of information to the subject that our Sail is
609+line so that we could add that sort of information to the subject that our Sail
600−rendered against. The wing expression `p.bem.gas` looks for `p` within `bem`
610+is rendered against. The wing expression `p.bem.gas` looks for `p` within `bem`
601within `gas`, which happens to be where the name of the ship is located.
611within `gas`, which happens to be where the name of the ship is located.
602
612
603Note that `{what-kind}` does not have a `<>` wrapper. Why do you think this is?
613Note that `{what-kind}` does not have a `<>` wrapper. Why do you think this is?
@@ -609,17 +619,17 @@ Note that `{what-kind}` does not have a `<>` wrapper. Why do you think this is?
609```
619```
610
620
611The `;div;` node above is only rendered, as an alternative to the above list,
621The `;div;` node above is only rendered, as an alternative to the above list,
612−if `show-list` is evaluated as true. This means it won’t be shown with your
622+if `show-list` is evaluated as `true`. This means it won't be shown with your
613−default code. To show this line, change the `&` on line 2 to `|` (“false”).
623+default code. To show this line, change the `&` on line 2 to `|` (`false`).
614
624
615### Sail Runes
625### Sail Runes
616
626
617−In the previous example, we used a few special runes that aren’t used in typical
627+In the previous example, we used a few special runes that aren't used in typical
618Hoon code. But there are others that are worth learning about at this point.
628Hoon code. But there are others that are worth learning about at this point.
619
629
620`;+` is an expression that resolves to a single node. We saw this on line 20
630`;+` is an expression that resolves to a single node. We saw this on line 20
621in our Sail example above: `;+ ?: show-list` resolves to the node `;ol` and
631in our Sail example above: `;+ ?: show-list` resolves to the node `;ol` and
622−all of that node’s children.
632+all of that node's children.
623
633
624`;*` is an expression that resolves to a list of nodes. If we want to render
634`;*` is an expression that resolves to a list of nodes. If we want to render
625multiple nodes side-by-side, and not just the children of a single node, this
635multiple nodes side-by-side, and not just the children of a single node, this
@@ -627,8 +637,7 @@ is the expression that we use.
627
637
628`;=` turns a tuple of nodes into a list of nodes.
638`;=` turns a tuple of nodes into a list of nodes.
629
639
630−
631−To see how these runes work, let’s take a chunk of our previous code starting at
640+To see how these runes work, let's take a chunk of our previous code starting at
632line 20 and modify it a bit:
641line 20 and modify it a bit:
633
642
634```
643```
@@ -650,8 +659,8 @@ side-by-side -- notice that the `;ol` is absent from the first branch.
650We begin with the `;*` rune, which resolves to a list of nodes, instead of the
659We begin with the `;*` rune, which resolves to a list of nodes, instead of the
651`;+` rune, which only resolves to a single node.
660`;+` rune, which only resolves to a single node.
652
661
653−But that’s not enough on its own. `;*` needs to resolve to a list, and a few
662+But that's not enough on its own. `;*` needs to resolve to a list, and a few
654−Sail nodes aren’t lists until they are explicitly made into lists. Until we wrap
663+Sail nodes aren't lists until they are explicitly made into lists. Until we wrap
655those nodes in `;=`, the nodes treated as mere tuples. All branches must be
664those nodes in `;=`, the nodes treated as mere tuples. All branches must be
656valid lists for the `;* ?: show-list` expression to resolve.
665valid lists for the `;* ?: show-list` expression to resolve.
657
666
@@ -661,9 +670,9 @@ You should now have foundational knowledge for making web pages with Sail. There
661is, of course, more to learn.
670is, of course, more to learn.
662
671
663The [Ford manual](https://urbit.org/docs/arvo/internals/ford/runes/)
672The [Ford manual](https://urbit.org/docs/arvo/internals/ford/runes/)
664−can show you how to access various ship resources for user in your pages. To
673+can show you how to access various ship resources for use in your pages. To
665learn more about how the renderer works, take a look at the
674learn more about how the renderer works, take a look at the
666−`/home/ren/urb.hoon` file inside your urbit.
675+`/home/ren/urb.hoon` file inside your pier.
667
676
668## Udon: A Guide {#udon}
677## Udon: A Guide {#udon}
669
678
@@ -688,7 +697,7 @@ will use the `frontpage.hoon` method that we are already familiar with.
688To test out Udon, put a `;>` under the `^- manx` in your `frontpage.hoon` file,
697To test out Udon, put a `;>` under the `^- manx` in your `frontpage.hoon` file,
689and then put all your Udon code under that `;>`. Then run `|commit %home`
698and then put all your Udon code under that `;>`. Then run `|commit %home`
690in the Dojo. If you've already run the `|serve` command code from the first
699in the Dojo. If you've already run the `|serve` command code from the first
691−section, the new content should appear at `localhost/test`.
700+section, the new content should appear at `http://localhost/test`.
692
701
693## Udon Syntax
702## Udon Syntax
694
703
@@ -705,7 +714,7 @@ As an example, let's look at the front matter of this very page:
705
714
706```
715```
707:- :~ navhome/'/docs/'
716:- :~ navhome/'/docs/'
708− sort/'11'
717+ sort/'28'
709 title/'Udon'
718 title/'Udon'
710 ==
719 ==
711;>
720;>
@@ -719,13 +728,13 @@ for Udon.
719
728
720`:~` creates a list out of the three elements: `navhome/'/docs/'`, which
729`:~` creates a list out of the three elements: `navhome/'/docs/'`, which
721indicates that navigating "home" will bring you to the urbit.org/docs section
730indicates that navigating "home" will bring you to the urbit.org/docs section
722−of the website; `sort/'28',` which assigns it the 28th position of the
731+of the website; `sort/'28'`, which assigns it the 28th position of the
723immediate section that contains it, the one you see in the sidebar;
732immediate section that contains it, the one you see in the sidebar;
724and `title/'Udon'`, which gives the page its title. The `==` digraph
733and `title/'Udon'`, which gives the page its title. The `==` digraph
725terminates the list.
734terminates the list.
726
735
727`;>` is a Sail rune that creates a node that contains everything that follows
736`;>` is a Sail rune that creates a node that contains everything that follows
728−it, telling the parser that that text should be interpreted as Udon.
737+it, telling the parser that this text should be interpreted as Udon.
729It's not technically front matter, but you'll always find it following the
738It's not technically front matter, but you'll always find it following the
730front matter, since all Udon must come after this rune.
739front matter, since all Udon must come after this rune.
731
740
@@ -749,16 +758,18 @@ parsing.
749
758
750Headers in Udon begin the line with one or more `#` characters,
759Headers in Udon begin the line with one or more `#` characters,
751followed by a single space. After that space comes the actual text to be
760followed by a single space. After that space comes the actual text to be
752−displayed. The number of leading `#`s corresponds to the resulting HTML
761+displayed. The number of leading `#` characters corresponds to the resulting HTML
753header-size element: `#` yields an `<h1>`, `##` yields an `<h2>`, and so on,
762header-size element: `#` yields an `<h1>`, `##` yields an `<h2>`, and so on,
754through `<h6>`. The header for this section is `### Headers`.
763through `<h6>`. The header for this section is `### Headers`.
755
764
756**Example:**
765**Example:**
766+
757```
767```
758#### Header (h4)
768#### Header (h4)
759
769
760##### Header (h5)
770##### Header (h5)
761```
771```
772+
762**Produces:**
773**Produces:**
763
774
764#### Header (h4)
775#### Header (h4)
@@ -773,7 +784,6 @@ element.
773Enclosing text with `*` will cause that text to appear bolded, using a `<b>`
784Enclosing text with `*` will cause that text to appear bolded, using a `<b>`
774element.
785element.
775
786
776−
777**Example:**
787**Example:**
778
788
779```
789```
@@ -797,31 +807,33 @@ Here's the first line.
797
807
798This second line is separated by two newlines, so it's a separate paragraph.
808This second line is separated by two newlines, so it's a separate paragraph.
799
809
800−This line looks like a distinct paragraph, but...
810+This line looks like a distinct paragraph, but ...
801It's only separated by a single newline, so it's included in the same paragraph.
811It's only separated by a single newline, so it's included in the same paragraph.
802```
812```
803−**Produces:**
804
813
814+**Produces:**
805
815
806Here's the first line.
816Here's the first line.
807
817
808This second line is separated by two newlines, so it's a separate paragraph.
818This second line is separated by two newlines, so it's a separate paragraph.
809
819
810−This line looks like a distinct paragraph, but...
820+This line looks like a distinct paragraph, but ...
811It's only separated by a single newline, so it's included in the same paragraph.
821It's only separated by a single newline, so it's included in the same paragraph.
812
822
813#### Backslash Line Break
823#### Backslash Line Break
814
824
815A backslash at the end of a line inserts a line break (`<br>`)
825A backslash at the end of a line inserts a line break (`<br>`)
816−after that line. This contrasts with the normal udon behavior of
826+after that line. This contrasts with the normal Udon behavior of
817converting newlines to spaces.
827converting newlines to spaces.
818
828
819**Example:**
829**Example:**
830+
820```
831```
821I wonder how long each line
832I wonder how long each line
822will be if I put backslashes\
833will be if I put backslashes\
823at the ends of the lines.
834at the ends of the lines.
824```
835```
836+
825**Produces:**
837**Produces:**
826
838
827I wonder how long each line
839I wonder how long each line
@@ -837,14 +849,13 @@ as an escape character, causing it to be rendered raw.
837
849
838```
850```
839Here is some *bold* text.
851Here is some *bold* text.
840−Here is some \*not bold* text.
852+Here is some \*not bold\* text.
841```
853```
842
854
843**Produces:**
855**Produces:**
844
856
845Here is some **bold** text.
857Here is some **bold** text.
846−Here is some \*not bold* text.
858+Here is some \*not bold\* text.
847−
848
859
849### List
860### List
850
861
@@ -859,7 +870,7 @@ a number corresponding to its position in that list.
859New list elements are delineated by newlines beginning with list symbols of
870New list elements are delineated by newlines beginning with list symbols of
860the appropriate type (`-` or `+`).
871the appropriate type (`-` or `+`).
861
872
862−Just as with non-list text, text on a bare newline will appear on line before,
873+Just as with non-list text, text on a bare newline will appear on the line before,
863separated by a space. A `\\` is used to create a line-break that isn't the list
874separated by a space. A `\\` is used to create a line-break that isn't the list
864itself and isn't a list. Both of these kinds of newlines must be indented by two
875itself and isn't a list. Both of these kinds of newlines must be indented by two
865spaces, or else the page will not parse.
876spaces, or else the page will not parse.
@@ -870,7 +881,7 @@ directly after either kind of aforementioned newline that isn't a list element;
870only lines that are themselves list elements can nest sub-lists.
881only lines that are themselves list elements can nest sub-lists.
871
882
872A newline after a blank line is interpreted as a new paragraph in normal text.
883A newline after a blank line is interpreted as a new paragraph in normal text.
873−Between to list elements, however, a blank line is semantically equivalent to
884+Between two list elements, however, a blank line is semantically equivalent to
874a bare newline. To separate two lists with blank space, create a blank line
885a bare newline. To separate two lists with blank space, create a blank line
875followed by a `\\` on its own line.
886followed by a `\\` on its own line.
876
887
@@ -954,7 +965,7 @@ destination.
954
965
955The second type is a reference-style link, which uses a relative path, based on
966The second type is a reference-style link, which uses a relative path, based on
956the current page's location. Instead of the full url, we use `..` to fill in
967the current page's location. Instead of the full url, we use `..` to fill in
957−the all of the URL that the destination has in common with the origin page.
968+all of the URL that the destination has in common with the origin page.
958
969
959**Example:**
970**Example:**
960
971
@@ -979,14 +990,16 @@ so we need to use some [Sail](#sail). If there are two or more anchors with
979the same `id` on the page, you will arrive at the earliest instance of the the
990the same `id` on the page, you will arrive at the earliest instance of the the
980anchor.
991anchor.
981
992
993+Note that each HTML element `id` should be unique and not be used more than once.
994+
982**Example:**
995**Example:**
983
996
984```
997```
985Check out this [section](#here-we-are) that we want to jump to.
998Check out this [section](#here-we-are) that we want to jump to.
986
999
987−Four score and seven years ago....
1000+Four score and seven years ago ...
988
1001
989−It was the best of times, it was the worst of times...
1002+It was the best of times, it was the worst of times ...
990
1003
991## Here we are!
1004## Here we are!
992```
1005```
@@ -995,16 +1008,16 @@ It was the best of times, it was the worst of times...
995
1008
996Check out this [section](#here-we-are) that we want to jump to.
1009Check out this [section](#here-we-are) that we want to jump to.
997
1010
998−Four score and seven years ago....
1011+Four score and seven years ago ...
999
1012
1000−It was the best of times, it was the worst of times...
1013+It was the best of times, it was the worst of times ...
1001
1014
1002## Here we are!
1015## Here we are!
1003
1016
1004### Double Quote
1017### Double Quote
1005
1018
1006Text enclosed in double quotes (`"`) will be rendered with
1019Text enclosed in double quotes (`"`) will be rendered with
1007−opening and closing quotes -- that is, `“` and `”`.
1020+opening and closing quotes -- that is, `"` and `"`.
1008
1021
1009**Example:**
1022**Example:**
1010```
1023```
@@ -1013,8 +1026,7 @@ opening and closing quotes -- that is, `“` and `”`.
1013
1026
1014**Produces:**
1027**Produces:**
1015
1028
1016−“Yes,” he said. “That is the way with him.”
1029+"Yes," he said. "That is the way with him."
1017−
1018
1030
1019### Code Literal
1031### Code Literal
1020
1032
@@ -1035,14 +1047,16 @@ Enclosing some text in `` ` `` characters will cause it to be displayed as code,
1035inside a `<code>` HTML element with monospace font and highlighted with a
1047inside a `<code>` HTML element with monospace font and highlighted with a
1036different background color.
1048different background color.
1037
1049
1038−Using `` ` `` is useful when you want to designated only part of a line as code.
1050+Using `` ` `` is useful when you want to designate only part of a line as code.
1039Since this page is written in Udon, we've been using this operation
1051Since this page is written in Udon, we've been using this operation
1040−throughout this guide to `format text` to distinguish code from prose.
1052+throughout this guide to _format text_ to distinguish `code` from prose.
1041
1053
1042**Example:**
1054**Example:**
1055+
1043```
1056```
1044`*[a 2 b c] -> *[*[a b] *[a c]]` is like lisp's `apply`.
1057`*[a 2 b c] -> *[*[a b] *[a c]]` is like lisp's `apply`.
1045```
1058```
1059+
1046**Produces:**
1060**Produces:**
1047
1061
1048`*[a 2 b c] -> *[*[a b] *[a c]]` is like lisp's `apply`.
1062`*[a 2 b c] -> *[*[a b] *[a c]]` is like lisp's `apply`.
@@ -1070,7 +1084,6 @@ Most of our examples so far have used.
1070
1084
1071**Example:**
1085**Example:**
1072
1086
1073−
1074 ```
1087 ```
1075 (def Y (fn [f]
1088 (def Y (fn [f]
1076 ((fn [x]
1089 ((fn [x]
@@ -1094,7 +1107,7 @@ Most of our examples so far have used.
1094### Hoon Constants
1107### Hoon Constants
1095
1108
1096Hoon has several syntactic forms for literals (numbers, strings, dates, etc.)
1109Hoon has several syntactic forms for literals (numbers, strings, dates, etc.)
1097−that can be used in udon as well. Udon detects such code, and so these
1110+that can be used in Udon as well. Udon detects such code, and so these
1098forms will automatically appear inside a `<code>` element like inline code.
1111forms will automatically appear inside a `<code>` element like inline code.
1099
1112
1100Example:
1113Example:
@@ -1105,17 +1118,16 @@ Example:
1105%term
1118%term
1106```
1119```
1107
1120
1108−produces:\
1121+Produces:\
1109
1122
1110`~2017.8.29` \
1123`~2017.8.29` \
1111`0xdead.beef` \
1124`0xdead.beef` \
1112`%term`
1125`%term`
1113
1126
1114−
1115### Horizontal Rule
1127### Horizontal Rule
1116
1128
1117Three or more hyphens, such as `---`, on their own line produce an `<hr>`
1129Three or more hyphens, such as `---`, on their own line produce an `<hr>`
1118−element, the 'horizontal rule'. This is rendered as a horizontal line the
1130+element, the "horizontal rule". This is rendered as a horizontal line the
1119width of its containing paragraph.
1131width of its containing paragraph.
1120
1132
1121**Example:**
1133**Example:**
@@ -1130,7 +1142,6 @@ And below this line, too
1130
1142
1131**Produces:**
1143**Produces:**
1132
1144
1133−
1134Above the line
1145Above the line
1135
1146
1136---
1147---
@@ -1144,7 +1155,7 @@ And below this line, too
1144### Block Quote
1155### Block Quote
1145
1156
1146A section of text with the first line beginning with `>` and a space,
1157A section of text with the first line beginning with `>` and a space,
1147−and each successive newline indented by two spaces yields a
1158+and each successive newline indented by two spaces, yields a
1148`<blockquote>` HTML element. This block quote can itself contain more Udon,
1159`<blockquote>` HTML element. This block quote can itself contain more Udon,
1149including more block quotes to render nested levels of quotation.
1160including more block quotes to render nested levels of quotation.
1150
1161
@@ -1175,10 +1186,9 @@ Quote break.
1175
1186
1176> He is pale and thin, he wears a thin and ragged linen shirt.
1187> He is pale and thin, he wears a thin and ragged linen shirt.
1177
1188
1178−
1179### Poem
1189### Poem
1180
1190
1181−A poem is a section of text with meaningful newlines. Recall that,
1191+A poem is a section of text with meaningful newlines. Recall that,
1182normally in Udon, newlines are treated as spaces and do not create a
1192normally in Udon, newlines are treated as spaces and do not create a
1183new line of text. If you want to embed text where newlines are retained, then
1193new line of text. If you want to embed text where newlines are retained, then
1184indent the text in question with **eight spaces**.
1194indent the text in question with **eight spaces**.
@@ -1191,6 +1201,7 @@ indent the text in question with **eight spaces**.
1191 Is moving its slow thighs, while all about it
1201 Is moving its slow thighs, while all about it
1192 Reel shadows of the indignant desert birds.
1202 Reel shadows of the indignant desert birds.
1193```
1203```
1204+
1194**Produces:**
1205**Produces:**
1195
1206
1196 A shape with lion body and the head of a man,
1207 A shape with lion body and the head of a man,
@@ -1198,14 +1209,12 @@ indent the text in question with **eight spaces**.
1198 Is moving its slow thighs, while all about it
1209 Is moving its slow thighs, while all about it
1199 Reel shadows of the indignant desert birds.
1210 Reel shadows of the indignant desert birds.
1200
1211
1201−
1202## Sail Expressions
1212## Sail Expressions
1203
1213
1204It's possible to use Udon as an HTML templating language akin to
1214It's possible to use Udon as an HTML templating language akin to
1205PHP, ERB, JSP, or Handlebars templates. This facility derives
1215PHP, ERB, JSP, or Handlebars templates. This facility derives
1206in part from the support for embedding Hoon code inside the markup.
1216in part from the support for embedding Hoon code inside the markup.
1207
1217
1208−
1209Sail is a domain-specific language within Hoon for creating XML nodes,
1218Sail is a domain-specific language within Hoon for creating XML nodes,
1210including HTML. It can be used directly within Udon to provide
1219including HTML. It can be used directly within Udon to provide
1211scripting capability with Hoon and also to provide more precise control over the
1220scripting capability with Hoon and also to provide more precise control over the
@@ -1226,9 +1235,8 @@ Example:
1226
1235
1227Produces:
1236Produces:
1228
1237
1229−
1230<p>
1238<p>
1231− <strong>Don't panic!</strong>
1239+ <strong>Don't panic!</strong>
1232− <br>
1240+ <br />
1233− <small>[reactive publishing intensifies]</small>
1241+ <small>[reactive publishing intensifies]</small>
1234</p>
1242</p>
tutorials/ship-troubleshooting.md+15−36
@@ -23,7 +23,7 @@ An ounce of prevention is worth a pound of cure, so let's first go over some bes
23
23
24Once your ship is booted with your keyfile, you should never use that same keyfile again. If you do boot with the same keyfile twice, any other ship on the network that your ship has communicated with will not be able to talk to your ship.
24Once your ship is booted with your keyfile, you should never use that same keyfile again. If you do boot with the same keyfile twice, any other ship on the network that your ship has communicated with will not be able to talk to your ship.
25
25
26−If you accidentally booted with the same keyfile twice, the only remedy is performing a [personal breach](#personal-breach), which is explained in the next section.
26+If you accidentally booted with the same keyfile twice, the only remedy is performing a [personal breach](#personal-breach), which is explained in the next section.
27
27
28### Do not delete your pier
28### Do not delete your pier
29
29
@@ -33,16 +33,17 @@ Urbit is stateful, meaning that it needs to hold onto all your data. If you dele
33
33
34When you first start your ship, you should make sure you put it a place where you can find it again and where it won't get accidentally deleted. Remember that you must perform `|mount %` in your ship's Dojo to make your ship visible as a directory in the Unix file system.
34When you first start your ship, you should make sure you put it a place where you can find it again and where it won't get accidentally deleted. Remember that you must perform `|mount %` in your ship's Dojo to make your ship visible as a directory in the Unix file system.
35
35
36−### Avoid killing the Urbit process directly
36+### Avoid killing the urbit process directly
37+
37The best way to end an urbit process is to use `ctrl-d` from the Dojo. Unix methods to kill the process, such as with `ctrl-z` or with the `kill` Bash command, or simply closing the window, should only be used if `ctrl-d` does not work.
38The best way to end an urbit process is to use `ctrl-d` from the Dojo. Unix methods to kill the process, such as with `ctrl-z` or with the `kill` Bash command, or simply closing the window, should only be used if `ctrl-d` does not work.
38
39
39### Keep up-to-date builds
40### Keep up-to-date builds
40
41
41−Check for latest Urbit version at https://github.com/urbit/urbit/releases. If you're behind, update using [this guide](/operations/)
42+Check for latest Urbit version at https://github.com/urbit/urbit/releases. If you're behind, update using [this guide](@using/install.md).
42
43
43### `|hi` your star to see if you're connected
44### `|hi` your star to see if you're connected
44
45
45−Find out who your star is by running `(sein:title our now our)` in the Dojo. Then, run `|hi ~star`, where `~star` is the star's name, and if things are working properly, you should get the message `hi ~star successful`. It could also be helpful to use `|hi` to check connectivity with `~zod` or another planet that you're in a Talk channel with.
46+Find out who your star is by running `(sein:title our now our)` in the Dojo. Then, run `|hi ~star`, where `~star` is the star's name, and if things are working properly, you should get the message `hi ~star successful`. It could also be helpful to use `|hi` to check connectivity with `~zod` or another planet that you're in a Chat channel with.
46
47
47### Turn your ship off and on again
48### Turn your ship off and on again
48
49
@@ -66,9 +67,9 @@ So for example, to silence all Ames packet-related errors, try `|knob %hole %hus
66
67
67### Perform a personal breach. {#personal-breach}
68### Perform a personal breach. {#personal-breach}
68
69
69−A personal breach is when a ship tells all the other ships that have communicated with it to treat it as though the ship was just started for the first time again, since everyone has network has forgotten about it.
70+A personal breach is when a ship tells all the other ships that have communicated with it to treat it as though the ship was just started for the first time again, since everyone on the network has forgotten about it.
70
71
71−Personal breaches often fix connectivity issues, but should only be used as a last resort. To find out how to perform a personal breach, check out our [Guide to Breaches](../guide-to-breaches). Before taking such a drastic measure, try other methods in this guide. You can also ask for help on `~dopzod/urbit-help`, or, failing that, in the #ship-starting-support channel in our [Discord server](https://discord.gg/n9xhMdz).
72+Personal breaches often fix connectivity issues, but should only be used as a last resort. To find out how to perform a personal breach, check out our [Guide to Breaches](../guide-to-breaches). Before taking such a drastic measure, try other methods in this guide. You can also ask for help on `~/~dopzod/urbit-help`, or, failing that, in the `#ship-starting-support` channel in our [Discord server](https://discord.gg/n9xhMdz).
72
73
73## Operation Issues {#operation-issues}
74## Operation Issues {#operation-issues}
74
75
@@ -80,7 +81,7 @@ Run `|wash-gall`. This clears caches in Gall, and may result in steep performanc
80
81
81Sometimes this happens if you're processing a very large event, or if you're in an infinite loop, or for a variety of other reasons.
82Sometimes this happens if you're processing a very large event, or if you're in an infinite loop, or for a variety of other reasons.
82
83
83−Before doing anything, try waiting for a minute: an event might finish processing. If it doesn't clear up, then use Unix kill-command, `ctrl-z`, to end your ship's process. Then restart your ship.
84+Before doing anything, try waiting for a minute: an event might finish processing. If it doesn't clear up, then use the Unix kill-command, `ctrl-z`, to end your ship's process. Then restart your ship.
84
85
85### When I try to type into the Dojo, it prints `dy-noprompt`
86### When I try to type into the Dojo, it prints `dy-noprompt`
86
87
@@ -92,10 +93,6 @@ Since version `0.8.0`, changes no longer automatically sync between the Unix sid
92
93
93## Connectivity Issues {#connectivity-issues}
94## Connectivity Issues {#connectivity-issues}
94
95
95−### I can `|hi` my sponsor star, but I cannot get syncs from it or discover peers
96−
97−This means you have one-way connectivity with your star, with your star being unable to send your messages; many connectivity problems are derived from this. Run `|nuke ~star`, where `~star` is your sponsor star in the Dojo. Then run `|nuke ~star` again. This can solve various communication problems. You can find your sponsor by running `(sein:title our now our)`.
98−
99### I can't communicate with anyone
96### I can't communicate with anyone
100
97
101You may have booted a ship with your keyfile twice in the same era. To fix this, you must perform a [personal breach](#personal-breach).
98You may have booted a ship with your keyfile twice in the same era. To fix this, you must perform a [personal breach](#personal-breach).
@@ -104,15 +101,15 @@ You may have booted a ship with your keyfile twice in the same era. To fix this,
104
101
105You may see a message like this one: `/~zod/home/~2019.7.22..18.55.46..83a3/sys/vane/ames:<[line column].[line column]>`. This is a clay path to a Hoon file, pointing to the line and column where an expression crashed. This kind of error might be accompanied by a `crud` message.
102You may see a message like this one: `/~zod/home/~2019.7.22..18.55.46..83a3/sys/vane/ames:<[line column].[line column]>`. This is a clay path to a Hoon file, pointing to the line and column where an expression crashed. This kind of error might be accompanied by a `crud` message.
106
103
107−This means that another ship is sending invalid packets to you. This could be because one of the ships has not updated the other ship's "life number," which is the number that starts at one and increments every time that ship performs a personal breach.
104+This means that another ship is sending invalid packets to you. This could be because one of the ships has not updated the other ship's "life number", which is the number that starts at one and increments every time that ship performs a personal breach.
108
105
109−This can happen if they have the wrong keys of yours, or if you have the wrong keys of theirs. You can figure out who has the wrong keys by running this scry command in your dojo: `.^(* %j /=life=/shipname)`, where shipname is the other ship's name. Save that information. Then, go to the [Azimuth contract on Etherscan](https://etherscan.io/address/0x223c067f8cf28ae173ee5cafea60ca44c335fecb#readContract), scroll down to `32. points`, and put in the hexadecimal representation of the other ship's `@p`. You can find the hexadecimal representation by running...
106+This can happen if they have the wrong keys of yours, or if you have the wrong keys of theirs. You can figure out who has the wrong keys by running this scry command in your dojo: `.^(* %j /=life=/shipname)`, where shipname is the other ship's name. Save that information. Then, go to the [Azimuth contract on Etherscan](https://etherscan.io/address/0x223c067f8cf28ae173ee5cafea60ca44c335fecb#readContract), scroll down to `32. points`, and put in the hexadecimal representation of the other ship's `@p`. You can find the hexadecimal representation by running ...
110
107
111```
108```
112`@ux`~sampel-palnet
109`@ux`~sampel-palnet
113```
110```
114
111
115−in the Dojo, where `~sampel-palnet` is the other ship's name. Then, compare it to the scry information that you saved. If that information matches up, it means that the other ship is the problem. If it **doesn't** match up, your ship has wrong information about the other ship. If you have such wrong information, you can fix this by running:
112+... in the Dojo, where `~sampel-palnet` is the other ship's name. Then, compare it to the scry information that you saved. If that information matches up, it means that the other ship is the problem. If it **doesn't** match up, your ship has wrong information about the other ship. If you have such wrong information, you can fix this by running:
116
113
117```
114```
118:azimuth-tracker|listen ~ %app %azimuth-tracker
115:azimuth-tracker|listen ~ %app %azimuth-tracker
@@ -132,24 +129,6 @@ The above commands work if you have the wrong keys of other ships. If other ship
132
129
133This is the result of deleting your pier and starting your ship again. To fix this, you must perform a [personal breach](#personal-breach).
130This is the result of deleting your pier and starting your ship again. To fix this, you must perform a [personal breach](#personal-breach).
134
131
135−### I have two ships, and only one can connect with the other
136−
137−One-way connectivity (OWC) means that ship `~A` can't `|hi` ship `~B`, but ship `~B` can `|hi` ship `~A`. If you have two ships that are suffering from this problem, it can be solved by a series of steps.
138−
139−1. Turn both ships off and on again. This sometimes solves this problem.
140−
141−2. On ship `~B` -- the ship that can connect to the other -- `|nuke ~A`, where `~A` is the ship that cannot `|hi` the other. Wait several minutes. Do you see any messages in your console? If not, try sending a `|hi ~A` from `~B`. If “blocked” or similar messages start appearing, `|nuke ~A` again to unblock, and check if connectivity has been restored.
142−
143−3. If you can’t get any packets to be sent to `~B`, you’re going to have to temporarily modify your ship’s Ames to trick it into sending packets. Make sure to do this on its home desk so as to not impact any syncs. Open `~A/home/sys/vanes/ames.hoon` and find `++ harv`. Just above `(gth caw nif) check`, insert the a line of this code: `=? caw =(caw nif) +(caw)`. Save the file and run `|commit %home`.
144−
145−4. Try running `|hi ~B`. Wait a bit. Are you seeing `%blocked` or `%bad-ack` messages yet? If not, send another `|hi ~B`.
146−
147−5. Once the messages start rolling in, revert the Ames change that you made on `~A` in step 3. Then `|nuke ~A` again from `~B`. Wait a little bit, then check if this resolved the OWC.
148−
149−6. If the OWC is still not resolved, try step 6.
150−
151−7. Be patient. After following these steps, your |hi may still not go through instantly even though OWC has silently been fixed: there could be something like a very large sync queued up.
152−
153## Booting Issues {#booting-issues}
132## Booting Issues {#booting-issues}
154
133
155### My ship won't boot and gets a `terminals database is inaccessible` message
134### My ship won't boot and gets a `terminals database is inaccessible` message
@@ -168,13 +147,13 @@ This means that you gave your development ship an invalid `@p`. So, you will get
168
147
169### I got a `bail` error and my ship crashed
148### I got a `bail` error and my ship crashed
170
149
171−Try just bringing it back up; it will often start working just fine again.
150+Try bringing it back up; it will often start working just fine again.
172
151
173−However, if you get a `bail` error again, you should perform a personal breach.
152+However, if you get a `bail` error again, you should perform a [personal breach](#personal-breach).
174
153
175#### Making a GitHub issue out of your `bail`
154#### Making a GitHub issue out of your `bail`
176
155
177−You can get help with you problem by creating an issue at github.com/urbit/urbit. But to make a good issue, you need to include some information.
156+You can get help with you problem by creating an issue at [github.com/urbit/urbit](https://github.com/urbit/urbit/issues). But to make a good issue, you need to include some information.
178
157
179When your urbit crashes with a `bail`, you'll probably get a core dump, which is a file that contains the program state of your urbit when it crashed. On Mac, core dumps can be found in `/cores`. On Linux, cores can often be found in `/var/crash`, or the home directory.
158When your urbit crashes with a `bail`, you'll probably get a core dump, which is a file that contains the program state of your urbit when it crashed. On Mac, core dumps can be found in `/cores`. On Linux, cores can often be found in `/var/crash`, or the home directory.
180
159
@@ -201,7 +180,7 @@ Copy this stack trace and include it in your GitHub issue.
201
180
202### My ship crashed with a `bail: oops` error
181### My ship crashed with a `bail: oops` error
203
182
204−Restart your ship. These issues often just go away on their own. If this error repeats after restart two or more times, post the messages in an issue at github.com/urbit/urbit/issues.
183+Restart your ship. These issues often just go away on their own. If this error repeats after restart two or more times, post the messages in an issue at [github.com/urbit/urbit](https://github.com/urbit/urbit/issues).
205
184
206This same error might also appear with a message like `Assertion '0'`.
185This same error might also appear with a message like `Assertion '0'`.
207
186