@@ -15,23 +15,22 @@ Threads are managed by the gall agent called `spider`.
1515
1616## Thread location
1717
18−Threads live in the `ted` directory of your desk:
18+Threads live in the `ted` directory of each desk. For example, in a desk named `%sandbox`:
1919
2020```
21−%
21+%sandbox
2222├──app
2323├──gen
2424├──lib
2525├──mar
2626├──sur
27−├──sys
2827└──ted <-
2928 ├──foo
3029 │ └──bar.hoon
3130 └──baz.hoon
3231```
3332
34−From the dojo, `ted/baz.hoon` can be run with `-baz`, and `ted/foo/bar.hoon` with `-foo-bar`.
33+From the dojo, `ted/baz.hoon` can be run with `-sandbox!baz`, and `ted/foo/bar.hoon` with `-sandbox!foo-bar`. Threads in the `%base` desk can just be run like `-foo`, but all others must have the format `-desk!thread`.
3534
3635**NOTE:** When the dojo sees the `-` prefix it automatically handles creating a thread ID, composing the argument, poking the `spider` gall agent and subscribing for the result. Running a thread from another context (eg. a gall agent) requires doing these things explicitly and is outside the scope of this particular tutorial.
3736
@@ -57,7 +56,7 @@ That is, a gate which takes a `vase` and returns the `form` of a `strand` that p
5756
5857
5958
60−This is because threads typically do a bunch of I/O so it can't just immediately produce a result and end. Instead the strand will get some input, produce output, get some new input, produce new output, and so forth, until they eventually produce a `%done` with the actual final result.
59+This is because threads typically do a bunch of I/O so it can't just immediately produce a result and end. Instead the strand will get some input, produce output, get some new input, produce new output, and so forth, until they eventually produce a `%done` with the actual final result.
6160
6261## Strands
6362
@@ -66,9 +65,10 @@ Strands are the building blocks of threads. A thread will typically compose mult
6665A strand is a function of `strand-input:strand -> output:strand` and is defined in `/lib/strand/hoon`. You can see the details of `strand-input` [here](https://github.com/urbit/urbit/blob/master/pkg/arvo/lib/strand.hoon#L2-L21) and `output:strand` [here](https://github.com/urbit/urbit/blob/master/pkg/arvo/lib/strand.hoon#L23-L48). At this stage you don't need to know the nitty-gritty but it's helpful to have a quick look through. We'll discuss these things in more detail later.
6766
6867A strand is a core that has three important arms:
68+
6969- `form` - the mold of the strand
7070- `pure` - produces a strand that does nothing except return a value
71−- `bind` - monadic bind, like `then` in javascript promises
71+- `bind` - monadic bind, like `then` in javascript promises
7272
7373We'll discuss each of these arms later.
7474
@@ -81,7 +81,7 @@ Strands are conventionally given the face `m` like:
8181...
8282```
8383
84−**NOTE:** a comma prefix as in `,vase` is the irregular form of `^:` which is a gate that returns the sample value if it's of the correct type, but crashes otherwise.
84+**NOTE:** a comma prefix as in `,vase` is the irregular form of `^:` which is a gate that returns the sample value if it's of the correct type, but crashes otherwise.
8585
8686## Form and Pure
8787
@@ -104,12 +104,12 @@ We'll cover `bind` later.
104104## A trivial thread
105105
106106```hoon
107−/- spider
108−=, strand=strand:spider
109−^- thread:spider
110−|= arg=vase
111−=/ m (strand ,vase)
112−^- form:m
107+/- spider
108+=, strand=strand:spider
109+^- thread:spider
110+|= arg=vase
111+=/ m (strand ,vase)
112+^- form:m
113113(pure:m arg)
114114```
115115
@@ -117,7 +117,6 @@ The above code is a simple thread that just returns its argument, and it's a goo
117117
118118Save the above code as a file in `ted/mythread.hoon` and `|commit` it. Run it with `-mythread 'foo'`, you should see the following:
119119
120−
121120```
122121> -mythread 'foo'
123122[~ 'foo']
@@ -130,8 +129,8 @@ Save the above code as a file in `ted/mythread.hoon` and `|commit` it. Run it wi
130129We'll go through it line-by line.
131130
132131```hoon
133−/- spider
134−=, strand=strand:spider
132+/- spider
133+=, strand=strand:spider
135134```
136135
137136First we import `/sur/spider/hoon` which includes `/lib/strand/hoon` and give give the latter the face `strand` for convenience.
@@ -155,7 +154,7 @@ We create a gate that takes a vase, the first part of the previously mentioned t
155154Inside the gate we create our `strand` specialised to produce a `vase` and give it the canonical face `m`.
156155
157156```hoon
158−^- form:m
157+^- form:m
159158```
160159
161160We cast the output to `form` - the mold of the strand we created.