2title = "4n: Virtualization"
11Accepts a nock subject-formula cell and wraps it into a `unit`.
12`fol` is pure nock, meaning that nock `11` operations result in a block,
17`sub` is a subject noun.
19`fol` is a formula noun, which is generally a `nock`.
31 =/ ton (mink [sub fol] |~(^ ~))
32 ?.(?=(%0 -.ton) ~ `product.ton)
38> (mack [[1 2 3] [0 1]])
47> (mack [[[0 2] [1 3]] 4 4 4 4 0 5])
50> ;;((unit @tas) (mack [[1 %yes %no] 6 [0 2] [0 6] 0 7]))
60Bottom-level mock (virtual nock) interpreter. Produces a
61`tone`, a nock computation result. If nock 12 is invoked, `scry`
62computes on the subject and produces a `(unit (unit))` result. An empty
63result becomes a `%1` `tone`, indicating a block.
67`subject` is the subject as a noun.
69`formula` is the formula as a noun.
71`scry` is an `%iron` gate invoked with nock operator 12.
82 |= $: [subject=* formula=*]
83 scry=$-(^ (unit (unit)))
85 =| trace=(list [@ta *])
89 =/ head $(formula -.formula)
91 =/ tail $(formula +.formula)
93 [%0 product.head product.tail]
96 =/ part (frag axis.formula subject)
101 [%0 constant.formula]
103 [%2 subject=* formula=*]
104 =/ subject $(formula subject.formula)
105 ?. ?=(%0 -.subject) subject
106 =/ formula $(formula formula.formula)
107 ?. ?=(%0 -.formula) formula
109 subject product.subject
110 formula product.formula
114 =/ argument $(formula argument.formula)
115 ?. ?=(%0 -.argument) argument
116 [%0 .?(product.argument)]
119 =/ argument $(formula argument.formula)
120 ?. ?=(%0 -.argument) argument
121 ?^ product.argument [%2 trace]
122 [%0 .+(product.argument)]
125 =/ a $(formula a.formula)
127 =/ b $(formula b.formula)
129 [%0 =(product.a product.b)]
131 [%6 test=* yes=* no=*]
132 =/ result $(formula test.formula)
133 ?. ?=(%0 -.result) result
136 %& $(formula yes.formula)
137 %| $(formula no.formula)
140 [%7 subject=* next=*]
141 =/ subject $(formula subject.formula)
142 ?. ?=(%0 -.subject) subject
144 subject product.subject
149 =/ head $(formula head.formula)
150 ?. ?=(%0 -.head) head
152 subject [product.head subject]
157 =/ core $(formula core.formula)
158 ?. ?=(%0 -.core) core
159 =/ arm (frag axis.formula product.core)
166 [%10 [axis=@ value=*] target=*]
167 ?: =(0 axis.formula) [%2 trace]
168 =/ target $(formula target.formula)
169 ?. ?=(%0 -.target) target
170 =/ value $(formula value.formula)
171 ?. ?=(%0 -.value) value
173 (edit axis.formula product.target product.value)
178 =/ next $(formula next.formula)
179 ?. ?=(%0 -.next) next
182 [11 tag.formula 1 product.next]
184 [%11 [tag=@ clue=*] next=*]
185 =/ clue $(formula clue.formula)
186 ?. ?=(%0 -.clue) clue
189 ?=(?(%hunk %hand %lose %mean %spot) tag.formula)
190 [[tag.formula product.clue] trace]
191 $(formula next.formula)
192 ?. ?=(%0 -.next) next
195 [11 [tag.formula 1 product.clue] 1 product.next]
198 =/ ref $(formula ref.formula)
200 =/ path $(formula path.formula)
201 ?. ?=(%0 -.path) path
202 =/ result (scry product.ref product.path)
206 [%2 [%hunk product.ref product.path] trace]
220 noun ?-(pick %2 -.noun, %3 +.noun)
224 |= [axis=@ target=* value=*]
232 target ?-(pick %2 -.target, %3 +.target)
236 %2 `[u.mutant +.target]
237 %3 `[-.target u.mutant]
245> (mink [20 [4 0 1]] ,~)
248> (mink [[[4 5] [6 14 15]] [0 7]] ,~)
251> (mink [42 12 [0 1] [1 73]] |=(a=^ ``(add (,[@ @] a))))
254> (mink [0 12 [1 0] [1 0]] |=(* ~))
265Compute formula on subject with hint
267Produces a `toon`, which is either a sucessful, blocked, or
268crashed result. If nock 11 is invoked, `gul` computes on the subject and
269produces a `(unit (unit))` result. An empty result becomes a `%1` `tune`,
274`sub` is the subject as a noun.
276`fol` is the formula as a noun.
278`gul` is an %iron gate invoked with nock operator 11.
288 |= [[sub=* fol=*] gul=$-(^ (unit (unit)))]
289 (mook (mink [sub fol] gul))
298> (mock [0 12 [0 1] [0 1]] |=(* ``999))
301> (mock [42 12 [0 1] [0 1]] |=(* ~))
312Intelligently render crash annotation
314Converts a `%2` `tone` nock stack trace to a list of `tank`. Each may be a
315`tank`, `cord`, `spot`, or trapped `tank`.
333 |^ [%2 (turn skip rend)]
337 =/ yel (lent trace.ton)
338 ?. (gth yel 1.024) trace.ton
342 :_ (slag (sub yel 512) trace.ton)
344 (crip "[skipped {(scow %ud (sub yel 1.024))} frames]")
346 :: +rend: raw stack frame to tank
348 :: $% [%hunk ref=* path] :: failed scry ([~ ~])
349 :: [%lose cord] :: skipped frames
350 :: [%hand *] :: mug any
351 :: [%mean $@(cord (trap tank))] :: ~_ et al
352 :: [%spot spot] :: source location
360 leaf+"mook.{(rip 3 tag)}"
363 ?@ dat leaf+"mook.hunk"
364 =/ sof=(unit path) ((soft path) +.dat)
365 ?~ sof leaf+"mook.hunk"
369 ?^ dat leaf+"mook.lose"
373 leaf+(scow %p (mug dat))
376 ?@ dat leaf+(rip 3 dat)
377 =/ mac (mack dat -.dat)
379 =/ sof ((soft tank) u.mac)
380 ?~ sof leaf+"mook.mean"
384 =/ sof=(unit spot) ((soft spot) dat)
385 ?~ sof leaf+"mook.spot"
390 =/ ud |=(a=@u (scow %ud a))
391 leaf+"<[{(ud p.l)} {(ud q.l)}].[{(ud p.r)} {(ud q.r)}]>"
403> (mook [%2 ~[[%hunk %rose ["<" "," ">"] ~[[%leaf "err"]]]]])
404[%2 p=~[[%leaf p="mook.hunk"]]]
406> (mook [%2 ~[[%mean |.(>(add 5 6)<)]]])
407[%2 p=~[[%leaf p="11"]]]
409> (mook [%2 ~[[%spot /b/repl [1 1]^[1 2]] [%mean |.(!!)]]])
419 q=[i=[%leaf p="b"] t=[i=[%leaf p="repl"] t=~]]
421 t=[i=[%leaf p="<[1 1].[1 2]>"] t=~]
435Kicks a `trap`, producing its result in a `unit` if successful, or a null `unit`
436if it crashed. Unitized version of [`++mule`](#mule).
444A `(unit *)`, where the `*` will be the type produced by the expression.
460> (mole |.(`@t`(add 50 47)))
463> (mole |.(~|('Error!' !!)))
473Produces a `toon` computation result from slamming `gat` with
474`sam`, using `gul` to compute or block on nock 11 when applicable.
478`gat` is a noun that is generally a `gate`.
480`sam` is a sample noun.
482`gul` is an `%iron` gate invoked with nock operator 11.
492 |= [[gat=* sam=*] gul=$-(^ (unit (unit)))]
494 ?. ?=([* ^] gat) [%2 ~]
495 (mock [gat(+< sam) %9 2 %0 1] gul)
501> (mong [|=(@ 20) ~] ,~)
504> (mong [|=(@ !!) ~] ,~)
507> (mong [|=(a=@ (add 20 a)) ~] ,~)
510> (mong [|=(a=[@ @] (add 20 -.a)) ~] ,~)
513> (mong [|=(a=[@ @] (add 20 -.a)) [4 6]] ,~)
516> (mong [|=(a=@ .^(* a)) 99] |=(^ ``+<))
517[%0 p=[[140 1.853.189.998] 99]]
519> (mong [|=(a=@ .^(@ a)) 99] |=([* a=*] ``+((,@ a))))
529Kicks a `trap`, producing its results or any errors that occur along
530the way. Used to lazily compute stack traces.
534`tap` is a `trap`, generally producing a list of `tank`s.
538An `(each * (list tank))` - `%.y` indicates success and `%.n` indicates a crash.
556> (mule |.((add 1 1)))
559> (mule |.(~|(%error !!)))
560[%.n p=~[[%leaf p="%error"]]]
567Untyped unitary virtual
569Kicks a `trap`, producing its results in a `unit` which is null if it crashed.
570The result is just a noun, no type information is preserved.
586 =/ ton (mink [tap %9 2 %0 1] |=((pair) ``.*(~ [%12 1+p 1+q])))
587 ?.(?=(%0 -.ton) ~ `product.ton)
593> (mure |.(~|(%error !!)))
596> (mure |.((add 1 1)))
602> ((unit @t) (mure |.('foo')))
612Kicks a `trap`, producing its result as a noun or the tanks of any error that
613occurs. Similar to [`++mule`](#mule), but preserves no type information.
621A `(each * (list tank))`, where `%.y` indicates success and `%.n` indicates
629 ^- (each * (list tank))
630 =/ ton (mock [tap %9 2 %0 1] |=((pair) ``.*(~ [%12 1+p 1+q])))
634 %1 =/ sof=(unit path) ((soft path) p.ton)
635 [%| ?~(sof leaf+"mute.hunk" (smyt u.sof)) ~]
644> (mute |.(leaf+"hello"))
645[%.y p=[1.717.658.988 104 101 108 108 111 0]]
650> (mute |.(~|(%error !!)))
651[%.n p=~[[%leaf p="%error"]]]
653> (mute |.((cat 3 'foo' 'bar')))
654[%.y p=125.762.588.864.358]
661Slam a gate on a sample using raw nock, untyped
663Slam `gat` with `sam`. Uses a raw `.*` nock expression internally and does not
664preserve type information for the result. This will crash if evaluation crashes.
669> (slum |=([a=@ b=@] (add a b)) [7 9])
672> (slum (cury cat 3) ['foo' 'bar'])
675> (@t (slum (cury cat 3) ['foo' 'bar']))
679dojo: hoon expression failed
688Clam (mold) noun `fud` with `mold` `han`, producing a `unit` of the result. The
689`unit` is null if clamming failed. This is curried, so the soft-clamming gate can
690be stored and called repeatedly.
700A `(unit *)`, where the `*` will be the type produced by the mold.
707 |=(fud=* (mole |.((han fud))))
719> ((soft ,[@ux @ux]) ['a' 'b'])
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