on b00decd help sign in
384 lines 6.9 kB history raw
1+++
2title = "3g: Molds and Mold-Builders"
3weight = 27
4template = "doc.html"
5+++
7### `++coin`
10Noun-literal syntax cases
12Syntax cases for nouns-literal: atoms, jammed nouns, and nestable tuples. Parsed
13and printed using `++so` and `++co` cores.
15#### Source
17```hoon
18 ++ coin $% [$$ p=dime]
19 [$blob p=*]
20 [$many p=(list coin)]
21 ==
22```
24---
25#### Examples
27```
28 > `coin`(need (slay '~s1'))
29 [%$ p=[p=~.dr q=18.446.744.073.709.551.616]]
31 > `coin`(need (slay '0x2b59'))
32 [%$ p=[p=~.ux q=11.097]]
34 > ~(rend co [%many ~[[%$ %ud 1] [%$ %tas 'a'] [%$ %s -2]]])
35 "._1_a_-2__"
36 > ._1_a_-2__
37 [1 %a -2]
39 > `@uv`(jam [3 4])
40 0v2cd1
42 > (slay '~02cd1')
43 [~ u=[%blob p=[3 4]]]
45 > ~02cd1
46 [3 4]
47```
50---
51### `++dime`
53Aura-atom pair
55Used in `++coin`. Convenience methods [`++scot`](/docs/hoon/reference/stdlib/4m) and
56[`++scow`](/docs/hoon/reference/stdlib/4m) print dimes as `++cord` and `++tape`, respectively.
57[`++slat`](/docs/hoon/reference/stdlib/4m), [`++slav`](/docs/hoon/reference/stdlib/4m), and [`++slaw`](/docs/hoon/reference/stdlib/4m) are used
58to parse atoms of specific auras.
60#### Source
62```hoon
63 ++ dime [p=@ta q=@]
64```
66#### Examples
68```
69 > +>:(slay '0x123')
70 p=[p=~.ux q=291]
71```
73---
74### `++edge`
76Parsing location metadata. Parsing location input `p` and optional result `p.q` and parsing continuation `q.q`.
78#### Source
80```hoon
81 ++ edge [p=hair q=(unit [p=* q=nail])] :: parsing output
82```
84#### Examples
86```
87 > *edge
88 [p=[p=0 q=0] q=~]
90 > (tall:vast [1 1] "a b")
91 [p=[p=1 q=3] q=[~ u=[p=[%wing p=~[%a]] q=[p=[p=1 q=2] q=" b"]]]]
92```
94#### Discussion
96See also: [Section 3g](/docs/hoon/reference/stdlib/3g#rule), `++rule`
99---
100### `++hair`
102Parsing line and column
104A pair of two `@ud` used in parsing indicating line and column number.
106#### Source
108```hoon
109 ++ hair [p=@ud q=@ud]
110```
112#### Examples
114```
115 > *hair
116 [p=0 q=0]
118 > `hair`[1 1] :: parsing starts at [1 1] as a convention.
119 [p=1 q=1]
121 > ((plus ace) [1 1] " --")
122 [p=[p=1 q=4] q=[~ u=[p=[~~. " "] q=[p=[p=1 q=4] q="--"]]]]
124 > `hair`p:((plus ace) [1 1] " --")
125 [p=1 q=4]
126```
128---
129### `++like`
131Generic edge
133Generates an `++edge` with a parsed result set to a specific type.
135#### Source
137```hoon
138 ++ like |* a=gate
139 |= b=_`*`[(hair) ~]
140 :- p=(hair -.b)
141 ^= q
142 :- ~
143 u=[p=(a +>-.b) q=[p=(hair -.b) q=(tape +.b)]]
144```
146#### Examples
148```
149 > *(like char)
150 [p=[p=0 q=0] q=~]
152 > (ace [1 1] " a")
153 [p=[p=1 q=2] q=[~ u=[p=' ' q=[p=[p=1 q=2] q="a"]]]]
155 > `(like char)`(ace [1 1] " a")
156 [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q="a"]]]]
158 > `(like ,@)`(ace [1 1] " a")
159 [p=[p=1 q=2] q=[~ u=[p=32 q=[p=[p=1 q=2] q="a"]]]]
160```
162---
163### `++nail`
165Location, remainder of parsed text
167Indicates parsing position `p`, and remaining text to be parsed `q`.
169#### Source
171```hoon
172 ++ nail [p=hair q=tape]
173```
175#### Examples
177```
178 > +<:;~(plug cab cab)
179 c=[p=[p=0 q=0] q=""]
180```
182---
183### `++path`
185Filesystem path
187A list of `++knot`s. `++knot` is another name for `@ta`.
189#### Source
191```hoon
192 ++ path (list knot)
193```
195#### Examples
197```
198 > `path`"abc"
199 /a/b/c
200```
202#### Discussion
204Used in `%clay` and `%eyre` extensively.
206---
207### `++pint`
209Parsing range
211A `++pint` is a pair of `++hair`, indicating from `p` to `q`. Mostly used for
212stack traces.
214#### Source
216```hoon
217 ++ pint [p=[p=@ q=@] q=[p=@ q=@]]
218```
220#### Examples
222```
223 > !:(!!) :: !! always produces a crash
224 /~zod/home/~2014.9.20..01.22.04..52e3/:<[1 4].[1 6]>
226 > `pint`[[1 4] [1 6]]
227 [p=[p=1 q=4] q=[p=1 q=6]]
228```
231---
232### `++rule`
234Parsing rule
236An empty parsing rule, but used to check that parsing rules match this with `_`.
239#### Source
241```hoon
242 ++ rule _|=(nail *edge)
243```
245#### Examples
247```
248 > ([|=(a=nail [p.a ~ u=['a' a]])]:|6 [1 1] "hi")
249 [[p=1 q=1] ~ u=['a' p=[p=1 q=1] q="hi"]]
250```
252---
253### `++spot`
255Stack trace line
257The stack trace that is printed after crashing.
259#### Source
261```hoon
262 ++ spot [p=path q=pint]
263```
265#### Examples
267```
268 > !: !! :: !! always produces a crash
269 /~zod/home/~2018.8.8..21.42.40..7852:<[1 5].[1 7]>
270 ! exit
271```
273---
274### `++tone`
276Nock result, error report
278Produces either success (`%0`), a block with list of requests blocked on (`%1`),
279or failure with an error report (`%2`).
282#### Source
284```hoon
285 ++ tone $% [$0 p=*] :: success
286 [$1 p=(list)] :: blocks
287 [$2 p=(list [@ta *])] :: error report
288 ==
289```
291#### Examples
293```
294 > (mink [[20 21] 0 3] $~)
295 [%0 p=21]
298 > (mink [[1 2] !=(!:(+(.)))] ,~)
299 [ %2
300 p
301 ~[
302 [ ~.spot
303 [ [ \/72.245.008.048.359.254.300.063.028.130.093.488.830.539.186.242.06\/
304 3.318.457.928.725.368.447.417.075.673.617.723.940.025.940.705.343
305 .057.601.925.133.611.559.292.046.932.324.629.048.702
306 \/ \/
307 1.701.670.760
308 \/347.698.068.472.453.194.464.038.059.283.550.210.118.689.128.761.6\/
309 88.459.326.078
310 \/ \/
311 0
312 ]
313 [1 20]
314 1
315 24
316 ]
317 ]
318 ]
319```
321---
322### `++toon`
324Nock result, stack trace
326Produces either success (`%0`), a block with list of requests blocked on (`%1`),
327or failure with a stack trace (`%2`).
330#### Source
332```hoon
333 ++ toon $% [$0 p=*] :: success
334 [$1 p=(list)] :: blocks
335 [$2 p=(list tank)] :: stack trace
336 ==
337```
339#### Examples
341```
342 > (mock [[20 21] 0 3] $~)
343 [%0 p=21]
345 > (mock [[1 2] !=(!:(+(.)))] ,~)
346 [%2 p=~[[%leaf p="/~zod/try/~2014.9.23..18.34.32..d3c5/:<[1 20].[1 24]>"]]]
347```
349---
350### `++wonk`
352Product from edge
354Pull result out of a `++edge`, or crash if there's no result.
356#### Source
358```hoon
359 ++ wonk |*(veq=edge ?~(q.veq !! p.u.q.veq))
360```
362#### Examples
364```
365 > (wide:vast [1 1] "(add 2 2)")
366 [ p=[p=1 q=10]
367 q
368 [ ~
369 u
370 [ p=[%cnhp p=[%wing p=~[%add]] q=~[[%sand p=%ud q=2] [%sand p=%ud q=2]]]
371 q=[p=[p=1 q=10] q=""]
372 ]
373 ]
374 ]
376 > (wonk (wide:vast [1 1] "(add 2 2)"))
377 [%cnhp p=[%wing p=~[%add]] q=~[[%sand p=%ud q=2] [%sand p=%ud q=2]]]
378```
380#### Discussion
382See also: `++edge`
384---