on master help sign in
/docs/tutorials/arvo/gall/: inline code fixes/additions; minor copy edits (#722)
commit515a95fb920d797ffc30f17d30e54d265ca88e32 authorjfranklin9000 <jfranklin9000@gmail.com> dateFri 15 Nov 2019, 12:41 (7 years ago) parent3337f0d
1 file changed+32−32
tutorials/arvo/gall.md+32−32
tutorials/arvo/gall.md+32−32
@@ -89,7 +89,7 @@ for events) separately.
8989#### Reading
9090
9191A connector exposes a tree of data. Every read request has a
92−`care`, which is generally either `%x` or `%y. `%x` is a request
92+`care`, which is generally either `%x` or `%y`. `%x` is a request
9393for a particular piece of data, while `%y` is a request for a
9494directory listing. Roughly, `%x` means Unix `cat` and `%y` means
9595Unix `ls`.
@@ -802,7 +802,7 @@ If not, we check whether the atom is `'on'`. If so, we set `on` and
802802we don't take any other immediate action. If it was both off and not in
803803progress, then we send an HTTP request.
804804
805−If the argument is neither 'off' nor 'on', then we assume it's an
805+If the argument is neither `'off'` nor `'on'`, then we assume it's an
806806actual url, so we save it in `target`.
807807
808808Here's the move that sends the HTTP request:
@@ -811,7 +811,7 @@ Here's the move that sends the HTTP request:
811811[ost.hid %hiss /request ~ %httr %purl (need (de-purl:html target))]
812812```
813813
814−> Remember, we are expected to produce a **list** of moves. Note the `~` after the move in the full example. This is a convenient shortcut for creating a list of a single element. It's part of a small family of such shortcuts. `~[a b c]` is `[a b c ~]`, `[a b c]~` is `[[a b c] ~]` and `\`[a b c]` is `[~ a b c]`. These may be mixed and matched to create various convoluted structures and emojis.
814+> Remember, we are expected to produce a **list** of moves. Note the `~` after the move in the full example. This is a convenient shortcut for creating a list of a single element. It's part of a small family of such shortcuts. `~[a b c]` is `[a b c ~]`, `[a b c]~` is `[[a b c] ~]` and `` `[a b c] `` is `[~ a b c]`. These may be mixed and matched to create various convoluted structures and emojis.
815815
816816The correspondence between this move and `[bone card]` can be hard to
817817visualize on one line. Here it is more pedantically:
@@ -949,7 +949,7 @@ marked atom and convert it to our new mark.
949949 '57'
950950```
951951
952−ASCII 9 is 57. There's no requirement, implicit or otherwise,
952+ASCII `9` is `57`. There's no requirement, implicit or otherwise,
953953that conversions back and forth between marks be inverses of each
954954other. These are semantic conversions, in that they refer to the
955955same concept. They're not isomorphisms.
@@ -1246,7 +1246,7 @@ Or, in pseudo-code:
12461246
12471247Let's walk through each of these elements step by step.
12481248
1249−###### Bones ("cause")
1249+##### Bones ("cause")
12501250
12511251If you look up `++bone` in `hoon.hoon`, you'll see that it's a number (`@ud`),
12521252and that it's an opaque reference to a duct. `++duct` in `hoon.hoon` is a list
@@ -1262,10 +1262,10 @@ packet, file change, or timer event. When Arvo is given this event, it routes
12621262the event to appropriate kernel module for handling.
12631263
12641264Sometimes, the module can immediately handle the event and produce any necessary
1265−results. For example, when we poked the `++poke-atom` arm above, we poked %gall,
1265+results. For example, when we poked the `++poke-atom` arm above, we poked `%gall`,
12661266our application server, which was able to respond to our poke directly. When the
12671267module cannot service the request itself, it sends instructions to another
1268−kernel module or application (through the %gall module) to do a specified
1268+kernel module or application (through the `%gall` module) to do a specified
12691269action, and produces the result from that.
12701270
12711271Furthermore, when one module sends a message to another kernel module or
@@ -1300,7 +1300,7 @@ generally a good idea to make the wire human-readable for bug-handling purposes.
13001300##### Term (sys-call)
13011301
13021302Each move also has a `term`, composed of lowercase ASCII and/or `-`. This `term`
1303−has the sign `@tas`. In this case, our `term` is `%poke`, which is the name of
1303+has the aura `@tas`. In this case, our `term` is `%poke`, which is the name of
13041304the particular kind of move we're sending. You can always use `%poke` to message
13051305an app. Other common names include `%warp`, to read from the filesystem;
13061306`%wait`, to set a timer; and `%them`, to send an http request.
@@ -1323,7 +1323,7 @@ urbit as for sending messages between apps on different urbits.
13231323
13241324- Modify `pong.hoon` to print out a message when it receives acknowledgement.
13251325
1326−- Write two apps, `even` and `odd`. When you pass an atom to `even`, check whether it's even. If so, divide it by two and recurse; otherwise, poke `odd` with it. When `odd` receives an atom, check whether it's equal to one. If so, terminate, printing "%success". Otherwise, check whether it's odd. If so, multiply it by three, add one, and recurse; otherwise, poke `even` with it. When either app receives a number, print it out along with the name of the app. In the end, you should be able to watch Collatz's conjecture play out between the two apps. Sample output:
1326+- Write two apps, `even` and `odd`. When you pass an atom to `even`, check whether it's even. If so, divide it by two and recurse; otherwise, poke `odd` with it. When `odd` receives an atom, check whether it's equal to one. If so, terminate, printing `%success`. Otherwise, check whether it's odd. If so, multiply it by three, add one, and recurse; otherwise, poke `even` with it. When either app receives a number, print it out along with the name of the app. In the end, you should be able to watch Collatz's conjecture play out between the two apps. Sample output:
13271327
13281328```
13291329~fintud-macrep:dojo> :even &atom 18
@@ -1350,7 +1350,7 @@ urbit as for sending messages between apps on different urbits.
13501350%success
13511351```
13521352
1353−- Put `even` and `odd` on two separate urbits and pass the messages over the network. Post a link to a working solution in :talk to receive a cookie.
1353+- Put `even` and `odd` on two separate urbits and pass the messages over the network. Post a link to a working solution in `:talk` to receive a cookie.
13541354
13551355
13561356## Security Drivers
@@ -1618,9 +1618,9 @@ Just like with Basic Authentication, you should be able to run
16181618`+https://api.github.com/user` and get a response indicating who
16191619you're logged in as.
16201620
1621−Some drivers a slightly more complicated. For example, Github's
1621+Some drivers are slightly more complicated. For example, Github's
16221622access token's don't expire, but that's not the case for all
1623−service. The googleapis driver shows the flow when the access
1623+services. The googleapis driver shows the flow when the access
16241624token can expire. Twitter uses OAuth1, for which we have another
16251625library.
16261626
@@ -1711,7 +1711,7 @@ identity), and `eny` (512 bits of guaranteed-fresh entropy). For the full list
17111711of things in `++bowl`, search for `++ bowl` (note: two spaces) in
17121712`/arvo/zuse.hoon`.
17131713
1714−> This is, perhaps, the most common way to learn Hoon. The easiest way to learn about an identifier you see in code is to search in `/arvo/sys/zuse.hoon` and `/arvo/sys/hoon.hoon` for it.\\ Urbit's codebase is less than 30000 lines of code combined, including the hoon parser, the compiler, and the `/arvo` microkernel, so you can usually use the code and its comments as a reference doc. You can also read [zuse.hoon](https://github.com/urbit/urbit/blob/master/pkg/arvo/sys/zuse.hoon) and [hoon.hoon](https://github.com/urbit/urbit/blob/master/pkg/arvo/sys/hoon.hoon) in your browser.
1714+> This is, perhaps, the most common way to learn Hoon. The easiest way to learn about an identifier you see in code is to search in `/arvo/sys/zuse.hoon` and `/arvo/sys/hoon.hoon` for it. Urbit's codebase is less than 30000 lines of code combined, including the hoon parser, the compiler, and the `/arvo` microkernel, so you can usually use the code and its comments as a reference doc. You can also read [zuse.hoon](https://github.com/urbit/urbit/blob/master/pkg/arvo/sys/zuse.hoon) and [hoon.hoon](https://github.com/urbit/urbit/blob/master/pkg/arvo/sys/hoon.hoon) in your browser.
17151715
17161716The second thing we should clear up is this: Urbit needs no "serialize to disk"
17171717step. Everything you produce in the app state is persistent across calls to the
@@ -1724,9 +1724,9 @@ to set up and write to a database.
17241724
17251725**Exercises**:
17261726
1727−- Modify `:sum` to reset the counter when you poke it with 0.
1727+- Modify `:sum` to reset the counter when you poke it with `0`.
17281728
1729−- Write an app called `last` that prints out the previous value you poked it with.
1729+- Write an app called `:last` that prints out the previous value you poked it with.
17301730
17311731Sample output:
17321732
@@ -1884,7 +1884,7 @@ Two notes:
18841884
18851885- `bowl` is the type of the system state within our app. For example, it includes things like `our`, the name of the host urbit, and `now`, the current time.
18861886
1887−- You may have noticed the separate `|%` above the application core `|_`. We usually put our types in another core on top of the application core. We can access these type from our `|_` because in `hoon.hoon` files, all cores are called against each other. (The shorthand for 'called' is `=>`.) Thus, the `|%` with the types is in the context of the `|_`, as it lies above it: `hoon.hoon` `=> |% w types => |_`
1887+- You may have noticed the separate `|%` above the application core `|_`. We usually put our types in another core on top of the application core. We can access these type from our `|_` because in `.hoon` files, all cores are called against each other. (The shorthand for 'called' is `=>`.) Thus, the `|%` with the types is in the context of the `|_`, as it lies above it: `hoon.hoon` `=> |% w types => |_`
18881888
18891889Here's some sample output of the two working together:
18901890
@@ -1924,7 +1924,7 @@ Here's some sample output of the two working together:
19241924>=
19251925```
19261926
1927−###### :source
1927+##### :source
19281928
19291929Hopefully you can get a sense for what's happening here. When we poke
19301930`:sink` with `%on`, `:sink` subscribes to `:source`,
@@ -1981,7 +1981,7 @@ which is a move that provides bone `o` with this subscription update:
19811981`[%noun non]`". This is fairly dense code, but what it's doing is
19821982straightforward!
19831983
1984−###### :sink
1984+##### :sink
19851985
19861986`:source` should now make sense. `:sink` is a little longer, but not much more
19871987complicated.
@@ -2001,11 +2001,11 @@ will happen correctly.
20012001
20022002The only state we need for `:sink` is a boolean to indicate whether
20032003we're already subscribed to `:source`. We use `val=?`, where `?`
2004−is the sign of type boolean (similar to `*`, `@`), which defaults to true (that
2005−is, `0`).
2004+is the type associated with boolean (similar to `*`, `@`), which defaults
2005+to `%.y` (that is, `0`).
20062006
2007−In `++poke-noun` we check our input to see both if it's `%on` and we're
2008−available (`val` is true). If so, we produce the move to subscribe to
2007+In `++poke-noun` we check our input to see both if it's `%on` and
2008+available (`val` is `%.y`). If so, we produce the move to subscribe to
20092009`:source`:
20102010
20112011```hoon
@@ -2018,15 +2018,15 @@ available (`val` is true). If so, we produce the move to subscribe to
20182018==
20192019```
20202020
2021−Also, in the preceding lines, we set `val` to false (`|`) with `+>.$(val |)`.
2021+Also, in the preceding lines, we set `val` to `%.n` (`|`) with `+>.$(val |)`.
20222022Remember that the `:_` constructs an inverted cell, with the first child
2023−(`+>.$(val |` in our case) as the tail and the second child as the head. Here,
2024−the cell we produce when our subscription is `%on` and `val` is true has a
2025−head with our new state where `val` is set to false and a tail of our list of
2023+(`+>.$(val |)` in our case) as the tail and the second child as the head. Here,
2024+the cell we produce when our subscription is `%on` and `val` is `%.y` has a
2025+head with our new state where `val` is set to `%.n` and a tail of our list of
20262026moves, which is shown in the code block above.
20272027
20282028Otherwise, if our input is `%off` and we're already subscribed (i.e. `val`
2029−is false), then we unsubscribe from `:source` and set `val` back to true (`&`),
2029+is `%.n`), then we unsubscribe from `:source` and set `val` back to `%.y` (`&`),
20302030again using our handy inverted cell constructor mold `:_`:
20312031
20322032```hoon
@@ -2038,7 +2038,7 @@ It's important to send over the same bone and wire (`/subscribe`) as the
20382038one we originally subscribed on.
20392039
20402040If neither of these cases are true, then we print our current subscription
2041−state, based on whether `val` is true or false, and return a cell containing
2041+state, based on whether `val` is `%.y` or `%.n`, and return a cell containing
20422042a null list of moves and our unchanged app state:
20432043
20442044```hoon
@@ -2134,7 +2134,7 @@ producing `%click`.
21342134
21352135We also convert from json by parsing a json string with `so:dejs-soft:format`,
21362136asserting the parsing succeeded with `need`, and asserting the
2137−result was 'click' with `?>`, which asserts that its first child
2137+result was `'click'` with `?>`, which asserts that its first child
21382138is true.
21392139
21402140> Note the argument to `++json`is `jon=^json`. Why `^json`? `++json` shadows the type definition, so if we want to refer to the type, we have to prepend a `^`. This extends to multiple levels: `^^^foo` means the fourth most innermost instance of `foo`.
@@ -2178,7 +2178,7 @@ And save the following as `/mar/clicks.hoon`:
21782178`clicks` is just an atom. We convert to json by creating an
21792179object with a single field "clicks" with our value.
21802180
2181−> Be sure to check out section 3bD, JSON and XML, in zuse.hoon `frond:enjs:format` is just a function that takes a key-value pair and produces a JSON object with one element.
2181+> Be sure to check out section 3bD, JSON and XML, in `zuse.hoon`. `frond:enjs:format` is just a function that takes a key-value pair and produces a JSON object with one element.
21822182
21832183```
21842184~fintud-macrep:dojo> &json &clicks 6
@@ -2275,7 +2275,7 @@ $(function() {
22752275```
22762276
22772277We set up two event handlers. When we click the button, we run
2278−`window.urb.send`, which sends a poke to the app specified as the first argument, in this case our :click app. The arguments
2278+`window.urb.send`, which sends a poke to the app specified as the first argument, in this case our `:click` app. The arguments
22792279are data, parameters, and the callback. The data is the specific
22802280data we want to send. The parameters are all optional, but here's a list
22812281of the available ones:
@@ -2296,7 +2296,7 @@ div that we defined above. Otherwise, we printf to the console a
22962296message saying the poke succeeded. As is common, we gray
22972297out the button when it is clicked. It is only reenabled when positive acknowledgement is received.
22982298
2299−Our second event handler is `window.urb.bind`, which is called immediately when the page is loaded, subscribing the page to the specified data stream on the app set with `urb.appl` (which is, in this case, :click). It also takes three arguments: path, parameters, and callback. The path is the path on the app to subscribe to. The parameters are all optional (indeed, we omit them entirely here), but are similar to those for `send`:
2299+Our second event handler is `window.urb.bind`, which is called immediately when the page is loaded, subscribing the page to the specified data stream on the app set with `urb.appl` (which is, in this case, `:click`). It also takes three arguments: path, parameters, and callback. The path is the path on the app to subscribe to. The parameters are all optional (indeed, we omit them entirely here), but are similar to those for `send`:
23002300
23012301- `ship`: target urbit. Defaults to `window.urb.ship`, which defaults to the urbit which served the page.
23022302- `appl`: target app. Defaults to `window.urb.appl`, which defaults to null.