on 883cb21 help sign in
308 lines 6.1 kB history raw
1+++
2title = "Irregular forms"
3weight = 20
4template = "doc.html"
5aliases = ["docs/reference/hoon-expressions/irregular/"]
6+++
8##### Reading guide
10Headings contain runes, phonetics and tokens. Description contains a link to the
11docs and a short description of the rune. Both regular and irregular forms are given.
13Want to `Ctrl-f` to find out the meaning of something weird you saw? Search for `\symbol`. ie `\?` or `\=`. It'll show you to the irregular forms that uses that symbol.
15## `.` dot (nock)
17Anything Nock can do, Hoon can do also.
19### `.+` dotlus
21[docs](/docs/hoon/reference/rune/dot#dotlus) \\+
23`[%dtls p=atom]`: increment an atom with Nock 4.
25Regular: `.+(p)`
27Irregular: `+(p)`
29### `.=` dottis
31[docs](/docs/hoon/reference/rune/dot#dottis) \\=
33`[%dtts p=hoon q=hoon]`: test for equality with Nock 5.
35Regular: `.=(p q)`
37Irregular: `=(p q)`
39## `;` mic (make)
41Miscellaneous useful macros.
43### `;:` miccol
45[docs](/docs/hoon/reference/rune/mic#miccol) \\:
47`[%mccl p=hoon q=(list hoon)]`: call a binary function as an n-ary function.
49Regular: `;:(p q)`
51Irregular: `:(p q)`
53## `:` col (cells)
55The cell runes.
57### `:-` colhep
59[docs](/docs/hoon/reference/rune/col#colhep) \\[\\]\\^\\+\\\`\\~
61`[%clhp p=hoon q=hoon]`: construct a cell (2-tuple).
63Regular: `:-(p q)`
65Irregular:
67```
68 [a b] ==> :-(a b)
69[a b c] ==> [a [b c]]
70 a^b^c ==> [a b c]
71 a/b ==> [%a b]
72 a+b ==> [%a b]
73 `a ==> [~ a]
74 ~[a b] ==> [a b ~]
75 [a b]~ ==> [[a b] ~]
76```
78## `=` tis (flow)
80Flow hoons change the subject. All non-flow hoons (except cores) pass the subject down unchanged.
82### `=<` tisgal
84[docs](/docs/hoon/reference/rune/tis#tisgal) \\:
86`[%tsgl p=hoon q=hoon]`: compose two hoons, inverted.
88Regular: `=<(p q)`
90Irregular: `p:q`
92## `|` bar (core)
94[docs](/docs/hoon/reference/rune/bar) \\$
96Core hoons are flow hoon.
98Technically not irregular syntax, but worth mentioning.
100- `|= bartis`
101- `|. bardot`
102- `|- barhep`
103- `|* bartar`
105The above runes produce a core with a single arm, named `$` ("buc"). We can recompute this arm with changes, useful for recursion among other things. Commonly used with the irregular syntax for `%=`, `:make`, like so: `$()`.
107## `%` cen (call)
109The invocation family of runes.
111### `%=` centis
113[docs](/docs/hoon/reference/rune/cen#centis) \\(\\)
115`[%cnts p=wing q=(list (pair wing hoon))]`: take a wing with changes.
117Regular: `%=(p a 1)`
119Irregular: `p(a 1)`
121### `%~` censig
123[docs](/docs/hoon/reference/rune/cen#censig) \\~
125`[%cnsg p=wing q=hoon r=hoon]`: call with multi-armed door.
127Regular: `%~(p q r)`
129Irregular: `~(p q r)`
131### `%-` cenhep
133[docs](/docs/hoon/reference/rune/cen#cenhep) \\(\\)
135`[%cnhp p=hoon q=hoon]`: call a gate (function).
137Regular: `%-(p q)`
139Irregular: `(p q)`
141Note: `(p)` becomes `$:p` (`=<($ p)`), which behaves as you would expect (func call w/o args).
143## `$` buc (mold)
145A mold is a gate (function) that helps us build simple and rigorous data structures.
147### `$?` bucwut
149[docs](/docs/hoon/reference/rune/buc#bucwut) \\?
151`[%bcwt p=(list model)]`: mold which normalizes a general union.
153Regular: `$?(p)`
155Irregular: `?(p)`
157### `$_` buccab
159[docs](/docs/hoon/reference/rune/buc#buccab) \\\_
161`[%bccb p=value]`: mold which normalizes to an example.
163Regular: `$_(p)`
165Irregular: `_p`
167## `?` wut (test)
169Hoon has the usual branches and logical tests.
171### `?!` wutzap
173[docs](/docs/hoon/reference/rune/wut#wutzap) \\!
175`[%wtzp p=hoon]`: logical not.
177Regular: `?!(p)`
179Irregular: `!(p)`
181### `?&` wutpam
183[docs](/docs/hoon/reference/rune/wut#wutpam) \\&
185`[%wtpm p=(list hoon)]`: logical and.
187Regular: `?&(p)`
189Irregular: `&(p)`
191### `?|` wutbar
193[docs](/docs/hoon/reference/rune/wut#wutbar) \\|
195`[%wtbr p=(list hoon)]`: logical or.
197Regular: `?|(p)`
199Irregular: `|(p)`
201## `^` ket (cast)
203Lets us adjust types without violating type constraints.
205### `^:` ketcol
207[docs](/docs/hoon/reference/rune/ket#ketcol) \\,
209`[%ktcl p=spec]`: mold gate for type `p`.
211Regular: `^:(p)`
213Irregular: `,p`
215### `^-` kethep
217[docs](/docs/hoon/reference/rune/ket#kethep) \\\`
219`[%kthp p=model q=value]`: typecast by mold.
221Regular: `^-(p q)`
223Irregular: `` `p`q ``
225### `^*` kettar
227[docs](/docs/hoon/reference/rune/ket#kettar) \\\*
229`[%kttr p=spec]`: produce bunt value of mold.
231Regular: `^*(p)`
233Irregular: `*p`
235### `^=` kettis
237[docs](/docs/hoon/reference/rune/ket#kettis) \\=
239`[%ktts p=toga q=value]`: name a value.
241Regular: `^=(p q)`
243Irregular: `p=q`
245## Miscellaneous
247### Trivial molds
249- `*` noun.
250- `@` atom.
251- `^` cell.
252- `?` loobean.
253- `~` null.
255### Values
257\\~\\-\\.\\&\\|
259- `~` null.
260- `&` loobean true.
261- `|` loobean false.
262- `%a` constant `a`, where `a` can be an ((ir)regularly defined) atom or a symbol.
264See [%sand](/docs/hoon/reference/rune/constants#warm) for other irregular definitions of atoms.
266### List addressing
268- `&n` nth element of a list.
269- `|n` tail of list after nth element (i.e. n is the head).
271### Limbs
273[docs](/docs/hoon/reference/limbs/limb) \\+\\.\\^
275`[%limb p=(each @ud [p=@ud q=@tas])]`: attribute of subject.
277- `+15` is slot 15
278- `.` is the whole subject (slot 1)
279- `^a` is the `a` "of a higher scope", i.e. "resolve variable a, ignoring the first one found".
280- `^^p` even higher, etc.
281- 'Lark' syntax for slots / tree addressing:
283```
284+1
285+2 -
286+3 +
287+4 -<
288+5 ->
289+6 +<
290+7 +>
291+8 -<-
292...
293```
295### Wings
297[docs](content/docs/hoon/reference/limbs/wing)
298`[%wing p=(list limb)]`; a limb search path.
299`a.b` finds limb `a` within limb `b` ("var" `a` within "var" `b`).
301### Printing stuff
303- `<a b c>` prints a [tape](/docs/hoon/reference/stdlib/2q/#-tape).
304- `>a b c<` prints a [tank](/docs/hoon/reference/stdlib/2q/#-tank).
306## Commentary
308In our in-house examples throughout our documentation, we use irregular forms instead of regular for the sake of verbosity. But remember with irregular forms: everything is just runes! Like magic. In general, irregular forms (usually) read better, but of course regular forms provide more information about what you're doing by showing you the full rune. Of course, it's up to you, the Hoon programmer, as to whether or not you want to use these.