on master help sign in
gall-guide: minor tweaks and typo fixes to lesson 3
commit95d92903aef1166e5dbe44d36503b2d01080e9f2 authorTinnus Napbus <admin@tinnus-napbus.xyz> dateSat 20 Nov 2021, 23:11 (5 years ago) parent9981480
1 file changed+23−24
content/docs/userspace/gall-guide/3-imports-and-aliases.md+23−24
content/docs/userspace/gall-guide/3-imports-and-aliases.md+23−24
@@ -21,20 +21,20 @@ Let's look at each in more detail:
2121
2222### `default-agent`
2323
24−The `%default-agent` library contains a basic agent with sane default behaviours
24+The `default-agent` library contains a basic agent with sane default behaviours
2525for each arm. In some cases it just crashes and prints an error message to the
2626terminal, and in others it succeeds but does nothing. It has two primary uses:
2727
2828- For any agent arms you don't need, you can just have them call the matching
29− function in `%default-agent`, rather than having to manually handle events on
29+ function in `default-agent`, rather than having to manually handle events on
3030 those arms.
3131- A common pattern in an agent is to switch on the input of an arm with
3232 [wutlus](/docs/hoon/reference/rune/wut#-wutlus) (`?+`) runes or maybe
3333 [wutcol](/docs/hoon/reference/rune/wut#wutcol) (`?:`) runes. For any
34− unexpected input, you can just pass it to the relevant arm of `%default-agent`
34+ unexpected input, you can just pass it to the relevant arm of `default-agent`
3535 rather than handling it manually.
3636
37−The `%default-agent` library lives in `/lib/default-agent/hoon` of the `%base`
37+The `default-agent` library lives in `/lib/default-agent/hoon` of the `%base`
3838desk, and you would typically include a copy in any new desk you created. It's
3939imported at the beginning of an agent with the
4040[faslus](/docs/arvo/ford/ford#ford-runes) (`/+`) rune.
@@ -50,7 +50,7 @@ typical agent core. Usually you would define an alias for it in a virtual arm
5050
5151### `dbug`
5252
53−The `%dbug` library lets you inspect the state and `bowl` of your agent from the
53+The `dbug` library lets you inspect the state and `bowl` of your agent from the
5454dojo. It includes an `agent:dbug` function which wraps your whole `agent:gall`
5555`door`, adding its extra debugging functionality while transparently passing
5656events to your agent for handling like usual.
@@ -116,9 +116,9 @@ A virtual arm in an agent might look something like this:
116116
117117`this`, `def` and `hc` are the aliases, and next to each one is the hoon
118118expresion it's aliasing. Notice that unlike most things that take _n_ arguments,
119−a virtual arm is not terminated with a `==`. You can define as many
120−aliases as you like. The three in this example are conventional ones you'd
121−likely use in most agents you write. Their purposes are:
119+a virtual arm is not terminated with a `==`. You can define as many aliases as
120+you like. The three in this example are conventional ones you'd use in most
121+agents you write. Their purposes are:
122122
123123```hoon
124124this .
@@ -132,9 +132,8 @@ agent core.
132132def ~(. (default-agent this %.n) bowl)
133133```
134134
135−This sets up the `%default-agent` library we [described
136−above](#default-agent), so you can easily call its arms like `on-poke:def`,
137−`on-agent:def`, etc.
135+This sets up the `default-agent` library we [described above](#default-agent),
136+so you can easily call its arms like `on-poke:def`, `on-agent:def`, etc.
138137
139138```hoon
140139hc ~(. +> bowl)
@@ -145,7 +144,7 @@ helper cores later, so don't worry about this for now.
145144
146145## Additional cores
147146
148−While Gall expects a single 10-arm agent core, it's still possible to include
147+While Gall expects a single 10-arm agent core, it's possible to include
149148additional cores by composing them into the subject of the agent core itself.
150149The contents of these cores will then be available to arms of the agent core.
151150
@@ -157,9 +156,9 @@ expression, which means you can just butt separate cores up against one another
157156and they'll all still get composed.
158157
159158You can add as many extra cores as you'd like before the agent core, but
160−typically you'd just add one containing structure definitions for the agent's
161−state, as well as any other useful structures. We'll look at the state in more
162−detail in the next lesson.
159+typically you'd just add one containing type definitions for the agent's state,
160+as well as any other useful structures. We'll look at the state in more detail
161+in the next lesson.
163162
164163## Example
165164
@@ -197,9 +196,9 @@ into the subject of our agent so they're available for use. You can read more
197196about Ford runes in the [Ford section of the vane
198197documenation](/docs/arvo/ford/ford#ford-runes).
199198
200−Next, we've added an extra core. Notive how it's not explicitly composed, since
201−the build system will do that for use. In this case we've just added a single
202−`card` arm, which just makes it simpler to reference the `card:agent:gall` type.
199+Next, we've added an extra core. Notice how it's not explicitly composed, since
200+the build system will do that for us. In this case we've just added a single
201+`card` arm, which makes it simpler to reference the `card:agent:gall` type.
203202
204203After that core, we call `agent:dbug` with our whole agent core as its argument.
205204This allows us to use the `dbug` features described earlier.
@@ -213,7 +212,7 @@ of aliases:
213212```
214213
215214In most of the arms, you see we've been able to replace the dummy code with
216−simple calls to the corresponding arms of `%default-agent`, which we set up and
215+simple calls to the corresponding arms of `default-agent`, which we set up and
217216aliased as `def` in the virtual arm. We've also replaced the old `..on-init`
218217with our alias `this` in the `on-init` arm as an example - it makes things a bit
219218simpler.
@@ -264,14 +263,14 @@ idea of its basic usage.
264263The key takeaways are:
265264
266265- Libraries can be imported with `/+`.
267−- `%default-agent` is a library that provides default behaviours for Gall agent
266+- `default-agent` is a library that provides default behaviours for Gall agent
268267 arms.
269−- `%dbug` is a library that lets you inspect the state and `bowl` of an agent
268+- `dbug` is a library that lets you inspect the state and `bowl` of an agent
270269 from the dojo, with the `+dbug` generator.
271270- Convenient aliases for hoon expressions can be defined in a virtual arm with
272271 the [lustar](/docs/hoon/reference/rune/lus#-lustar) (`+*`) rune.
273272- `this` is a conventional alias for the agent core itself.
274−- `def` is a conventional alias for accessing arms in the `%default-agent`
273+- `def` is a conventional alias for accessing arms in the `default-agent`
275274 library.
276275- Extra cores can be composed into the subject of the agent core. The
277276 composition is done implicitly by the build system. Typically we'd include one
@@ -280,14 +279,14 @@ The key takeaways are:
280279
281280## Exercises
282281
283−- Run through the [Example](#example) yourself on a fake ship if you've not done
282+- Run through the [example](#example) yourself on a fake ship if you've not done
284283 so already.
285284- Have a read through the [Ford rune
286285 documentation](/docs/arvo/ford/ford#ford-runes) for details about importing
287286 libraries, structures and other things.
288287- Try the `+dbug` generator out on some other agents, like `:settings-store +dbug`, `:btc-wallet +dbug`, etc, and try some of its options [described
289288 above](#dbug).
290−- Have a quick look over the source of the `%default-agent` library, locate at
289+- Have a quick look over the source of the `default-agent` library, located at
291290 `/lib/default-agent.hoon` in the `%base` desk. We've not yet covered what the
292291 different arms do but it's still useful to get a general idea, and you'll
293292 likely want to refer back to it later.