on master help sign in
Merge pull request #634 from urbit/poprox-hoon-school
4d1738frmariani
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
65
65
66Generators 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.
66Generators 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.
67
67
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.
69
69
70If 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.
70If 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.
71
71
learn/hoon/hoon-tutorial/type-checking-and-type-inference.md+4−6
@@ -77,7 +77,7 @@ nest-fail
77
77
78### The `.=` and `.+` Runes
78### The `.=` and `.+` Runes
79
79
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`.
81
81
82```
82```
83> =(12 [33 44])
83> =(12 [33 44])
@@ -129,7 +129,7 @@ nest-fail
129nest-fail
129nest-fail
130```
130```
131
131
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.
133
133
134This 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 `%_`.
134This 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 `%_`.
135
135
@@ -175,7 +175,7 @@ It's important to remember to include a cast rune with each gate expression. Th
175
175
176### (Dry) Gate Sample Definitions
176### (Dry) Gate Sample Definitions
177
177
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).
179
179
180The 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:
180The 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:
181
181
@@ -190,13 +190,11 @@ $(a +(a), b (dec b)) :: add a+1 and b-1
190We run it in the dojo using a cell to pass the two arguments:
190We run it in the dojo using a cell to pass the two arguments:
191
191
192```
192```
193−> +add [12 14]
193+> +add 12 14
19426
19426
195
195
196> +add 22
196> +add 22
197nest-fail
197nest-fail
198−-want.{a/@ b/@}
199−-have.@ud
200```
198```
201
199
202If 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.
200If 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
189
189
190### Parametric Polymorphism and `+*` Arms
190### Parametric Polymorphism and `+*` Arms
191
191
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.
193
193
194For 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`:
194For 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`:
195
195