on b00decd help sign in
375 lines 6.1 kB history raw
1+++
2title = "2q: Molds and Mold-Builders"
3weight = 20
4template = "doc.html"
5+++
7### `++char`
9Character
11A single character. Aura `@tD` designates a single UTF-8 byte. All parsers
12consume `tape`s, which are lists of `char`.
15#### Source
17```hoon
18 ++ char @tD
19```
21#### Examples
23```
24 > *char
25 ''
27 > `@tD`97
28 'a'
29```
31---
32### `++cord`
34UTF-8 text
36One of Hoon's two string types (the other being `tape`). A cord is an
37atom of UTF-8 text.
39#### Source
41```hoon
42 ++ cord @t
43```
45#### Examples
47```
48 > *cord
49 ''
51 > `@ux`'foobar'
52 0x7261.626f.6f66
54 > `@t`97
55 'a'
57 > `@`'urbit'
58 499.984.265.845
60 > `@t`499.984.265.845
61 'urbit'
62```
64#### Discussion
66Aura `@t` designates a Unicode atom, little-endian: the first character
67in the text is the least-significant byte.
69[`trip`](/docs/hoon/reference/stdlib/4b) converts from `cord` to `tape`, and [`crip`](/docs/hoon/reference/stdlib/4b) converts
70from `tape` to `cord`.
74---
75### `++date`
77Point in time
79A boolean designating AD or BC, a year atom, a month atom, and a `tarp`,
80which is a day atom and a time.
82#### Source
84```hoon
85 ++ date [[a=? y=@ud] m=@ud t=tarp]
86```
88#### Examples
90```
91 > *date
92 [[a=%.y y=0] m=0 t=[d=0 h=0 m=0 s=0 f=~]]
94 > `date`(yore ~2014.6.6..21.09.15..0a16)
95 [[a=%.y y=2.014] m=6 t=[d=6 h=21 m=9 s=15 f=~[0xa16]]]
97 > now
98 ~2018.5.25..17.55.15..9ad8
99```
102#### Discussion
104See also: [`year`](/docs/hoon/reference/stdlib/3c), [`yore`](/docs/hoon/reference/stdlib/3c)
106---
107### `++knot`
109ASCII
111An atom type that only permits ASCII characters.
113#### Source
115```hoon
117 ++ knot @ta
118```
120#### Examples
122```
123 > *knot
124 ~.
126 > `@ta`105
127 ~.i
128```
130---
131### `++tang`
133Generic print structure
135A list of `tank`s. It's for printing types and bottom-up printing of stack
136traces.
138#### Source
140```hoon
141 ++ tang (list tank)
142```
144#### Examples
146```
147 > *tang
148 ~
150 > (~(win re [%palm ["1" "2" "3" "4"] [%leaf "foobar"] [%leaf "bazbud"] [%leaf "zzzzzzqaaa"] ~]) 0 50)
151 <<"23foobar1bazbud1zzzzzzqaaa4">>
153 > (~(win re [%palm ["1" "2" "3" "4"] [%leaf "foobar"] [%leaf "bazbud"] [%leaf "zzzzzzqaaa"] ~]) 0 10)
154 <<"2 foobar" " bazbud" "zzzzzzqaaa">>
156 > (~(win re [%rose ["1" "2" "3"] [%leaf "foobar"] [%leaf "bazbud"] ~]) 0 20)
157 <<"2foobar1bazbud3">>
159 > (~(win re [%rose ["1" "2" "3"] [%leaf "foobar"] [%leaf "bazbud"] ~]) 0 10)
160 <<"2 foobar" " bazbud" "3">>
161```
163---
164### `++tank`
166Pretty-printing structure
168A `tank` is one of three cases: a `%leaf` is simply a string (a printed line);
169a `%palm` is list of `tank` delimited by the strings in `p`, with back-steps at
170new lines; and a `%rose` is a list of `tank` delimited by the strings in `p`
171without back-steps at new lines.
174#### Source
176```hoon
177 ++ tank $% [$leaf p=tape]
178 $: $palm
179 p=[p=tape q=tape r=tape s=tape]
180 q=(list tank)
181 ==
182 $: $rose
183 p=[p=tape q=tape r=tape]
184 q=(list tank)
185 ==
186 ==
187```
189#### Examples
192```
193 > *tank
194 [%rose p=[p="" q="" r=""] q=~]
196 > (wash [0 80] >(bex 20) (bex 19)<) :: at 80 cols
197 <<"[1.048.576 524.288]">>
199 > (wash [0 15] >(bex 20) (bex 19)<) :: at 15 cols
200 <<"[ 1.048.576" " 524.288" "]">>
202 > [(bex 150) (bex 151)] :: at 80 cols
203 [ 1.427.247.692.705.959.881.058.285.969.449.495.136.382.746.624
204 2.854.495.385.411.919.762.116.571.938.898.990.272.765.493.248
205 ]
207 > (wash [0 40] >(bex 150) (bex 151)<)
208 <<
209 "[ \\/1.427.247.692.705.959.881.058.285.\\/"
210 " 969.449.495.136.382.746.624"
211 " \\/ \\/"
212 " \\/2.854.495.385.411.919.762.116.571.\\/"
213 " 938.898.990.272.765.493.248"
214 " \\/ \\/"
215 "]"
216 >>
217```
220---
221### `++tape`
223List of characters
225One of Hoon's two string types, the other being `++cord`. A tape is a list of
226`char`.
228#### Source
230```hoon
231 ++ tape (list @tD)
232```
234#### Examples
236```
237 > *tape
238 ""
240 > `tape`"foobar"
241 "foobar"
243 >`(list @t)`"foobar"
244 <|f o o b a r|>
246 >`(list @tD)`"foobar"
247 "foobar"
249 > `(list @)`"foobar"
250 ~[102 111 111 98 97 114]
251```
253---
254### `++tarp`
256Parsed time
258The time component of a `date`: day, hour, minute, second and a list of `@ux`
259for precision.
261#### Source
263```hoon
264 ++ tarp [d=@ud h=@ud m=@ud s=@ud f=(list @ux)]
265```
267#### Examples
269```
270 > *tarp
271 [d=0 h=0 m=0 s=0 f=~]
273 > (yell now)
274 [d=106.751.991.821.625 h=22 m=58 s=10 f=~[0x44ff]]
276 > `tarp`(yell ~2014.6.6..21.09.15..0a16)
277 [d=106.751.991.820.172 h=21 m=9 s=15 f=~[0xa16]]
279 > (yell ~d20)
280 [d=20 h=0 m=0 s=0 f=~]
281```
284---
285### `++term`
287Hoon constant
289A restricted text atom for Hoon constants. The only characters permitted are
290lowercase ASCII letters, `-`, and `0-9`, the latter two of which cannot be the
291first character. The syntax for `@tas` is the text itself, always preceded by
292`%`. The empty `@tas` has a
293special syntax, `$`.
296#### Source
298```hoon
299 ++ term @tas
300```
302#### Examples
304```
305 > *term
306 %$
308 > *%term
309 %term
311 > %dead-fish9
312 %dead-fish9
314 > -:!>(%dead-fish9)
315 #t/$dead-fish9
316```
319---
320### `++wain`
322List of strings
324A list of `cord`s. A `wain` is used instead of a single `cord` with `\n`.
327#### Source
329```hoon
330 ++ wain (list cord)
331```
333#### Examples
335```
336 > *wain
337 <||>
339 > `wain`/som/del/rok
340 <|som del rok|>
341```
343---
344### `++wall`
346List of list of characters
348A list of `tape`s. `wall` is used instead of a single `tape` with `\n`.
350#### Source
352```hoon
353 ++ wall (list tape)
354```
355#### Examples
357```
358 > *wall
359 <<>>
361 > `wall`(wash [0 20] leaf+<(bex 256)>)
362 <<
363 "\\/115.792.089.237.\\/"
364 " 316.195.423.570."
365 " 985.008.687.907."
366 " 853.269.984.665."
367 " 640.564.039.457."
368 " 584.007.913.129."
369 " 639.936"
370 "\\/ \\/"
371 >>
372```
375---