on master help sign in
151-ize some rune docs.
c53507aC. Guy Yarvin
docs/system/hoon/core/twig/mold.md+2−2
@@ -10,7 +10,7 @@ molds are often called "structures.")
10
10
11## Overview
11## Overview
12
12
13−While Hoon can't check this property statically, any true mold
13+While Hoon can't check this property statically, a proper mold
14is a *rectifier*: an idempotent function across all nouns. If
14is a *rectifier*: an idempotent function across all nouns. If
15the sample of a gate has span `%noun`, and its body obeys the
15the sample of a gate has span `%noun`, and its body obeys the
16constraint that for any x, `=((mold x) (mold (mold x)))`, it's a
16constraint that for any x, `=((mold x) (mold (mold x)))`, it's a
@@ -129,7 +129,7 @@ Similarly, `%foo` is the number `7.303.014` or `0x6f.6f66`;
129Translation:
129Translation:
130
130
131```
131```
132−{a b c}` :bank(a b c)
132+{a b c} :bank(a b c)
133a/b :coat(a b)
133a/b :coat(a b)
134?(a b c) :pick(a b c)
134?(a b c) :pick(a b c)
135_a :shoe(a)
135_a :shoe(a)
docs/system/hoon/runes/bc/bank.mdnew file+26
@@ -0,0 +1,26 @@
1+# `:bank`, `$:`, "buccol", `{$bank p/(list moss)}`
2+
3+The product: a mold which applies the tuple `p` to its sample.
4+
5+Usage: define a record type.
6+
7+Regular form: *running*.
8+
9+Irregular form:
10+```
11+{a b c} :bank(a b c)
12+```
13+
14+Example:
15+```
16+~zod:dojo> =a :bank(p/@ud q/@tas)
17+
18+~zod:dojo> (a 33 %foo)
19+[p=33 q=%foo]
20+
21+~zod:dojo> `a`[33 %foo]
22+[p=33 q=%foo]
23+
24+~zod:dojo> $:a
25+[p=0 q=%$]
26+```
docs/system/hoon/runes/bc/bcbr.mddeleted−41
@@ -1,41 +0,0 @@
1−`$| bucbar`
2−===========
3−
4−Union between atom and cell.
5−
6−[mold]() that's a union of an atom `p` and cell `q`.
7−`$|` is similar to [`$?`](), but is more strict in that in
8−only contains one atom mold and one cell mold.
9−
10−### Produces
11−
12−A validator function that validates atoms as mold `p` and cells as mold `q`.
13−
14−### Accepts
15−
16−`p` is a `mold` of an atom and `q` is a `mold` of a cell.
17−
18−### Tall form
19−
20− $| p
21− q
22−
23−### Wide form
24−
25− $|(p q)
26−
27−### Examples
28−
29− ~zod/try=> ($|(@t [@ud @ux]) 'hello')
30− 'hello'
31− ~zod/try=> (,$|(@ [@t @ud]) 44 44)
32− [',' 44]
33− ~zod/try=> *$|(~ [~ u=@])
34− ~
35−
36− ++ list |* a=_,* :: null-terminated list
37− $|(~ [i=a t=(list a)]) ::
38−
39−In `++list`, `$|` specifies that every element in a noun that can be
40−cast to a `++list` is either the atom `~` or the cell
41−`[i=a t=(list a)]`.
docs/system/hoon/runes/bc/bccb.mddeleted−52
@@ -1,52 +0,0 @@
1−`$_ buccab`
2−===========
3−
4−Unbunt (create mold from example).
5−
6−Uses a [++twig]() `p` to produce a [mold]() for the type (span)
7−of `p`. The validator function has a default value of `p`. Used
8−when either (1) you want the default value of a mold to be
9−anything other than the standard default value ([bunt]()), or (2)
10−you are referring to a type (span) that is difficult or
11−cumbersome to describe in any way other than by example.
12−
13−Produces
14−--------
15−
16−A mold whose span is the span of `p`.
17−
18−Accepts
19−-------
20−
21−`p` is a twig.
22−
23−Tall form
24−---------
25−
26− $_ p
27−
28−Wide form
29−---------
30−
31− $_(p)
32−
33−Irregular form
34−--------------
35−
36− _p
37−
38−Examples
39−--------
40−
41− ~zod/try=> *_12
42− 12
43− ~zod/try=> *@
44− 0
45− ~zod/try=> :type; *_12
46− 12
47− @ud
48− ~zod/try=> ^-(_(add 2 2) 'a')
49− 97
50−
51−Here, see how the default value of `_12` is 12, whereas the
52−default value of `@`--the type ([span]()) of `12`--is `0`.
docs/system/hoon/runes/bc/bccl.mddeleted−44
@@ -1,44 +0,0 @@
1−`$: buccol`
2−===========
3−
4−Tuple of molds.
5−
6−Produces
7−--------
8−
9−A validator function that validates a tuple of nouns against a tuple of [mold]()s.
10−
11−Accepts
12−--------
13−
14−`p` is a list of molds.
15−
16−Tall form
17−---------
18−
19− $: i.p
20− i.t.p
21− i.t.t.p
22− ==
23−
24−Wide form
25−---------
26−
27− $:(i.p i.t.p i.t.t.p)
28−
29−Irregular form
30−--------------
31−
32− {i.p i.t.p i.t.t.p}
33−
34−Examples
35−--------
36−
37− ~zod/try=> *[1 2]
38− [%1 %2]
39− ~zod/try=> (,$:(1 2) "ham")
40− [%1 %2]
41− ~zod/try=> (,[1 2] "ham")
42− [%1 %2]
43− ~zod/try=> (,[@ 2] "ham")
44− [104 %2]
docs/system/hoon/runes/bc/bccn.mddeleted−52
@@ -1,52 +0,0 @@
1−`$% buccen`
2−====
3−
4−Tagged union.
5−
6−Produces a [mold]() of a tagged union of a list of case pairs.
7−
8−Produces
9−--------
10−
11−A validator function that uses the value's [head]() as a tag to select a mold validate the tail of the value.
12−
13−Accepts
14−-------
15−
16−A list of cells of molds whose heads must be a [cube]().
17−
18−Tall form
19−---------
20−
21− $% p
22− q
23− ==
24−
25−Examples
26−--------
27−
28− ~zod/try=> $%([%& @p] [%| @t])
29− <1.dhe [* @n <246.qra 41.uuw 374.glo 100.rip 1.ypj %164>]>
30− ~zod/try=> *$%([%& @p] [%| @t])
31− [%.y ~zod]
32− ~zod/try=> :type; *$%([%& @p] [%| @t])
33− [%.y ~zod]
34− {[%.y @p] [%.n @t]}
35− ~zod/try=> :type; *(each ,@p ,@t)
36− [%.y p=~zod]
37− {[%.y p=@p] [%.n p=@t]}
38− ~zod/try=> $%(~ [%a 1])
39− ~ <syntax error at [1 13]>
40− ~zod/try=> $%([%~ ~] [%a 1])
41− <1.yck [* @n <246.qra 41.uuw 374.glo 100.rip 1.ypj %164>]>
42− ~zod/try=> *$%([%~ ~] [%a 1])
43− [~ ~]
44−
45− ++ foot $% [%ash p=twig] :: dry, geometric
46− [%elm p=twig] :: wet, generic
47− [%oak ~] :: XX not used
48− [%yew p=(map term foot)] :: XX not used
49− ==
50−
51−In `++foot`, `$%` creates a list of possible cases. That is, a `++foot`
52−can be either `%ash`, `%elm`, `%oak` or `%yew`.
docs/system/hoon/runes/bc/bcls.mddeleted−57
@@ -1,57 +0,0 @@
1−`$+ buclus`
2−===========
3−
4−Type of function (type signature).
5−
6−Produces a [mold]() for a function that accepts `p` and produces `q`. Used when we want to use the type of a function that we do not want to compute.
7−
8−Reduces to `$_(|+(p _q))`.
9−
10−Produces
11−--------
12−
13−A mold whose [span]() is used to validate the types of functions.
14−
15−Accepts
16−-------
17−
18−`p` is the mold of the [argument]() ([sample]()) and `q` is a mold of the product.
19−
20−Tall form
21−---------
22−
23− $+ p q
24−
25−Wide form
26−---------
27−
28− $+(p q)
29−
30−Examples
31−--------
32−
33− ++ sort :: quicksort
34− ~/ %sort
35− !:
36− |* [a=(list) b=$+([* *] ?)]
37− => .(a ^.(homo a))
38− |- ^+ a
39− ?~ a ~
40− %+ weld
41− $(a (skim t.a |=(c=_i.a (b c i.a))))
42− ^+ t.a
43− [i.a $(a (skim t.a |=(c=_i.a !(b c i.a))))]
44−
45−In ++sort, `$+` is a mold for a comparator gate, which takes two nouns
46−and produces a loobean.
47−
48− ~zod/try=> |=(a=@ (add 2 a))
49− <1.sgg [a=@ [[@da @ta] [@p @ta] *''] @n <246.qra 41.uuw 374.glo 100.rip 1.ypj %164>]>
50− ~zod/try=> `$+(@ @)`|=(a=@ (add 2 a))
51− <1|crm [@ [[@da @ta] [@p @ta] *''] @n <246.qra 41.uuw 374.glo 100.rip 1.ypj %164>]>
52− ~zod/try=> +<:|=(a=@ (add 2 a))
53− a=0
54− ~zod/try=> +<:`$+(@ @)`|=(a=@ (add 2 a))
55− ! -axis.6
56− ! peek-park
57− ! exit
docs/system/hoon/runes/bc/bcpm.mddeleted−30
@@ -1,30 +0,0 @@
1−`$& bucpam`
2−===========
3−
4−Union of two cells: one w/cellular head & other w/atomic head.
5−
6−Produces a [mold]() that's a union between two different kinds of noun: a cell whose head is a cell (`p`), and cell whose head is an atom (`q`). Its default value ([bunt]()) is the value of `q`. One important use of `$&` is to implement autocons in [`++twig`]().
7−
8−Produces
9−--------
10−
11−A validator function that uses mold `p` to validate cells whose head is a cell, and `q` to validate cells whose head is an atom. Default value is the bunt of `q`.
12−
13−Accepts
14−-------
15−
16−A mold of a cell whose head is a cell `p` and a mold of a cell whose head is an atom `q`.
17−
18−Tall form
19−---------
20−
21− $& p
22− q
23−
24−Wide form
25−---------
26−
27− $&(p q)
28−
29−Examples
30−--------
docs/system/hoon/runes/bc/bctr.mddeleted−41
@@ -1,41 +0,0 @@
1−`$* buctar`
2−===========
3−
4−Bunt (default value).
5−
6−Produces the default value ([bunt]()) of [mold]() `p`. Does so as a compile-time constant if possible. If not possible, then it is produced dynamically.
7−
8−Produces
9−--------
10−
11−The default value (bunt) of the mold `p`.
12−
13−Accepts
14−-------
15−
16−A mold `p`.
17−
18−Tall form
19−---------
20−
21− $* p
22−
23−Wide form
24−---------
25−
26− $*(p)
27−
28−Irregular form
29−--------------
30−
31− *p
32−
33−Examples
34−--------
35−
36− ~zod/try=> *@t
37− ''
38− ~zod/try=> *[@p @ux]
39− [~zod 0x0]
40− ~zod/try=> *(list ,@)
41− ~
docs/system/hoon/runes/bc/bcts.mddeleted−59
@@ -1,59 +0,0 @@
1−`$= buctis`
2−===========
3−
4−Add variable name.
5−
6−Wraps a [++face]() around another [mold](). Used primarily to add variable names to values.
7−
8−Produces
9−--------
10−
11−Produces a [mold]() that validates the input value with `q`, before adding face `p`.
12−
13−Accepts
14−------
15−
16−`p` is a [++term]().
17−
18−`q` is a mold.
19−
20−Tall form
21−---------
22−
23− $= p
24− q
25−
26−Wide form
27−---------
28−
29− $=(p q)
30−
31−Irregular form
32−--------------
33−
34− `p=q`
35−note: this is only the case when in mold syntax
36−
37−Examples
38−--------
39−
40−`a=*` parses as `[%bark %a %noun]`.
41−
42− ~zod/try=> *$=(a @)
43− a=0
44− ~zod/try=> :type; *$=(a @)
45− a=0
46− a=@
47− ~zod/try=> :type; *a=@
48− a=0
49− a=@
50− ~zod/try=> :type; *a=[1 2]
51− a=[%1 %2]
52− a=[%1 %2]
53−
54− |_ [hid=bowl vat=axle]
55− ...
56− --
57−See here how we wrap the faces 'hid' and 'vat' around the two [sample]() (input) types of the core above. We can now refer to our 'bowl' and 'vat' by these names.
58−
59−
docs/system/hoon/runes/bc/bcwt.mddeleted−42
@@ -1,42 +0,0 @@
1−`$? bucwut`
2−===========
3−
4−Union of types.
5−
6−Produce a union between a non-empty list of [mold]()s `p`. The default value ([bunt]()) is the value of the first element.
7−
8−Produces
9−--------
10−
11−A validator function that keeps trying to validate a value using every mold in `p` from left to right. On a success, the value is produced. If no mold in `p` succeeds, the default value of the last element in `p` is produced.
12−
13−Accepts
14−-------
15−
16−`p` is a [++list]() of mold.
17−
18−Tall form
19−---------
20−
21− $? p
22− q
23− ==
24−
25−Irregular form
26−--------------
27−
28− ?(p q)
29−
30−Examples
31−--------
32−
33− ++ base ?([%atom p=odor] %noun %cell %bean %null) :: axils, @ * ^ ? ~
34−
35−`++base`, `?` (the irregular form of `$?`) specifies a list of
36−orthoganal cases for the `%axil` mold.
37−
38− ~zod/try=> *?(%a %b %c)
39− %a
40− ~zod/try=> :type; *?(%a %b %c)
41− %a
42− {%a %b %c}
docs/system/hoon/runes/bc/book.mdnew file+21
@@ -0,0 +1,21 @@
1+# `:book`, `$%`, "buctis", `{$book p/(list moss)}`
2+
3+The product: a mold producing the tagged union of the molds in
4+`p`, all of which must be of the form `:bank(stem bulb)`, where
5+`stem` is an atomic mold.
6+
7+Usage: define a type which is a tagged union.
8+
9+Regular form: *running*.
10+
11+Examples:
12+
13+```
14+~zod:dojo> =a :book({$foo p/@ud q/@ud} {$bar p/@ud})
15+
16+~zod:dojo> (a [%bar 37])
17+[%bar p=37]
18+
19+~zod:dojo> $:a
20+[%foo p=0 q=0]~
21+```
docs/system/hoon/runes/bc/bush.mdnew file+25
@@ -0,0 +1,25 @@
1+# `:bush`, `$&`, "bucpam", `{$bush p/moss q/moss}`
2+
3+The product: a mold which applies `p` if the head of its sample
4+is a cell, `q` if the head of its sample is a cell.
5+
6+Usage: add a default pair behavior (like "autocons" in Nock
7+formulas) to a tagged union type.
8+
9+Regular form: *2-fixed*.
10+
11+Example:
12+```
13+~zod:dojo> =a :book({$foo p/@ud q/@ud} {$bar p/@ud})
14+
15+~zod:dojo> =b :bush({a a} a)
16+
17+~zod:dojo> (b [[%bar 33] [%foo 19 22]])
18+[[%bar p=33] [%foo p=19 q=22]]
19+
20+~zod:dojo> (b [%foo 19 22])
21+[%foo p=19 q=22]
22+
23+~zod:dojo> $:b
24+[%bar p=0]
25+```
docs/system/hoon/runes/bc/claw.mdnew file+22
@@ -0,0 +1,22 @@
1+# `:claw`, `$@`, "bucpat", `{$claw p/moss q/moss}`
2+
3+The product: a mold which applies `p` if its sample is an atom,
4+`q` if its sample is a cell.
5+
6+Usage: define a type which is either an atom or a cell.
7+
8+Regular form: *2-fixed*.
9+
10+Example:
11+```
12+~zod:dojo> =a :claw($foo :bank(p/$bar q/@ud))
13+
14+~zod:dojo> (a %foo)
15+%foo
16+
17+~zod:dojo> `a`[%bar 99]
18+[p=%bar q=99]
19+
20+~zod:dojo> $:a
21+[%foo p=0 q=0]
22+```
docs/system/hoon/runes/bc/coat.mdnew file+21
@@ -0,0 +1,21 @@
1+# `:coat`, `$=`, "buctis", `{$coat p/@tas q/moss}
2+
3+The product: a mold which puts the label `p` on the mold `q`.
4+
5+Usage: name a typed attribute or variable.
6+
7+Regular form: *2-fixed*.
8+
9+Irregular form:
10+```
11+a/b :coat(a b)
12+```
13+
14+Examples:
15+
16+```
17+~zod:dojo> =a :coat(p $foo)
18+
19+~zod:dojo> (a %bar)
20+p=%foo
21+```
docs/system/hoon/runes/bc/lamb.mdnew file+15
@@ -0,0 +1,15 @@
1+# `:lamb`, `$-`, "buchep", `{$lamb p/moss q/moss}`
2+
3+The product: a mold producing a gate accepting
4+
5+Usage: define a function type.
6+
7+Regular form: *2-fixed*.
8+
9+Example:
10+```
11+~zod:dojo> =a :lamb($foo $bar)
12+
13+~zod:dojo> ($:a %foo)
14+%bar
15+```
docs/system/hoon/runes/bc/pick.mdnew file+22
@@ -0,0 +1,22 @@
1+# `:pick`, `$?`, "bucwut", `{$? p/(list moss)}`
2+
3+The product: a mold which tries each of the alternatives in `p`.
4+
5+Usage: a generalized type union. Use `:pick` only if none of
6+`:book` (`$%`), `:claw` (`$@`) or `:bush` (`$&`) applies.
7+
8+Regular form: *running*.
9+
10+Example:
11+```
12+~zod:dojo> =a :pick($foo $bar $baz)
13+
14+~zod:dojo> (a %baz)
15+%baz
16+
17+~zod:dojo> (a [37 45])
18+%foo
19+
20+~zod:dojo> $:a
21+$foo
22+```
docs/system/hoon/runes/bc/shoe.mdnew file+26
@@ -0,0 +1,26 @@
1+# `:shoe`, `$_`, "buccab", `{$shoe p/twig}`
2+
3+The product: a mold whose product is always `p`.
4+
5+Usage: define a type as a single example.
6+
7+Regular form: *1-fixed*.
8+
9+Irregular form:
10+```
11+_%foo :shoe(%foo)
12+```
13+
14+Example:
15+```
16+~zod:dojo> =a :shoe([%foobar %moobaz])
17+
18+~zod:dojo> (a %foo %bar)
19+[%foobar %moobaz]
20+
21+~zod:dojo> `a`[%foobar %moobaz]
22+[%foobar %moobaz]
23+
24+~zod:dojo $:a
25+[%foobar %moobaz]
26+```