on master help sign in
Merge pull request #634 from urbit/poprox-hoon-school

fixing references in chapter 2 and updating instruction on using |commit

commit4d1738f2fc957e475ee66cd901085f3cfcfd9a1a authorrmariani <robert@tlon.io> dateWed 11 Sep 2019, 12:42 (7 years ago) parent4dfcf0fd603866
3 files changed+6−8
learn/hoon/hoon-tutorial/setup.md+1−1 learn/hoon/hoon-tutorial/type-checking-and-type-inference.md+4−6 learn/hoon/hoon-tutorial/type-polymorphism.md+1−1
learn/hoon/hoon-tutorial/setup.md+1−1
@@ -65,7 +65,7 @@ You asked dojo to evaluate `17` and it echoed the number back at you. This valu
6565
6666Generators 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.
6767
68−The simplest type of generator is the **naked generator**. All naked generators are `gates`: functions that take an argument and produce an output. 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. To run a generator named `mygen.hoon`, you would type `+mygen <argument>` in your ship's Dojo.
68+The simplest type of generator is the **naked generator**. All naked generators are `gates`: functions that take an argument and produce an output. 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. 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.
6969
7070If this doesn't make sense yet, that's okay. In the [next lesson](../list-of-numbers), we will walk you through an example `gate` that is run as a generator.
7171
learn/hoon/hoon-tutorial/type-checking-and-type-inference.md+4−6
@@ -77,7 +77,7 @@ nest-fail
7777
7878### The `.=` and `.+` Runes
7979
80−You saw earlier in the chapter how a type check is performed when `.=` -- or its irregular variant, `=( )` -- is used. For any expression of the form `=(a b)`, either the type of `a` must be a subset of the type of `b` or the type of `b` must be a subset of the type of `a`. Otherwise, the type check fails and you'll get a `nest-fail`.
80+You saw earlier in Chapter 1 how a type check is performed when `.=` -- or its irregular variant, `=( )` -- is used. For any expression of the form `=(a b)`, either the type of `a` must be a subset of the type of `b` or the type of `b` must be a subset of the type of `a`. Otherwise, the type check fails and you'll get a `nest-fail`.
8181
8282```
8383> =(12 [33 44])
@@ -129,7 +129,7 @@ nest-fail
129129nest-fail
130130```
131131
132−We'll talk in more detail about the various kinds of type-checking that can occur at arm evaluation when we discuss type polymorphism in Chapter 3.
132+We'll talk in more detail about the various kinds of type-checking that can occur at arm evaluation when we discuss type polymorphism later in Chapter 2.
133133
134134This isn't a comprehensive list of the type checks in Hoon. It's only some of the most commonly used kinds. Two other runes that include a type check are `=.` and `%_`.
135135
@@ -175,7 +175,7 @@ It's important to remember to include a cast rune with each gate expression. Th
175175
176176### (Dry) Gate Sample Definitions
177177
178−By now you've used the `|=` rune to define several gates. This rune is used to produce a 'dry' gate, which has different type-checking and type-inference properties than a 'wet' gate does. We won't explain the wet/dry distinction until Chapter 3 -- for now, just keep in mind that we're only dealing with one kind of gate (albeit the more common kind).
178+By now you've used the `|=` rune to define several gates. This rune is used to produce a 'dry' gate, which has different type-checking and type-inference properties than a 'wet' gate does. We won't explain the wet/dry distinction until later in Chapter 2 -- for now, just keep in mind that we're only dealing with one kind of gate (albeit the more common kind).
179179
180180The first subexpression after the `|=` defines the sample type. Any faces used in this definition have the type declared for it in this definition. Consider again the addition function:
181181
@@ -190,13 +190,11 @@ $(a +(a), b (dec b)) :: add a+1 and b-1
190190We run it in the dojo using a cell to pass the two arguments:
191191
192192```
193−> +add [12 14]
193+> +add 12 14
19419426
195195
196196> +add 22
197197nest-fail
198−-want.{a/@ b/@}
199−-have.@ud
200198```
201199
202200If you try to call this gate with the wrong kind of argument, you get a `nest-fail`. If the call succeeds, then the argument takes on the type of the sample definition: `[a=@ b=@]`. Accordingly, the inferred type of `a` is `@`, and the inferred type of `b` is `@`. In this case some type information has been thrown away; the inferred type of `[12 14]` is `[@ud @ud]`, but the addition program takes all atoms, regardless of aura.
learn/hoon/hoon-tutorial/type-polymorphism.md+1−1
@@ -189,7 +189,7 @@ As is the case with dry arms, there is a type-check associated with each wet arm
189189
190190### Parametric Polymorphism and `+*` Arms
191191
192−In Chapter 2 we saw how to use the `+*` rune to define an arm that produced a more complex type from one or more simpler types. This rune provides a way of making use of **parametric polymorphism** in Hoon.
192+We may use the `+*` rune to define an arm that produced a more complex type from one or more simpler types. This rune provides a way of making use of **parametric polymorphism** in Hoon.
193193
194194For example, we have `list`s, `tree`s, and `set`s in Hoon, which are each defined in `hoon.hoon` with `+*` arms. (Take a moment to see for yourself.) Each `+*` arm is followed by an argument definition, inside brackets `[ ]`. After that subexpression comes another that defines a type, relative to the input value. For example, here is the definition of `list` from `hoon.hoon`:
195195