on master help sign in
wip
bc2b071iko
zod/luau/lib/strand.hoonnew file+1
@@ -0,0 +1 @@
1+rand
zod/luau/lib/strandio.hoonnew file+812
@@ -0,0 +1,812 @@
1+/- spider
2+/+ libstrand=strand
3+=, strand=strand:libstrand
4+=, strand-fail=strand-fail:libstrand
5+|%
6+++ send-raw-cards
7+ |= cards=(list =card:agent:gall)
8+ =/ m (strand ,~)
9+ ^- form:m
10+ |= strand-input:strand
11+ [cards %done ~]
12+::
13+++ send-raw-card
14+ |= =card:agent:gall
15+ =/ m (strand ,~)
16+ ^- form:m
17+ (send-raw-cards card ~)
18+::
19+++ ignore
20+ |= tin=strand-input:strand
21+ `[%fail %ignore ~]
22+::
23+++ get-bowl
24+ =/ m (strand ,bowl:strand)
25+ ^- form:m
26+ |= tin=strand-input:strand
27+ `[%done bowl.tin]
28+::
29+++ get-beak
30+ =/ m (strand ,beak)
31+ ^- form:m
32+ |= tin=strand-input:strand
33+ `[%done [our q.byk da+now]:bowl.tin]
34+::
35+++ get-time
36+ =/ m (strand ,@da)
37+ ^- form:m
38+ |= tin=strand-input:strand
39+ `[%done now.bowl.tin]
40+::
41+++ get-our
42+ =/ m (strand ,ship)
43+ ^- form:m
44+ |= tin=strand-input:strand
45+ `[%done our.bowl.tin]
46+::
47+++ get-entropy
48+ =/ m (strand ,@uvJ)
49+ ^- form:m
50+ |= tin=strand-input:strand
51+ `[%done eny.bowl.tin]
52+::
53+:: Convert skips to %ignore failures.
54+::
55+:: This tells the main loop to try the next handler.
56+::
57+++ handle
58+ |* a=mold
59+ =/ m (strand ,a)
60+ |= =form:m
61+ ^- form:m
62+ |= tin=strand-input:strand
63+ =/ res (form tin)
64+ =? next.res ?=(%skip -.next.res)
65+ [%fail %ignore ~]
66+ res
67+::
68+:: Wait for a poke with a particular mark
69+::
70+++ take-poke
71+ |= =mark
72+ =/ m (strand ,vase)
73+ ^- form:m
74+ |= tin=strand-input:strand
75+ ?+ in.tin `[%skip ~]
76+ ~
77+ `[%wait ~]
78+ ::
79+ [~ %poke @ *]
80+ ?. =(mark p.cage.u.in.tin)
81+ `[%skip ~]
82+ `[%done q.cage.u.in.tin]
83+ ==
84+::
85+++ take-sign-arvo
86+ =/ m (strand ,[wire sign-arvo])
87+ ^- form:m
88+ |= tin=strand-input:strand
89+ ?+ in.tin `[%skip ~]
90+ ~
91+ `[%wait ~]
92+ ::
93+ [~ %sign *]
94+ `[%done [wire sign-arvo]:u.in.tin]
95+ ==
96+::
97+:: Wait for a subscription update on a wire
98+::
99+++ take-fact-prefix
100+ |= =wire
101+ =/ m (strand ,[path cage])
102+ ^- form:m
103+ |= tin=strand-input:strand
104+ ?+ in.tin `[%skip ~]
105+ ~ `[%wait ~]
106+ [~ %agent * %fact *]
107+ ?. =(watch+wire (scag +((lent wire)) wire.u.in.tin))
108+ `[%skip ~]
109+ `[%done (slag (lent wire) wire.u.in.tin) cage.sign.u.in.tin]
110+ ==
111+::
112+:: Wait for a subscription update on a wire
113+::
114+++ take-fact
115+ |= =wire
116+ =/ m (strand ,cage)
117+ ^- form:m
118+ |= tin=strand-input:strand
119+ ?+ in.tin `[%skip ~]
120+ ~ `[%wait ~]
121+ [~ %agent * %fact *]
122+ ?. =(watch+wire wire.u.in.tin)
123+ `[%skip ~]
124+ `[%done cage.sign.u.in.tin]
125+ ==
126+::
127+:: Wait for a subscription close
128+::
129+++ take-kick
130+ |= =wire
131+ =/ m (strand ,~)
132+ ^- form:m
133+ |= tin=strand-input:strand
134+ ?+ in.tin `[%skip ~]
135+ ~ `[%wait ~]
136+ [~ %agent * %kick *]
137+ ?. =(watch+wire wire.u.in.tin)
138+ `[%skip ~]
139+ `[%done ~]
140+ ==
141+::
142+++ echo
143+ =/ m (strand ,~)
144+ ^- form:m
145+ %- (main-loop ,~)
146+ :~ |= ~
147+ ^- form:m
148+ ;< =vase bind:m ((handle ,vase) (take-poke %echo))
149+ =/ message=tape !<(tape vase)
150+ %- (slog leaf+"{message}..." ~)
151+ ;< ~ bind:m (sleep ~s2)
152+ %- (slog leaf+"{message}.." ~)
153+ (pure:m ~)
154+ ::
155+ |= ~
156+ ^- form:m
157+ ;< =vase bind:m ((handle ,vase) (take-poke %over))
158+ %- (slog leaf+"over..." ~)
159+ (pure:m ~)
160+ ==
161+::
162+++ take-watch
163+ =/ m (strand ,path)
164+ |= tin=strand-input:strand
165+ ?+ in.tin `[%skip ~]
166+ ~ `[%wait ~]
167+ [~ %watch *]
168+ `[%done path.u.in.tin]
169+ ==
170+::
171+++ take-wake
172+ |= until=(unit @da)
173+ =/ m (strand ,~)
174+ ^- form:m
175+ |= tin=strand-input:strand
176+ ?+ in.tin `[%skip ~]
177+ ~ `[%wait ~]
178+ [~ %sign [%wait @ ~] %behn %wake *]
179+ ?. |(?=(~ until) =(`u.until (slaw %da i.t.wire.u.in.tin)))
180+ `[%skip ~]
181+ ?~ error.sign-arvo.u.in.tin
182+ `[%done ~]
183+ `[%fail %timer-error u.error.sign-arvo.u.in.tin]
184+ ==
185+::
186+++ take-tune
187+ |= =wire
188+ =/ m (strand ,[spar:ames (unit roar:ames)])
189+ ^- form:m
190+ |= tin=strand-input:strand
191+ ?+ in.tin `[%skip ~]
192+ ~ `[%wait ~]
193+ ::
194+ [~ %sign * %ames %tune ^ *]
195+ ?. =(wire wire.u.in.tin)
196+ `[%skip ~]
197+ `[%done +>.sign-arvo.u.in.tin]
198+ ==
199+::
200+++ take-poke-ack
201+ |= =wire
202+ =/ m (strand ,~)
203+ ^- form:m
204+ |= tin=strand-input:strand
205+ ?+ in.tin `[%skip ~]
206+ ~ `[%wait ~]
207+ [~ %agent * %poke-ack *]
208+ ?. =(wire wire.u.in.tin)
209+ `[%skip ~]
210+ ?~ p.sign.u.in.tin
211+ `[%done ~]
212+ `[%fail %poke-fail u.p.sign.u.in.tin]
213+ ==
214+::
215+++ take-watch-ack
216+ |= =wire
217+ =/ m (strand ,~)
218+ ^- form:m
219+ |= tin=strand-input:strand
220+ ?+ in.tin `[%skip ~]
221+ ~ `[%wait ~]
222+ [~ %agent * %watch-ack *]
223+ ?. =(watch+wire wire.u.in.tin)
224+ `[%skip ~]
225+ ?~ p.sign.u.in.tin
226+ `[%done ~]
227+ `[%fail %watch-ack-fail u.p.sign.u.in.tin]
228+ ==
229+::
230+++ poke
231+ |= [=dock =cage]
232+ =/ m (strand ,~)
233+ ^- form:m
234+ =/ =card:agent:gall [%pass /poke %agent dock %poke cage]
235+ ;< ~ bind:m (send-raw-card card)
236+ (take-poke-ack /poke)
237+::
238+++ raw-poke
239+ |= [=dock =cage]
240+ =/ m (strand ,~)
241+ ^- form:m
242+ =/ =card:agent:gall [%pass /poke %agent dock %poke cage]
243+ ;< ~ bind:m (send-raw-card card)
244+ =/ m (strand ,~)
245+ ^- form:m
246+ |= tin=strand-input:strand
247+ ?+ in.tin `[%skip ~]
248+ ~
249+ `[%wait ~]
250+ ::
251+ [~ %agent * %poke-ack *]
252+ ?. =(/poke wire.u.in.tin)
253+ `[%skip ~]
254+ `[%done ~]
255+ ==
256+::
257+++ raw-poke-our
258+ |= [app=term =cage]
259+ =/ m (strand ,~)
260+ ^- form:m
261+ ;< =bowl:spider bind:m get-bowl
262+ (raw-poke [our.bowl app] cage)
263+::
264+++ poke-our
265+ |= [=term =cage]
266+ =/ m (strand ,~)
267+ ^- form:m
268+ ;< our=@p bind:m get-our
269+ (poke [our term] cage)
270+::
271+++ watch
272+ |= [=wire =dock =path]
273+ =/ m (strand ,~)
274+ ^- form:m
275+ =/ =card:agent:gall [%pass watch+wire %agent dock %watch path]
276+ ;< ~ bind:m (send-raw-card card)
277+ (take-watch-ack wire)
278+::
279+++ watch-one
280+ |= [=wire =dock =path]
281+ =/ m (strand ,cage)
282+ ^- form:m
283+ ;< ~ bind:m (watch wire dock path)
284+ ;< =cage bind:m (take-fact wire)
285+ ;< ~ bind:m (take-kick wire)
286+ (pure:m cage)
287+::
288+++ watch-our
289+ |= [=wire =term =path]
290+ =/ m (strand ,~)
291+ ^- form:m
292+ ;< our=@p bind:m get-our
293+ (watch wire [our term] path)
294+::
295+++ scry
296+ |* [=mold =path]
297+ =/ m (strand ,mold)
298+ ^- form:m
299+ ?> ?=(^ path)
300+ ?> ?=(^ t.path)
301+ ;< =bowl:spider bind:m get-bowl
302+ %- pure:m
303+ .^(mold i.path (scot %p our.bowl) i.t.path (scot %da now.bowl) t.t.path)
304+::
305+++ leave
306+ |= [=wire =dock]
307+ =/ m (strand ,~)
308+ ^- form:m
309+ =/ =card:agent:gall [%pass watch+wire %agent dock %leave ~]
310+ (send-raw-card card)
311+::
312+++ leave-our
313+ |= [=wire =term]
314+ =/ m (strand ,~)
315+ ^- form:m
316+ ;< our=@p bind:m get-our
317+ (leave wire [our term])
318+::
319+++ rewatch
320+ |= [=wire =dock =path]
321+ =/ m (strand ,~)
322+ ;< ~ bind:m ((handle ,~) (take-kick wire))
323+ ;< ~ bind:m (flog-text "rewatching {<dock>} {<path>}")
324+ ;< ~ bind:m (watch wire dock path)
325+ (pure:m ~)
326+::
327+++ wait
328+ |= until=@da
329+ =/ m (strand ,~)
330+ ^- form:m
331+ ;< ~ bind:m (send-wait until)
332+ (take-wake `until)
333+::
334+++ keen
335+ |= [=wire =spar:ames]
336+ =/ m (strand ,~)
337+ ^- form:m
338+ (send-raw-card %pass wire %arvo %a %keen spar)
339+::
340+++ sleep
341+ |= for=@dr
342+ =/ m (strand ,~)
343+ ^- form:m
344+ ;< now=@da bind:m get-time
345+ (wait (add now for))
346+::
347+++ send-wait
348+ |= until=@da
349+ =/ m (strand ,~)
350+ ^- form:m
351+ =/ =card:agent:gall
352+ [%pass /wait/(scot %da until) %arvo %b %wait until]
353+ (send-raw-card card)
354+::
355+++ map-err
356+ |* computation-result=mold
357+ =/ m (strand ,computation-result)
358+ |= [f=$-([term tang] [term tang]) computation=form:m]
359+ ^- form:m
360+ |= tin=strand-input:strand
361+ =* loop $
362+ =/ c-res (computation tin)
363+ ?: ?=(%cont -.next.c-res)
364+ c-res(self.next ..loop(computation self.next.c-res))
365+ ?. ?=(%fail -.next.c-res)
366+ c-res
367+ c-res(err.next (f err.next.c-res))
368+::
369+++ set-timeout
370+ |* computation-result=mold
371+ =/ m (strand ,computation-result)
372+ |= [time=@dr computation=form:m]
373+ ^- form:m
374+ ;< now=@da bind:m get-time
375+ =/ when (add now time)
376+ =/ =card:agent:gall
377+ [%pass /timeout/(scot %da when) %arvo %b %wait when]
378+ ;< ~ bind:m (send-raw-card card)
379+ |= tin=strand-input:strand
380+ =* loop $
381+ ?: ?& ?=([~ %sign [%timeout @ ~] %behn %wake *] in.tin)
382+ =((scot %da when) i.t.wire.u.in.tin)
383+ ==
384+ `[%fail %timeout ~]
385+ =/ c-res (computation tin)
386+ ?: ?=(%cont -.next.c-res)
387+ c-res(self.next ..loop(computation self.next.c-res))
388+ ?: ?=(%done -.next.c-res)
389+ =/ =card:agent:gall
390+ [%pass /timeout/(scot %da when) %arvo %b %rest when]
391+ c-res(cards [card cards.c-res])
392+ c-res
393+::
394+++ send-request
395+ |= =request:http
396+ =/ m (strand ,~)
397+ ^- form:m
398+ (send-raw-card %pass /request %arvo %i %request request *outbound-config:iris)
399+::
400+++ send-cancel-request
401+ =/ m (strand ,~)
402+ ^- form:m
403+ (send-raw-card %pass /request %arvo %i %cancel-request ~)
404+::
405+++ take-client-response
406+ =/ m (strand ,client-response:iris)
407+ ^- form:m
408+ |= tin=strand-input:strand
409+ ?+ in.tin `[%skip ~]
410+ ~ `[%wait ~]
411+ ::
412+ [~ %sign [%request ~] %iris %http-response %cancel *]
413+ ::NOTE iris does not (yet?) retry after cancel, so it means failure
414+ :- ~
415+ :+ %fail
416+ %http-request-cancelled
417+ ['http request was cancelled by the runtime']~
418+ ::
419+ [~ %sign [%request ~] %iris %http-response %finished *]
420+ `[%done client-response.sign-arvo.u.in.tin]
421+ ==
422+::
423+:: Wait until we get an HTTP response or cancelation and unset contract
424+::
425+++ take-maybe-sigh
426+ =/ m (strand ,(unit httr:eyre))
427+ ^- form:m
428+ ;< rep=(unit client-response:iris) bind:m
429+ take-maybe-response
430+ ?~ rep
431+ (pure:m ~)
432+ :: XX s/b impossible
433+ ::
434+ ?. ?=(%finished -.u.rep)
435+ (pure:m ~)
436+ (pure:m (some (to-httr:iris +.u.rep)))
437+::
438+++ take-maybe-response
439+ =/ m (strand ,(unit client-response:iris))
440+ ^- form:m
441+ |= tin=strand-input:strand
442+ ?+ in.tin `[%skip ~]
443+ ~ `[%wait ~]
444+ [~ %sign [%request ~] %iris %http-response %cancel *]
445+ `[%done ~]
446+ [~ %sign [%request ~] %iris %http-response %finished *]
447+ `[%done `client-response.sign-arvo.u.in.tin]
448+ ==
449+::
450+++ extract-body
451+ |= =client-response:iris
452+ =/ m (strand ,cord)
453+ ^- form:m
454+ ?> ?=(%finished -.client-response)
455+ %- pure:m
456+ ?~ full-file.client-response ''
457+ q.data.u.full-file.client-response
458+::
459+++ fetch-cord
460+ |= url=tape
461+ =/ m (strand ,cord)
462+ ^- form:m
463+ =/ =request:http [%'GET' (crip url) ~ ~]
464+ ;< ~ bind:m (send-request request)
465+ ;< =client-response:iris bind:m take-client-response
466+ (extract-body client-response)
467+::
468+++ fetch-json
469+ |= url=tape
470+ =/ m (strand ,json)
471+ ^- form:m
472+ ;< =cord bind:m (fetch-cord url)
473+ =/ json=(unit json) (de:json:html cord)
474+ ?~ json
475+ (strand-fail %json-parse-error ~)
476+ (pure:m u.json)
477+::
478+++ hiss-request
479+ |= =hiss:eyre
480+ =/ m (strand ,(unit httr:eyre))
481+ ^- form:m
482+ ;< ~ bind:m (send-request (hiss-to-request:html hiss))
483+ take-maybe-sigh
484+::
485+:: +build-file: build the source file at the specified $beam
486+::
487+++ build-file
488+ |= [[=ship =desk =case] =spur]
489+ =* arg +<
490+ =/ m (strand ,(unit vase))
491+ ^- form:m
492+ ;< =riot:clay bind:m
493+ (warp ship desk ~ %sing %a case spur)
494+ ?~ riot
495+ (pure:m ~)
496+ ?> =(%vase p.r.u.riot)
497+ (pure:m (some !<(vase q.r.u.riot)))
498+::
499+++ build-file-hard
500+ |= [[=ship =desk =case] =spur]
501+ =* arg +<
502+ =/ m (strand ,vase)
503+ ^- form:m
504+ ;< =riot:clay
505+ bind:m
506+ (warp ship desk ~ %sing %a case spur)
507+ ?> ?=(^ riot)
508+ ?> ?=(%vase p.r.u.riot)
509+ (pure:m !<(vase q.r.u.riot))
510+:: +build-mark: build a mark definition to a $dais
511+::
512+++ build-mark
513+ |= [[=ship =desk =case] mak=mark]
514+ =* arg +<
515+ =/ m (strand ,dais:clay)
516+ ^- form:m
517+ ;< =riot:clay bind:m
518+ (warp ship desk ~ %sing %b case /[mak])
519+ ?~ riot
520+ (strand-fail %build-mark >arg< ~)
521+ ?> =(%dais p.r.u.riot)
522+ (pure:m !<(dais:clay q.r.u.riot))
523+:: +build-tube: build a mark conversion gate ($tube)
524+::
525+++ build-tube
526+ |= [[=ship =desk =case] =mars:clay]
527+ =* arg +<
528+ =/ m (strand ,tube:clay)
529+ ^- form:m
530+ ;< =riot:clay bind:m
531+ (warp ship desk ~ %sing %c case /[a.mars]/[b.mars])
532+ ?~ riot
533+ (strand-fail %build-tube >arg< ~)
534+ ?> =(%tube p.r.u.riot)
535+ (pure:m !<(tube:clay q.r.u.riot))
536+::
537+:: +build-nave: build a mark definition to a $nave
538+::
539+++ build-nave
540+ |= [[=ship =desk =case] mak=mark]
541+ =* arg +<
542+ =/ m (strand ,vase)
543+ ^- form:m
544+ ;< =riot:clay bind:m
545+ (warp ship desk ~ %sing %e case /[mak])
546+ ?~ riot
547+ (strand-fail %build-nave >arg< ~)
548+ ?> =(%nave p.r.u.riot)
549+ (pure:m q.r.u.riot)
550+:: +build-cast: build a mark conversion gate (static)
551+::
552+++ build-cast
553+ |= [[=ship =desk =case] =mars:clay]
554+ =* arg +<
555+ =/ m (strand ,vase)
556+ ^- form:m
557+ ;< =riot:clay bind:m
558+ (warp ship desk ~ %sing %f case /[a.mars]/[b.mars])
559+ ?~ riot
560+ (strand-fail %build-cast >arg< ~)
561+ ?> =(%cast p.r.u.riot)
562+ (pure:m q.r.u.riot)
563+::
564+:: Read from Clay
565+::
566+++ warp
567+ |= [=ship =riff:clay]
568+ =/ m (strand ,riot:clay)
569+ ;< ~ bind:m (send-raw-card %pass /warp %arvo %c %warp ship riff)
570+ (take-writ /warp)
571+::
572+++ read-file
573+ |= [[=ship =desk =case] =spur]
574+ =* arg +<
575+ =/ m (strand ,cage)
576+ ;< =riot:clay bind:m (warp ship desk ~ %sing %x case spur)
577+ ?~ riot
578+ (strand-fail %read-file >arg< ~)
579+ (pure:m r.u.riot)
580+::
581+++ check-for-file
582+ |= [[=ship =desk =case] =spur]
583+ =/ m (strand ,?)
584+ ;< =riot:clay bind:m (warp ship desk ~ %sing %u case spur)
585+ ?> ?=(^ riot)
586+ (pure:m !<(? q.r.u.riot))
587+::
588+++ list-tree
589+ |= [[=ship =desk =case] =spur]
590+ =* arg +<
591+ =/ m (strand ,(list path))
592+ ;< =riot:clay bind:m (warp ship desk ~ %sing %t case spur)
593+ ?~ riot
594+ (strand-fail %list-tree >arg< ~)
595+ (pure:m !<((list path) q.r.u.riot))
596+::
597+:: Take Clay read result
598+::
599+++ take-writ
600+ |= =wire
601+ =/ m (strand ,riot:clay)
602+ ^- form:m
603+ |= tin=strand-input:strand
604+ ?+ in.tin `[%skip ~]
605+ ~ `[%wait ~]
606+ [~ %sign * ?(%behn %clay) %writ *]
607+ ?. =(wire wire.u.in.tin)
608+ `[%skip ~]
609+ `[%done +>.sign-arvo.u.in.tin]
610+ ==
611+:: +check-online: require that peer respond before timeout
612+::
613+++ check-online
614+ |= [who=ship lag=@dr]
615+ =/ m (strand ,~)
616+ ^- form:m
617+ %+ (map-err ,~) |=(* [%offline *tang])
618+ %+ (set-timeout ,~) lag
619+ ;< ~ bind:m
620+ (poke [who %hood] %helm-hi !>(~))
621+ (pure:m ~)
622+::
623+++ eval-hoon
624+ |= [gen=hoon bez=(list beam)]
625+ =/ m (strand ,vase)
626+ ^- form:m
627+ =/ sut=vase !>(..zuse)
628+ |-
629+ ?~ bez
630+ (pure:m (slap sut gen))
631+ ;< vax=vase bind:m (build-file-hard i.bez)
632+ $(bez t.bez, sut (slop vax sut))
633+::
634+++ send-thread
635+ |= [=bear:khan =shed:khan =wire]
636+ =/ m (strand ,~)
637+ ^- form:m
638+ (send-raw-card %pass wire %arvo %k %lard bear shed)
639+::
640+:: Queue on skip, try next on fail %ignore
641+::
642+++ main-loop
643+ |* a=mold
644+ =/ m (strand ,~)
645+ =/ m-a (strand ,a)
646+ =| queue=(qeu (unit input:strand))
647+ =| active=(unit [in=(unit input:strand) =form:m-a forms=(list $-(a form:m-a))])
648+ =| state=a
649+ |= forms=(lest $-(a form:m-a))
650+ ^- form:m
651+ |= tin=strand-input:strand
652+ =* top `form:m`..$
653+ =. queue (~(put to queue) in.tin)
654+ |^ (continue bowl.tin)
655+ ::
656+ ++ continue
657+ |= =bowl:strand
658+ ^- output:m
659+ ?> =(~ active)
660+ ?: =(~ queue)
661+ `[%cont top]
662+ =^ in=(unit input:strand) queue ~(get to queue)
663+ ^- output:m
664+ =. active `[in (i.forms state) t.forms]
665+ ^- output:m
666+ (run bowl in)
667+ ::
668+ ++ run
669+ ^- form:m
670+ |= tin=strand-input:strand
671+ ^- output:m
672+ ?> ?=(^ active)
673+ =/ res (form.u.active tin)
674+ =/ =output:m
675+ ?- -.next.res
676+ %wait `[%wait ~]
677+ %skip `[%cont ..$(queue (~(put to queue) in.tin))]
678+ %cont `[%cont ..$(active `[in.u.active self.next.res forms.u.active])]
679+ %done (continue(active ~, state value.next.res) bowl.tin)
680+ %fail
681+ ?: &(?=(^ forms.u.active) ?=(%ignore p.err.next.res))
682+ %= $
683+ active `[in.u.active (i.forms.u.active state) t.forms.u.active]
684+ in.tin in.u.active
685+ ==
686+ `[%fail err.next.res]
687+ ==
688+ [(weld cards.res cards.output) next.output]
689+ --
690+::
691+++ retry
692+ |* result=mold
693+ |= [crash-after=(unit @ud) computation=_*form:(strand (unit result))]
694+ =/ m (strand ,result)
695+ =| try=@ud
696+ |- ^- form:m
697+ =* loop $
698+ ?: =(crash-after `try)
699+ (strand-fail %retry-too-many ~)
700+ ;< ~ bind:m (backoff try ~m1)
701+ ;< res=(unit result) bind:m computation
702+ ?^ res
703+ (pure:m u.res)
704+ loop(try +(try))
705+::
706+++ backoff
707+ |= [try=@ud limit=@dr]
708+ =/ m (strand ,~)
709+ ^- form:m
710+ ;< eny=@uvJ bind:m get-entropy
711+ %- sleep
712+ %+ min limit
713+ ?: =(0 try) ~s0
714+ %+ add
715+ (mul ~s1 (bex (dec try)))
716+ (mul ~s0..0001 (~(rad og eny) 1.000))
717+::
718+:: ----
719+::
720+:: Output
721+::
722+++ flog
723+ |= =flog:dill
724+ =/ m (strand ,~)
725+ ^- form:m
726+ (send-raw-card %pass / %arvo %d %flog flog)
727+::
728+++ flog-text
729+ |= =tape
730+ =/ m (strand ,~)
731+ ^- form:m
732+ (flog %text tape)
733+::
734+++ flog-tang
735+ |= =tang
736+ =/ m (strand ,~)
737+ ^- form:m
738+ =/ =wall
739+ (zing (turn (flop tang) (cury wash [0 80])))
740+ |- ^- form:m
741+ =* loop $
742+ ?~ wall
743+ (pure:m ~)
744+ ;< ~ bind:m (flog-text i.wall)
745+ loop(wall t.wall)
746+::
747+++ trace
748+ |= =tang
749+ =/ m (strand ,~)
750+ ^- form:m
751+ (pure:m ((slog tang) ~))
752+::
753+++ app-message
754+ |= [app=term =cord =tang]
755+ =/ m (strand ,~)
756+ ^- form:m
757+ =/ msg=tape :(weld (trip app) ": " (trip cord))
758+ ;< ~ bind:m (flog-text msg)
759+ (flog-tang tang)
760+::
761+:: ----
762+::
763+:: Handle domains
764+::
765+++ install-domain
766+ |= =turf
767+ =/ m (strand ,~)
768+ ^- form:m
769+ (send-raw-card %pass / %arvo %e %rule %turf %put turf)
770+::
771+:: ----
772+::
773+:: Threads
774+::
775+++ start-thread
776+ |= file=term
777+ =/ m (strand ,tid:spider)
778+ ;< =bowl:spider bind:m get-bowl
779+ (start-thread-with-args byk.bowl file *vase)
780+::
781+++ start-thread-with-args
782+ |= [=beak file=term args=vase]
783+ =/ m (strand ,tid:spider)
784+ ^- form:m
785+ ;< =bowl:spider bind:m get-bowl
786+ =/ tid
787+ (scot %ta (cat 3 (cat 3 'strand_' file) (scot %uv (sham file eny.bowl))))
788+ =/ poke-vase !>(`start-args:spider`[`tid.bowl `tid beak file args])
789+ ;< ~ bind:m (poke-our %spider %spider-start poke-vase)
790+ ;< ~ bind:m (sleep ~s0) :: wait for thread to start
791+ (pure:m tid)
792+::
793++$ thread-result
794+ (each vase [term tang])
795+::
796+++ await-thread
797+ |= [file=term args=vase]
798+ =/ m (strand ,thread-result)
799+ ^- form:m
800+ ;< =bowl:spider bind:m get-bowl
801+ =/ tid (scot %ta (cat 3 'strand_' (scot %uv (sham file eny.bowl))))
802+ =/ poke-vase !>(`start-args:spider`[`tid.bowl `tid byk.bowl file args])
803+ ;< ~ bind:m (watch-our /awaiting/[tid] %spider /thread-result/[tid])
804+ ;< ~ bind:m (poke-our %spider %spider-start poke-vase)
805+ ;< ~ bind:m (sleep ~s0) :: wait for thread to start
806+ ;< =cage bind:m (take-fact /awaiting/[tid])
807+ ;< ~ bind:m (take-kick /awaiting/[tid])
808+ ?+ p.cage ~|([%strange-thread-result p.cage file tid] !!)
809+ %thread-done (pure:m %& q.cage)
810+ %thread-fail (pure:m %| ;;([term tang] q.q.cage))
811+ ==
812+--
zod/luau/mar/lua.hoon+5−10
@@ -1,22 +1,17 @@
1−/- lua
1+|_ txt=wain
2−/+ lua-parser
3−/+ lua-printer
4−
5−|_ ast=ast:lua
6−++ grad %noun
2+++ grad %mime
7++ grow
3++ grow
8 |%
4 |%
9− ++ noun ast
10 ++ mime
5 ++ mime
11 ^- ^mime
6 ^- ^mime
12− [/text/lua (as-octt:mimes:html (lua-printer ast))]
7+ [/text/lua (as-octs:mimes:html (of-wain:format txt))]
13 --
8 --
14++ grab
9++ grab
15 |%
10 |%
16− ++ noun ast:lua
11+ ++ noun wain
17 ++ mime
12 ++ mime
18 |= [=mite len=@ tex=@]
13 |= [=mite len=@ tex=@]
19− (rash tex lua-parser)
14+ (to-wain:format tex)
20 --
15 --
21--
16--
22
17
zod/luau/tests/all.lua → zod/luau/res/lua/all.luarenamed

The content is the same.

zod/luau/tests/api.lua → zod/luau/res/lua/api.luarenamed

The content is the same.

zod/luau/tests/attrib.lua → zod/luau/res/lua/attrib.luarenamed

The content is the same.

zod/luau/tests/big.lua → zod/luau/res/lua/big.luarenamed

The content is the same.

zod/luau/tests/bitwise.lua → zod/luau/res/lua/bitwise.luarenamed

The content is the same.

zod/luau/tests/bwcoercion.lua → zod/luau/res/lua/bwcoercion.luarenamed

The content is the same.

zod/luau/tests/calls.lua → zod/luau/res/lua/calls.luarenamed

The content is the same.

zod/luau/tests/closure.lua → zod/luau/res/lua/closure.luarenamed

The content is the same.

zod/luau/tests/code.lua → zod/luau/res/lua/code.luarenamed

The content is the same.

zod/luau/tests/constructs.lua → zod/luau/res/lua/constructs.luarenamed

The content is the same.

zod/luau/tests/coroutine.lua → zod/luau/res/lua/coroutine.luarenamed

The content is the same.

zod/luau/tests/cstack.lua → zod/luau/res/lua/cstack.luarenamed

The content is the same.

zod/luau/tests/db.lua → zod/luau/res/lua/db.luarenamed

The content is the same.

zod/luau/tests/errors.lua → zod/luau/res/lua/errors.luarenamed

The content is the same.

zod/luau/tests/events.lua → zod/luau/res/lua/events.luarenamed

The content is the same.

zod/luau/tests/files.lua → zod/luau/res/lua/files.luarenamed

The content is the same.

zod/luau/tests/foo.lua → zod/luau/res/lua/foo.luarenamed+1−1
@@ -1,6 +1,6 @@
1foosjis = nil
1foosjis = nil
2
2
3−baz = bar[nil]
3+az = bar[nil]
4baz = bar(1).foo
4baz = bar(1).foo
5
5
6i = 3
6i = 3
zod/luau/tests/gc.lua → zod/luau/res/lua/gc.luarenamed

The content is the same.

zod/luau/tests/gengc.lua → zod/luau/res/lua/gengc.luarenamed

The content is the same.

zod/luau/tests/goto.lua → zod/luau/res/lua/goto.luarenamed

The content is the same.

zod/luau/tests/heavy.lua → zod/luau/res/lua/heavy.luarenamed

The content is the same.

zod/luau/tests/literals.lua → zod/luau/res/lua/literals.luarenamed

The content is the same.

zod/luau/tests/locals.lua → zod/luau/res/lua/locals.luarenamed

The content is the same.

zod/luau/tests/main.lua → zod/luau/res/lua/main.luarenamed

The content is the same.

zod/luau/tests/math.lua → zod/luau/res/lua/math.luarenamed

The content is the same.

zod/luau/tests/nextvar.lua → zod/luau/res/lua/nextvar.luarenamed

The content is the same.

zod/luau/tests/pm.lua → zod/luau/res/lua/pm.luarenamed

The content is the same.

zod/luau/tests/sort.lua → zod/luau/res/lua/sort.luarenamed

The content is the same.

zod/luau/tests/strings.lua → zod/luau/res/lua/strings.luarenamed

The content is the same.

zod/luau/tests/tpack.lua → zod/luau/res/lua/tpack.luarenamed

The content is the same.

zod/luau/tests/tracegc.lua → zod/luau/res/lua/tracegc.luarenamed

The content is the same.

zod/luau/tests/utf8.lua → zod/luau/res/lua/utf8.luarenamed

The content is the same.

zod/luau/tests/vararg.lua → zod/luau/res/lua/vararg.luarenamed

The content is the same.

zod/luau/tests/verybig.lua → zod/luau/res/lua/verybig.luarenamed

The content is the same.

zod/luau/sur/spider.hoonnew file+27
@@ -0,0 +1,27 @@
1+/+ libstrand=strand
2+=, strand=strand:libstrand
3+|%
4++$ thread $-(vase shed:khan)
5++$ input [=tid =cage]
6++$ tid tid:strand
7++$ bowl bowl:strand
8++$ http-error
9+ $? %bad-request :: 400
10+ %forbidden :: 403
11+ %nonexistent :: 404
12+ %offline :: 504
13+ ==
14++$ start-args
15+ $: parent=(unit tid)
16+ use=(unit tid)
17+ =beak
18+ file=term
19+ =vase
20+ ==
21++$ inline-args
22+ $: parent=(unit tid)
23+ use=(unit tid)
24+ =beak
25+ =shed:khan
26+ ==
27+--
zod/luau/ted/test-lua.hoonnew file+23
@@ -0,0 +1,23 @@
1+/- spider
2+/+ *strandio
3+=<
4+=/ m (strand:spider ,vase)
5+^- thread:spider
6+|= arg=vase
7+^- form:m
8+;< bek=beak bind:m get-beak
9+;< lua-files=(list path) bind:m (list-tree [bek /res/lua])
10+:: ;< * bind:m ((map-m ,@ud ~) ~[1 2 3] |=(x=@ (flog-text "{<x>}")))
11+;< results=(list test-result) bind:m
12+ =/ m (strand:spider ,(list test-result))
13+ =/ res=(list test-result) ~
14+ |-
15+ ?~ lua-files (pure:m res)
16+ ;< =cage bind:m (read-file [bek i.lua-files])
17+ =/ bar (of-wain:format !<(wain +.cage))
18+ :: ;< * bind:m (flog-text "{<i.lua-files>} {(scag 50 (trip bar))}")
19+ $(lua-files t.lua-files, res [%ok res])
20+(pure:m !>(~))
21+|%
22++$ test-result $?(%ok %err)
23+--