on master help sign in
style sprucin'
080114fTobias Merkle
docs/arvo/basic.md+82−67
@@ -6,7 +6,7 @@ title: Hoon refresher / crash course
6
6
7# Basic Hoon
7# Basic Hoon
8
8
9−This recapitulates material you've already learned in Core Hoon.
9+This recapitulates material you've already learned in [Hoon](/docs/hoon/).
10It will be a very abrupt tutorial if you don't know Hoon already,
10It will be a very abrupt tutorial if you don't know Hoon already,
11but it may be enough in and of itself. If you don't find it obvious at first
11but it may be enough in and of itself. If you don't find it obvious at first
12glance, read it over again.
12glance, read it over again.
@@ -28,8 +28,8 @@ operation](/docs/user/basic) of your urbit.
28
28
29If you haven't copied in the examples repo, running the following commands from your urbit directory should do the trick:
29If you haven't copied in the examples repo, running the following commands from your urbit directory should do the trick:
30
30
31−`cp -r {wherever-you've-pulled-to}/examples/gall/*/ arvo/`
31+`$ cp -r {wherever-you've-pulled-to}/examples/gall/*/ arvo/`
32−`cp -r {wherever-you've-pulled-to}/examples/dojo/*/ arvo/`
32+`$ cp -r {wherever-you've-pulled-to}/examples/dojo/*/ arvo/`
33
33
34Run an example to ensure it worked:
34Run an example to ensure it worked:
35
35
@@ -114,10 +114,10 @@ more detail later.
114### How to form expressions
114### How to form expressions
115
115
116Hoon does not typically use reserved words to form expressions. Instead,
116Hoon does not typically use reserved words to form expressions. Instead,
117−expressions are formed with runes--diagraphs of two
117+expressions are formed with _runes_: digraphs of two
118−ascii symbols. Each rune takes a specific number of
118+ASCII symbols. Each rune takes a specific number of
119−children--either expressions formed by other runes or literals
119+children, either expressions formed by other runes or literals
120−that produce their own value (some runes take n children, and are usually closed with `==`).
120+that produce their own value (some runes take _N_ children, and are usually closed with `==`).
121
121
122For example, the rune `?:` from line 17 is the classic
122For example, the rune `?:` from line 17 is the classic
123'if-then-else' statement, and thus takes three children:
123'if-then-else' statement, and thus takes three children:
@@ -130,16 +130,16 @@ Since runes are such a fundamental structure in Hoon, we found
130ourselves speaking them out loud frequently. It quickly grew
130ourselves speaking them out loud frequently. It quickly grew
131cumbersome to have to say "question mark, colon" to describe
131cumbersome to have to say "question mark, colon" to describe
132`?:`. To alleviate this problem, we came up with our own naming
132`?:`. To alleviate this problem, we came up with our own naming
133−scheme: each ascii glyph has a single syllable pronunciation
133+scheme: each ASCII glyph has a single-syllable pronunciation
134phonetically designed to be both easily remembered and easily
134phonetically designed to be both easily remembered and easily
135pronounced in conjunction with the other glyphs (when forming a
135pronounced in conjunction with the other glyphs (when forming a
136rune).
136rune).
137
137
138−See the entire naming schema below/or link to it:
138+See the entire naming scheme below.
139
139
140```
140```
141 ace [1 space] gal < pel (
141 ace [1 space] gal < pel (
142− bar | gap [>1 space, nl] per )
142+ bar | gap [>1 space, \n] per )
143 bas \ gar > sel [
143 bas \ gar > sel [
144 buc $ hax # sem ;
144 buc $ hax # sem ;
145 cab _ hep - ser ]
145 cab _ hep - ser ]
@@ -151,9 +151,9 @@ See the entire naming schema below/or link to it:
151 fas / pat @ zap !
151 fas / pat @ zap !
152```
152```
153
153
154−Using our naming scheme `?:` is said 'wut col'.
154+Using this scheme, we would pronounce `?:` as 'wutcol'.
155
155
156−For those that would prefer to use reserved words to form expressions, you can substitute a rune's keyword--which you can find in `++twig` in `/arvo/hoon.hoon`--for the rune. For example, here's the code for `?:` in `++twig`:
156+For those who prefer to use reserved words to form expressions, you can substitute any rune with that rune's keyword, which you can find in `++twig` in `/arvo/hoon.hoon`. For example, here's the code for `?:` in `++twig`:
157
157
158`{$if p/twig q/twig r/twig} :: ?: if/then/else`
158`{$if p/twig q/twig r/twig} :: ?: if/then/else`
159
159
@@ -173,8 +173,8 @@ if(=(1 2) 'this is true' 'this is false')
173### Lines 12-34
173### Lines 12-34
174
174
175Now let's quickly walk through this code line-by-line. Lines
175Now let's quickly walk through this code line-by-line. Lines
176−12-34 are wrapped in a `|%` (pronounced 'bar cen'), which
176+12-34 are wrapped in a `|%` ('barcen'), which produces a core.
177−produces a core, a fundamental datatype in hoon similar to a
177+Cores are a fundamental datatype in Hoon, similar to a
178struct, class, or object. A core is just a map of names
178struct, class, or object. A core is just a map of names
179to any kind of code, whether it be functions or data. Each
179to any kind of code, whether it be functions or data. Each
180element in this map begins with a `++` followed by the name and
180element in this map begins with a `++` followed by the name and
@@ -182,8 +182,8 @@ the corresponding code. Since `|%` takes an arbitrary number of
182children, it needs to be closed with a `--`.
182children, it needs to be closed with a `--`.
183
183
184<blockquote class="blockquote">
184<blockquote class="blockquote">
185−`++` is not technically a rune, since it is only used in core
185+`++` ('luslus') is not technically a rune, since it is only used
186−syntax as shown above
186+in core syntax, as shown above.
187</blockquote>
187</blockquote>
188
188
189Let's step into each of the three arms within our core.
189Let's step into each of the three arms within our core.
@@ -195,16 +195,16 @@ Let's step into each of the three arms within our core.
195 (add (five a) (three a))
195 (add (five a) (three a))
196 --
196 --
197
197
198−`|=` produces a function, much like a lambda in lisp. It takes two children:
198+`|=` ('bartis') produces a function, much like a lambda in lisp. It takes two children:
199
199
200−- A set of argument(s). In this case our argument set only
200+1. A set of argument(s). In this case our argument set only
201− contains one: `a`, which is required to be an atom or natural
201+ contains one: `a`, which is required to be an atom or natural
202 number, denoted by `@`.
202 number, denoted by `@`.
203
203
204−- The body of the function itself, which is executed when the
204+1. The body of the function itself, which is executed when the
205 function is called (in this case, with `(sum 1.000)`). This
205 function is called (in this case, with `(sum 1.000)`). This
206 particular function adds the results of evaluating the gates `++
206 particular function adds the results of evaluating the gates `++
207− five` and `++three` with each of their respective input
207+ five` and `++three` with each of their respective input
208 parameters set to `a`.
208 parameters set to `a`.
209
209
210### ++ three
210### ++ three
@@ -221,20 +221,35 @@ As above, `++three` takes an integer argument, `a`, and then
221executes the remainder of the code with `a` set to the actual
221executes the remainder of the code with `a` set to the actual
222arguments.
222arguments.
223
223
224−Similarly, `=|` pushes its first child, `b` into our context (in
224+Similarly, `=|` ('tisbar') pushes its first child, `b` into our
225−other words, it declares a variable `b`) and executes the
225+context (in other words, it declares a variable `b`) and executes
226−remainder of the code. However, `b` is not an argument; `=|`
226+the remainder of the code. However, `b` is not an argument; `=|`
227sets `b` to the default value of whatever type it is declared as.
227sets `b` to the default value of whatever type it is declared as.
228Since the default value of an atom is `0`, b is set to `0`.
228Since the default value of an atom is `0`, b is set to `0`.
229
229
230+<blockquote class="blockquote">
231+To find the default value of any given type, use `$*` ('buctar') followed by the type.
232+Alternatively, use the irregular form `*`.
233+
234+ > ($* @)
235+ 0
236+
237+ > *@
238+ 0
239+
240+ > *@p
241+ ~zod
242+
243+</blockquote>
244+
230So now we have two variables: `a` is set to our input, and `b` is
245So now we have two variables: `a` is set to our input, and `b` is
231initialized to `0`.
246initialized to `0`.
232
247
233−The easiest way to think about `|-` that it lays down a recursion
248+One way to think about `|-` ('barhep') is that it lays down a recursion
234point. More on this later.
249point. More on this later.
235
250
236−`^-` is just a cast that sets the result of the remainder of the
251+`^-` ('kethep') is just a cast that sets the result of the remainder of
237−code to an unsigned integer, `@u`.
252+the code to an unsigned integer, `@u`.
238
253
239In pseudocode, the last three lines read like this: if `a` is
254In pseudocode, the last three lines read like this: if `a` is
240less than `b`, produce zero. Else, add `b` to the result of
255less than `b`, produce zero. Else, add `b` to the result of
@@ -249,73 +264,73 @@ you recurse by an actual function call, then you have to specify
249every argument.
264every argument.
250
265
251<blockquote class="blockquote">
266<blockquote class="blockquote">
252−If you're familiar with Clojure, `|-` is `loop` and `$()` is
267+If you're familiar with Clojure, `|-` is `loop` and `$()` is `recur`.
253−recur.
254</blockquote>
268</blockquote>
255
269
256**Exercises**:
270**Exercises**:
257
271
258−Please tweak your code to complete the following excercises.
272+Tweak your code to complete the following excercises.
259
273
260−There are a few runes and some syntaxes that we have yet to cover that
274+There are a few runes and some syntax that we have yet to cover that
261you will need to complete the excercises below. For these, please
275you will need to complete the excercises below. For these, please
262refer to our cheatsheat at the bottom.
276refer to our cheatsheat at the bottom.
263
277
264−- Read and understand `++five` line by line.
278+1. Read and understand `++five` line by line.
265
279
266−- Change `++sum` to accept two variables, `a` and `b`. Pass `a`
280+1. Change `++sum` to accept two variables, `a` and `b`. Pass `a`
267− to three and `b` to five. Then run the code with `a` set to
281+ to `three` and `b` to `five`. Then run the code with `a` set to
268− `1.000` and ` q` set to `2.000`.
282+ `1.000` and `q` set to `2.000`.
269
283
270−- Check if this new result is under one thousand. If it is,
284+1. Check if this new result is under one thousand. If it is,
271− return the string 'result is less than one thousand'. If not,
285+ return the string `'result < 1.000'`. If not,
272− return 'result is greater than or equal to one thousand'.
286+ return `'result >= 1.000'`.
273
287
274−```
275−Review
288+### Review
276
289
277−|% start core (collection of named ++ arms; an "object")
290+ |% ('barcen') start core (collection of named ++ arms; an "object")
278−|= define function
291+ |= ('bartis') define function
279−=| define variable from type with default value
292+ =| ('tisbar') define variable from type with default value
280−|- drop a recursion point
293+ |- ('barhep') drop a recursion point
281−^- cast
294+ ^- ('kethep') cast
282−?: if-then-else
295+ ?: ('wutcol') if-then-else
283−=(a b) test equality
296+ =(a b) test equality
284−(function args ...) call function
297+ (function args ...) call function with args
285
298
286−New material
299+### New material
287
300
288−- There are two syntaxes for writing Hoon: tall form and wide
301+1. There are two syntaxes for writing Hoon: tallform and wideform.
289− form.
290
302
291− In tall form, expressions are formed with either two spaces or
303+ In tallform, expressions are formed with either two spaces or
292 a line break separating both a rune from its children and each
304 a line break separating both a rune from its children and each
293− of its children from one another. We use tall form when writing
305+ of its children from one another. We use tallform when writing
294 multiline expressions.
306 multiline expressions.
295
307
296 For more concise expressions, we use wideform, which is always
308 For more concise expressions, we use wideform, which is always
297− a single line. Wideform can be used inside tall form
309+ a single line. Wideform can be used inside tallform
298 expressions, but not vice versa.
310 expressions, but not vice versa.
299
311
300− Wideform expressions are formed with a rune followed by ()
312+ Wideform expressions are formed with a rune followed by `()`
301 containing its children, all of which are separated by a
313 containing its children, all of which are separated by a
302− single space. For example to make a cell of two elements:
314+ single space. For example, to make a cell of two elements:
303
315
304− :-(a b)
316+ :-(a b)
305
317
306 We've already seen wideform in action, for example with
318 We've already seen wideform in action, for example with
307− =((mod b 3) 0). In this case = is actually an irregular form
319+ `=((mod b 3) 0)`. In this case, `=` is actually an irregular form
308− of .=, which tests its two children for equality.
320+ of `.=`, which tests its two children for equality.
309
321
310− Surrounding a function with () is an irregular wide form
322+ Surrounding a function with `()` is an irregular wide form
311− syntax for calling a function with n arguments. More on this later.
323+ syntax for calling a function with _N_ arguments. More on this later.
312
324
313−- :- makes a cell of values. The irregular wide form of this is
325+1. `:-` makes a cell of values. The irregular wide form of this is
326+ `[a b]`, with two expressions separated by a single space.
314− [a b], with two expressions separated by a single space. (While the regular form of this rune takes a fixed number of children--2--its irregular wide form can accept n expressions:[a1..an])
327+ While the regular form of this rune takes a fixed number of
328+ children (two), its irregular wide form can accept _N_ expressions:
329+ `[a1..an]`
315
330
316−- Cords are one datatype for text in hoon. They're just a big
331+2. Cords are one datatype for text in Hoon. They're just a big
317 atom formed from adjacent unicode bytes -- a "c string". To
332 atom formed from adjacent unicode bytes -- a "c string". To
318− produce a cord enclose text within single quotes. To set the type
333+ produce a cord, enclose text within single quotes. To set the type
319− of an argument to a cord, use @t.
334+ of an argument to a cord, use `@t`.
335+
320
336
321−```
docs/using/admin.md+2−2
@@ -22,11 +22,11 @@ You can turn your Urbit off with `^D` from the `:talk` or `:dojo` prompts.
22
22
23To restart your Urbit simply pass the name of your pier:
23To restart your Urbit simply pass the name of your pier:
24
24
25− bin/urbit some-planet
25+ $ bin/urbit some-planet
26
26
27or
27or
28
28
29− bin/urbit comet
29+ $ bin/urbit comet
30
30
31## Console
31## Console
32
32
docs/using/web.md+6−2
@@ -25,7 +25,7 @@ We ship `tree` as compiled JavaScript on your Urbit, but the source lives in its
25Your Urbit runs a web server and can be found at either `http://localhost:8080/` (or `8081` if you're running other processes that might be occupying `8080`, you can determine which port your urbit is on by looking at your boot sequence — it's specified there), or `http://your-urbit.urbit.org/`.
25Your Urbit runs a web server and can be found at either `http://localhost:8080/` (or `8081` if you're running other processes that might be occupying `8080`, you can determine which port your urbit is on by looking at your boot sequence — it's specified there), or `http://your-urbit.urbit.org/`.
26
26
27(Make sure you have a desk mounted to unix, as covered in the
27(Make sure you have a desk mounted to unix, as covered in the
28−[filesystem walkthrough](/docs/using/filesystem))
28+[filesystem walkthrough](/docs/using/filesystem)).
29
29
30To switch the desk you're serving from:
30To switch the desk you're serving from:
31
31
@@ -37,7 +37,7 @@ To host a file on the web try putting the following in `/home/web/test.md` (from
37
37
38 This is a simple markdown file.
38 This is a simple markdown file.
39
39
40−Create a folder with two more markdown files in it and copy it to `/home/web/test/`. (In urbit, there is no distinction between a director and a file--in this case `test` is both a file and a directory. So, if you're adding files directly from unix, simply `mkdir test` and urbit will treat the file and directory as the same entity.)
40+Create the directory `/home/web/test/` and add two more markdown files in it. (In urbit, there is no distinction between a directory and a file. In this case, `test` is both a file and a directory. So, if you're adding files directly from unix, simply `mkdir test` and urbit will treat the file and directory as the same entity.)
41
41
42Now modify `/home/web/test.md` to list the children using the `<list/>` JSX:
42Now modify `/home/web/test.md` to list the children using the `<list/>` JSX:
43
43
@@ -55,6 +55,10 @@ To view your file as raw `html`:
55
55
56 http://localhost:8080/test.html
56 http://localhost:8080/test.html
57
57
58+You may have noticed that we just created both `test.md` and `test/`. In urbit, there is no distinction between a directory and a file. So, if you're adding files directly from unix, simply `mkdir test` and urbit will treat the file and directory as the same entity.
59+
60+You can use this feature to change your homepage at `your-urbit.urbit.org`. By default, this page will display some info about your urbit, but you can create the file `/home/web.md` to customize this page to your heart's content.
61+
58## Examples
62## Examples
59
63
60We've created a few simple examples of how to get set up publishing content from your Urbit. Feel free to ask questions in the comments.
64We've created a few simple examples of how to get set up publishing content from your Urbit. Feel free to ask questions in the comments.