on 705ca06 help sign in
386 lines 6.8 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/reference/library/4m.md) and
56[`++scow`](@/docs/reference/library/4m.md) print dimes as `++cord` and `++tape`, respectively.
57[`++slat`](@/docs/reference/library/4m.md), [`++slav`](@/docs/reference/library/4m.md), and [`++slaw`](@/docs/reference/library/4m.md) 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
78Optional result `p` and parsing continuation `q`.
80#### Source
82```hoon
83 ++ hair [p=@ud q=@ud]
84```
86#### Examples
88```
89 > *edge
90 [p=[p=0 q=0] q=~]
92 > (tall:vast [1 1] "a b")
93 [p=[p=1 q=3] q=[~ u=[p=[%wing p=~[%a]] q=[p=[p=1 q=2] q=" b"]]]]
94```
96#### Discussion
98See also: [Section 2e](@/docs/reference/library/2e.md), `++rule`
101---
102### `++hair`
104Parsing line and column
106A pair of two `@ud` used in parsing indicating line and column number.
108#### Source
110```hoon
111 ++ hair [p=@ud q=@ud]
112```
114#### Examples
116```
117 > *hair
118 [p=0 q=0]
120 > `hair`[1 1] :: parsing starts at [1 1] as a convention.
121 [p=1 q=1]
123 > ((plus ace) [1 1] " --")
124 [p=[p=1 q=4] q=[~ u=[p=[~~. " "] q=[p=[p=1 q=4] q="--"]]]]
126 > `hair`p:((plus ace) [1 1] " --")
127 [p=1 q=4]
128```
130---
131### `++like`
133Generic edge
135Generates an `++edge` with a parsed result set to a specific type.
137#### Source
139```hoon
140 ++ like |* a=gate
141 |= b=_`*`[(hair) ~]
142 :- p=(hair -.b)
143 ^= q
144 :- ~
145 u=[p=(a +>-.b) q=[p=(hair -.b) q=(tape +.b)]]
146```
148#### Examples
150```
151 > *(like char)
152 [p=[p=0 q=0] q=~]
154 > (ace [1 1] " a")
155 [p=[p=1 q=2] q=[~ u=[p=' ' q=[p=[p=1 q=2] q="a"]]]]
157 > `(like char)`(ace [1 1] " a")
158 [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q="a"]]]]
160 > `(like ,@)`(ace [1 1] " a")
161 [p=[p=1 q=2] q=[~ u=[p=32 q=[p=[p=1 q=2] q="a"]]]]
162```
164---
165### `++nail`
167Location, remainder of parsed text
169Indicates parsing position `p`, and remaining text to be parsed `q`.
171#### Source
173```hoon
174 ++ nail [p=hair q=tape]
175```
177#### Examples
179```
180 > +<:;~(plug cab cab)
181 c=[p=[p=0 q=0] q=""]
182```
184---
185### `++path`
187Filesystem path
189A list of `++knot`s. `++knot` is another name for `@ta`.
191#### Source
193```hoon
194 ++ path (list knot)
195```
197#### Examples
199```
200 > `path`"abc"
201 /a/b/c
202```
204#### Discussion
206Used in `%clay` and `%eyre` extensively.
208---
209### `++pint`
211Parsing range
213A `++pint` is a pair of `++hair`, indicating from `p` to `q`. Mostly used for
214stack traces.
216#### Source
218```hoon
219 ++ pint [p=[p=@ q=@] q=[p=@ q=@]]
220```
222#### Examples
224```
225 > !:(!!) :: !! always produces a crash
226 /~zod/home/~2014.9.20..01.22.04..52e3/:<[1 4].[1 6]>
228 > `pint`[[1 4] [1 6]]
229 [p=[p=1 q=4] q=[p=1 q=6]]
230```
233---
234### `++rule`
236Parsing rule
238An empty parsing rule, but used to check that parsing rules match this with `_`.
241#### Source
243```hoon
244 ++ rule _|=(nail *edge)
245```
247#### Examples
249```
250 > ([|=(a=nail [p.a ~ u=['a' a]])]:|6 [1 1] "hi")
251 [[p=1 q=1] ~ u=['a' p=[p=1 q=1] q="hi"]]
252```
254---
255### `++spot`
257Stack trace line
259The stack trace that is printed after crashing.
261#### Source
263```hoon
264 ++ spot [p=path q=pint]
265```
267#### Examples
269```
270 > !: !! :: !! always produces a crash
271 /~zod/home/~2018.8.8..21.42.40..7852:<[1 5].[1 7]>
272 ! exit
273```
275---
276### `++tone`
278Nock result, error report
280Produces either success (`%0`), a block with list of requests blocked on (`%1`),
281or failure with an error report (`%2`).
284#### Source
286```hoon
287 ++ tone $% [$0 p=*] :: success
288 [$1 p=(list)] :: blocks
289 [$2 p=(list [@ta *])] :: error report
290 ==
291```
293#### Examples
295```
296 > (mink [[20 21] 0 3] $~)
297 [%0 p=21]
300 > (mink [[1 2] !=(!:(+(.)))] ,~)
301 [ %2
302 p
303 ~[
304 [ ~.spot
305 [ [ \/72.245.008.048.359.254.300.063.028.130.093.488.830.539.186.242.06\/
306 3.318.457.928.725.368.447.417.075.673.617.723.940.025.940.705.343
307 .057.601.925.133.611.559.292.046.932.324.629.048.702
308 \/ \/
309 1.701.670.760
310 \/347.698.068.472.453.194.464.038.059.283.550.210.118.689.128.761.6\/
311 88.459.326.078
312 \/ \/
313 0
314 ]
315 [1 20]
316 1
317 24
318 ]
319 ]
320 ]
321```
323---
324### `++toon`
326Nock result, stack trace
328Produces either success (`%0`), a block with list of requests blocked on (`%1`),
329or failure with a stack trace (`%2`).
332#### Source
334```hoon
335 ++ toon $% [$0 p=*] :: success
336 [$1 p=(list)] :: blocks
337 [$2 p=(list tank)] :: stack trace
338 ==
339```
341#### Examples
343```
344 > (mock [[20 21] 0 3] $~)
345 [%0 p=21]
347 > (mock [[1 2] !=(!:(+(.)))] ,~)
348 [%2 p=~[[%leaf p="/~zod/try/~2014.9.23..18.34.32..d3c5/:<[1 20].[1 24]>"]]]
349```
351---
352### `++wonk`
354Product from edge
356Pull result out of a `++edge`, or crash if there's no result.
358#### Source
360```hoon
361 ++ wonk |*(veq=edge ?~(q.veq !! p.u.q.veq))
362```
364#### Examples
366```
367 > (wide:vast [1 1] "(add 2 2)")
368 [ p=[p=1 q=10]
369 q
370 [ ~
371 u
372 [ p=[%cnhp p=[%wing p=~[%add]] q=~[[%sand p=%ud q=2] [%sand p=%ud q=2]]]
373 q=[p=[p=1 q=10] q=""]
374 ]
375 ]
376 ]
378 > (wonk (wide:vast [1 1] "(add 2 2)"))
379 [%cnhp p=[%wing p=~[%add]] q=~[[%sand p=%ud q=2] [%sand p=%ud q=2]]]
380```
382#### Discussion
384See also: `++edge`
386---