Merge branch 'joemfb-twig-expansions'
commit750d967f1d200e95066d42013080c1934f6a8355
authorC. Guy Yarvin <cgyarvin@gmail.com>
dateWed 13 Jul 2016, 15:11 (10 years ago)
parentaa78b7c94ed4f4
docs/hoon/twig/bar-core/cab-door.md+6
@@ -18,6 +18,12 @@ with a sample.
1818==
1919```
2020
21+```
22+=| p
23+|% q
24+==
25+```
26+
2127## Syntax
2228
2329Regular: *1-fixed*, then *battery*.
docs/hoon/twig/bar-core/dot-trap.md+6−1
@@ -14,7 +14,12 @@ sort: 3
1414:core
1515++ $ p
1616--
17−```
17+```
18+
19+```
20+|% ++ $ p
21+--
22+```
1823
1924## Syntax
2025
docs/hoon/twig/bar-core/hep-loop.md+6−4
@@ -12,10 +12,12 @@ sort: 4
1212
1313```
1414:rap $
15−:core
16−++ $ p
17−--
18−```
15+:trap p
16+```
17+
18+```
19+=<($ |.(p))
20+```
1921
2022## Syntax
2123
docs/hoon/twig/bar-core/tar-gill.md+7−1
@@ -11,13 +11,19 @@ core with sample.
1111## Expands to
1212
1313```
14−:new p
14+:new p
1515:core
1616+- $
1717 q
1818--
1919```
2020
21+```
22+=| p
23+|% +- $ q
24+--
25+```
26+
2127## Syntax
2228
2329Regular: *2-fixed*.
docs/hoon/twig/bar-core/tis-gate.md+7−1
@@ -11,13 +11,19 @@ sort: 2
1111## Expands to
1212
1313```
14−:new p
14+:new p
1515:core
1616++ $
1717 q
1818--
1919```
2020
21+```
22+=| p
23+|% ++ $ q
24+--
25+```
26+
2127## Syntax
2228
2329Regular: *2-fixed*.
docs/hoon/twig/buc-mold/base.md+2−2
@@ -11,8 +11,8 @@ sort: 1
1111## Produces
1212
1313A mold for the base in `p`. `$noun` is any noun; `$atom` is any
14−atom; `$cell` is a cell of nouns; `$bean` is a loobean, `?(`@f`0
15−`@f`1)`. `$null` is zero with aura `@n`.
14+atom; `$cell` is a cell of nouns; `$bean` is a loobean, ``?(`@f`0
15+`@f`1)``. `$null` is zero with aura `@n`.
1616
1717## Syntax
1818
docs/hoon/twig/buc-mold/cab-shoe.md+4
@@ -14,6 +14,10 @@ sort: 9
1414p
1515```
1616
17+```
18+|=(* p)
19+```
20+
1721## Syntax
1822
1923Regular: *1-fixed*.
docs/hoon/twig/buc-mold/hep-lamb.md+5
@@ -17,6 +17,11 @@ sort: 8
1717$:q
1818```
1919
20+```
21+$_ ^|
22+|=(p $:q)
23+```
24+
2025## Syntax
2126
2227Regular: *2-fixed*.
docs/hoon/twig/buc-mold/tis-coat.md+5
@@ -15,6 +15,11 @@ sort: 3
1515:name(p :call(q +6))
1616```
1717
18+```
19+|= *
20+^=(p %-(q +6))
21+```
22+
1823## Syntax
1924
2025Regular: *2-fixed*.
docs/hoon/twig/cen-call/cab-keep.md+4
@@ -15,6 +15,10 @@ preserving type.
1515:like(p :make(p q))
1616```
1717
18+```
19+^+(p %=(p q))
20+```
21+
1822## Syntax
1923
2024Regular: *1-fixed*, then *jogging*.
docs/hoon/twig/cen-call/dot-lace.md+7−1
@@ -9,7 +9,13 @@ sort: 5
99
1010## Expands to
1111
12−`:call(q p)`.
12+```
13+:call(q p)
14+```
15+
16+```
17+%-(q p)
18+```
1319
1420## Syntax
1521
docs/hoon/twig/cen-call/hep-call.md+7−1
@@ -9,7 +9,13 @@ sort: 4
99
1010## Expands to
1111
12−`:open($ p q)`.
12+```
13+:open($ p q)
14+```
15+
16+```
17+%~($ p q)
18+```
1319
1420## Syntax
1521
docs/hoon/twig/cen-call/ket-calq.md+7−1
@@ -9,7 +9,13 @@ sort: 7
99
1010## Expands to
1111
12−`:call(p [q r s])`.
12+```
13+:call(p [q r s])
14+```
15+
16+```
17+%-(p [q r s])
18+```
1319
1420## Syntax
1521
docs/hoon/twig/cen-call/lus-calt.md+7−1
@@ -9,7 +9,13 @@ sort: 6
99
1010## Expands to
1111
12−`:call(p [q r])`.
12+```
13+:call(p [q r])
14+```
15+
16+```
17+%-(p [q r])
18+```
1319
1420## Syntax
1521
docs/hoon/twig/cen-call/sig-open.md+12−2
@@ -10,9 +10,18 @@ sort: 3
1010## Expands to
1111
1212```
13−:rap(p :make(q +6 r))
13+:pin :name(a q)
14+:rap(p :make(a +6 r))
1415```
1516
17+```
18+=+ a=q
19+=<(p %=(a +6 r))
20+```
21+
22+> Note: the expansion implementation is hygienic -- it doesn't actually add the
23+> `a` face to the subject. It's shown here because `:make` requires a `wing`.
24+
1625## Syntax
1726
1827Regular: *3-fixed*.
@@ -24,7 +33,8 @@ Irregular: `~(a b c)` is `%~(a b c)`; `~(a b c d e)` is `%~(a b
2433
2534`:open` is the general case of a function call, `:call`. In
2635both, we replace the sample (`+6`) of a core. In `:call` the
27−core is a gate and we
36+core is a gate and we pull the `$` arm, in `:open` the
37+core is a door and we can pull any of its arms.
2838
2939Most languages do not have cores, doors, or `:open`. "Just
3040learn to step outside your linear, Western way of thinking."
docs/hoon/twig/col-cell/cab-scon.md+4
@@ -13,6 +13,10 @@ sort: 6
1313:cons(q p)
1414```
1515
16+```
17+:-(q p)
18+```
19+
1620### Syntax
1721
1822Regular: *2-fixed*.
docs/hoon/twig/col-cell/ket-conq.md+4
@@ -13,6 +13,10 @@ sort: 3
1313:cons(p :cons(q :cons(r s)))
1414```
1515
16+```
17+:-(p :-(q :-(r s)))
18+```
19+
1620## Syntax
1721
1822Regular: *4-fixed*.
docs/hoon/twig/col-cell/lus-cont.md+4
@@ -13,6 +13,10 @@ sort: 2
1313:cons(p :cons(q r))
1414```
1515
16+```
17+:-(p :-(q r))
18+```
19+
1620## Syntax
1721
1822Regular: *3-fixed*.
docs/hoon/twig/col-cell/sig-conl.md+21−1
@@ -9,8 +9,28 @@ sort: 5
99
1010## Expands to
1111
12+*Pseudocode*, `a`, `b`, `c`, ... as elements of `p`
13+
14+```
15+:cons(a :cons(b :cons(c :cons(... :cons(z ~)))))
16+```
17+
18+### Compiler macro
19+
20+```
21+:loop
22+:ifno p
23+ ~
24+:cons i.p
25+:moar(p t.p)
26+```
27+
1228```
13−|-(?~(p ~ :cons(i.p $(p t.p))))
29+|-
30+?~ p
31+ ~
32+:- i.p
33+$(p t.p)
1434```
1535
1636## Syntax
docs/hoon/twig/col-cell/tar-conp.md+25−1
@@ -9,8 +9,32 @@ sort: 4
99
1010## Expands to
1111
12+*Pseudocode*, `a`, `b`, `c`, ... as elements of `p`
13+
14+```
15+:cons(a :cons(b :cons(c :cons(... z)))))
16+```
17+
18+### Compiler macro
19+
20+```
21+:loop
22+:ifno p
23+ !!
24+:ifno t.p
25+ i.p
26+:cons i.p
27+:moar(p t.p)
28+```
29+
1230```
13−|-(?~(p !! ?~(t.p i.p :cons(i.p $(p t.p)))))
31+|-
32+?~ p
33+ !!
34+?~ t.p
35+ i.p
36+:- i.p
37+$(p t.p)
1438```
1539
1640## Syntax
docs/hoon/twig/ket-cast/hep-cast.md+4
@@ -13,6 +13,10 @@ sort: 2
1313:like(:bunt(p) q)
1414```
1515
16+```
17+^+(*p q)
18+```
19+
1620## Syntax
1721
1822Regular: *2-fixed*.
docs/hoon/twig/sem-make/col-wad.md+23−1
@@ -9,8 +9,30 @@ sort: 3
99
1010## Expands to
1111
12+*Pseudocode*, `a`, `b`, `c`, ... as elements of `q`
13+
14+```
15+:call(p a :call(p b :call(p c ...)))
16+```
17+
18+### Compiler macro
19+
20+```
21+:loop
22+:ifno q !!
23+:ifno t.q !!
24+:ifno t.t.q
25+ :call(p i.q i.t.q)
26+:call(p i.q :moar(q t.q))
27+```
28+
1229```
13−|-(?~(q !! ?~(t.q !! ?~(t.t.q :call(p i.q i.t.q) :call(p i.q $(q t.q))))))
30+|-
31+?~ q !!
32+?~ t.q !!
33+?~ t.t.q
34+ (p i.q i.t.q)
35+(p i.q $(q t.q))
1436```
1537
1638## Syntax
docs/hoon/twig/sem-make/fas-nub.md+7−3
@@ -10,11 +10,15 @@ sort: 4
1010## Expands to
1111
1212```
13−[%$ [%$ p ~] ~]
13+:conl(%$ :conl(%$ p))
14+```
15+
16+```
17+~[%$ ~[%$ 'p']]
1418```
1519
1620## Examples
1721```
18−~zod/try=> :/("foo"
19−[[%$ [%$ "foo] ~] ~]
22+~zod/try=> :/"foo"
23+[[%~. [%~. "foo] ~] ~]
2024```
docs/hoon/twig/sem-make/sem-fry.md+12−1
@@ -10,9 +10,20 @@ sort: 1
1010## Expands to
1111
1212```
13−:pin(:name(a (p q)) :sure(=(a (p a)) a))
13+:pin :name(a (p q))
14+:sure =(a (p a))
15+a
1416```
1517
18+```
19+=+ a=(p q)
20+?> =(a (p a))
21+a
22+```
23+
24+> Note: the expansion implementation is hygienic -- it doesn't actually add the
25+> `a` face to the subject.
26+
1627## Syntax
1728
1829Regular: *2-fixed*.
docs/hoon/twig/sig-hint/fas-funk.md+4
@@ -14,6 +14,10 @@ registered context.
1414:fast(p +7 ~ q)
1515```
1616
17+```
18+~%(p +7 ~ q)
19+```
20+
1721## Syntax
1822
1923Regular: *2-fixed*.
docs/hoon/twig/tis-flow/bar-new.md+4
@@ -13,6 +13,10 @@ sort: 5
1313:pin(:bunt(p) q)
1414```
1515
16+```
17+=+(*p q)
18+```
19+
1620## Syntax
1721
1822Regular: *2-fixed*.
docs/hoon/twig/tis-flow/col-fix.md+5−1
@@ -10,7 +10,11 @@ sort: 9
1010## Expands to
1111
1212```
13−:per(:keep(. p q) r)
13+:per(:keep(. p) q)
14+```
15+
16+```
17+=>(%_(. p) q)
1418```
1519
1620## Syntax
docs/hoon/twig/tis-flow/dot-set.md+4
@@ -13,6 +13,10 @@ sort: 8
1313:per(:keep(. p q) r)
1414```
1515
16+```
17+=>(%_(. p q) r)
18+```
19+
1620## Syntax
1721
1822Regular: *3-fixed*.
docs/hoon/twig/tis-flow/fas-var.md+35−1
@@ -10,8 +10,42 @@ noun with the subject.
1010
1111## Expands to
1212
13+*if `p` is a symbol*:
14+
15+```
16+:pin(:name(p q) r)
17+```
18+
19+```
20+=+(^=(p q) r)
21+```
22+
23+*if `p` is a symbol with a mold*:
24+
25+```
26+:pin(:cast(p q) r)
27+```
28+
29+```
30+=+(^-(p q) r)
31+```
32+
33+### Compiler macro
34+
35+```
36+:ifat p
37+ :pin :name(p q)
38+ r
39+:pin :cast(:coat(p.p q.p) q)
40+r
41+```
42+
1343```
14−?@(p :pin(:name(p q) r) :pin(:cast(:coat(p q) r)
44+?@ p
45+ =+ p=q
46+ r
47+=+ ^-($=(p.p q.p) q)
48+r
1549```
1650
1751## Syntax
docs/hoon/twig/tis-flow/gal-rap.md+4
@@ -13,6 +13,10 @@ sort: 2
1313:per(q p)
1414```
1515
16+```
17+=>(q p)
18+```
19+
1620## Syntax
1721
1822Regular: *2-fixed*.
docs/hoon/twig/tis-flow/hep-nip.md+4
@@ -13,6 +13,10 @@ sort: 4
1313:per(:cons(q .) p)
1414```
1515
16+```
17+=>([q .] p)
18+```
19+
1620## Syntax
1721
1822Regular: *2-fixed*.
docs/hoon/twig/tis-flow/ket-sip.md+4
@@ -14,6 +14,10 @@ a leg with the tail.
1414:var(p -.r :set(q +.r s))
1515```
1616
17+```
18+=/(p -.r =.(q +.r s))
19+```
20+
1721## Syntax
1822
1923Regular: *4-fixed*.
docs/hoon/twig/tis-flow/lus-pin.md+4
@@ -13,6 +13,10 @@ sort: 3
1313:per(:cons(p .) q)
1414```
1515
16+```
17+=>([p .] q)
18+```
19+
1620## Syntax
1721
1822Regular: *2-fixed*.
docs/hoon/twig/tis-flow/sem-rev.md+5−1
@@ -11,7 +11,11 @@ subject, inverted.
1111## Expands to
1212
1313```
14−?@(p :pin(:name(p r) q) :pin(:cast(:coat(p r) q)
14+:var(p r q)
15+```
16+
17+```
18+=/(p r q)
1519```
1620
1721## Syntax
docs/hoon/twig/wut-test/bar-or.md+18
@@ -9,7 +9,16 @@ sort: 9
99
1010## Expands to
1111
12+*Pseudocode*, `a`, `b`, `c`, ... as elements of `p`
13+
14+```
15+:if(a & :if(b & :if(c & :if(... :if(z & |)))))
16+```
17+
18+### Compiler macro
19+
1220```
21+:loop
1322:ifno p
1423 |
1524:if i.p
@@ -17,6 +26,15 @@ sort: 9
1726:moar(p t.p)
1827```
1928
29+```
30+|-
31+?~ p
32+ |
33+?: i.p
34+ &
35+$(p t.p)
36+```
37+
2038## Syntax
2139
2240Regular: *running*.
docs/hoon/twig/wut-test/dot-lest.md+4
@@ -15,6 +15,10 @@ sort: 2
1515q
1616```
1717
18+```
19+?:(p r q)
20+```
21+
1822## Syntax
1923
2024Regular: *3-fixed*.
docs/hoon/twig/wut-test/gal-deny.md+5−1
@@ -11,10 +11,14 @@ sort: 10
1111
1212```
1313:if p
14− :zpzp
14+ !!
1515q
1616```
1717
18+```
19+?:(p !! q)
20+```
21+
1822## Syntax
1923
2024Regular: *2-fixed*.
docs/hoon/twig/wut-test/gar-sure.md+5−1
@@ -11,10 +11,14 @@ sort: 11
1111
1212```
1313:lest p
14− :zpzp
14+ !!
1515q
1616```
1717
18+```
19+?.(p !! q)
20+```
21+
1822## Syntax
1923
2024Regular: *2-fixed*.
docs/hoon/twig/wut-test/hep-case.md+23−1
@@ -10,14 +10,36 @@ union, with no default.
1010
1111## Expands to
1212
13+*Pseudocode*, `a`, `b`, `c`, ... as elements of `q`
14+
15+```
16+:if :fits(p.a) q.a
17+:if :fits(p.b) q.b
18+:if :fits(p.c) q.c
19+...
20+:show(%mint-lost !!)
21+```
22+
23+### Compiler macro
24+
1325```
26+:loop
1427:ifno q
15− :lost
28+ :show(%mint-lost !!)
1629:if :fits(p.i.q p)
1730 q.i.q
1831:moar(q t.q)
1932```
2033
34+```
35+|-
36+?. q
37+ ~|(%mint-lost !!)
38+?: ?=(p.i.q p)
39+ q.i.q
40+$(q t.q)
41+```
42+
2143## Syntax
2244
2345Regular: *1-fixed*, then *jogging*.
docs/hoon/twig/wut-test/ket-ifcl.md+4
@@ -16,6 +16,10 @@ of the subject is null.
1616r
1717```
1818
19+```
20+?:(?=(^ p) q r)
21+```
22+
1923## Syntax
2024
2125Regular: *3-fixed*.
docs/hoon/twig/wut-test/lus-deft.md+22
@@ -10,7 +10,20 @@ a union, with a default.
1010
1111## Expands to
1212
13+*Pseudocode*, `a`, `b`, `c`, ... as elements of `r`
14+
15+```
16+:if :fits(p.a) q.a
17+:if :fits(p.b) q.b
18+:if :fits(p.c) q.c
19+...
20+q
21+```
22+
23+### Compiler macro
24+
1325```
26+:loop
1427:ifno r
1528 q
1629:if :fits(p.i.r p)
@@ -18,6 +31,15 @@ a union, with a default.
1831:moar(r t.r)
1932```
2033
34+```
35+|-
36+?. r
37+ q
38+?: ?=(p.i.r p)
39+ q.i.r
40+$(r t.r)
41+```
42+
2143## Syntax
2244
2345Regular: *2-fixed*, then *jogging*.
docs/hoon/twig/wut-test/pam-and.md+18
@@ -9,7 +9,16 @@ sort: 8
99
1010## Expands to
1111
12+*Pseudocode*, `a`, `b`, `c`, ... as elements of `p`
13+
14+```
15+:lest(a | :lest(b | :lest(c | :lest(... :lest(z | &)))))
16+```
17+
18+### Compiler macro
19+
1220```
21+:loop
1322:ifno p
1423 &
1524:lest i.p
@@ -17,6 +26,15 @@ sort: 8
1726:moar(p t.p)
1827```
1928
29+```
30+|-
31+?~ p
32+ &
33+?. i.p
34+ |
35+$(p t.p)
36+```
37+
2038## Syntax
2139
2240Regular: *running*.
docs/hoon/twig/wut-test/pat-ifat.md+5−1
@@ -11,11 +11,15 @@ of the subject is an atom.
1111## Expands to
1212
1313```
14−:if :fits($~ p)
14+:if :fits(@ p)
1515 q
1616r
1717```
1818
19+```
20+?:(?=(@ p) q r)
21+```
22+
1923## Syntax
2024
2125Regular: *3-fixed*.
docs/hoon/twig/wut-test/sig-ifno.md+4
@@ -16,6 +16,10 @@ of the subject is null.
1616r
1717```
1818
19+```
20+?:(?=($~ p) q r)
21+```
22+
1923## Syntax
2024
2125Regular: *3-fixed*.
docs/hoon/twig/wut-test/zap-not.md+4
@@ -13,6 +13,10 @@ sort: 7
1313:same(%.n p)
1414```
1515
16+```
17+.=(| p)
18+```
19+
1620Produces the logical "not" of `p`.
1721
1822## Syntax