on master help sign in
bar
commit32c88d6ac989ed96dfeabf79a968686e33a7ed2f authorHenry Ault <henry@tlon.io> dateMon 28 Mar 2016, 21:17 (11 years ago) parent7e26f16
9 files changed+99−291
docs/system/hoon/runes/br/brcb.md+8−8 docs/system/hoon/runes/br/brcn.md+19−58 docs/system/hoon/runes/br/brdt.md+6−25 docs/system/hoon/runes/br/brhp.md+5−25 docs/system/hoon/runes/br/brkt.md+12−32 docs/system/hoon/runes/br/brls.md+10−31 docs/system/hoon/runes/br/brtr.md+10−32 docs/system/hoon/runes/br/brts.md+6−35 docs/system/hoon/runes/br/brwt.md+23−45
docs/system/hoon/runes/br/brcb.md+8−8
@@ -6,19 +6,19 @@ sort: 7
66
77Door: core with sample (input values).
88
9−Product: a core whose sample is `p` and arms are `q`.
9+Produces: a core whose sample is `p` and arms are `q`.
1010
1111Regular form: *1-fixed*, then *battery*
1212
1313Similar to `|%`, but also takes input data (aka sample)
1414available within the entire core. Cores of this type are called doors.
15−Moreover, `|_` only accepts [dry or `%elm`]() arms--in other words,
15+Moreover, `|_` only accepts dry or `%elm` arms--in other words,
1616type checking on these arms is performed on the input before computation.
1717
1818Examples:
1919
2020 /~zod/try=> =mol
21− |_ a=@ud
21+ |_ a/@ud
2222 ++ succ +(a)
2323 ++ prev (dec a)
2424 --
@@ -27,14 +27,14 @@ Examples:
2727 /~zod/try=> ~(succ mol ~(succ mol ~(prev mol 5)))
2828 6
2929
30−In this example we create a door `mol` that operates on a [`@ud`](),
30+In this example we create a door `mol` that operates on a `@ud`,
3131`a`. We add two arms to our door, `++succ` and `++prev`, and invoke them
32−with the irregular form of [`%~`](). Doors are commonly invoked with
32+with the irregular form of `%~`. Doors are commonly invoked with
3333`%~`, irregular form `~(arm door sample)`, which replaces the door's
3434sample and calls the specified arm.
3535
3636 /~zod/try=> =kom
37− |_ a=(list)
37+ |_ a/(list)
3838 ++ hed -.a
3939 ++ tal +.a
4040 --
@@ -56,7 +56,7 @@ sample and calls the specified arm.
5656
5757Here we're demonstrating the difference between `|_` and `|/`. We create
5858a nearly identical door using both runes, each with an arm that produces
59−the tail of the sample `a`. You can see that [wet]() functions use the
59+the tail of the sample `a`. You can see that wet functions use the
6060sample as a mold to produce well-typed output.
6161
6262 ++ ne
@@ -82,5 +82,5 @@ arms who all take the same sample.
8282
8383Here we put `++ne` to work a bit. Our first call renders 12 in base 16.
8484Since `99` is within the ASCII character range, we can cast it to a
85−[`@t`]() and get `'c'`. Conveniently, casting `12` to a [`@ux`]()
85+`@t` and get `'c'`. Conveniently, casting `12` to a `@ux`
8686results in `0xc`.
docs/system/hoon/runes/br/brcn.md+19−58
@@ -2,42 +2,20 @@
22sort: 1
33---
44
5−`|% barcen`
6−===========
5+# `:core, |%, "buccab", {$shoe p/twig}`
76
87Generic core.
98
10−Constructs a generic core with n named expressions, closed with `--`. Cores are
11−similar to an object with named properties (aka [arms]()) that can contain either functions or data. Accepts both [dry or `%elm`]() and [wet or `%ash`]() arms.
9+Produces: a core with `p`, an associative array with `++term` keys and `++foot` values.
1210
13−Produces
14−--------
11+Regular form: *Battery*
1512
16−Twig: `[%brcn p=(map term foot)]`
17−
18−Accepts
19−-------
20−
21−`p` is a [`++map`]() with [`++term`]() keys and [`++foot`]() values, which
22−are called arms.
23−
24−Tall form
25−---------
26−
27− |%
28− ++ p.n.q
29− q.n.q
30− +- p.n.l.q
31− q.n.l.q
32− --
33−
34−Examples
35−--------
13+Example:
3614
3715 /~zod/try=>
3816 =a |%
3917 ++ n 100
40− ++ g |= b=@
18+ ++ g |= b/@
4119 (add b n)
4220 --
4321 new var %a
@@ -54,7 +32,7 @@ function. `g` adds our constant `n` to whatever is passed to it.
5432 ++ r 100
5533 ++ s 4
5634 --
57− ++ g |= b=@
35+ ++ g |= b/@
5836 (div (add b r:l) s:l)
5937 --
6038 changed %a
@@ -67,36 +45,19 @@ and make our function `g` a bit more complicated. `g` now computes the
6745sum of its argument and the arm `r` inside `l`, and divides that by `s`
6846inside `l`.
6947
70− ++ yo
71− |% ++ cet 36.524 :: (add 24 (mul 100 365))
72− ++ day 86.400 :: (mul 24 hor)
73− ++ era 146.097 :: (add 1 (mul 4 cet))
74− ++ hor 3.600 :: (mul 60 mit)
75− ++ jes 106.751.991.084.417 :: (mul 730.692.561 era)
76− ++ mit 60
77− ++ moh `(list ,@ud)`[31 28 31 30 31 30 31 31 30 31 30 31 ~]
78− ++ moy `(list ,@ud)`[31 29 31 30 31 30 31 31 30 31 30 31 ~]
79− ++ qad 126.144.001 :: (add 1 (mul 4 yer))
80− ++ yer 31.536.000 :: (mul 365 day)
81− --
82−
83−[`++yo`](), found in `hoon.hoon`, uses `|%` to create a core whose arms
84−contain constant data for calculating time. As the following examples
85−shows, `|%` is also used to encapsulate arms that perform calculations.
86−
8748 ++ si :: signed integer
8849 |%
89− ++ abs |=(a=@s (add (end 0 1 a) (rsh 0 1 a)))
90− ++ dif |=([a=@s b=@s] (sum a (new !(syn b) (abs b))))
91− ++ dul |=([a=@s b=@] =+(c=(old a) ?:(-.c (mod +.c b) (sub b +.c))))
92− ++ fra |= [a=@s b=@s]
50+ ++ abs |=(a/@s (add (end 0 1 a) (rsh 0 1 a)))
51+ ++ dif |=([a/@s b/@s] (sum a (new !(syn b) (abs b))))
52+ ++ dul |=([a/@s b/@] =+(c=(old a) ?:(-.c (mod +.c b) (sub b +.c))))
53+ ++ fra |= [a/@s b/@s]
9354 (new =(0 (mix (syn a) (syn b))) (div (abs a) (abs b)))
94− ++ new |=([a=? b=@] `@s`?:(a (mul 2 b) ?:(=(0 b) 0 +((mul 2 (dec b))))))
95− ++ old |=(a=@s [(syn a) (abs a)])
96− ++ pro |= [a=@s b=@s]
55+ ++ new |=([a/? b/@] `@s`?:(a (mul 2 b) ?:(=(0 b) 0 +((mul 2 (dec b))))))
56+ ++ old |=(a/@s [(syn a) (abs a)])
57+ ++ pro |= [a/@s b/@s]
9758 (new =(0 (mix (syn a) (syn b))) (mul (abs a) (abs b)))
98− ++ rem |=([a=@s b=@s] (dif a (pro b (fra a b))))
99− ++ sum |= [a=@s b=@s]
59+ ++ rem |=([a/@s b/@s] (dif a (pro b (fra a b))))
60+ ++ sum |= [a/@s b/@s]
10061 ~| %si-sum
10162 =+ [c=(old a) d=(old b)]
10263 ?: -.c
@@ -110,10 +71,10 @@ shows, `|%` is also used to encapsulate arms that perform calculations.
11071 (new | (sub +.c +.d))
11172 (new & (sub +.d +.c))
11273 (new | (add +.c +.d))
113− ++ sun |=(a=@u (mul 2 a))
114− ++ syn |=(a=@s =(0 (end 0 1 a)))
74+ ++ sun |=(a/@u (mul 2 a))
75+ ++ syn |=(a/@s =(0 (end 0 1 a)))
11576 --
11677
117−[`++si`](), found in `hoon.hoon`, uses `|%` to create a core whose arms
118−contain functions used to calculate with signed integers, [`@s`](). In this
78+`++si`, found in `hoon.hoon`, uses `|%` to create a core whose arms
79+contain functions used to calculate with signed integers, `@s`. In this
11980case our core is made up entirely of functions.
docs/system/hoon/runes/br/brdt.md+6−25
@@ -2,34 +2,15 @@
22sort: 3
33---
44
5−`|. bardot`
6−===========
5+# `:trap. |., "bardot", {$trap p/twig}`
76
8−Trap: `|=` with no argument & not called automatically.
7+Trap: `|=` with no argument; expression not evaluated automatically.
98
10−Similar to `|=` except that it takes no arguments and is not automatically
9+Produces: a core with a single arm `$` that it takes no arguments and is not automatically
1110called (you must activate it with the irregular wideform of `%-`, which is
12−`()`. More specifically, its single arm [$]() (the empty name) is not automatically called when the [core]() is constructed. The core produced is both [dry] and [`%gold`](). Used to prevent thunk. XX
11+`()`).
1312
14−Produces
15−--------
16−
17−Twig: `[%brdt p=twig]`
18−
19−Accepts
20−-------
21−
22−`p` is a [`++twig`]().
23−
24−Tall form
25−---------
26−
27− |. p
28−
29−Wide form
30−---------
31−
32− |.(p)
13+Regular form: *1-fixed*
3314
3415Examples
3516--------
@@ -68,7 +49,7 @@ Examples
6849
6950This is a simple example. We assign a shell variable `a` to be a trap
7051that simply produces the atom `42`. Printing `a` prints the core and its
71−context. Calling `a` using `(`, the irregular form of [`%-`](), produces
52+context. Calling `a` using `(`, the irregular form of `%-`, produces
7253its value. As does pulling the arm `$` from inside it using `$:a`.
7354
7455 /~zod/try=>
docs/system/hoon/runes/br/brhp.md+5−25
@@ -2,35 +2,15 @@
22sort: 4
33---
44
5−`|- barhep`
6−===========
5+# `:loop, |-, "barfas", {$trap p/twig}`
76
87Trap: automatically called function with no arguments.
98
10−A function with no arguments that's automatically called when constructed. More specifically, it produces a [dry]() [%gold]() [core]() whose single [arm]() [$]() (the empty name) is automatically called when the core is constructed. Similar to creating and calling an anonymous function and is quite commonly used for loops or recursion.
9+Produces: a core whose single arm $ (the empty name) is automatically called when the core is constructed. Similar to creating and calling an anonymous function and is quite commonly used for loops or recursion.
1110
12−Produces
13−--------
11+Regular form: *1-fixed*
1412
15−[`++twig`]: `[%brhp p=twig]`
16−
17−Accepts
18−-------
19−
20−`p` is a twig
21−
22−Tall form
23−---------
24−
25− |- p
26−
27−Wide form
28−---------
29−
30− |-(p)
31−
32−Examples
33−--------
13+Examples:
3414
3515 /~zod/try=> |-(42)
3616 42
@@ -51,7 +31,7 @@ producing a nested tuple.
5131
5232 ++ dec :: decrement
5333 ~/ %dec
54− |= a=@
34+ |= a/@
5535 ~| %decrement-underflow
5636 ?< =(0 a)
5737 =+ b=0
docs/system/hoon/runes/br/brkt.md+12−32
@@ -2,36 +2,16 @@
22sort: 6
33---
44
5−`|^ barket`
6−===========
5+# `:cork`, `|^`, "barket", `{$cork p/twig q/(map term foot)}`
76
8−Same as `|-` except that it can contain internal arms.
7+Same as `|-` (expression evaluated automatically) except that it can contain internal arms.
98
10−`|^` is a synthetic rune that produces and then calls a [`%gold`]()
11−[book]() with sample `p` as a [`%$(p)`](), and a list of [arm]()s `q`.
9+Produces a `%gold` (XX elaborate on what gold, book mean?) book with sample `p` as a `%$(p)`, and a list of arms `q`.
1210`q` must be closed with a `--`.
1311
14−Produces
15−--------
12+Regular form: *1-fixed*
1613
17−Twig: `[%brkt p=twig q=(map term foot)]`
18−
19−Accepts
20−-------
21−
22−`p` is a [++twig](). `q` is a [`map`]() with [`++term`]() keys and
23−[`++foot`]() values, which are called arms.
24−
25−Tall form
26−---------
27−
28− |^ p
29− ++ p.n.q
30− q.n.q
31− --
32−
33−Examples
34−--------
14+Examples:
3515
3616 /~zod/try=> =+ a=21
3717 |^ [square double]
@@ -46,15 +26,15 @@ commonly used inside another gate or core.
4626
4727 ++ mum :: mug with murmur3
4828 ~/ %mum
49− |= a=*
29+ |= a/*
5030 |^ (trim ?@(a a (mix $(a -.a) (mix 0x7fff.ffff $(a +.a)))))
5131 ++ spec :: standard murmur3
52− |= [syd=@ key=@]
32+ |= [syd/@ key/@]
5333 ?> (lte (met 5 syd) 1)
5434 =+ ^= row
55− |= [a=@ b=@]
35+ |= [a/@ b/@]
5636 (con (end 5 1 (lsh 0 a b)) (rsh 0 (sub 32 a) b))
57− =+ mow=|=([a=@ b=@] (end 5 1 (mul a b)))
37+ =+ mow=|=([a/@ b/@] (end 5 1 (mul a b)))
5838 =+ len=(met 5 key)
5939 =- =. goc (mix goc len)
6040 =. goc (mix goc (rsh 4 1 goc))
@@ -63,7 +43,7 @@ commonly used inside another gate or core.
6343 =. goc (mow goc 0xc2b2.ae35)
6444 (mix goc (rsh 4 1 goc))
6545 ^= goc
66− =+ [inx=0 goc=syd]
46+ =+ [inx/0 goc/syd]
6747 |- ^- @
6848 ?: =(inx len) goc
6949 =+ kop=(cut 5 [inx 1] key)
@@ -76,7 +56,7 @@ commonly used inside another gate or core.
7656 $(inx +(inx))
7757 ::
7858 ++ trim :: 31-bit nonzero
79− |= key=@
59+ |= key/@
8060 =+ syd=0xcafe.babe
8161 |- ^- @
8262 =+ haz=(spec syd key)
@@ -85,5 +65,5 @@ commonly used inside another gate or core.
8565 --
8666 ::
8767
88−[`++mum`]() is a hashing gate, which uses two helper arms to compute
68+`++mum` is a hashing gate, which uses two helper arms to compute
8969its results. The `|^` at the top performs the computation.
docs/system/hoon/runes/br/brls.md+10−31
@@ -7,47 +7,26 @@ sort: 9
77
88Function with unreadable sample.
99
10−`|+` is a synthetic rune that produces a [dry]() [`%iron`]() function
11−with argument (aka [sample]()) [`$*(p)`]() and [arm]()s `q`. `|+` is similar to `|=`, but differs in that its input (sample) cannot be read and thus cannot interfere with the type system.
10+Produces:a dry `%iron` gate with argument (aka sample) `$*(p)` and arms
11+`q`. Similar to `|=`, but differs in that its input (sample) cannot be
12+read and thus cannot interfere with the type system.
1213
13−Produces
14−--------
14+Examples:
1515
16−Twig: `[%brls p=mold q=twig]`
17−
18−Accepts
19−-------
20−
21−`p` is a [mold](). `q` is a [`++twig`]().
22−
23−Tall form
24−---------
25−
26− |+ p
27− q
28−
29−Wide form
30−---------
31−
32− |+(p q)
33−
34−Examples
35−--------
36−
37− ~zod/try=> +<:|+(a=@ a)
16+ ~zod/try=> +<:|+(a/@ a)
3817 ! -axis.6
3918 ! peek-park
4019 ! exit
41− ~zod/try=> +<:|=(a=@ a)
20+ ~zod/try=> +<:|=(a/@ a)
4221 a=0
4322
44−Here we're trying to read the sample, using the [head]() of the [tail]() of two different kinds of functions. With `|+` you can see we cause an error, whereas with `|=` our default sample is `a=0`.
23+Here we're trying to read the sample, using the head of the tail of two different kinds of functions. With `|+` you can see we cause an error, whereas with `|=` our default sample is `a=0`.
4524
46− ~zod/try=> %.(20 |+(a=@ a))
25+ ~zod/try=> %.(20 |+(a/@ a))
4726 20
48− ~zod/try=> %.(20 |=(a=@ a))
27+ ~zod/try=> %.(20 |=(a/@ a))
4928 20
50− ~zod/try=> %.(20 |+(a=@ (add a 12)))
29+ ~zod/try=> %.(20 |+(a/@ (add a 12)))
5130 32
5231
5332Kicking a `|+` gate, however, is the same as `|=`.
docs/system/hoon/runes/br/brtr.md+10−32
@@ -2,42 +2,20 @@
22sort: 10
33---
44
5−`|* bartar`
6−===========
5+# `:gill`, `|*`, "bartar", `{$gill p/twig q/twig}`
76
8−Wet function.
7+Function with arguments; type checking at call time
98
10−Similar to `|=` except that it does type checking at
11−call time, and that the product type is checked to be the same as
12−the input type (in other words it's [wet]()), rather than the input ([sample]()) [mold]().
9+Produces: a gate with argument `p` and body `q`. Type checking happens at
10+call time.
1311
14−Produces
15−--------
12+Regular form: *1-fixed*, followed by Battery
1613
17−Twig: `[%brtr p=mold q=twig]`
14+Examples:
1815
19−Accepts
20−-------
21−
22−`p` is a mold. `q` is a [++twig]().
23−
24−Tall form
25−---------
26−
27− |* p
28− q
29−
30−Wide form
31−---------
32−
33− |*(p q)
34−
35−Examples
36−--------
37−
38− ~zod/try=> %.('c' |*(a=@ a))
16+ ~zod/try=> %.('c' |*(a/@ a))
3917 'c'
40− ~zod/try=> %.('c' |=(a=@ a))
18+ ~zod/try=> %.('c' |=(a/@ a))
4119 99
4220
4321This is a concise way of understanding the difference between `|*` and
@@ -48,7 +26,7 @@ input sample type.
4826
4927 ++ flop :: reverse
5028 ~/ %flop
51− |* a=(list)
29+ |* a/(list)
5230 => .(a (homo a))
5331 ^+ a
5432 =+ b=`_a`~
@@ -57,6 +35,6 @@ input sample type.
5735 b
5836 $(a t.a, b [i.a b])
5937
60−In [`++flop`](), `|*` is used so the type information within the passed
38+In `++flop`, `|*` is used so the type information within the passed
6139in list is maintained. Without a `|*`, any cords would be cast to nouns
6240as in our previous example.
docs/system/hoon/runes/br/brts.md+6−35
@@ -2,45 +2,16 @@
22sort: 2
33---
44
5−`|= bartis`
6−===========
5+# `:gate`, `|=`, "bartis", `{$gate p/twig q/twig}`
76
87Function with argument(s).
98
10−`|=`, is a synthetic rune that produces a [dry]() [`%gold`]() gate with
11−sample [`$*(p)`](), arm `q`. A gate is a core with one arm, [`$`](), the
12−empty name. `|=` checks its input sample against its [mold](), `p`.
13−
14−`|=` is similar to a function that takes a defined input and produces
15−the result of some computation. `|=` differs from `|*` in that its
16−typechecking occurs at compile-time to ensure that all inputs match its
17−sample mold.
18−
19−Produces
20−--------
21−
22−Twig: `[%brts p=mold q=twig]`
23−
24−Accepts
25−-------
26−
27−`p` is a mold. `q` is a twig.
28−
29−Tall form
30−---------
31−
32− |= p
33− q
34−
35−Wide form
36−---------
37−
38− |=(p q)
9+Produces: a dry `%gold` gate with sample `$*(p)`, arm `q`. A gate is a core with one arm, `$`, the
10+empty name.
3911
4012Examples
41−--------
4213
43− ~zod/try=> =inc |=(a=@ +(a))
14+ ~zod/try=> =inc |=(a/@ +(a))
4415 ~zod/try=> (inc 20)
4516 21
4617
@@ -50,13 +21,13 @@ arguments.
5021
5122 ++ add :: add
5223 ~/ %add
53− |= [a=@ b=@]
24+ |= [a/@ b=@]
5425 ^- @
5526 ?: =(0 a)
5627 b
5728 $(a (dec a), b +(b))
5829
59−In [++add](), from `hoon.hoon`, `|=` creates a gate whose sample takes
30+In ++add, from `hoon.hoon`, `|=` creates a gate whose sample takes
6031two atoms labeled `a` and `b`, and whose arm evaluates an expression
6132that produces the sum of the atoms by decrementing `a` until it is `0`
6233and incrementing `b` at each step. Here, `$` is used for recursion,
docs/system/hoon/runes/br/brwt.md+23−45
@@ -2,51 +2,29 @@
22sort: 5
33---
44
5−`|? barwut`
6−===========
5+# `:tray`, `|?`, "barwut", `{$tray p/twig}`
76
87`|-` with hidden context.
98
10−Similar to `|-` except for that the [sample]() and
11−[context]() of the core being passed is hidden in order to avoid
12−type conflicts with a core that has a different [sample]() and
13−context. In urbit language, `|?` produces a [dry]() [%lead]() trap.
14−
15−Produces
16−--------
17−
18−Twig: `[%brwt q=twig]`
19−
20−Accepts
21−-------
22−
23−`p` is a [++twig]().
24−
25−Tall form
26−---------
27−
28− |? p
29−
30−Wide form
31−---------
32−
33− |?(p)
34−
35−Examples
36−--------
37−
38− ~zod/try=> |?(20)
39− < 1?lld
40− [[[@da @ta] [@p @ta] *''] @n <250.yum 41.int 414.hhh 100.xkc 1.ypj %164>]
41− >
42− ~zod/try=> +:|?(20)
43− ! -axis.3
44− ! peek-park
45− ! exit
46− ~zod/try=> +:|.(20)
47− [ [[~2014.10.22..19.39.41..0440 ~.~2014.10.22..19.39.41..0440] [~zod ~.~zod] <||>]
48− ~
49− <250.yum 41.int 414.hhh 100.xkc 1.ypj %164>
50− ]
51−
52−A lead core's payload cannot be read or written.
9+Produces: a lead trap with expression `p` whose context is hidden to avoid type conflicts.
10+
11+Examples:
12+
13+ > |?(20)
14+ < 1?aoy
15+ { {a/^#3.?({i/@ud t/#3} ^#2.?({i/@ud t/#2} it(@ud))) our/@p now/@da eny/@uvI}
16+ $~
17+ <282.ucw 42.juj 402.arm 110.jyx 1.ztu $151>
18+ }
19+ > ~zod/try=> +:|?(20)
20+ > +:|.(20)
21+ [ [ a=[i=1 t=[i=2 t=[i=3 t=~]]]
22+ our=~sivtyv-barnel
23+ now=~2016.3.29..04.14.18..9a26
24+ eny=0v16.dkepv.qm6er.7v2mh.kcdva.oisv9.th4dl.era7v.pj315.fd6la.76d34
25+ ]
26+ ~
27+ <282.ucw 42.juj 402.arm 110.jyx 1.ztu $151>
28+ ]
29+
30+As demonstrated above, a lead core's payload cannot be read or written.