2title = "5c: Compiler Backend & Prettyprinter"
13This core is too large to include here, refer to `hoon.hoon` for the source.
23This core is too large to include here, refer to `hoon.hoon` for the source.
31Pretty-print a `vase` as a `tank` using `++deal`. This is the same as
51> (cain !>(['foo' 'bar']))
52[%rose p=[p=" " q="[" r="]"] q=~[[%leaf p="'foo'"] [%leaf p="'bar'"]]]
61Pretty-print a `vase` as a `tape`. This is the same as [`++text`](#text).
80> (noah !>(['foo' 'bar']))
90Convert a `vise` (old `vase`) to the new `vase`. This is the same as
110> (onan `vise`!>(['foo' 'bar']))
111[#t/[@t @t] q=[7.303.014 7.496.034]]
120Check if type `b` nests under type `a`. Produces `%.y` if it nests and crashes
144> (levi -:!>('foo') -:!>(%foo))
147> (levi -:!>(%foo) -:!>('foo'))
159Pretty print vase `vax` as a `tape`.
180> (text !>(['foo' 'bar']))
190Convert `typo` (old type) to the new `type`.
203++ seem |=(toy=typo `type`toy)
219Convert a `vise` (old `vase`) to the new `vase`.
232++ seer |=(vix=vise `vase`vix)
246Pretty-print vase to a tank
248Pretty-print vase `vax` to a `tank` using `++deal:us`.
266 (~(deal us p.vax) q.vax)
272> (sell !>(['foo' 'bar']))
273[%rose p=[p=" " q="[" r="]"] q=~[[%leaf p="'foo'"] [%leaf p="'bar'"]]]
280Pretty-print type to tank
282Pretty-print type `typ` to a `tank` using `++duck:ut`.
304> (skol -:!>(['foo' 'bar']))
305[%rose p=[p=" " q="[" r="]"] q=~[[%leaf p="@t"] [%leaf p="@t"]]]
314Slam `gat`, a gate in a `vase`, with `sam`, a sample in a `vase`. Produces a
315`vase` containing the result.
319`gat` is a gate in a `vase`.
321`sam` is a noun in a `vase`.
331 |= [gat=vase sam=vase] ^- vase
335 [%cnsg [%$ ~] [%$ 2] [%$ 3] ~]
336 =+ gun=(~(mint ut typ) %noun gen)
337 [p.gun (slum q.gat q.sam)]
343> (slam !>(|=([a=@ud b=@ud] [b a])) !>([1 2]))
344[#t/[@ud @ud] q=[2 1]]
353States whether you can access named wing `cog` in type `typ` using access method `way`.
357`way` is a `?(%read %rite %both)` (A `$vial` without `%free`). This represents
358the access method (read, write, or both read and write).
360`cog` is a `@tas`, the name of a wing.
372 |= [way=?(%read %rite %both) cog=@tas typ=type]
374 (~(fond ut typ) way ~[cog])
379> (slab %read %a -:!>(au))
381> (slab %rite %a -:!>(au))
383> (slab %both %a -:!>(au))
386> (slab %both %blah -:!>(au))
389> =fe ^|(|=(a=@ +(a)))
390> (slab %read %a -:!>(fe))
392> (slab %rite %a -:!>(fe))
394> (slab %both %a -:!>(fe))
404Compile hoon `gen` with subject `vax` using `.*`, producing a `vase` of the
409`vax` is a noun in a `vase`, and is the subject.
421 |= [vax=vase gen=hoon] ^- vase
422 =+ gun=(~(mint ut p.vax) %noun gen)
423 [p.gun .*(q.vax q.gun)]
429> (slap !>(b='foo') (ream '|=(a=@t [a b])'))
430[#t/<1.qgm [a=@t b=@t]> q=[[[0 6] 0 7] 0 7.303.014]]
432> !<($-(@t [@t @t]) (slap !>(b='foo') (ream '|=(a=@t [a b])')))
435> (!<($-(@t [@t @t]) (slap !>(b='foo') (ream '|=(a=@t [a b])'))) 'bar')
445Prints stack trace `a` if the stack trace isn't null, then produces the other
446input. `+slog` first takes `a`, producing a gate. The gate then takes some hoon.
450`a` is a `tang`, and is the sample of `+slog`.
452`(slog a)` takes some `hoon`.
456The result of the hoon given to `(slog a)`, with `a` printed to the terminal.
464 ?~(a same ~>(%slog.[pri i.a] $(a t.a)))
471> ((slog leaf+"foo" ~) (add 1 1))
477`slog` is intended to be put in the middle of a bunch of chained function
478calls that string a piece of data through them, so that an error message will be
479printed if there's one to print.
487Ends the program and prints `a`, a tracing error message.
495A crash, with `a` printed to the terminal.
512dojo: hoon expression failed
521Evaluate a `trap`, producing the result if successful or else
522crashing with a trace.
551> (road |.(~|('crash!' !!)))
553dojo: hoon expression failed
562Get axis `axe` in vase `vax`, producing the resulting `vase` in a `unit` which is null if
563the axis cannot be retrieved.
579 |= [axe=@ vax=vase] ^- (unit vase)
583 $(axe (mas axe), q.vax .*(q.vax [0 (cap axe)]))
585 `[(~(peek ut p.vax) %free axe) .*(q.vax [0 axe])]
591> (slew 3 !>(['foo' 'bar']))
592[~ [#t/@t q=7.496.034]]
594> !<(@t (need (slew 3 !>(['foo' 'bar']))))
597> (slew 7 !>(['foo' 'bar']))
607Convert a `vise` (old `vase`) to a `vase`. Identical to [`++seer`](#seer).
638The `type` produced if a gate of type `gat` were slammed with a sample of type `sam`.
654 |= [gat=type sam=type]
655 ?> (~(nest ut (~(peek ut gat) %free 6)) & sam)
656 (~(play ut [%cell gat sam]) [%cnsg [%$ ~] [%$ 2] [%$ 3] ~])
662> (slit -:!>(|*(a=@ [a a])) -:!>(42))
665> (slit -:!>(|*(a=@ [a a])) -:!>('foo'))
679 |= [cog=@tas typ=type]
682 [%hold *] $(typ ~(repo ut typ))
683 [%hint *] $(typ ~(repo ut typ))
687 ?| (~(has by q.q.n.q.r.q.typ) cog)
688 $(q.r.q.typ l.q.r.q.typ)
689 $(q.r.q.typ r.q.r.q.typ)
700Produces a list of the arms in a core of type `typ`.
717 [%hold *] $(typ ~(repo ut typ))
718 [%hint *] $(typ ~(repo ut typ))
721 %+ turn ~(tap by q.r.q.typ)
723 %+ turn ~(tap by q.b)
732> (sloe -:!>(|=(@ 1)))
754Produce the vase of a cell of vases `hed` and `tal`.
770 |= [hed=vase tal=vase]
772 [[%cell p.hed p.tal] [q.hed q.tal]]
778> (slop !>('foo') !>(42))
779[#t/[@t @ud] q=[7.303.014 42]]
781> !<([@t @ud] (slop !>('foo') !>(42)))
791Get axis `axe` in vase `vax`, returning it in a `vase`. Crashes if the axis
808 |= [axe=@ vax=vase] ^- vase
809 [(~(peek ut p.vax) %free axe) .*(q.vax [0 axe])]
815> (slot 3 !>(['foo' 'bar']))
818> !<(@t (slot 3 !>(['foo' 'bar'])))
821> (slot 7 !>(['foo' 'bar']))
822dojo: hoon expression failed
829Slam without sample-type
831Slam `gat`, a gate in a `vase`, with `sam`, a `noun`. The type of `sam` is
832ignored and the type of the resulting vase is determined by the gate alone.
848 |= [gat=vase sam=*] ^- vase
849 (slap gat(+<.q sam) [%limb %$])
855> (slym !>(|*(a=@ux [a a])) 'foo')
856[#t/[@ux @ux] q=[7.303.014 7.303.014]]
858> (slym !>(|*(a=@ux [a a])) "foobar")
859[#t/[@ux @ux] q=[[102 111 111 98 97 114 0] 102 111 111 98 97 114 0]]
875 ?@ q.vax (~(fuse ut p.vax) [%atom %$ ~])
879 [%wtgr [%wtts [%leaf %tas -.q.vax] [%& 2]~] [%$ 1]]
880 (~(fuse ut p.vax) [%cell %noun %noun])
889This is the same as [`++slap`](#slap) except `tap` is the subject `vase`
890encapsulated in a `trap`, and a `(trap vase)` is produced.
894`tap` is a `(trap vase)`.
906 |= [tap=(trap vase) gen=hoon]
908 =/ gun (~(mint ut p:$:tap) %noun gen)
910 [p.gun .*(q:$:tap q.gun)]
920 |.(!>(add-42=(cury add 42)))
921 (ream '|=(a=@ (add-42 a))')
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list