From fe338abe872936ed0556505504f96071b8e24b74 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 5 Feb 2015 21:00:35 -0800 Subject: [PATCH 001/219] Initial eyre paring down --- arvo/eyre.hoon | 3915 +++++++++++++++++++------------------- arvo/zuse.hoon | 15 +- main/app/shell/core.hook | 12 +- main/mar/md/door.hook | 4 + main/mar/psal/door.hook | 1 + main/mar/tang/door.hook | 10 +- 6 files changed, 1969 insertions(+), 1988 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index b23812b89b..cb81b7bf47 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -18,11 +18,11 @@ $% [%born ~] :: new unix process [%crud p=@tas q=(list tank)] :: XX rethink [%init p=@p] :: report install - [%them p=(unit hiss)] :: outbound request - [%they p=@ud q=httr] :: inbound response +:: [%them p=(unit hiss)] :: outbound request +:: [%they p=@ud q=httr] :: inbound response [%this p=? q=clip r=httq] :: inbound request [%thud ~] :: inbound cancel - [%wart p=sock q=@tas r=path s=*] :: urbit message +:: [%wart p=sock q=@tas r=path s=*] :: urbit message == :: ++ move ,[p=duct q=(mold note gift)] :: local move ++ note :: out request $-> @@ -69,35 +69,29 @@ [%vega p=path] :: == == == :: ++ sign :: in result $<- - $? $: %a :: by %ames - $% [%waft p=sock q=*] :: - [%went p=ship q=cape] :: - == == :: - $: %b :: by %batz - $% [%helo p=path q=prod] :: - [%talk p=tank] :: - [%tell p=(list ,@t)] :: - [%text p=tape] :: - [%warn p=tape] :: - == == :: + $? +:: $: %a :: by %ames +:: $% [%waft p=sock q=*] :: +:: [%went p=ship q=cape] :: +:: == == :: $: %c :: by %clay $% [%writ p=riot] :: == == :: - $: %e :: by %eyre - $% [%thou p=httr] :: - == == :: +:: $: %e :: by %eyre +:: $% [%thou p=httr] :: +:: == == :: $: %f :: by %ford $% [%made p=(each bead (list tank))] :: - == == :: - $: %g :: by %gall - $% [%dumb ~] :: - [%mean p=ares] :: - [%nice ~] :: - [%rush p=mark q=*] :: - [%rust p=mark q=*] :: - == == :: - $: %t :: by %time - $% [%wake ~] :: timer activate +:: == == :: +:: $: %g :: by %gall +:: $% [%dumb ~] :: +:: [%mean p=ares] :: +:: [%nice ~] :: +:: [%rush p=mark q=*] :: +:: [%rust p=mark q=*] :: +:: == == :: +:: $: %t :: by %time +:: $% [%wake ~] :: timer activate == == :: $: @tas :: by any $% [%crud p=@tas q=(list tank)] :: @@ -198,155 +192,153 @@ == :: -- :: |% -++ coss :: cookie search - |= [nam=@t mah=math] - ^- (unit hole) - =+ ^= cok ^- (list ,@t) - =+ cok=(~(get by mah) 'cookie') - ?~(cok ~ u.cok) - |- ^- (unit hole) - ?~ cok ~ - =+ mar=`(unit (list ,[p=@t q=@t]))`(rush i.cok cock:epur) - ?~ mar $(cok t.cok) - |- ^- (unit hole) - ?~ u.mar ^$(cok t.cok) - ?:(=(nam p.i.u.mar) [~ q.i.u.mar] $(u.mar t.u.mar)) -:: -++ ecca :: [hasp path] - |= [orx=oryx moh=moth] - ^- (unit ,[hasp path]) - =+ jun=(ecci orx moh) - :: ~& [%ecca jun] - ?~ jun ~ - =+ ^- (unit ,[his=ship app=term pax=term]) - %. u.jun - %- ot:jo - ~[[%ship (su:jo fed:ag)] [%appl so:jo] [%path so:jo]] - ?~ - ~ - =+ ^= pax - %+ rush pax.u - ;~(pfix fas (more fas ;~(simu next urs:ab))) - ?~ pax ~ - `[[his.u app.u] u.pax] -:: -++ ecce :: JS from moth - |= moh=moth - ^- (unit json) - =+ ten=(~(get by q.moh) 'content-type') - ?~ ten ~ - ?~ u.ten ~ - ?. =('text/json' (end 3 9 i.u.ten)) - ~| %ecce-content-type ~ - ?~ r.moh ~ - `(unit json)`(rush q.u.r.moh apex:poja) -:: -++ ecci :: ecce w/oryx - |= [orx=oryx moh=moth] - ^- (unit json) - =+ jun=(ecce moh) - ?~ jun ~ - ?. ?=(%o -.u.jun) ~ - :: ?. =([~ %s orx] (~((get by p.u.jun) %oryx)) - :: ~& [%oryx-sent ~(get by p.u.jun) %oryx)] - :: ~& [%oryx-good orx] - :: ~ - ~? !=([~ %s orx] (~(get by p.u.jun) %oryx)) - [%oryx [%sent (~(get by p.u.jun) %oryx)] [%good orx]] - =+ nuj=(~(get by p.u.jun) %xyro) - ?~(nuj [~ ~] [~ u.nuj]) -:: +:: ++ coss :: cookie search +:: |= [nam=@t mah=math] +:: ^- (unit hole) +:: =+ ^= cok ^- (list ,@t) +:: =+ cok=(~(get by mah) 'cookie') +:: ?~(cok ~ u.cok) +:: |- ^- (unit hole) +:: ?~ cok ~ +:: =+ mar=`(unit (list ,[p=@t q=@t]))`(rush i.cok cock:epur) +:: ?~ mar $(cok t.cok) +:: |- ^- (unit hole) +:: ?~ u.mar ^$(cok t.cok) +:: ?:(=(nam p.i.u.mar) [~ q.i.u.mar] $(u.mar t.u.mar)) +:: :: +:: ++ ecca :: [hasp path] +:: |= [orx=oryx moh=moth] +:: ^- (unit ,[hasp path]) +:: =+ jun=(ecci orx moh) +:: :: ~& [%ecca jun] +:: ?~ jun ~ +:: =+ ^- (unit ,[his=ship app=term pax=term]) +:: %. u.jun +:: %- ot:jo +:: ~[[%ship (su:jo fed:ag)] [%appl so:jo] [%path so:jo]] +:: ?~ - ~ +:: =+ ^= pax +:: %+ rush pax.u +:: ;~(pfix fas (more fas ;~(simu next urs:ab))) +:: ?~ pax ~ +:: `[[his.u app.u] u.pax] +:: :: +:: ++ ecce :: JS from moth +:: |= moh=moth +:: ^- (unit json) +:: =+ ten=(~(get by q.moh) 'content-type') +:: ?~ ten ~ +:: ?~ u.ten ~ +:: ?. =('text/json' (end 3 9 i.u.ten)) +:: ~| %ecce-content-type ~ +:: ?~ r.moh ~ +:: `(unit json)`(rush q.u.r.moh apex:poja) +:: :: +:: ++ ecci :: ecce w/oryx +:: |= [orx=oryx moh=moth] +:: ^- (unit json) +:: =+ jun=(ecce moh) +:: ?~ jun ~ +:: ?. ?=(%o -.u.jun) ~ +:: :: ?. =([~ %s orx] (~((get by p.u.jun) %oryx)) +:: :: ~& [%oryx-sent ~(get by p.u.jun) %oryx)] +:: :: ~& [%oryx-good orx] +:: :: ~ +:: ~? !=([~ %s orx] (~(get by p.u.jun) %oryx)) +:: [%oryx [%sent (~(get by p.u.jun) %oryx)] [%good orx]] +:: =+ nuj=(~(get by p.u.jun) %xyro) +:: ?~(nuj [~ ~] [~ u.nuj]) +:: :: ++ ecco :: eat headers - |= hed=(list ,[p=@t q=@t]) - =+ mah=*math - |- ^- math - ?~ hed mah - =+ cus=(cass (rip 3 p.i.hed)) - =+ zeb=(~(get by mah) cus) - $(hed t.hed, mah (~(put by mah) cus ?~(zeb [q.i.hed ~] [q.i.hed u.zeb]))) -:: -++ eccu :: [hasp json] - |= [orx=oryx moh=moth] - ^- (unit ,[hasp mark json]) - =+ jun=(ecci orx moh) - ?~ jun ~& %no-ecci ~ - =+ ^- (unit ,[his=term app=term for=mark jon=json]) - %. u.jun - %- ot:jo - :~ [%ship so:jo] - [%appl so:jo] - [%mark so:jo] - [%data |=(json (some +<))] - == - ?~ - ~& %no-json ~ - =+ his=(slaw %p (cat 3 '~' his.u)) - ?~ his ~& %no-ship ~ - `[[u.his app.u] for.u jon.u] -:: -++ lopo :: cage to love - |= cay=cage - ^- love - ?> ?=(%mime p.cay) - ((hard love) [%mid q.q.cay]) -:: -++ loga :: tanks to manx - |= [til=tape mog=(list manx) tac=(list tank)] - ^- manx - =+ ^= wol - |- ^- wall - ?~ tac ~ - (weld `wall`[~(ram re i.tac) ~] $(tac t.tac)) - =+ ^= tax - |- ^- (list manx) - (turn wol |=(a=tape [/p ;"{a}"])) - ;html - ;head - ;title: {til} - == - ;body - ;code - ;* (weld tax mog) - == - == - == -:: -++ lofa :: scripts in head - |= [mog=(list manx) luv=love] - ^- love - ?: =(~ mog) luv - ?+ -.luv luv - %mid - ?. =('')) - ;~(plug next (knee *tape ..$)) - (easy ~) - == - =+ hop=(need q:(hed *hair (trip q.q.luv))) - ?~ q.q.hop luv - =+ rep=:(welp p.hop scr q.q.hop) - [%mid p.luv (tact rep)] - == -:: -++ loft :: love to response - |= luv=love - ^- httr - ?- -.luv - %mid [200 ~[content-type/(moon p.luv)] [~ q.luv]] - %ham [200 ~[content-type/'text/html'] [~ (tact (poxo p.luv))]] - %raw p.luv - %wan :+ 200 - ~[content-type/'text/plain'] - :- ~ - %- taco - %+ rap 3 - |- ^- (list ,@) - ?~(p.luv ~ [i.p.luv 10 $(p.luv t.p.luv)]) - %zap :+ p.luv - ~[content-type/'text/html'] - [~ (tact (poxo (loga "server error" ~ q.luv)))] - == + |= hed=(list ,[p=@t q=@t]) ^- math + %+ roll hed + |= [a=[p=cord cord] b=math] + =. p.a (cass (trip p.a)) + (~(add ja b) a) +:: :: +:: ++ eccu :: [hasp json] +:: |= [orx=oryx moh=moth] +:: ^- (unit ,[hasp mark json]) +:: =+ jun=(ecci orx moh) +:: ?~ jun ~& %no-ecci ~ +:: =+ ^- (unit ,[his=term app=term for=mark jon=json]) +:: %. u.jun +:: %- ot:jo +:: :~ [%ship so:jo] +:: [%appl so:jo] +:: [%mark so:jo] +:: [%data |=(json (some +<))] +:: == +:: ?~ - ~& %no-json ~ +:: =+ his=(slaw %p (cat 3 '~' his.u)) +:: ?~ his ~& %no-ship ~ +:: `[[u.his app.u] for.u jon.u] +:: :: +:: ++ lopo :: cage to love +:: |= cay=cage +:: ^- love +:: ?> ?=(%mime p.cay) +:: ((hard love) [%mid q.q.cay]) +:: :: +:: ++ loga :: tanks to manx +:: |= [til=tape mog=(list manx) tac=(list tank)] +:: ^- manx +:: =+ ^= wol +:: |- ^- wall +:: ?~ tac ~ +:: (weld `wall`[~(ram re i.tac) ~] $(tac t.tac)) +:: =+ ^= tax +:: |- ^- (list manx) +:: (turn wol |=(a=tape [/p ;"{a}"])) +:: ;html +:: ;head +:: ;title: {til} +:: == +:: ;body +:: ;code +:: ;* (weld tax mog) +:: == +:: == +:: == +:: :: +:: ++ lofa :: scripts in head +:: |= [mog=(list manx) luv=love] +:: ^- love +:: ?: =(~ mog) luv +:: ?+ -.luv luv +:: %mid +:: ?. =('')) +:: ;~(plug next (knee *tape ..$)) +:: (easy ~) +:: == +:: =+ hop=(need q:(hed *hair (trip q.q.luv))) +:: ?~ q.q.hop luv +:: =+ rep=:(welp p.hop scr q.q.hop) +:: [%mid p.luv (tact rep)] +:: == +:: :: +:: ++ loft :: love to response +:: |= luv=love +:: ^- httr +:: ?- -.luv +:: %mid [200 ~[content-type/(moon p.luv)] [~ q.luv]] +:: %ham [200 ~[content-type/'text/html'] [~ (tact (poxo p.luv))]] +:: %raw p.luv +:: %wan :+ 200 +:: ~[content-type/'text/plain'] +:: :- ~ +:: %- taco +:: %+ rap 3 +:: |- ^- (list ,@) +:: ?~(p.luv ~ [i.p.luv 10 $(p.luv t.p.luv)]) +:: %zap :+ p.luv +:: ~[content-type/'text/html'] +:: [~ (tact (poxo (loga "server error" ~ q.luv)))] +:: == -- |% :: functions ++ ye :: per event @@ -374,143 +366,151 @@ ?- -.+.sih %crud +>.$(mow [[hen %slip %d %flog +.sih] mow]) - :: - ?(%dumb %mean %nice %rush %rust) - ?> ?=([%hoop @ @ @ ?([%mess @ @ ~] [%show @ ~])] tea) - =+ our=(slav %p i.t.tea) - =* ses i.t.t.tea - =+ nap=(slav %ud i.t.t.t.tea) - =+ ouy=(yolk:(gale our ses) nap) - ?~ ouy - +>.$ - =* mab t.t.t.t.tea - =+ woy=(yule:u.ouy ?+(i.mab !! %mess %meg, %show %sub)) - ?- -.+.sih - %dumb - abet:work:abet:dumb:woy - :: - %nice - =< abet =< work =< abet - ?. ?=(%mess i.mab) - u.ouy - (hear:woy ~ %& %json !>((joba %ok %b &))) - :: - %mean - =< abet =< work =< abet - =+ jon=(rong p.+.sih) - ?: ?=(%mess i.mab) - (hear:woy ~ %& %json !>(jon)) - =+ can=(slav %ud i.t.mab) - =+ sem=(~(get by can.sub.siq:beat:u.ouy) can) - ?~ sem :: XX shouldn't occur - u.ouy - (soon %& u.sem u.ouy can %show ?.(?=(%show i.mab) jon (wrap u.sem jon))) - :: - ?(%rust %rush) - ?> ?=(%show i.mab) - =+ can=(slav %ud i.t.mab) - =+ sem=(need (~(get by can.sub.siq:beat:u.ouy) can)) - =. mow.u.ouy - :_(mow.u.ouy [hen %pass tea [%g %took [- + ~]:hap.sem you.u.ouy]]) - ?: =(0 can) - =< abet =< work =< abet - ?~ num.sem - (hear:woy ~ %& %json !>((joba %reload %b %&))) - ?> -.u.num.sem - =+ huq=``[p.+.sih (slot 3 (spec (slot 3 [typ +.sih])))] - =+ yoo=abet:(busk:(yule:u.ouy %nil) p.u.num.sem 0 huq) - yoo(can.sub.siq (~(put by can.sub.siq.yoo) can sem(num ~))) - ?. ?=(%json p.+.sih) - %^ hooj our ses :^ nap can ?=(%rust -.+.sih) - :+ %cast %json - :+ %done ~ - [p.+.sih (slot 3 (spec (slot 3 [typ +.sih])))] - =< abet =< work =< abet - (soon ?=(%rust -.+.sih) sem u.ouy can %show (wrap sem (json q.+.sih))) - == +:: :: +:: ?(%dumb %mean %nice %rush %rust) +:: ?> ?=([%hoop @ @ @ ?([%mess @ @ ~] [%show @ ~])] tea) +:: =+ our=(slav %p i.t.tea) +:: =* ses i.t.t.tea +:: =+ nap=(slav %ud i.t.t.t.tea) +:: =+ ouy=(yolk:(gale our ses) nap) +:: ?~ ouy +:: +>.$ +:: =* mab t.t.t.t.tea +:: =+ woy=(yule:u.ouy ?+(i.mab !! %mess %meg, %show %sub)) +:: ?- -.+.sih +:: %dumb +:: abet:work:abet:dumb:woy +:: :: +:: %nice +:: =< abet =< work =< abet +:: ?. ?=(%mess i.mab) +:: u.ouy +:: (hear:woy ~ %& %json !>((joba %ok %b &))) +:: :: +:: %mean +:: =< abet =< work =< abet +:: =+ jon=(rong p.+.sih) +:: ?: ?=(%mess i.mab) +:: (hear:woy ~ %& %json !>(jon)) +:: =+ can=(slav %ud i.t.mab) +:: =+ sem=(~(get by can.sub.siq:beat:u.ouy) can) +:: ?~ sem :: XX shouldn't occur +:: u.ouy +:: (soon %& u.sem u.ouy can %show ?.(?=(%show i.mab) jon (wrap u.sem jon))) +:: :: +:: ?(%rust %rush) +:: ?> ?=(%show i.mab) +:: =+ can=(slav %ud i.t.mab) +:: =+ sem=(need (~(get by can.sub.siq:beat:u.ouy) can)) +:: =. mow.u.ouy +:: :_(mow.u.ouy [hen %pass tea [%g %took [- + ~]:hap.sem you.u.ouy]]) +:: ?: =(0 can) +:: =< abet =< work =< abet +:: ?~ num.sem +:: (hear:woy ~ %& %json !>((joba %reload %b %&))) +:: ?> -.u.num.sem +:: =+ huq=``[p.+.sih (slot 3 (spec (slot 3 [typ +.sih])))] +:: =+ yoo=abet:(busk:(yule:u.ouy %nil) p.u.num.sem 0 huq) +:: yoo(can.sub.siq (~(put by can.sub.siq.yoo) can sem(num ~))) +:: ?. ?=(%json p.+.sih) +:: %^ hooj our ses :^ nap can ?=(%rust -.+.sih) +:: :+ %cast %json +:: :+ %done ~ +:: [p.+.sih (slot 3 (spec (slot 3 [typ +.sih])))] +:: =< abet =< work =< abet +:: (soon ?=(%rust -.+.sih) sem u.ouy can %show (wrap sem (json q.+.sih))) +:: == :: %made ?+ tea +>.$ - [%honk @ @ @ ~] - %- galt - [(slav %p i.t.tea) i.t.t.tea (slav %ud i.t.t.t.tea) p.+.sih] - :: - [%hooj @ @ @ @ @ ~] - =+ ^= ouy - %- yolk:(gale (slav %p i.t.tea) i.t.t.tea) - (slav %ud i.t.t.t.tea) - ?~ ouy - ~& %hooj-made-no-ouy +>.$ - =+ can=(slav %ud i.t.t.t.t.tea) - =+ ful=(slav %f i.t.t.t.t.t.tea) - =+ sem=(need (~(get by can.sub.siq:beat:u.ouy) can)) - =< abet =< work =< abet - %^ soon (,? ful) sem :^ u.ouy can %show - %+ wrap sem - ?: ?=(%& -.p.+.sih) - (json q.q.q.p.p.+.sih) - (rong ~ %to-json-fail p.p.+.sih) - :: - [%hoop @ @ @ %mess @ @ ~] - =+ ^= ouy - %- yolk:(gale (slav %p i.t.tea) i.t.t.tea) - (slav %ud i.t.t.t.tea) - ?~ ouy - ~& %hoop-made-no-ouy +>.$ - ?- -.p.+.sih - %& - =* mab t.t.t.t.tea - %= +>.$ - mow - :_ mow - :* hen %pass tea %g - %mess [(slav %p i.t.mab) i.t.t.mab ~] - you:beat:u.ouy q.p.p.sih - == - == - :: - %| - =< abet =< work =< abet - %^ hear:(yule:u.ouy %meg) ~ %& - [%json !>((rong ~ %from-json-fail p.p.+.sih))] + [%neu @ ~] + :: ~& e/ford/hen + =+ our=(slav %p i.t.tea) + ?- -.p.sih + | :: (back our tea %tang !>(p.p.sih)) :: XX broken tang door + =- (muff (tuff text//plain (role (turn - crip)))) + ^- wall %- zing ^- (list wall) + (turn p.p.sih |=(a=tank (wash 0^160 a))) + & =* cag q.p.p.sih + ?> ?=(%mime p.cag) + =+ ((hard ,[mit=mite rez=octs]) q.q.cag) :: XX + (muff %thou 200 [content-type/(moon mit)]~ ~ rez) == +:: :: +:: [%honk @ @ @ ~] +:: %- galt +:: [(slav %p i.t.tea) i.t.t.tea (slav %ud i.t.t.t.tea) p.+.sih] +:: :: +:: [%hooj @ @ @ @ @ ~] +:: =+ ^= ouy +:: %- yolk:(gale (slav %p i.t.tea) i.t.t.tea) +:: (slav %ud i.t.t.t.tea) +:: ?~ ouy +:: ~& %hooj-made-no-ouy +>.$ +:: =+ can=(slav %ud i.t.t.t.t.tea) +:: =+ ful=(slav %f i.t.t.t.t.t.tea) +:: =+ sem=(need (~(get by can.sub.siq:beat:u.ouy) can)) +:: =< abet =< work =< abet +:: %^ soon (,? ful) sem :^ u.ouy can %show +:: %+ wrap sem +:: ?: ?=(%& -.p.+.sih) +:: (json q.q.q.p.p.+.sih) +:: (rong ~ %to-json-fail p.p.+.sih) +:: :: +:: [%hoop @ @ @ %mess @ @ ~] +:: =+ ^= ouy +:: %- yolk:(gale (slav %p i.t.tea) i.t.t.tea) +:: (slav %ud i.t.t.t.tea) +:: ?~ ouy +:: ~& %hoop-made-no-ouy +>.$ +:: ?- -.p.+.sih +:: %& +:: =* mab t.t.t.t.tea +:: %= +>.$ +:: mow +:: :_ mow +:: :* hen %pass tea %g +:: %mess [(slav %p i.t.mab) i.t.t.mab ~] +:: you:beat:u.ouy q.p.p.sih +:: == +:: == +:: :: +:: %| +:: =< abet =< work =< abet +:: %^ hear:(yule:u.ouy %meg) ~ %& +:: [%json !>((rong ~ %from-json-fail p.p.+.sih))] +:: == == - :: - %thou :: remote return - ?> ?=([@ @ *] tea) - (hajj (slav %p i.tea) (slav %p i.t.tea) t.t.tea p.+.sih) - :: - %waft - ?. ?=([%hork @ ~] tea) - +>.$ - (gosh q.p.+.sih (slav %ud i.t.tea) ((hard httr) q.+.sih)) - :: - %wake - ?> ?=([%leep @ @ @ @ ~] tea) - =+ ^= ouy - %- yolk:(gale (slav %p i.t.tea) i.t.t.tea) - (slav %ud i.t.t.t.tea) - ?~ ouy - +>.$ - ?: (lth ~m2 (sub now tim.bet.siq:beat:u.ouy)) :: XX unnecessary - abet:work:amok:u.ouy - ~& %bad-timer - +>.$ - :: - %went - +>.$ +:: :: +:: %thou :: remote return +:: ?> ?=([@ @ *] tea) +:: (hajj (slav %p i.tea) (slav %p i.t.tea) t.t.tea p.+.sih) +:: :: +:: %waft +:: ?. ?=([%hork @ ~] tea) +:: +>.$ +:: (gosh q.p.+.sih (slav %ud i.t.tea) ((hard httr) q.+.sih)) +:: :: +:: %wake +:: ?> ?=([%leep @ @ @ @ ~] tea) +:: =+ ^= ouy +:: %- yolk:(gale (slav %p i.t.tea) i.t.t.tea) +:: (slav %ud i.t.t.t.tea) +:: ?~ ouy +:: +>.$ +:: ?: (lth ~m2 (sub now tim.bet.siq:beat:u.ouy)) :: XX unnecessary +:: abet:work:amok:u.ouy +:: ~& %bad-timer +:: +>.$ +:: :: +:: %went +:: +>.$ :: %writ - ?. ?=([%hoot @ @ @ ~] tea) + ?< ?=([%hoot @ @ @ ~] tea) +>.$ - %- gout - [(slav %p i.t.tea) i.t.t.tea (slav %ud i.t.t.t.tea) p.+.sih] - :: - ?(%helo %tell %text %talk %warn) - ?. ?=([%cons @ @ @ ~] tea) - +>.$ - %- goat - [(slav %p i.t.tea) i.t.t.tea (slav %ud i.t.t.t.tea) sih] +:: %- gout +:: [(slav %p i.t.tea) i.t.t.tea (slav %ud i.t.t.t.tea) p.+.sih] == :: ++ apex @@ -532,30 +532,30 @@ ~ == == - :: - %them :: outbound request - ?~ p.kyz - =+ sud=(need (~(get by kes) hen)) - %= +>.$ - mow :_(mow [ged [%give %thus sud ~]]) - q.ask (~(del by q.ask) sud) - kes (~(del by kes) hen) - == - :: ~& eyre-them/(earn p.u.p.kyz) - %= +>.$ - mow :_(mow [ged [%give %thus p.ask p.kyz]]) - p.ask +(p.ask) - q.ask (~(put by q.ask) p.ask hen u.p.kyz) - kes (~(put by kes) hen p.ask) - == - :: - %they :: inbound response - =+ kas=(need (~(get by q.ask) p.kyz)) - :: ~& > eyre-they/[p.q.kyz (earn p.q.kas)] - %= +>.$ - mow :_(mow [p.kas [%give %thou q.kyz]]) - q.ask (~(del by q.ask) p.kas) - == +:: :: +:: %them :: outbound request +:: ?~ p.kyz +:: =+ sud=(need (~(get by kes) hen)) +:: %= +>.$ +:: mow :_(mow [ged [%give %thus sud ~]]) +:: q.ask (~(del by q.ask) sud) +:: kes (~(del by kes) hen) +:: == +:: :: ~& eyre-them/(earn p.u.p.kyz) +:: %= +>.$ +:: mow :_(mow [ged [%give %thus p.ask p.kyz]]) +:: p.ask +(p.ask) +:: q.ask (~(put by q.ask) p.ask hen u.p.kyz) +:: kes (~(put by kes) hen p.ask) +:: == +:: :: +:: %they :: inbound response +:: =+ kas=(need (~(get by q.ask) p.kyz)) +:: :: ~& > eyre-they/[p.q.kyz (earn p.q.kas)] +:: %= +>.$ +:: mow :_(mow [p.kas [%give %thou q.kyz]]) +:: q.ask (~(del by q.ask) p.kas) +:: == :: %this :: inbound request =* sec p.kyz :: ? :: https bit @@ -573,25 +573,33 @@ (hell pul +.kyz [p.heq mah s.heq]) :: %thud :: cancel request - =+ dul=(~(get by lor) hen) - ?~ dul +>.$ - =. lor (~(del by lor) hen) - ?- -.q.u.dul - & =+ boy=(myth p.p.q.u.dul q.p.q.u.dul) - ?~(boy +>.$ abet:(idle:u.boy p.u.dul)) - | (hops p.q.u.dul p.u.dul) - == - :: - %wart :: remote request - ?+ q.kyz - ~& [%strange-wart p.kyz q.kyz] - +>.$ - :: - %pr (hare p.p.kyz r.kyz q.p.kyz s.kyz) - %pc (here p.p.kyz q.p.kyz s.kyz) - == + ~& e/gone/hen + +>.$ +:: =+ dul=(~(get by lor) hen) +:: ?~ dul +>.$ +:: =. lor (~(del by lor) hen) +:: ?- -.q.u.dul +:: & =+ boy=(myth p.p.q.u.dul q.p.q.u.dul) +:: ?~(boy +>.$ abet:(idle:u.boy p.u.dul)) +:: | (hops p.q.u.dul p.u.dul) +:: == +:: :: +:: %wart :: remote request +:: ?+ q.kyz +:: ~& [%strange-wart p.kyz q.kyz] +:: +>.$ +:: :: +:: %pr (hare p.p.kyz r.kyz q.p.kyz s.kyz) +:: %pc (here p.p.kyz q.p.kyz s.kyz) +:: == == :: + ++ back :: %ford bounce + |= [our=ship tea=wire cag=cage] + =+ sil=[%cast %mime %done ~ cag] + %_ +>.$ + mow :_(mow [hen %pass tea %f %exec our ~ sil]) + == ++ doss :: host to ship |= hot=host ^- (unit ship) @@ -600,87 +608,79 @@ ?. &(?=(& -.hot) ?=(^ p.hot)) ~ (rush -:(flop p.hot) fed:ag) :: - ++ fail :: request failed - |= [sas=@ud str=tape] - ^+ +> - %- muff - :- %thou - ^- httr - [sas ~[content-type/'text/plain'] [~ (tact str)]] - :: - ++ gale :: ya from response - |= [our=ship ses=hole] - =+ sef=(need (~(get by own) our)) - =+ cyz=(need (~(get by wup.sef) ses)) - ~(. ya [our ses] sef cyz) - :: - ++ galt :: - |= [our=ship ses=hole num=@ud mez=(each bead (list tank))] - ^+ +> - =+ suf=(~(get by own) our) - ?~ suf +>.$ - =+ cuz=(~(get by wup.u.suf) ses) - ?~ cuz +>.$ - abet:work:(~(inch ya [our ses] u.suf u.cuz) num mez) - :: - ++ goat :: console response - |= [our=ship ses=hole num=@ud sih=sign] - =+ suf=(~(get by own) our) - ?~ suf +>.$ - =+ cuz=(~(get by wup.u.suf) ses) - ?~ cuz +>.$ - abet:work:(~(dodo ya [our ses] u.suf u.cuz) num sih) - :: - ++ gosh :: receive %pr response - |= [him=ship num=@ud har=httr] - ^+ +> - =+ ryt=(~(get by fon) him) - ?~ ryt +>.$ - =+ zur=(~(get by q.rem.u.ryt) num) - ?~ zur +>.$ - %_ +>.$ - mow :_(mow [u.zur [%give %thou har]]) - fon (~(put by fon) him u.ryt(q.rem (~(del by q.rem.u.ryt) num))) - == - :: - ++ gout :: receive %clay - |= [our=ship ses=hole num=@ud rot=riot] - ^+ +> - =+ suf=(~(get by own) our) - ?~ suf +>.$ - =+ cuz=(~(get by wup.u.suf) ses) - ?~ cuz +>.$ - abet:work:(~(iota ya [our ses] u.suf u.cuz) num rot) - :: - ++ haji :: send %pc login - |= [our=ship him=ship ses=hole] - ^+ +> - +>.$(mow :_(mow [hen %pass ~ %a [%want [our him] [%r %pc %e ~] ses]])) - :: - ++ hajj :: send %pr response - |= [our=ship him=ship tus=path har=httr] - ^+ +> - +>.$(mow :_(mow [hen %pass ~ %a [%want [our him] [%r %pr %e tus] har]])) - :: - ++ hare :: receive request - |= [our=ship tus=path him=ship hor=*] - ^+ +> - =+ hux=((hard (unit httx)) hor) - %_ +>.$ - mow - :_ mow - :- hen - :^ %pass [(scot %p our) (scot %p him) tus] - %e - ?~(hux [%thud ~] [%this u.hux]) - == - :: - ++ here :: receive auth - |= [our=ship him=ship hez=*] - ^+ +> - =+ boy=(myth our (need ((sand %ta) ((hard ,@) hez)))) - ?~(boy +>.$ abet:(auth:u.boy him)) - :: +:: ++ fail :: request failed +:: |= [sas=@ud str=tape] +:: ^+ +> +:: %- muff +:: :- %thou +:: ^- httr +:: [sas ~[content-type/'text/plain'] [~ (tact str)]] +:: :: +:: ++ gale :: ya from response +:: |= [our=ship ses=hole] +:: =+ sef=(need (~(get by own) our)) +:: =+ cyz=(need (~(get by wup.sef) ses)) +:: ~(. ya [our ses] sef cyz) +:: :: +:: ++ galt :: +:: |= [our=ship ses=hole num=@ud mez=(each bead (list tank))] +:: ^+ +> +:: =+ suf=(~(get by own) our) +:: ?~ suf +>.$ +:: =+ cuz=(~(get by wup.u.suf) ses) +:: ?~ cuz +>.$ +:: abet:work:(~(inch ya [our ses] u.suf u.cuz) num mez) +:: :: +:: ++ gosh :: receive %pr response +:: |= [him=ship num=@ud har=httr] +:: ^+ +> +:: =+ ryt=(~(get by fon) him) +:: ?~ ryt +>.$ +:: =+ zur=(~(get by q.rem.u.ryt) num) +:: ?~ zur +>.$ +:: %_ +>.$ +:: mow :_(mow [u.zur [%give %thou har]]) +:: fon (~(put by fon) him u.ryt(q.rem (~(del by q.rem.u.ryt) num))) +:: == +:: :: +:: ++ gout :: receive %clay +:: |= [our=ship ses=hole num=@ud rot=riot] +:: ^+ +> +:: =+ suf=(~(get by own) our) +:: ?~ suf +>.$ +:: =+ cuz=(~(get by wup.u.suf) ses) +:: ?~ cuz +>.$ +:: abet:work:(~(iota ya [our ses] u.suf u.cuz) num rot) +:: :: +:: ++ haji :: send %pc login +:: |= [our=ship him=ship ses=hole] +:: ^+ +> +:: +>.$(mow :_(mow [hen %pass ~ %a [%want [our him] [%r %pc %e ~] ses]])) +:: :: +:: ++ hajj :: send %pr response +:: |= [our=ship him=ship tus=path har=httr] +:: ^+ +> +:: +>.$(mow :_(mow [hen %pass ~ %a [%want [our him] [%r %pr %e tus] har]])) +:: :: +:: ++ hare :: receive request +:: |= [our=ship tus=path him=ship hor=*] +:: ^+ +> +:: =+ hux=((hard (unit httx)) hor) +:: %_ +>.$ +:: mow +:: :_ mow +:: :- hen +:: :^ %pass [(scot %p our) (scot %p him) tus] +:: %e +:: ?~(hux [%thud ~] [%this u.hux]) +:: == +:: :: +:: ++ here :: receive auth +:: |= [our=ship him=ship hez=*] +:: ^+ +> +:: =+ boy=(myth our (need ((sand %ta) ((hard ,@) hez)))) +:: ?~(boy +>.$ abet:(auth:u.boy him)) +:: :: ++ hell :: request, no ship |= [pul=purl hyx=httx moh=moth] ^+ +> @@ -694,26 +694,35 @@ :: ?~(gow [~ q.q.pul] [gow t.q.q.pul]) :: =+ oar=`(unit ship)`?^(wiq wiq (doss r.p.pul)) =+ oar=(fall (doss r.p.pul) (need hov)) - ?. (home oar) - (hork oar hyx) - (huff oar q.hyx pul moh) - :: - ++ home :: do we own? - |= who=ship - ^- ? - ?: (~(has by own) who) & - ?: (~(has by fon) who) | - !=(~ (sky /a/(scot %p who)/buck/(scot %da now))) - :: - ++ hoot :: clay request - |= [our=ship num=@ud ses=hole rif=riff] - %_ +> - mow - :_ mow - :+ hen %pass - [[%hoot (scot %p our) ses (scot %ud num) ~] %c [%warp [our our] rif]] - == - :: + =+ ext=(fall p.q.pul %html) + =+ ^- bem=beam + |- + ?~ q.q.pul $(q.q.pul /index) + :- [oar i.q.q.pul [%da now]] + :+ %web + ~(rent co (flux:ya /'' r.pul)) + (flop t.q.q.pul) + (honk oar [%cast %mime %boil ext bem ~]) +:: ?. (home oar) +:: (hork oar hyx) +:: (huff oar q.hyx pul moh) +:: :: +:: ++ home :: do we own? +:: |= who=ship +:: ^- ? +:: ?: (~(has by own) who) & +:: ?: (~(has by fon) who) | +:: !=(~ (sky /a/(scot %p who)/buck/(scot %da now))) +:: :: +:: ++ hoot :: clay request +:: |= [our=ship num=@ud ses=hole rif=riff] +:: %_ +> +:: mow +:: :_ mow +:: :+ hen %pass +:: [[%hoot (scot %p our) ses (scot %ud num) ~] %c [%warp [our our] rif]] +:: == +:: :: ++ hone :: kill ford |= [our=ship num=@ud ses=hole] %_ +> @@ -723,1596 +732,1564 @@ == :: ++ honk :: ford request - |= [our=ship num=@ud ses=hole kas=silk] + |= [our=ship kas=silk] :: ~& [%honk our num ses -.kas] %_ +> mow :_ mow - [hen %pass [%honk (scot %p our) ses (scot %ud num) ~] %f [%exec our `kas]] + [hen %pass [%neu (scot %p our) ~] %f [%exec our `kas]] == - :: - ++ hooj :: ford json request - |= [our=ship ses=hole nap=@ud can=@ud ful=? kas=silk] - %_ +> - mow - :_ mow - :^ hen %pass - ~[%hooj (scot %p our) ses (scot %ud nap) (scot %ud can) (scot %f ful)] - [%f [%exec our `kas]] - == - :: - ++ hops :: cancel remote - |= [him=ship num=@] - ^+ +> - =+ mun=(scot %ud num) - =+ rot=(need (~(get by fon) him)) - %_ +>.$ - mow - :_ mow - :- hen - :^ %pass [%hork (scot %p sor.rot) mun ~] - %a - [%want [sor.rot him] [%q %pr %e %hork mun ~] ~] - == - :: - ++ hork :: remote request - |= [him=ship hyx=httx] - ^+ +> - =+ ^= sur ^- (unit ship) - ?^ hov hov - ?^ own [~ p.n.own] - ~ - ?~ sur (fail 500 "no vessel available to proxy {}") - ?. (gth (met 3 him) (met 3 u.sur)) :: very permissive - (fail 500 "{} cannot proxy for {}") - =+ ^= rot ^- rote - =+ rut=(~(get by fon) him) - ?^ rut u.rut - [0 u.sur [0 ~]] - =+ num=p.rem.rot - =+ mun=(scot %ud num) - %_ +>.$ - lor (~(put by lor) hen num [%| him]) - mow - :_ mow - :- hen - :^ %pass [%hork (scot %p sor.rot) mun ~] - %a - [%want [sor.rot him] [%q %pr %e %hork mun ~] [~ hyx]] - :: - fon - %+ ~(put by fon) him - %_ rot - cnt +(cnt.rot) - p.rem +(p.rem.rot) - q.rem (~(put by q.rem.rot) num hen) - == - == - :: +:: :: +:: ++ hooj :: ford json request +:: |= [our=ship ses=hole nap=@ud can=@ud ful=? kas=silk] +:: %_ +> +:: mow +:: :_ mow +:: :^ hen %pass +:: ~[%hooj (scot %p our) ses (scot %ud nap) (scot %ud can) (scot %f ful)] +:: [%f [%exec our `kas]] +:: == +:: :: +:: ++ hops :: cancel remote +:: |= [him=ship num=@] +:: ^+ +> +:: =+ mun=(scot %ud num) +:: =+ rot=(need (~(get by fon) him)) +:: %_ +>.$ +:: mow +:: :_ mow +:: :- hen +:: :^ %pass [%hork (scot %p sor.rot) mun ~] +:: %a +:: [%want [sor.rot him] [%q %pr %e %hork mun ~] ~] +:: == +:: :: +:: ++ hork :: remote request +:: |= [him=ship hyx=httx] +:: ^+ +> +:: =+ ^= sur ^- (unit ship) +:: ?^ hov hov +:: ?^ own [~ p.n.own] +:: ~ +:: ?~ sur (fail 500 "no vessel available to proxy {}") +:: ?. (gth (met 3 him) (met 3 u.sur)) :: very permissive +:: (fail 500 "{} cannot proxy for {}") +:: =+ ^= rot ^- rote +:: =+ rut=(~(get by fon) him) +:: ?^ rut u.rut +:: [0 u.sur [0 ~]] +:: =+ num=p.rem.rot +:: =+ mun=(scot %ud num) +:: %_ +>.$ +:: lor (~(put by lor) hen num [%| him]) +:: mow +:: :_ mow +:: :- hen +:: :^ %pass [%hork (scot %p sor.rot) mun ~] +:: %a +:: [%want [sor.rot him] [%q %pr %e %hork mun ~] [~ hyx]] +:: :: +:: fon +:: %+ ~(put by fon) him +:: %_ rot +:: cnt +(cnt.rot) +:: p.rem +(p.rem.rot) +:: q.rem (~(put by q.rem.rot) num hen) +:: == +:: == +:: :: ++ horn :: irregular request |= [pul=purl cip=clip moh=moth] ^- (unit gift) - =- ?: &(=(/favicon q.q.pul) ?=([~ ?(%ico %png)] p.q.pul)) - :- ~ - :- %thou - ^- httr - [200 ~[content-type/'image/png'] [~ (taco fac)]] - ?: &(=(/robots q.q.pul) ?=([~ %txt] p.q.pul)) - :- ~ - :- %thou - ^- httr - [200 ~[content-type/'text/plain'] [~ (taco rob)]] - ~ - :* - ^= rob - %- role - :~ 'User-agent: *' - 'Disallow: /' - == - :: - ^= fac + ?+ [(fall p.q.pul %$) q.q.pul] ~ + [?(%ico %png) %favicon ~] + :- ~ + %+ tuff image//png 0w89wg.GV4jA.l9000.00dPb.YzBT6.giO00.o100d.wZcqc.a9tg-.VTG0b. AUIvE.HBM3g.cK4SE.0aagi.l090p.I1P5g.Y-80r.y1YS9.1xE~Y.qgpFY. vKN1V.905y0.2UwvL.43TUw.uL406.0-31h.xwoJF.Ul454.ilk00.00Yps. BNumh.xpl9B.pS5Ji.i1BoC.ZAgg1.BsC5T.t6pLk.Thohn.gp000.0ov~P. 7M000.0o840.00010.0001i.h4x93.g0000.Eq2wR.7jB29 + :: + [%txt %robots ~] + :- ~ + %+ tuff text//plain + %- role + :~ 'User-agent: *' + 'Disallow: /' + == == :: - ++ huff :: request by ship - |= [our=ship cip=clip pul=purl moh=moth] - =* sec p.p.pul - =+ ^= sef ^- serf - =+ suf=(~(get by own) our) - ?^ suf u.suf - =+ sef=*serf - sef(pef (cat 3 gub (rsh 3 1 (scot %p our)))) :: XX transitional - =+ ^= saw ^- [p=hole q=cyst] - =+ lig=(coss pef.sef q.moh) - ?^ lig - =+ cyz=(need (~(get by wup.sef) u.lig)) - [u.lig cyz(cug ~)] - =+ ses=(rsh 3 1 (scot %p (end 6 1 ney))) - :- ses - ^- cyst - :* ^- cred - :* [sec q.p.pul r.p.pul] - ~ - (rsh 3 1 (scot %p (end 6 1 (shaf %oryx ses)))) - :: - =+ lag=(~(get by q.moh) %accept-language) - ?~(lag ~ ?~(u.lag ~ [~ i.u.lag])) - :: - cip - ~ - == - :: - ~ - :: - :_ ~ - %^ cat 3 - (cat 3 (cat 3 pef.sef '=') ses) - :: (cat 3 '; HttpOnly' ?.(sec '' '; Secure')) - '; Path=/; HttpOnly' - :: - now - ~ - [1 ~] - == - abet:work:(~(into ya [our p.saw] sef q.saw) pul moh) +:: ++ huff :: request by ship +:: |= [our=ship cip=clip pul=purl moh=moth] +:: =* sec p.p.pul +:: =+ ^= sef ^- serf +:: =+ suf=(~(get by own) our) +:: ?^ suf u.suf +:: =+ sef=*serf +:: sef(pef (cat 3 gub (rsh 3 1 (scot %p our)))) :: XX transitional +:: =+ ^= saw ^- [p=hole q=cyst] +:: =+ lig=(coss pef.sef q.moh) +:: ?^ lig +:: =+ cyz=(need (~(get by wup.sef) u.lig)) +:: [u.lig cyz(cug ~)] +:: =+ ses=(rsh 3 1 (scot %p (end 6 1 ney))) +:: :- ses +:: ^- cyst +:: :* ^- cred +:: :* [sec q.p.pul r.p.pul] +:: ~ +:: (rsh 3 1 (scot %p (end 6 1 (shaf %oryx ses)))) +:: :: +:: =+ lag=(~(get by q.moh) %accept-language) +:: ?~(lag ~ ?~(u.lag ~ [~ i.u.lag])) +:: :: +:: cip +:: ~ +:: == +:: :: +:: ~ +:: :: +:: :_ ~ +:: %^ cat 3 +:: (cat 3 (cat 3 pef.sef '=') ses) +:: :: (cat 3 '; HttpOnly' ?.(sec '' '; Secure')) +:: '; Path=/; HttpOnly' +:: :: +:: now +:: ~ +:: [1 ~] +:: == +:: abet:work:(~(into ya [our p.saw] sef q.saw) pul moh) :: ++ muff :: return card |= gef=gift +>(mow :_(mow [hen %give gef])) :: - ++ myth :: load session - |= [our=ship ses=hole] - =+ suf=(~(get by own) our) - ?~ suf ~ - =+ cuz=(~(get by wup.u.suf) ses) - ?~ cuz ~ - [~ u=~(. ya [our ses] u.suf u.cuz)] - :: - ++ noon :: login page - |= [our=ship ses=hole whu=(unit ship) rul=tape] - ^- manx - =+ ^= sic ^- manx - ;script:''' - var seal = { - who: goal, - url: burl, - pas: null, - ses: sesh - } - var hist = [] - var hind = 0 - $( - function() { - $input = $('#input .line') - $prompt = $('#input .prompt') - $prompt.addClass('prefix') - $output = $('#output') - $input.focus() - $('body').click(function() { $input.focus() }) - ctrl = false; + ++ tuff + |= [mit=mite rez=@] :: success response + ^- gift + [%thou 200 ~[content-type/(moon mit)] [~ (taco rez)]] +:: :: +:: ++ myth :: load session +:: |= [our=ship ses=hole] +:: =+ suf=(~(get by own) our) +:: ?~ suf ~ +:: =+ cuz=(~(get by wup.u.suf) ses) +:: ?~ cuz ~ +:: [~ u=~(. ya [our ses] u.suf u.cuz)] +:: :: +:: ++ noon :: login page +:: |= [our=ship ses=hole whu=(unit ship) rul=tape] +:: ^- manx +:: =+ ^= sic ^- manx +:: ;script:''' +:: var seal = { +:: who: goal, +:: url: burl, +:: pas: null, +:: ses: sesh +:: } +:: var hist = [] +:: var hind = 0 +:: $( +:: function() { +:: $input = $('#input .line') +:: $prompt = $('#input .prompt') +:: $prompt.addClass('prefix') +:: $output = $('#output') +:: $input.focus() +:: $('body').click(function() { $input.focus() }) +:: ctrl = false; - start = function(ship) { - $prompt.text('vessel: ~') - $input.attr('placeholder', 'ship-name') - if(ship) { - $input.val(ship) - } - } +:: start = function(ship) { +:: $prompt.text('vessel: ~') +:: $input.attr('placeholder', 'ship-name') +:: if(ship) { +:: $input.val(ship) +:: } +:: } - ident = function() { - seal.who = $input.val() +:: ident = function() { +:: seal.who = $input.val() - if( (seal.who.length != 13) && - (seal.who.length != 6) && - (seal.who.length != 3) ) - { - $output.text('not a ship name - try again.'); - return false; - } +:: if( (seal.who.length != 13) && +:: (seal.who.length != 6) && +:: (seal.who.length != 3) ) +:: { +:: $output.text('not a ship name - try again.'); +:: return false; +:: } - if(seal.who !== host) { - var all = $.extend({}, seal, {oth:host}); - delete all.pas; +:: if(seal.who !== host) { +:: var all = $.extend({}, seal, {oth:host}); +:: delete all.pas; - console.log('redirect') - window.location= - "http://"+seal.who+".urbit.org/gul?" - + $.param(all); - return false; - } +:: console.log('redirect') +:: window.location= +:: "http://"+seal.who+".urbit.org/gul?" +:: + $.param(all); +:: return false; +:: } - $output.text($prompt.text() + " " + seal.who) - $input.val('') - $input.attr('placeholder', 'ronber-bacnub-hanmev-labnyd') - $prompt.text('secret: ~') +:: $output.text($prompt.text() + " " + seal.who) +:: $input.val('') +:: $input.attr('placeholder', 'ronber-bacnub-hanmev-labnyd') +:: $prompt.text('secret: ~') - return true; - } +:: return true; +:: } - login = function() { - seal.pas = $input.val() - var oth = /[&?]oth=[^&]*/.exec(location.search) - if(oth && oth.length) - seal.oth = oth[0].slice(5) +:: login = function() { +:: seal.pas = $input.val() +:: var oth = /[&?]oth=[^&]*/.exec(location.search) +:: if(oth && oth.length) +:: seal.oth = oth[0].slice(5) - output = $output.html() - console.log($output.html()) - $output.html(output.replace( - 'sorry. please try again.
','')) +:: output = $output.html() +:: console.log($output.html()) +:: $output.html(output.replace( +:: 'sorry. please try again.
','')) - $.post("/pul", seal, function(data,xhr,status) { - console.log(data); - if(data.ok == true) { - document.location = data.next; - } else { - $output.prepend('sorry. please try again.
') - } - }) - } +:: $.post("/pul", seal, function(data,xhr,status) { +:: console.log(data); +:: if(data.ok == true) { +:: document.location = data.next; +:: } else { +:: $output.prepend('sorry. please try again.
') +:: } +:: }) +:: } - steps = [ident,login] - step = 0 - start(seal.who) - if(seal.who) { - ident() - step++ - } +:: steps = [ident,login] +:: step = 0 +:: start(seal.who) +:: if(seal.who) { +:: ident() +:: step++ +:: } - $input.on('keydown', function(e) { - if(e.keyCode == 17) { - ctrl = true - return; - } +:: $input.on('keydown', function(e) { +:: if(e.keyCode == 17) { +:: ctrl = true +:: return; +:: } - if(e.keyCode == 68 && - ctrl == true && - step == 1) { - $output.text('') - step = 0 - start(null) - return; - } +:: if(e.keyCode == 68 && +:: ctrl == true && +:: step == 1) { +:: $output.text('') +:: step = 0 +:: start(null) +:: return; +:: } - if(e.keyCode == 13) { - if(steps[step]() && step < steps.length-1) - step++ - return; - } - }); +:: if(e.keyCode == 13) { +:: if(steps[step]() && step < steps.length-1) +:: step++ +:: return; +:: } +:: }); - $input.on('keyup', function(e) { - if(e.keyCode == 17) { - ctrl = false - } - }); - }) - ''' - =+ ^= cof - ;= - ; var host = '{(trip (rsh 3 1 (scot %p our)))}'; - ; var goal = '{?~(whu ~ (trip (rsh 3 1 (scot %p u.whu))))}'; - ; var burl = '{rul}'; - ; var sesh = '{(trip ses)}'; - == - => .(+.sic (weld `marl`cof `marl`+.sic)) - =+ jqu="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" - =+ ^= hed - ;head - ;title: urbit login - ;script(type "text/javascript", src jqu); - ;style:''' - body { - margin: 60px 120px; - font: normal 12px "Menlo" monospace; - background-color: #000; - color: #fff; - } +:: $input.on('keyup', function(e) { +:: if(e.keyCode == 17) { +:: ctrl = false +:: } +:: }); +:: }) +:: ''' +:: =+ ^= cof +:: ;= +:: ; var host = '{(trip (rsh 3 1 (scot %p our)))}'; +:: ; var goal = '{?~(whu ~ (trip (rsh 3 1 (scot %p u.whu))))}'; +:: ; var burl = '{rul}'; +:: ; var sesh = '{(trip ses)}'; +:: == +:: => .(+.sic (weld `marl`cof `marl`+.sic)) +:: =+ jqu="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" +:: =+ ^= hed +:: ;head +:: ;title: urbit login +:: ;script(type "text/javascript", src jqu); +:: ;style:''' +:: body { +:: margin: 60px 120px; +:: font: normal 12px "Menlo" monospace; +:: background-color: #000; +:: color: #fff; +:: } - #output { +:: #output { - } +:: } - #input .prompt { - display: inline-block; - margin-right: 12px; - } +:: #input .prompt { +:: display: inline-block; +:: margin-right: 12px; +:: } - #input .line { - outline: none; - width: 80%; - border: 0; - background-color: transparent; - color: #fff; - font: normal 12px "Menlo" monospace; - } - ''' - == - =+ ^= bod ^- manx - ;body - ;div#output; - ;div#input - ;div.prompt; - ;input.line(type "text"); - == - == - =. +.bod (weld `marl`+.bod `marl`~[sic]) - ;html - ;+ hed - ;+ bod - == - :: - ++ rong - |= are=ares - %- jobe - :- [%ok %b |] - ?~ are ~ - :+ [%err %s p.u.are] - :+ %res %s - %- crip - %+ slag 2 - ^- tape - %+ roll q.u.are - |= [p=tank q=tape] - :(weld q "\\n" ~(ram re p)) - ~ - :: - ++ soon - |= [ful=? sem=stem ouy=_yo:ya can=@ud mab=?(%mess %show) jon=json] - ^+ yo:ya - =+ huq=``[%json !>(jon)] - ?~ num.sem - =+ woy=(yule:ouy ?-(mab %mess %meg, %show %sub)) - (hear:woy huq) - ?- -.u.num.sem - %& - =+ yoo=abet:(busk:(yule:ouy %nil) p.u.num.sem 0 huq) - yoo(can.sub.siq (~(put by can.sub.siq.yoo) can sem(num ~))) - %| - =+ ^= yoo - =< abet - %^ busk:(yule:(hear:(yule:ouy %sub) huq) %nil) - p.u.num.sem - 0 - `[%& %json !>((joba %ok %b &))] - yoo(can.sub.siq (~(put by can.sub.siq.yoo) can sem(num ~))) - == - :: - ++ wrap - |= [sem=stem jon=json] - %- jobe - :~ [%ship %s (rsh 3 1 (scot %p p.hap.sem))] - [%appl %s q.hap.sem] - [%path %s (crip )] - [%data `json`jon] - == - :: +:: #input .line { +:: outline: none; +:: width: 80%; +:: border: 0; +:: background-color: transparent; +:: color: #fff; +:: font: normal 12px "Menlo" monospace; +:: } +:: ''' +:: == +:: =+ ^= bod ^- manx +:: ;body +:: ;div#output; +:: ;div#input +:: ;div.prompt; +:: ;input.line(type "text"); +:: == +:: == +:: =. +.bod (weld `marl`+.bod `marl`~[sic]) +:: ;html +:: ;+ hed +:: ;+ bod +:: == +:: :: +:: ++ rong +:: |= are=ares +:: %- jobe +:: :- [%ok %b |] +:: ?~ are ~ +:: :+ [%err %s p.u.are] +:: :+ %res %s +:: %- crip +:: %+ slag 2 +:: ^- tape +:: %+ roll q.u.are +:: |= [p=tank q=tape] +:: :(weld q "\\n" ~(ram re p)) +:: ~ +:: :: +:: ++ soon +:: |= [ful=? sem=stem ouy=_yo:ya can=@ud mab=?(%mess %show) jon=json] +:: ^+ yo:ya +:: =+ huq=``[%json !>(jon)] +:: ?~ num.sem +:: =+ woy=(yule:ouy ?-(mab %mess %meg, %show %sub)) +:: (hear:woy huq) +:: ?- -.u.num.sem +:: %& +:: =+ yoo=abet:(busk:(yule:ouy %nil) p.u.num.sem 0 huq) +:: yoo(can.sub.siq (~(put by can.sub.siq.yoo) can sem(num ~))) +:: %| +:: =+ ^= yoo +:: =< abet +:: %^ busk:(yule:(hear:(yule:ouy %sub) huq) %nil) +:: p.u.num.sem +:: 0 +:: `[%& %json !>((joba %ok %b &))] +:: yoo(can.sub.siq (~(put by can.sub.siq.yoo) can sem(num ~))) +:: == +:: :: +:: ++ wrap +:: |= [sem=stem jon=json] +:: %- jobe +:: :~ [%ship %s (rsh 3 1 (scot %p p.hap.sem))] +:: [%appl %s q.hap.sem] +:: [%path %s (crip )] +:: [%data `json`jon] +:: == +:: :: ++ ya :: session engine =| [[our=ship ses=hole] serf cyst] =* sef ->- =* cyz ->+ |% - ++ abet :: resolve engine - ^+ ..ya - %= ..ya - own - (~(put by own) our sef(wup (~(put by wup) ses cyz))) - == - :: - ++ auth :: remote authorize - |= him=ship - %_(+> aut.ced (~(put ju aut.ced) %$ (scot %p him))) - :: - ++ dodo :: console s->c - |= [con=@ud sih=sign] - ^+ +> - =+ cal=(need (~(get by cow) con)) - =+ ^= jon ^- json - ?: ?=(%helo -.+.sih) - %+ joba %helo - %- jobe - :~ [%path [%a `(list json)`(turn p.+.sih |=(a=@ta [%s a]))]] - [%prod ~[%a [%s p.q.+.sih] (jape q.q.+.sih) (jape r.q.+.sih)]] - == - %+ joba %text - :- %a ^- (list json) - ?+ -.+.sih ~|(-.+.sih !!) - %tell (turn p.+.sih |=(a=@t [%s a])) - %text [%s (crip p.+.sih)]~ - %talk (turn (~(win re p.+.sih) [0 80]) |=(a=tape [%s (crip a)])) - %warn [%s (crip '!' p.+.sih)]~ - == - =+ ^= yov ^- (list ,@ud) - =+ yov=(~(get by voy.cal) ono.cal) - ?~(yov ~ u.yov) - =: voy.cal (~(del by voy.cal) ono.cal) - ono.cal +(ono.cal) - out.cal [jon out.cal] - == - =. cow (~(put by cow) con cal) - ?~(yov +>.$ (dove ~[%a (jone ono.cal) (jone ino.cal) jon] yov)) - :: - ++ iota :: fun change response - |= [num=@ud rot=riot] - ^+ +> - =+ pup=(~(get by q.rey) num) - ?~ pup - ~& [%iota-lost ses num rot] - +>.$ - ?> ?=(%way pez.u.pup) - +>.$(q.rey (~(put by q.rey) num u.pup(pez [%haz rot]))) - :: - ++ dove :: console waiting - |= [jon=json yov=(list ,@ud)] - ^+ +> - =+ noz=`pest`[%fin %mid /text/json (tact (pojo jon))] - |- ^+ +>.^$ - ?~ yov +>.^$ - =+ pup=(~(get by q.rey) i.yov) - ?~ pup $(yov t.yov) - ?> ?=(%way pez.u.pup) - $(yov t.yov, q.rey (~(put by q.rey) i.yov u.pup(pez noz))) - :: - ++ duty |= [nap=@ud you=ship] :: interface script - ^- cord - %^ cat 3 - %- crip - =- "window.urb = {(pojo (jobe -))}\0a" - :~ - [%ship (jape |1:)] - [%port (jone nap)] - [%oryx %s orx.ced] - [%auto %b %&] - [%user (jape |1:)] - == - ''' - window.urb.seqn_u = 0 - window.urb.seqn_h = 0 - window.urb.dely = 0 - window.urb.puls = 0 - window.urb.cabs = {} - window.urb.perms = { - pol:"gie", - sub:"tis", - uns:"tiu", - mes:"tim", - heb:"tih" - } +:: ++ abet :: resolve engine +:: ^+ ..ya +:: %= ..ya +:: own +:: (~(put by own) our sef(wup (~(put by wup) ses cyz))) +:: == +:: :: +:: ++ auth :: remote authorize +:: |= him=ship +:: %_(+> aut.ced (~(put ju aut.ced) %$ (scot %p him))) +:: :: +:: ++ iota :: fun change response +:: |= [num=@ud rot=riot] +:: ^+ +> +:: =+ pup=(~(get by q.rey) num) +:: ?~ pup +:: ~& [%iota-lost ses num rot] +:: +>.$ +:: ?> ?=(%way pez.u.pup) +:: +>.$(q.rey (~(put by q.rey) num u.pup(pez [%haz rot]))) +:: :: +:: ++ dove :: console waiting +:: |= [jon=json yov=(list ,@ud)] +:: ^+ +> +:: =+ noz=`pest`[%fin %mid /text/json (tact (pojo jon))] +:: |- ^+ +>.^$ +:: ?~ yov +>.^$ +:: =+ pup=(~(get by q.rey) i.yov) +:: ?~ pup $(yov t.yov) +:: ?> ?=(%way pez.u.pup) +:: $(yov t.yov, q.rey (~(put by q.rey) i.yov u.pup(pez noz))) +:: :: +:: ++ duty |= [nap=@ud you=ship] :: interface script +:: ^- cord +:: %^ cat 3 +:: %- crip +:: =- "window.urb = {(pojo (jobe -))}\0a" +:: :~ +:: [%ship (jape |1:)] +:: [%port (jone nap)] +:: [%oryx %s orx.ced] +:: [%auto %b %&] +:: [%user (jape |1:)] +:: == +:: ''' +:: window.urb.seqn_u = 0 +:: window.urb.seqn_h = 0 +:: window.urb.dely = 0 +:: window.urb.puls = 0 +:: window.urb.cabs = {} +:: window.urb.perms = { +:: pol:"gie", +:: sub:"tis", +:: uns:"tiu", +:: mes:"tim", +:: heb:"tih" +:: } - window.urb.req = function(method,url,params,json,cb) { - var xhr = new XMLHttpRequest() - xhr.open(method.toUpperCase(), url) - if(json) - xhr.setRequestHeader("content-type", "text/json") +:: window.urb.req = function(method,url,params,json,cb) { +:: var xhr = new XMLHttpRequest() +:: xhr.open(method.toUpperCase(), url) +:: if(json) +:: xhr.setRequestHeader("content-type", "text/json") - _data = {} - if(params.data) { _data.data = params.data; } - if(params.ship) { _data.ship = params.ship; } - if(params.path) { _data.path = params.path; } - if(params.appl) { _data.appl = params.appl; } - if(params.mark) { _data.mark = params.mark; } - __data = {oryx: window.urb.oryx, xyro: _data} +:: _data = {} +:: if(params.data) { _data.data = params.data; } +:: if(params.ship) { _data.ship = params.ship; } +:: if(params.path) { _data.path = params.path; } +:: if(params.appl) { _data.appl = params.appl; } +:: if(params.mark) { _data.mark = params.mark; } +:: __data = {oryx: window.urb.oryx, xyro: _data} - if(cb) { - xhr.onload = function() { - try { - err = null - res = { - status:this.status, - data: JSON.parse(this.responseText) - } - if(res.data.reload) - res.reload = res.data.reload - } catch(e) { - err = { - message:"Failed to parse JSON", - raw:this.responseText - } - res = null - } - cb(err,res) - } - xhr.onerror = function() { - cb({ - status:this.status, - data:this.responseText - }) - } - } - xhr.send(JSON.stringify(__data)) - } +:: if(cb) { +:: xhr.onload = function() { +:: try { +:: err = null +:: res = { +:: status:this.status, +:: data: JSON.parse(this.responseText) +:: } +:: if(res.data.reload) +:: res.reload = res.data.reload +:: } catch(e) { +:: err = { +:: message:"Failed to parse JSON", +:: raw:this.responseText +:: } +:: res = null +:: } +:: cb(err,res) +:: } +:: xhr.onerror = function() { +:: cb({ +:: status:this.status, +:: data:this.responseText +:: }) +:: } +:: } +:: xhr.send(JSON.stringify(__data)) +:: } - window.urb.reqq = [] - window.urb.qreq = function(method,url,params,json,cb) { - walk = function() { - qobj = {} - qobj.oargs = window.urb.reqq[0] - qobj.nargs = [].slice.apply(qobj.oargs,[0,4]) - qobj.nargs.push(function(){ - if(this.oargs[4]) - this.oargs[4].apply(window.urb,arguments) - window.urb.reqq.shift() - if(window.urb.reqq.length > 0) - walk() - }.bind(qobj)) - window.urb.req.apply(this,qobj.nargs) - } - l = window.urb.reqq.length - window.urb.reqq.push(arguments); - if(l == 0) { walk() } - } +:: window.urb.reqq = [] +:: window.urb.qreq = function(method,url,params,json,cb) { +:: walk = function() { +:: qobj = {} +:: qobj.oargs = window.urb.reqq[0] +:: qobj.nargs = [].slice.apply(qobj.oargs,[0,4]) +:: qobj.nargs.push(function(){ +:: if(this.oargs[4]) +:: this.oargs[4].apply(window.urb,arguments) +:: window.urb.reqq.shift() +:: if(window.urb.reqq.length > 0) +:: walk() +:: }.bind(qobj)) +:: window.urb.req.apply(this,qobj.nargs) +:: } +:: l = window.urb.reqq.length +:: window.urb.reqq.push(arguments); +:: if(l == 0) { walk() } +:: } - window.urb.gsig = function(params) { - path = params.path - if(!path) - path = "" - return params.appl+","+ - path.replace(/[^\x00-\x7F]/g, "")+","+ - params.ship - } +:: window.urb.gsig = function(params) { +:: path = params.path +:: if(!path) +:: path = "" +:: return params.appl+","+ +:: path.replace(/[^\x00-\x7F]/g, "")+","+ +:: params.ship +:: } - window.urb.poll = function(params,cb) { - if(!params) - throw new Error("You must supply params to urb.poll.") +:: window.urb.poll = function(params,cb) { +:: if(!params) +:: throw new Error("You must supply params to urb.poll.") - var method, perm, url, $this - method = "get" - perm = params.type ? this.perms[params.type] : "gie" - json = false - if(perm[0] == "t") { - method = "put" - json = true - } - seqn = this.seqn_u - if(params.seqn) - seqn = params.seqn() - url = [perm,this.user,this.port,seqn] - url = "/"+url.join("/") +:: var method, perm, url, $this +:: method = "get" +:: perm = params.type ? this.perms[params.type] : "gie" +:: json = false +:: if(perm[0] == "t") { +:: method = "put" +:: json = true +:: } +:: seqn = this.seqn_u +:: if(params.seqn) +:: seqn = params.seqn() +:: url = [perm,this.user,this.port,seqn] +:: url = "/"+url.join("/") - this.puls = 1 +:: this.puls = 1 - $this = this - this.req(method,url,params,json,function(err,data) { - if(data){ - if (data.reload) { - return document.location.reload() - } else { - fn = $this.gsig(data.data) - if($this.cabs[fn]) { - $this.cabs[fn].call(this,err, - {status: data.status, data: data.data.data}) - } - } - } +:: $this = this +:: this.req(method,url,params,json,function(err,data) { +:: if(data){ +:: if (data.reload) { +:: return document.location.reload() +:: } else { +:: fn = $this.gsig(data.data) +:: if($this.cabs[fn]) { +:: $this.cabs[fn].call(this,err, +:: {status: data.status, data: data.data.data}) +:: } +:: } +:: } - dely = params.dely ? params.dely : $this.dely +:: dely = params.dely ? params.dely : $this.dely - if(err) - dely = dely+Math.ceil(dely*.02) - else { - $this.dely = 0 - if(params.incs) - params.incs() - else - $this.seqn_u++ - } +:: if(err) +:: dely = dely+Math.ceil(dely*.02) +:: else { +:: $this.dely = 0 +:: if(params.incs) +:: params.incs() +:: else +:: $this.seqn_u++ +:: } - setTimeout(function() { - $this.poll(params,cb) - },dely) - }) - } +:: setTimeout(function() { +:: $this.poll(params,cb) +:: },dely) +:: }) +:: } - if (window.urb.auto) { - var tries = 0 - var cnt = 0 - var param = { - type:"pol" - } - window.urb.poll(param) - } +:: if (window.urb.auto) { +:: var tries = 0 +:: var cnt = 0 +:: var param = { +:: type:"pol" +:: } +:: window.urb.poll(param) +:: } - window.urb.heartbeat = function() { - this.poll({ - type:"heb", - ship:this.ship, - dely:30000, - seqn:function() { - return window.urb.seqn_h - }, - incs:function() { - window.urb.seqn_h = window.urb.seqn_h+1 - } - },function() { - console.log('heartbeat.') - }) - } - window.urb.heartbeat() - ''' - :: - ++ fape :: dispatch %ape - |= [fur=(unit term) you=@p paw=path] - ^- (unit seam) - ?> ?=(~ fur) - ?> ?=([@ @ ~] paw) - :- ~ - :* %ape - you - (slav %ui (cat 3 '0i' i.paw)) - (slav %ui (cat 3 '0i' i.t.paw)) - == - :: - ++ fapg :: dispatch %apg - |= [fur=(unit term) you=@p paw=path] - ^- (unit seam) - =+ for=?^(fur u.fur %html) - ?> ?=(^ paw) - :- ~ - :* %apg - (need ((sand %tas) i.paw)) - you - for - (turn t.paw |=(a=@ `@ta`(need ((sand %ta) a)))) - == - :: - ++ faph :: dispatch %aph - |= [fur=(unit term) you=@p paw=path moh=moth] - ^- (unit seam) - ?> ?=(~ fur) - ?> ?=([@ @ ~] paw) - :- ~ - :* %aph - you - (slav %ui (cat 3 '0i' i.paw)) - (slav %ui (cat 3 '0i' i.t.paw)) - (need (ecci orx.ced moh)) - == - :: - ++ fapm :: dispatch %apm - |= [fur=(unit term) you=@p paw=path moh=moth] - ^- (unit seam) - ?> ?=(~ fur) - ?> ?=([@ @ ~] paw) - :- ~ - :* %apm - you - (slav %ui (cat 3 '0i' i.paw)) - (slav %ui (cat 3 '0i' i.t.paw)) - (need (eccu orx.ced moh)) - == - :: - ++ fapp - |= [fur=(unit term) you=@p paw=path] - ?> ?=([~ %js] fur) - ?> ?=(?([%hart ~] [@ %hart ~]) paw) - :- ~ - :* %app - you - ?~ t.paw - ~ - (some (slav %ui (cat 3 '0i' i.paw))) - == - :: - ++ faps :: dispatch %aps - |= [fur=(unit term) you=@p paw=path moh=moth] - ^- (unit seam) - ?> ?=(~ fur) - ?> ?=([@ ~] paw) - :- ~ - :* %aps - you - (slav %ui (cat 3 '0i' i.paw)) - (need (ecca orx.ced moh)) - == - :: - ++ fapu :: dispatch %apu - |= [fur=(unit term) you=@p paw=path moh=moth] - ^- (unit seam) - ?> ?=(~ fur) - ?> ?=([@ ~] paw) - :- ~ - :* %apu - you - (slav %ui (cat 3 '0i' i.paw)) - (need (ecca orx.ced moh)) - == - :: - ++ flea :: permissive decimal - |= txt=@t - ^- (unit ,@ud) - =+ zac=(slay txt) - ?: ?=([~ %$ %ud @] zac) - [~ q.p.u.zac] - =+ soc=(rush txt dim:ag) - ?~(soc ~ [~ u.soc]) - :: - ++ foal :: url from query - |= [nam=@t yaq=(map ,@t ,@t)] - ^- (unit purl) - (biff (~(get by yaq) %url) epur) - :: - ++ folk :: seal from query - |= quy=quay - ^- (unit seal) - =+ yaq=(~(gas by *(map ,@t ,@t)) quy) - =+ pyl=(foal %url yaq) - =+ wit==(%yes (fall (~(get by yaq) %wit) %no)) - =+ huw=(~(get by yaq) %who) - =+ whu=?~(huw ~ (rush u.huw fed:ag)) - =+ pus=(~(get by yaq) %pas) - =+ tuh=(~(get by yaq) %oth) - =+ thu=?~(tuh ~ (rush u.tuh fed:ag)) - =+ sus=(~(get by yaq) %ses) - =+ foy=?~(sus ~ ?~(thu ~ [~ u.thu u.sus])) - ?~ pyl ~ - ?: &(wit |(=(~ whu) =(~ ses))) ~ - :: ~& [%folk-quay whu u.pyl wit foy pus] - [~ whu u.pyl wit foy pus] - :: - ++ fool :: domestic login get - |= quy=quay - ^- (unit seam) - (bind (folk quy) |=(a=seal [%lon a])) - :: - ++ foom :: domestic login post - |= moh=moth - ^- (unit seam) - ?. ?& ?=(^ r.moh) - :: .= [~ 'application/x-www-form-urlencoded' ~] - :: (~(get by q.moh) 'content-type') - == ~ - =+ yuq=(rush q.u.r.moh yquy:epur) - ?~(yuq ~ (fool u.yuq)) - :: - ++ flub :: console request - |= [paw=(list ,@t) muh=(unit moth)] - ^- (unit seam) - ?: ?=([@ ~] paw) - ?^ muh ~ - =+ fee=(flea i.paw) - ?~ fee ~ - [~ %con u.fee] - ?. ?=([@ @ ~] paw) ~ - =+ [fee=(flea i.paw) fum=(flea i.t.paw)] - ?. &(?=(^ fee) ?=(^ fum)) ~ - ?: |(?=(~ muh) ?=(~ r.u.muh)) - [~ %cog u.fee u.fum] - ?. =([~ 'text/json' ~] (~(get by q.u.muh) 'content-type')) - ~ - =+ jun=`(unit json)`(rush q.u.r.u.muh apex:poja) - ?~ jun - ~ - [~ %cop u.fee u.fum u.jun] - :: +:: window.urb.heartbeat = function() { +:: this.poll({ +:: type:"heb", +:: ship:this.ship, +:: dely:30000, +:: seqn:function() { +:: return window.urb.seqn_h +:: }, +:: incs:function() { +:: window.urb.seqn_h = window.urb.seqn_h+1 +:: } +:: },function() { +:: console.log('heartbeat.') +:: }) +:: } +:: window.urb.heartbeat() +:: ''' +:: :: +:: ++ fape :: dispatch %ape +:: |= [fur=(unit term) you=@p paw=path] +:: ^- (unit seam) +:: ?> ?=(~ fur) +:: ?> ?=([@ @ ~] paw) +:: :- ~ +:: :* %ape +:: you +:: (slav %ui (cat 3 '0i' i.paw)) +:: (slav %ui (cat 3 '0i' i.t.paw)) +:: == +:: :: +:: ++ fapg :: dispatch %apg +:: |= [fur=(unit term) you=@p paw=path] +:: ^- (unit seam) +:: =+ for=?^(fur u.fur %html) +:: ?> ?=(^ paw) +:: :- ~ +:: :* %apg +:: (need ((sand %tas) i.paw)) +:: you +:: for +:: (turn t.paw |=(a=@ `@ta`(need ((sand %ta) a)))) +:: == +:: :: +:: ++ faph :: dispatch %aph +:: |= [fur=(unit term) you=@p paw=path moh=moth] +:: ^- (unit seam) +:: ?> ?=(~ fur) +:: ?> ?=([@ @ ~] paw) +:: :- ~ +:: :* %aph +:: you +:: (slav %ui (cat 3 '0i' i.paw)) +:: (slav %ui (cat 3 '0i' i.t.paw)) +:: (need (ecci orx.ced moh)) +:: == +:: :: +:: ++ fapm :: dispatch %apm +:: |= [fur=(unit term) you=@p paw=path moh=moth] +:: ^- (unit seam) +:: ?> ?=(~ fur) +:: ?> ?=([@ @ ~] paw) +:: :- ~ +:: :* %apm +:: you +:: (slav %ui (cat 3 '0i' i.paw)) +:: (slav %ui (cat 3 '0i' i.t.paw)) +:: (need (eccu orx.ced moh)) +:: == +:: :: +:: ++ fapp +:: |= [fur=(unit term) you=@p paw=path] +:: ?> ?=([~ %js] fur) +:: ?> ?=(?([%hart ~] [@ %hart ~]) paw) +:: :- ~ +:: :* %app +:: you +:: ?~ t.paw +:: ~ +:: (some (slav %ui (cat 3 '0i' i.paw))) +:: == +:: :: +:: ++ faps :: dispatch %aps +:: |= [fur=(unit term) you=@p paw=path moh=moth] +:: ^- (unit seam) +:: ?> ?=(~ fur) +:: ?> ?=([@ ~] paw) +:: :- ~ +:: :* %aps +:: you +:: (slav %ui (cat 3 '0i' i.paw)) +:: (need (ecca orx.ced moh)) +:: == +:: :: +:: ++ fapu :: dispatch %apu +:: |= [fur=(unit term) you=@p paw=path moh=moth] +:: ^- (unit seam) +:: ?> ?=(~ fur) +:: ?> ?=([@ ~] paw) +:: :- ~ +:: :* %apu +:: you +:: (slav %ui (cat 3 '0i' i.paw)) +:: (need (ecca orx.ced moh)) +:: == +:: :: +:: ++ flea :: permissive decimal +:: |= txt=@t +:: ^- (unit ,@ud) +:: =+ zac=(slay txt) +:: ?: ?=([~ %$ %ud @] zac) +:: [~ q.p.u.zac] +:: =+ soc=(rush txt dim:ag) +:: ?~(soc ~ [~ u.soc]) +:: :: +:: ++ foal :: url from query +:: |= [nam=@t yaq=(map ,@t ,@t)] +:: ^- (unit purl) +:: (biff (~(get by yaq) %url) epur) +:: :: +:: ++ folk :: seal from query +:: |= quy=quay +:: ^- (unit seal) +:: =+ yaq=(~(gas by *(map ,@t ,@t)) quy) +:: =+ pyl=(foal %url yaq) +:: =+ wit==(%yes (fall (~(get by yaq) %wit) %no)) +:: =+ huw=(~(get by yaq) %who) +:: =+ whu=?~(huw ~ (rush u.huw fed:ag)) +:: =+ pus=(~(get by yaq) %pas) +:: =+ tuh=(~(get by yaq) %oth) +:: =+ thu=?~(tuh ~ (rush u.tuh fed:ag)) +:: =+ sus=(~(get by yaq) %ses) +:: =+ foy=?~(sus ~ ?~(thu ~ [~ u.thu u.sus])) +:: ?~ pyl ~ +:: ?: &(wit |(=(~ whu) =(~ ses))) ~ +:: :: ~& [%folk-quay whu u.pyl wit foy pus] +:: [~ whu u.pyl wit foy pus] +:: :: +:: ++ fool :: domestic login get +:: |= quy=quay +:: ^- (unit seam) +:: (bind (folk quy) |=(a=seal [%lon a])) +:: :: +:: ++ foom :: domestic login post +:: |= moh=moth +:: ^- (unit seam) +:: ?. ?& ?=(^ r.moh) +:: :: .= [~ 'application/x-www-form-urlencoded' ~] +:: :: (~(get by q.moh) 'content-type') +:: == ~ +:: =+ yuq=(rush q.u.r.moh yquy:epur) +:: ?~(yuq ~ (fool u.yuq)) +:: :: +:: ++ flub :: console request +:: |= [paw=(list ,@t) muh=(unit moth)] +:: ^- (unit seam) +:: ?: ?=([@ ~] paw) +:: ?^ muh ~ +:: =+ fee=(flea i.paw) +:: ?~ fee ~ +:: [~ %con u.fee] +:: ?. ?=([@ @ ~] paw) ~ +:: =+ [fee=(flea i.paw) fum=(flea i.t.paw)] +:: ?. &(?=(^ fee) ?=(^ fum)) ~ +:: ?: |(?=(~ muh) ?=(~ r.u.muh)) +:: [~ %cog u.fee u.fum] +:: ?. =([~ 'text/json' ~] (~(get by q.u.muh) 'content-type')) +:: ~ +:: =+ jun=`(unit json)`(rush q.u.r.u.muh apex:poja) +:: ?~ jun +:: ~ +:: [~ %cop u.fee u.fum u.jun] +:: :: ++ flux :: credential caboose - |= [nyp=path quy=quay] - ^- coin + |= [nyp=path quy=quay] ^- coin :* %many - [%many (turn nyp |=(a=span [%$ %ta a]))] + [%$ %ta ~] [%blob ced] |- ^- (list coin) ?~ quy ~ [[%$ %t p.i.quy] [%$ %t q.i.quy] $(quy t.quy)] == +:: :: +:: ++ foin :: version request +:: |= [fur=(unit term) you=@p paw=(list ,@t) quy=quay] +:: ^- (unit seam) +:: =. aut.ced (~(put ju aut.ced) %$ (scot %p you)) :: XX backwards +:: ?. ?& ?=(~ fur) +:: ?=(~ quy) +:: ?=([@ @ ~] paw) +:: ((sane %tas) i.t.paw) +:: == ~ +:: %+ bind +:: ^- (unit moat) +:: =+ soy=(slay i.paw) +:: ?~ soy ~ +:: ?+ u.soy +:: ~ +:: :: +:: [%$ ?(%da %ud %tas) @] +:: [~ (case p.u.soy) (case p.u.soy) /] +:: :: +:: [%many [%$ ?(%da %ud %tas) @] [%$ ?(%da %ud %tas) @] ~] +:: [~ (case i.p.u.soy) (case i.t.p.u.soy) /] +:: == +:: |= mot=moat +:: `seam`[%det i.t.paw mot] +:: :: +:: ++ funk :: functional request +:: |= [nep=@tas fur=(unit term) you=@p paw=(list ,@t) quy=quay] +:: ^- (unit seam) +:: =. aut.ced (~(put ju aut.ced) %$ (scot %p you)) :: XX backwards +:: =+ won==(%n (rsh 3 2 nep)) +:: %+ bind +:: ^- (unit ,[mark tube]) +:: =+ ^= zac ^- (unit ,[p=@ta q=path]) +:: ?: won +:: [~ (scot %da now) paw] +:: ?~ paw ~ +:: =+ zac=(slay i.paw) +:: ?. ?=([~ %$ ?(%ud %da %tas) *] zac) ~ +:: [~ i.paw t.paw] +:: ?: ?| ?=(~ zac) +:: ?=(~ q.u.zac) +:: !(levy t.q.u.zac (sane %ta)) +:: == ~ +:: :+ ~ ?~(fur %html u.fur) +:: ^- tube +:: :* (scot %p our) +:: i.q.u.zac +:: p.u.zac +:: t.q.u.zac +:: == +:: |= [for=mark toe=tube] +:: ^- seam +:: =+ nyp=?.(=(%i (cut 3 [1 1] nep)) /[nep] /[nep]/(rsh 3 1 (scot %p you))) +:: :^ %fun for +:: toe(s (weld s.toe `path`[(flux nyp quy) %web ~])) +:: ?. won ~ +:: :_ ~ +:: =- =+ pey="{(scag 2 (trip nep))}v" +:: =. pey %+ weld pey +:: ?. =(%i (snag 1 pey)) +:: "" +:: "/{(slag 1 (scow %p you))}" +:: =+ ven=+((,@ (need (sky %cw p.toe q.toe r.toe ~)))) +:: =+ ^= cal :/ +:: "path='". +:: "/{pey}". +:: "/{(scow %ud ven)}". +:: "/{(trip q.toe)}';" +:: [-.sac [cal +.sac]] +:: ^= sac +:: ;script +:: ; +:: ; tries = 0; +:: ; call = function() { +:: ; xhr = new XMLHttpRequest(); +:: ; xhr.open('GET', path, true); +:: ; xhr.addEventListener('load', function() { +:: ; if(this.status !== 200) { +:: ; return keep(); +:: ; } +:: ; document.location.reload(); +:: ; }); +:: ; xhr.addEventListener('error', keep); +:: ; xhr.addEventListener('abort', keep); +:: ; xhr.send(); +:: ; } +:: ; keep = function() { +:: ; setTimeout(call,1000*tries); +:: ; tries++; +:: ; } +:: ; call(); +:: == +:: :: +:: ++ holt :: login redirect +:: |= [whu=(unit ship) pul=purl] +:: ^- (unit seam) +:: :+ ~ +:: %red +:: :: :+ [p.p.pul q.p.pul r.p.pul] +:: :+ [| q.p.pul r.p.pul] :: XX https +:: [p.q.pul /gul] :: XX js discrimination +:: :- [%url (crip (earn pul(p.p |)))] +:: ?~ whu ~ +:: [%who (rsh 3 1 (scot %p u.whu))]~ +:: :: +:: ++ holy :: structured request +:: |= [pul=purl moh=moth] +:: ^- (unit seam) +:: ?~ q.q.pul ~ +:: =* nep i.q.q.pul +:: =+ paw=t.q.q.pul +:: =+ [one=(end 3 1 nep) two=(cut 3 [1 1] nep) tri=(cut 3 [2 1] nep)] +:: ?. ?& ?- p.moh +:: %conn | :: connect +:: %delt | :: delete +:: %get =(%g one) :: get +:: %head =(%g one) :: head +:: %opts | :: options +:: %post =(%p one) :: post +:: %put =(%t one) :: put +:: %trac | :: trace +:: == +:: :: +:: ?+ two | +:: %e & :: stranger +:: %u p.p.pul :: guest +:: %i p.p.pul :: neighbor +:: %o p.p.pul :: identified +:: == +:: :: +:: ?= $? %g :: app get +:: %c :: console +:: %e :: app update +:: %f :: functional +:: %v :: functional version +:: %l :: local login +:: %m :: app message +:: %r :: app response +:: %s :: app subscribe +:: %h :: app heartbeat +:: %p :: app script by port +:: %n :: now +:: %u :: app unsubscribe +:: %z :: app version +:: == +:: tri +:: :: +:: !&(=(%c tri) !=(%o two)) +:: =(3 (met 3 nep)) +:: == +:: ?: &(=(%get p.moh) ?=([~ [@ ~]] q.pul)) :: app shortcut +:: =- $(q.pul [`%html -]) +:: =+ ato=(~(tap in (~(get ju aut.ced) %$))) +:: =+ att=`(list ship)`(murn ato |=(a=span (slaw %p a))) +:: ?~ att [%geg i.q.q.pul ~] +:: ?: (~(has in (sa att)) our) +:: [%gog i.q.q.pul ~] +:: :+ %gig +:: (rsh 3 1 (scot %p (snag 0 (sort att lth)))) +:: /[i.q.q.pul] +:: ~ +:: =^ yun paw +:: ?+ two ~ +:: ?(%e %u) [`@`(shaf %fake ses) paw] +:: %i ?~ paw ~ +:: [(slav %p (cat 3 '~' i.paw)) t.paw] +:: %o [our paw] +:: == +:: ?: &(=(%i two) !(lash yun) !=(yun (shaf %fake ses))) +:: (holt [~ yun] pul) +:: ?: &(=(%o two) !(lash our)) +:: (holt [~ our] pul) +:: ?+ one ~ +:: %g +:: ?+ tri ~ +:: ?(%f %n) (funk nep p.q.pul yun paw r.pul) +:: %v (foin p.q.pul yun paw r.pul) +:: %c (flub paw ~) +:: %l (fool r.pul) +:: %g (fapg p.q.pul yun paw) +:: %e (fape p.q.pul yun paw) +:: %p (fapp p.q.pul yun paw) +:: == +:: :: +:: %p +:: ?+ tri ~ +:: %l (foom moh) +:: %m (fapm p.q.pul yun paw moh) +:: %s (faps p.q.pul yun paw moh) +:: %u (fapu p.q.pul yun paw moh) +:: == +:: :: +:: %t +:: ?+ tri ~ +:: %c (flub paw [~ moh]) +:: %h (faph p.q.pul yun paw moh) +:: %m (fapm p.q.pul yun paw moh) +:: %s (faps p.q.pul yun paw moh) +:: %u (fapu p.q.pul yun paw moh) +:: == +:: == +:: :: +:: ++ idle :: cancel request +:: |= num=@ud +:: ^+ +> +:: =+ pup=(~(get by q.rey) num) +:: ?~ pup +>.$ +:: =. q.rey (~(del by q.rey) num) +:: ?. ?=(%way pez.u.pup) +>.$ +:: ?: ?=(%det -.som.u.pup) +:: +>.$(..ya (hoot our num ses `riff`[p.som.u.pup ~])) +:: ?: ?=(%fun -.som.u.pup) +:: +>.$(..ya (hone our num ses)) +:: +>.$ +:: :: +:: ++ bush :: error response +:: |= [cod=@ud msg=@t num=@ud] +:: ^+ +> +:: =+ pup=(~(get by q.rey) num) +:: ?~ pup +>.$ +:: %= +>.$ +:: q.rey +:: %+ ~(put by q.rey) num +:: %= u.pup +:: pez +:: `pest`[%fin %raw cod ~[content-type/'text/plain'] `(taco msg)] +:: == +:: == +:: :: +:: ++ bust :: no-content response +:: |= [cod=@ud num=@ud] +:: ^+ +> +:: =+ pup=(~(get by q.rey) num) +:: ?~ pup +>.$ +:: :: ?> ?=(%way pez.u.pup) +:: %= +>.$ +:: q.rey +:: %+ ~(put by q.rey) num +:: u.pup(pez [%fin %raw cod *mess `*octs]) +:: == +:: :: +:: ++ erle :: url localize +:: |= [his=ship pul=purl] ^- purl +:: =+ pod=(mo (turn (~(tap by dop)) |=([p=host q=ship] [q p]))) +:: ?: (~(has by pod) his) +:: pul(p [& ~ (~(got by pod) his)]) +:: ?: ?=(hoke r.p.pul) +:: ~| %no-port +:: pul(q.p [~ ?+(his !! %~zod 8.443)]) :: XX +:: pul(p [& ~ [~ /org/urbit/(rsh 3 1 (scot %p his))]]) +:: :: +:: ++ inch :: function built +:: |= [num=@ud mez=(each bead (list tank))] +:: ^+ +> +:: =+ pup=(~(get by q.rey) num) +:: ?~ pup +:: ~& [%inch-lost ses num mez] +:: +>.$ +:: ?> ?=(%way pez.u.pup) +:: +>.$(q.rey (~(put by q.rey) num u.pup(pez [%fud mez]))) +:: :: +:: ++ into :: introduce +:: |= [pul=purl moh=moth] +:: ^+ +> +:: =+ num=p.rey +:: %= +>.$ +:: lor (~(put by lor) hen num [%& our ses]) +:: p.rey +(num) +:: q.rey +:: %+ ~(put by q.rey) num +:: ^- pimp +:: :* !?=(%head p.moh) +:: p.q.pul +:: hen +:: *seam +:: `pest`[%raw pul moh] +:: ~ +:: == +:: == +:: :: +:: ++ iota :: change response +:: |= [num=@ud rot=riot] +:: ^+ +> +:: =+ pup=(~(get by q.rey) num) +:: ?~ pup +:: ~& [%iota-lost ses num rot] +:: +>.$ +:: ?> ?=(%way pez.u.pup) +:: +>.$(q.rey (~(put by q.rey) num u.pup(pez [%haz rot]))) +:: :: +:: ++ lass :: load secret +:: ^- @ta +:: =+ pax=/(scot %p our)/code/(scot %da now)/(scot %p our) +:: %^ rsh 3 1 +:: (scot %p (,@ (need (sky %a pax)))) +:: :: +:: ++ lash :: user is authorized +:: |=(a=ship (~(has ju aut.ced) %$ (scot %p a))) +:: :: +:: ++ redi :: js login redirect +:: |= pul=purl ^- tape +:: "window.location = '{(earn pul)}". +:: "{?~(r.pul "?" "&")}url=' +". +:: "encodeURIComponent(window.location)" +:: :: +:: ++ step :: step in work +:: |- ^+ + +:: =^ zib +.$ +:: =+ yub=q.rey +:: |- ^- [(list ,[p=@ud q=pimp]) _+.^$] +:: ?~ yub [~ +.^$] +:: =^ sid +.^$ $(yub l.yub) +:: =^ dex +.^$ $(yub r.yub) +:: =^ top +.^$ (wink n.yub) +:: =+ pot=`(list ,[p=@ud q=pimp])`?~(top ~ [[p.n.yub u.top] ~]) +:: [:(weld pot dex sid) +.^$] +:: +.$(q.rey (~(gas by `_q.rey`~) zib)) :: - ++ foin :: version request - |= [fur=(unit term) you=@p paw=(list ,@t) quy=quay] - ^- (unit seam) - =. aut.ced (~(put ju aut.ced) %$ (scot %p you)) :: XX backwards - ?. ?& ?=(~ fur) - ?=(~ quy) - ?=([@ @ ~] paw) - ((sane %tas) i.t.paw) - == ~ - %+ bind - ^- (unit moat) - =+ soy=(slay i.paw) - ?~ soy ~ - ?+ u.soy - ~ - :: - [%$ ?(%da %ud %tas) @] - [~ (case p.u.soy) (case p.u.soy) /] - :: - [%many [%$ ?(%da %ud %tas) @] [%$ ?(%da %ud %tas) @] ~] - [~ (case i.p.u.soy) (case i.t.p.u.soy) /] - == - |= mot=moat - `seam`[%det i.t.paw mot] +:: ++ wink :: advance request +:: |= [num=@ud pip=pimp] +:: ^- [(unit pimp) _+>] +:: :: ~& wink-do/[?@(pez.pip pez.pip -.pez.pip) -.som.pip] +:: ?- pez.pip +:: %way [[~ pip] +>.$] +:: %new +:: ?- -.som.pip +:: %ape :: stream update +:: :: ~& :~ %eyre-ape +:: :: [%owner our] +:: :: [%requester num] +:: :: [%app p.som.pip] +:: :: [%user q.som.pip] +:: :: [%instance r.som.pip] +:: :: [%stream s.som.pip] +:: :: [%request t.som.pip] +:: :: == +:: [`(fall +< -(pez %way)) +>]:[pip (yoke num +.som.pip)] +:: :: +:: %apg :: simple get +:: :: ~& :~ %eyre-apg +:: :: [%owner our] +:: :: [%requester num] +:: :: [%app p.som.pip] +:: :: [%user q.som.pip] +:: :: [%logo r.som.pip] +:: :: [%path s.som.pip] +:: :: == +:: :- [~ pip(pez %way)] +:: (yokg num p.som.pip q.som.pip s.som.pip) +:: :: +:: %aph :: heartbeat +:: :: ~& [%wink-aph +.som.pip] +:: (yokh num +.som.pip) +:: :: +:: %apm :: message +:: :: ~& [%wink-apm +.som.pip] +:: :- [~ pip(pez %way)] +:: (yokm num +.som.pip) +:: :: +:: %app :: script by port +:: :: ~& [%wink-app +.som.pip] +:: (yokp num +.som.pip) +:: :: +:: %aps :: subscribe +:: :: ~& [%wink-aps +.som.pip] +:: :- [~ pip(pez %way)] +:: (yoks num +.som.pip) +:: :: +:: %apu :: unsubscribe +:: :: ~& [%wink-apu +.som.pip] +:: (yoku num +.som.pip) +:: :: +:: %con +:: !! +:: :: +:: %cog +:: !! +:: :: +:: %cop +:: !! +:: :: +:: %det +:: :- [~ pip(pez %way)] +:: +>.$(..ya (hoot our num ses [p.som.pip ~ [%| q.som.pip]])) +:: :: +:: %fun +:: :- [~ pip(pez %way)] +:: =+ bem=`beam`(need (tome q.som.pip)) +:: =+ kas=`silk`[%cast %mime `silk`[%boil p.som.pip bem ~]] +:: +>.$(..ya (honk our num ses kas)) +:: :: +:: %lon +:: ^- [(unit pimp) _+>.$] +:: ?~ pus.p.som.pip +:: :_ +>.$ +:: ?: ?~ whu.p.som.pip | +:: (lash u.whu.p.som.pip) +:: [~ pip(som [%red pul.p.som.pip])] +:: ?: wit.p.som.pip +:: [~ pip(pez [%who %$ (scot %p (need whu.p.som.pip))])] +:: =+ rul=(earn pul.p.som.pip) +:: =+ sus=?~(foy.p.som.pip ses q.u.foy.p.som.pip) +:: ~& auth-request/secret=`cord`lass +:: =+ ham=(noon our sus whu.p.som.pip rul) +:: [~ pip(pez [%fin %ham ham])] +:: ?. =(lass u.pus.p.som.pip) +:: :_ +>.$ +:: :- ~ +:: %= pip +:: pez +:: [%fin %mid /text/json (tact (pojo (jobe [%ok [%b |]]~)))] +:: == +:: =. aut.ced (~(put ju aut.ced) %$ (scot %p (need whu.p.som.pip))) +:: ?~ foy.p.som.pip +:: =+ ^= jon +:: %- jobe +:: :~ [%ok [%b &]] +:: [%next (jape (earn pul.p.som.pip))] +:: == +:: :_(+>.$ [~ pip(pez [%fin %mid /text/json (tact (pojo jon))])]) +:: =. ..ya (haji our u.foy.p.som.pip) +:: =+ ^= lup ^- purl +:: %+ erle p.u.foy.p.som.pip +:: :+ `hart`p.pul.p.som.pip +:: ^- pork +:: [~ /gul] +:: ^- quay +:: :~ [%who (rsh 3 1 (scot %p (need whu.p.som.pip)))] +:: [%url (crip (earn pul.p.som.pip))] +:: [%wit %yes] +:: == +:: =+ jon=(jobe ~[[%ok [%b &]] [%next (jape (earn lup))]]) +:: :_(+>.$ [~ pip(pez [%fin %mid /text/json (tact (pojo jon))])]) +:: :: +:: %red +:: :_ +>.$ +:: :- ~ +:: %= pip +:: pez +:: :- %fin +:: =+ pul=p.som.pip +:: ?: ?=([~ %js] p.q.pul) :: XX js discrimination +:: [%mid /application/javascript (tact (redi pul(p.q ~)))] +:: =. p.q.pul ~ +:: :- %raw +:: :+ 307 +:: [%location (crip (earn pul))]~ +:: ~ +:: == +:: :: +:: %sil +:: :- [~ pip(pez %way)] +:: +>.$(..ya (honk our num ses q.som.pip)) +:: == +:: :: +:: [%err *] +:: [~ +>.$(..ya (muff(hen hen.pip) [%thou (loft `love`[%zap +.pez.pip])]))] +:: :: +:: [%fin *] +:: =+ har=(loft p.pez.pip) +:: =. q.har (weld (turn cug |=(a=@t ['set-cookie' a])) q.har) +:: [~ +>.$(..ya (muff(hen hen.pip) [%thou har]))] +:: :: +:: [%haz *] +:: :_ +>.$ +:: [~ pip(pez [%fin %wan 'Hello, world' ~])] +:: :: +:: [%fud *] +:: =+ ^= mog ^- (list manx) +:: ?: ?=(%fun -.som.pip) +:: (weld r.som.pip sip.pip) +:: sip.pip +:: :_ +>.$ +:: :- ~ +:: %= pip +:: pez +:: ^- pest +:: ?- -.p.pez.pip +:: | =+ mad=(loga "server error" mog p.p.pez.pip) +:: :- %fin +:: :- %raw +:: ^- httr +:: :+ 500 +:: ~[content-type/'text/html'] +:: [~ (tact (poxo mad))] +:: & [%fin (lofa mog (lopo q.p.p.pez.pip))] +:: == +:: == +:: :: +:: [%raw *] +:: :_ +>.$ +:: ^- (unit pimp) +:: :- ~ +:: =+ hoy=(holy p.pez.pip) +:: ?~ hoy +:: pip(pez [%err 404 [[%leaf "invalid request"] ~]]) +:: pip(som u.hoy, pez %new) +:: :: +:: [%who *] +:: :_ +>.$ +:: ?.((~(has ju aut.ced) p.pez.pip q.pez.pip) [~ pip] [~ pip(pez %new)]) +:: == :: - ++ funk :: functional request - |= [nep=@tas fur=(unit term) you=@p paw=(list ,@t) quy=quay] - ^- (unit seam) - =. aut.ced (~(put ju aut.ced) %$ (scot %p you)) :: XX backwards - =+ won==(%n (rsh 3 2 nep)) - %+ bind - ^- (unit ,[mark tube]) - =+ ^= zac ^- (unit ,[p=@ta q=path]) - ?: won - [~ (scot %da now) paw] - ?~ paw ~ - =+ zac=(slay i.paw) - ?. ?=([~ %$ ?(%ud %da %tas) *] zac) ~ - [~ i.paw t.paw] - ?: ?| ?=(~ zac) - ?=(~ q.u.zac) - !(levy t.q.u.zac (sane %ta)) - == ~ - :+ ~ ?~(fur %html u.fur) - ^- tube - :* (scot %p our) - i.q.u.zac - p.u.zac - t.q.u.zac - == - |= [for=mark toe=tube] - ^- seam - =+ nyp=?.(=(%i (cut 3 [1 1] nep)) /[nep] /[nep]/(rsh 3 1 (scot %p you))) - :^ %fun for - toe(s (weld s.toe `path`[~(rent co (flux nyp quy)) %web ~])) - ?. won ~ - :_ ~ - =- =+ pey="{(scag 2 (trip nep))}v" - =. pey %+ weld pey - ?. =(%i (snag 1 pey)) - "" - "/{(slag 1 (scow %p you))}" - =+ ven=+((,@ (need (sky %cw p.toe q.toe r.toe ~)))) - =+ ^= cal :/ - "path='". - "/{pey}". - "/{(scow %ud ven)}". - "/{(trip q.toe)}';" - [-.sac [cal +.sac]] - ^= sac - ;script - ; - ; tries = 0; - ; call = function() { - ; xhr = new XMLHttpRequest(); - ; xhr.open('GET', path, true); - ; xhr.addEventListener('load', function() { - ; if(this.status !== 200) { - ; return keep(); - ; } - ; document.location.reload(); - ; }); - ; xhr.addEventListener('error', keep); - ; xhr.addEventListener('abort', keep); - ; xhr.send(); - ; } - ; keep = function() { - ; setTimeout(call,1000*tries); - ; tries++; - ; } - ; call(); - == - :: - ++ holt :: login redirect - |= [whu=(unit ship) pul=purl] - ^- (unit seam) - :+ ~ - %red - :: :+ [p.p.pul q.p.pul r.p.pul] - :+ [| q.p.pul r.p.pul] :: XX https - [p.q.pul /gul] :: XX js discrimination - :- [%url (crip (earn pul(p.p |)))] - ?~ whu ~ - [%who (rsh 3 1 (scot %p u.whu))]~ - :: - ++ holy :: structured request - |= [pul=purl moh=moth] - ^- (unit seam) - ?~ q.q.pul ~ - =* nep i.q.q.pul - =+ paw=t.q.q.pul - =+ [one=(end 3 1 nep) two=(cut 3 [1 1] nep) tri=(cut 3 [2 1] nep)] - ?. ?& ?- p.moh - %conn | :: connect - %delt | :: delete - %get =(%g one) :: get - %head =(%g one) :: head - %opts | :: options - %post =(%p one) :: post - %put =(%t one) :: put - %trac | :: trace - == - :: - ?+ two | - %e & :: stranger - %u p.p.pul :: guest - %i p.p.pul :: neighbor - %o p.p.pul :: identified - == - :: - ?= $? %g :: app get - %c :: console - %e :: app update - %f :: functional - %v :: functional version - %l :: local login - %m :: app message - %r :: app response - %s :: app subscribe - %h :: app heartbeat - %p :: app script by port - %n :: now - %u :: app unsubscribe - %z :: app version - == - tri - :: - !&(=(%c tri) !=(%o two)) - =(3 (met 3 nep)) - == - ?: &(=(%get p.moh) ?=([~ [@ ~]] q.pul)) :: app shortcut - =- $(q.pul [`%html -]) - =+ ato=(~(tap in (~(get ju aut.ced) %$))) - =+ att=`(list ship)`(murn ato |=(a=span (slaw %p a))) - ?~ att [%geg i.q.q.pul ~] - ?: (~(has in (sa att)) our) - [%gog i.q.q.pul ~] - :+ %gig - (rsh 3 1 (scot %p (snag 0 (sort att lth)))) - /[i.q.q.pul] - ~ - =^ yun paw - ?+ two ~ - ?(%e %u) [`@`(shaf %fake ses) paw] - %i ?~ paw ~ - [(slav %p (cat 3 '~' i.paw)) t.paw] - %o [our paw] - == - ?: &(=(%i two) !(lash yun) !=(yun (shaf %fake ses))) - (holt [~ yun] pul) - ?: &(=(%o two) !(lash our)) - (holt [~ our] pul) - ?+ one ~ - %g - ?+ tri ~ - ?(%f %n) (funk nep p.q.pul yun paw r.pul) - %v (foin p.q.pul yun paw r.pul) - %c (flub paw ~) - %l (fool r.pul) - %g (fapg p.q.pul yun paw) - %e (fape p.q.pul yun paw) - %p (fapp p.q.pul yun paw) - == - :: - %p - ?+ tri ~ - %l (foom moh) - %m (fapm p.q.pul yun paw moh) - %s (faps p.q.pul yun paw moh) - %u (fapu p.q.pul yun paw moh) - == - :: - %t - ?+ tri ~ - %c (flub paw [~ moh]) - %h (faph p.q.pul yun paw moh) - %m (fapm p.q.pul yun paw moh) - %s (faps p.q.pul yun paw moh) - %u (fapu p.q.pul yun paw moh) - == - == - :: - ++ idle :: cancel request - |= num=@ud - ^+ +> - =+ pup=(~(get by q.rey) num) - ?~ pup +>.$ - =. q.rey (~(del by q.rey) num) - ?. ?=(%way pez.u.pup) +>.$ - ?: ?=(%det -.som.u.pup) - +>.$(..ya (hoot our num ses `riff`[p.som.u.pup ~])) - ?: ?=(%fun -.som.u.pup) - +>.$(..ya (hone our num ses)) - +>.$ - :: - ++ bush :: error response - |= [cod=@ud msg=@t num=@ud] - ^+ +> - =+ pup=(~(get by q.rey) num) - ?~ pup +>.$ - %= +>.$ - q.rey - %+ ~(put by q.rey) num - %= u.pup - pez - `pest`[%fin %raw cod ~[content-type/'text/plain'] `(taco msg)] - == - == - :: - ++ bust :: no-content response - |= [cod=@ud num=@ud] - ^+ +> - =+ pup=(~(get by q.rey) num) - ?~ pup +>.$ - :: ?> ?=(%way pez.u.pup) - %= +>.$ - q.rey - %+ ~(put by q.rey) num - u.pup(pez [%fin %raw cod *mess `*octs]) - == - :: - ++ erle :: url localize - |= [his=ship pul=purl] ^- purl - =+ pod=(mo (turn (~(tap by dop)) |=([p=host q=ship] [q p]))) - ?: (~(has by pod) his) - pul(p [& ~ (~(got by pod) his)]) - ?: ?=(hoke r.p.pul) - ~| %no-port - pul(q.p [~ ?+(his !! %~zod 8.443)]) :: XX - pul(p [& ~ [~ /org/urbit/(rsh 3 1 (scot %p his))]]) - :: - ++ inch :: function built - |= [num=@ud mez=(each bead (list tank))] - ^+ +> - =+ pup=(~(get by q.rey) num) - ?~ pup - ~& [%inch-lost ses num mez] - +>.$ - ?> ?=(%way pez.u.pup) - +>.$(q.rey (~(put by q.rey) num u.pup(pez [%fud mez]))) - :: - ++ into :: introduce - |= [pul=purl moh=moth] - ^+ +> - =+ num=p.rey - %= +>.$ - lor (~(put by lor) hen num [%& our ses]) - p.rey +(num) - q.rey - %+ ~(put by q.rey) num - ^- pimp - :* !?=(%head p.moh) - p.q.pul - hen - *seam - `pest`[%raw pul moh] - ~ - == - == - :: - ++ iota :: change response - |= [num=@ud rot=riot] - ^+ +> - =+ pup=(~(get by q.rey) num) - ?~ pup - ~& [%iota-lost ses num rot] - +>.$ - ?> ?=(%way pez.u.pup) - +>.$(q.rey (~(put by q.rey) num u.pup(pez [%haz rot]))) - :: - ++ lass :: load secret - ^- @ta - =+ pax=/(scot %p our)/code/(scot %da now)/(scot %p our) - %^ rsh 3 1 - (scot %p (,@ (need (sky %a pax)))) - :: - ++ lash :: user is authorized - |=(a=ship (~(has ju aut.ced) %$ (scot %p a))) - :: - ++ redi :: js login redirect - |= pul=purl ^- tape - "window.location = '{(earn pul)}". - "{?~(r.pul "?" "&")}url=' +". - "encodeURIComponent(window.location)" - :: - ++ step :: step in work - |- ^+ + - =^ zib +.$ - =+ yub=q.rey - |- ^- [(list ,[p=@ud q=pimp]) _+.^$] - ?~ yub [~ +.^$] - =^ sid +.^$ $(yub l.yub) - =^ dex +.^$ $(yub r.yub) - =^ top +.^$ (wink n.yub) - =+ pot=`(list ,[p=@ud q=pimp])`?~(top ~ [[p.n.yub u.top] ~]) - [:(weld pot dex sid) +.^$] - +.$(q.rey (~(gas by `_q.rey`~) zib)) - :: - ++ wink :: advance request - |= [num=@ud pip=pimp] - ^- [(unit pimp) _+>] - :: ~& wink-do/[?@(pez.pip pez.pip -.pez.pip) -.som.pip] - ?- pez.pip - %way [[~ pip] +>.$] - %new - ?- -.som.pip - %ape :: stream update - :: ~& :~ %eyre-ape - :: [%owner our] - :: [%requester num] - :: [%app p.som.pip] - :: [%user q.som.pip] - :: [%instance r.som.pip] - :: [%stream s.som.pip] - :: [%request t.som.pip] - :: == - [`(fall +< -(pez %way)) +>]:[pip (yoke num +.som.pip)] - :: - %apg :: simple get - :: ~& :~ %eyre-apg - :: [%owner our] - :: [%requester num] - :: [%app p.som.pip] - :: [%user q.som.pip] - :: [%logo r.som.pip] - :: [%path s.som.pip] - :: == - :- [~ pip(pez %way)] - (yokg num p.som.pip q.som.pip s.som.pip) - :: - %aph :: heartbeat - :: ~& [%wink-aph +.som.pip] - (yokh num +.som.pip) - :: - %apm :: message - :: ~& [%wink-apm +.som.pip] - :- [~ pip(pez %way)] - (yokm num +.som.pip) - :: - %app :: script by port - :: ~& [%wink-app +.som.pip] - (yokp num +.som.pip) - :: - %aps :: subscribe - :: ~& [%wink-aps +.som.pip] - :- [~ pip(pez %way)] - (yoks num +.som.pip) - :: - %apu :: unsubscribe - :: ~& [%wink-apu +.som.pip] - (yoku num +.som.pip) - :: - %con - !! - :: - %cog - !! - :: - %cop - !! - :: - %det - :- [~ pip(pez %way)] - +>.$(..ya (hoot our num ses [p.som.pip ~ [%| q.som.pip]])) - :: - %fun - :- [~ pip(pez %way)] - =+ bem=`beam`(need (tome q.som.pip)) - =+ kas=`silk`[%cast %mime `silk`[%boil p.som.pip bem ~]] - +>.$(..ya (honk our num ses kas)) - :: - %lon - ^- [(unit pimp) _+>.$] - ?~ pus.p.som.pip - :_ +>.$ - ?: ?~ whu.p.som.pip | - (lash u.whu.p.som.pip) - [~ pip(som [%red pul.p.som.pip])] - ?: wit.p.som.pip - [~ pip(pez [%who %$ (scot %p (need whu.p.som.pip))])] - =+ rul=(earn pul.p.som.pip) - =+ sus=?~(foy.p.som.pip ses q.u.foy.p.som.pip) - ~& auth-request/secret=`cord`lass - =+ ham=(noon our sus whu.p.som.pip rul) - [~ pip(pez [%fin %ham ham])] - ?. =(lass u.pus.p.som.pip) - :_ +>.$ - :- ~ - %= pip - pez - [%fin %mid /text/json (tact (pojo (jobe [%ok [%b |]]~)))] - == - =. aut.ced (~(put ju aut.ced) %$ (scot %p (need whu.p.som.pip))) - ?~ foy.p.som.pip - =+ ^= jon - %- jobe - :~ [%ok [%b &]] - [%next (jape (earn pul.p.som.pip))] - == - :_(+>.$ [~ pip(pez [%fin %mid /text/json (tact (pojo jon))])]) - =. ..ya (haji our u.foy.p.som.pip) - =+ ^= lup ^- purl - %+ erle p.u.foy.p.som.pip - :+ `hart`p.pul.p.som.pip - ^- pork - [~ /gul] - ^- quay - :~ [%who (rsh 3 1 (scot %p (need whu.p.som.pip)))] - [%url (crip (earn pul.p.som.pip))] - [%wit %yes] - == - =+ jon=(jobe ~[[%ok [%b &]] [%next (jape (earn lup))]]) - :_(+>.$ [~ pip(pez [%fin %mid /text/json (tact (pojo jon))])]) - :: - %red - :_ +>.$ - :- ~ - %= pip - pez - :- %fin - =+ pul=p.som.pip - ?: ?=([~ %js] p.q.pul) :: XX js discrimination - [%mid /application/javascript (tact (redi pul(p.q ~)))] - =. p.q.pul ~ - :- %raw - :+ 307 - [%location (crip (earn pul))]~ - ~ - == - :: - %sil - :- [~ pip(pez %way)] - +>.$(..ya (honk our num ses q.som.pip)) - == - :: - [%err *] - [~ +>.$(..ya (muff(hen hen.pip) [%thou (loft `love`[%zap +.pez.pip])]))] - :: - [%fin *] - =+ har=(loft p.pez.pip) - =. q.har (weld (turn cug |=(a=@t ['set-cookie' a])) q.har) - [~ +>.$(..ya (muff(hen hen.pip) [%thou har]))] - :: - [%haz *] - :_ +>.$ - [~ pip(pez [%fin %wan 'Hello, world' ~])] - :: - [%fud *] - =+ ^= mog ^- (list manx) - ?: ?=(%fun -.som.pip) - (weld r.som.pip sip.pip) - sip.pip - :_ +>.$ - :- ~ - %= pip - pez - ^- pest - ?- -.p.pez.pip - | =+ mad=(loga "server error" mog p.p.pez.pip) - :- %fin - :- %raw - ^- httr - :+ 500 - ~[content-type/'text/html'] - [~ (tact (poxo mad))] - & [%fin (lofa mog (lopo q.p.p.pez.pip))] - == - == - :: - [%raw *] - :_ +>.$ - ^- (unit pimp) - :- ~ - =+ hoy=(holy p.pez.pip) - ?~ hoy - pip(pez [%err 404 [[%leaf "invalid request"] ~]]) - pip(som u.hoy, pez %new) - :: - [%who *] - :_ +>.$ - ?.((~(has ju aut.ced) p.pez.pip q.pez.pip) [~ pip] [~ pip(pez %new)]) - == - :: - ++ work - |- ^+ + - =+ sez=step - ?: =(rey.sez rey) sez - $(+ sez) - :: - ++ yoke :: long poll - |= [num=@ud you=ship nap=@ud cnt=@ud] - ^- [(unit pimp) _+>] - =+ yon=(yolk nap) - ?~ yon `(bust 204 num) - =. +>.$ abet:(hire:(yule %sub):u.yon cnt num) - :_ +>.$ - =+ pup=(~(get by q.rey) num) - ?~ pup ~ - ?. ?=(%sil -.som.u.pup) ~ - `u.pup - :: - ++ yokg :: main call - |= [num=@ud app=term you=ship pax=path] - ^+ +> - ?< (~(has by sok) num) - abet:(~(self yo num you *sink) app pax) - :: - ++ yokh :: heartbeat - |= [num=@ud you=ship nap=@ud cnt=@ud jon=json] - ^- [(unit pimp) _+>] - =+ yon=(yolk nap) - ?~ yon [~ (bust 204 num)] - [- abet:+]:(beat:u.yon cnt num jon) - :: - ++ yokm :: message - |= [num=@ud you=ship nap=@ud cnt=@ud hap=hasp for=mark jon=json] - ^+ +> - =+ yon=(yolk nap) - ?~ yon (bust 204 num) - abet:(post:u.yon cnt num hap for jon) - :: - ++ yokp :: script by port - |= [num=@ud you=ship nup=(unit ,@ud)] - ^- [(unit pimp) _+>] - ?~ nup - $(nup [~ num], +> ~(harp yo num you *sink)) - =+ yon=(yolk u.nup) - ?~ yon - =+ err=(bust 204 num) - [`(need (~(get by q.rey.err) num)) err] - [- abet:+]:(hark:u.yon num) - :: - ++ yoks :: subscribe - |= [num=@ud you=ship nap=@ud hap=hasp pax=path] - =+ yon=(yolk nap) - ?~ yon (bust 204 num) - abet:(scud:u.yon num hap pax) - :: - ++ yoku :: unsubscribe - |= [num=@ud you=ship nap=@ud hap=hasp pax=path] - ^- [(unit pimp) _+>] - =+ yon=(yolk nap) - ?~ yon [~ (bust 204 num)] - [- abet:+]:(scad:u.yon num hap pax) - :: - ++ yolk :: yo by instance - |= nap=@ud - =+ suy=(~(get by sok) nap) - ?~ suy ~ - (some ~(. yo nap=nap you=p.u.suy siq=q.u.suy)) - :: - ++ yo :: app instance - |_ $: nap=@ud :: instance number - you=ship :: client identity - siq=sink :: instance state - == - ++ abet :: resolve - %_ ..yo - sok (~(put by sok) nap [you siq]) - == - :: - ++ amok :: demolish - ^+ ..yo - =+ wuh=(~(tap by can.sub.siq)) - |- ^+ ..yo - ?~ wuh - %= ..yo - sok (~(del by sok) nap) - == - %= $ - wuh t.wuh - ..amok - (pass(hen hen.q.i.wuh) `p.i.wuh [%g %nuke [- + ~]:hap.q.i.wuh you]) - == - :: - ++ beat - |= [cnt=@ud num=@ud jon=json] - ^- [(unit pimp) _+>] - ?. =(cnt num.bet.siq) - [~ +>.$(..yo (bust 204 num))] - =. +>.$ hast - =. bet.siq bet.siq(num +(num.bet.siq), tim now, hen hen) - =. +>.$ hawa - =. +>.$ (hire:(yule %bet) cnt num) - =. +>.$ (hear:(yule %bet) ~ %& %json !>((joba %a-ok %b %&))) - [`(need (~(get by q.rey) num)) +>.$] - :: - ++ hark - |= num=@ud - ^- [(unit pimp) _+>] - =. +>.$ abet:(busk:(yule %nil) num *@ ~ %& %js !>((duty nap you))) - [`(need (~(get by q.rey) num)) +>.$] - :: - ++ harp - %* abet hawa - tim.bet.siq now - num.sub.siq 1 - == - :: - ++ hast - %_ . - mow - :_ mow - :- hen.bet.siq - :^ %pass - [%leep (scot %p our) ses (scot %ud nap) (scot %ud num.bet.siq) ~] - %t - :- %rest (add ~m2 tim.bet.siq) - == - :: - ++ hawa - %_ . - mow - :_ mow - ^- move - :- hen.bet.siq - :^ %pass - [%leep (scot %p our) ses (scot %ud nap) (scot %ud num.bet.siq) ~] - %t - :- %wait (add ~m2 now) - == - :: - ++ hoop :: request path - |= can=(each ,@ud hasp) - ^- path - :* %hoop - (scot %p our) - ses - (scot %ud nap) - ?- -.can - %& [%show (scot %ud p.can) ~] - %| [%mess (scot %p p.p.can) q.p.can ~] - == - == - :: - ++ pass :: pass - |= [can=(each ,@ud hasp) noh=note] - ^+ +> - +>(mow [[hen %pass (hoop can) noh] mow]) - :: - ++ post :: transmit - |= [cnt=@ud num=@ud hap=hasp for=mark jon=json] - ^+ +> - =. +>.$ - ?. =(cnt num.meg.siq) +>.$ - %+ pass(num.meg.siq +(num.meg.siq)) [%| hap] - `note`[%f %exec our ~ %cast for %done ~ %json !>(jon)] - ?. =(+(cnt) num.meg.siq) - +>.$(..yo (bust 204 num)) - (hire:(yule %meg) cnt num) - :: - ++ scad - |= [num=@ud hap=hasp pax=path] - ^- [(unit pimp) _+>] - =. +>.$ - %- ~(rep by can.sub.siq) - =+ [*p=[p=@ud q=stem] q=+>.$] |. - ?. =([hap pax] [hap.q.p pax.q.p]) q - =. q q(can.sub.siq (~(del by can.sub.siq:q) p.p)) - ([-(hen +)]:[pass:q hen.q.p] `p.p %g %nuke [- + ~]:hap you) - =+ huq=[~ %& %json !>((joba %ok %b %&))] - =. +>.$ abet:(busk:(yule %nil) num 0 huq) - [`(need (~(get by q.rey) num)) +>.$] - :: - ++ scud :: subscribe - |= [num=@ud hap=hasp pax=path] - =. can.sub.siq - (~(put by can.sub.siq) num.sub.siq [hap pax hen `[%| num]]) - =. +>.$ (pass `num.sub.siq `note`[%g %show [- + ~]:hap you pax]) - =. num.sub.siq +(num.sub.siq) - +>.$ - :: - ++ self :: request main - |= [app=term pax=path] - ^+ +> - =. tim.bet.siq now - =. can.sub.siq - (~(put by can.sub.siq) 0 [[our app] pax hen `[%& nap]]) - =. num.sub.siq +(num.sub.siq) - =. hen.bet.siq hen - =. +>.$ hawa - (pass `0 [%g %show [our app ~] you pax]) - :: - ++ yule - |= pla=?(%bet %meg %sub %nil) - %~ . yu :- pla - =< wig - ?-(pla %bet bet.siq, %meg meg.siq, %sub sub.siq, %nil [wig=*swig ~]) - :: - ++ yu :: swig state - |_ [pla=?(%bet %meg %sub %nil) wig=swig] - ++ abet - ^+ ..yu - ?- pla - %bet %_(..yu wig.bet.siq wig) - %meg %_(..yu wig.meg.siq wig) - %sub %_(..yu wig.sub.siq wig) - %nil ..yu - == - :: - ++ busk :: seam result - |= $: num=@ud - cnt=@ud - huq=(unit (each cage cage)) - == - ^+ +> - =+ pup=(~(get by q.rey) num) - ?~ pup +>.$ :: XX a hack - =. wig ?: ?=(%nil pla) wig - ?. =(toy.wig cnt) - ?>(=(toy.wig +(cnt)) wig) - %= wig - toy +(toy.wig) - red - ?: =(0 toy.wig) red.wig - :: ~& [%busk [%sent cnt] [%lost (dec toy.wig)]] - (~(del by red.wig) (dec toy.wig)) - == - =+ pip=u.pup - =+ ^= sip - ?. ?=(%apg -.som.pip) sip.pip - =* his q.som.pip - =+ mef=?:(=(our his) "gop" "gip/{|1:}") :: e.g. "gip/zod" - =+ hat="/{mef}/{(pojo (jone nap))}/hart.js" - [;script(src hat); ;meta(charset "utf-8"); sip.pip] - ?~ huq +>.$(..yo (bust 404 num)) - %= +>.$ - q.rey - %+ ~(put by q.rey) num - ^- pimp - %= pip - pez %new - sip sip - som ^- seam - :+ %sil - ?:(-.u.huq 200 203) - =+ don=`silk`[%done ~ `cage`p.u.huq] - ^- silk - :+ %cast %mime - ?~ fur.pip don - `silk`[%cast u.fur.pip don] - == - == - :: - ++ dumb :: reset - ^+ ..yu - =+ dum=(~(tap by wan.wig) ~) - |- ^+ ..yu - ?~ dum ..yu :: XX drop stream - $(dum t.dum, ..yo (bust 404 q.i.dum)) - :: - ++ hear :: produce - |= huq=(unit (each cage cage)) - ^+ ..yu - =< abet - =+ cnt=cnt.wig - =+ dul=(~(get by wan.wig) cnt) - :: ~& :~ %yu-hear - :: [%instance nap] - :: [%produced cnt] - :: ?~(dul %unrequested [%requester u.dul]) - :: == - =: cnt.wig +(cnt.wig) - wan.wig ?~(dul wan.wig (~(del by wan.wig) cnt.wig)) - red.wig (~(put by red.wig) cnt.wig huq) - == - ?~(dul +>.$ (busk u.dul cnt huq)) - :: - ++ hire :: consume - |= [cnt=@ud num=@ud] - ^+ ..yu - =< abet - :: ~& :~ %yu-hire - :: [%instance nap] - :: [%produced cnt.wig] - :: [%request cnt] - :: [%dispatched toy.wig] - :: [%requester num] - :: == - ?: |((lth +(cnt) toy.wig) (gth cnt toy.wig)) - ~& [%hire-improper [%request cnt] [%dispatched toy.wig]] - +>.$(..yo (bust 204 num)) - ?: (gte cnt cnt.wig) - :: ~& %hire-wait - =+ old=(~(get by wan.wig) cnt) - =. wan.wig (~(put by wan.wig) cnt num) - +>.$(..yo ?~(old ..yo (bust 204 u.old))) - =+ rud=(~(get by red.wig) cnt) - ?~ rud - :: ~& %hire-bust - +>.$(..yo (bust 204 num)) - :: ~& %hire-send - (busk num cnt u.rud) - -- - -- +:: ++ work +:: |- ^+ + +:: =+ sez=step +:: ?: =(rey.sez rey) sez +:: $(+ sez) +:: :: +:: ++ yoke :: long poll +:: |= [num=@ud you=ship nap=@ud cnt=@ud] +:: ^- [(unit pimp) _+>] +:: =+ yon=(yolk nap) +:: ?~ yon `(bust 204 num) +:: =. +>.$ abet:(hire:(yule %sub):u.yon cnt num) +:: :_ +>.$ +:: =+ pup=(~(get by q.rey) num) +:: ?~ pup ~ +:: ?. ?=(%sil -.som.u.pup) ~ +:: `u.pup +:: :: +:: ++ yokg :: main call +:: |= [num=@ud app=term you=ship pax=path] +:: ^+ +> +:: ?< (~(has by sok) num) +:: abet:(~(self yo num you *sink) app pax) +:: :: +:: ++ yokh :: heartbeat +:: |= [num=@ud you=ship nap=@ud cnt=@ud jon=json] +:: ^- [(unit pimp) _+>] +:: =+ yon=(yolk nap) +:: ?~ yon [~ (bust 204 num)] +:: [- abet:+]:(beat:u.yon cnt num jon) +:: :: +:: ++ yokm :: message +:: |= [num=@ud you=ship nap=@ud cnt=@ud hap=hasp for=mark jon=json] +:: ^+ +> +:: =+ yon=(yolk nap) +:: ?~ yon (bust 204 num) +:: abet:(post:u.yon cnt num hap for jon) +:: :: +:: ++ yokp :: script by port +:: |= [num=@ud you=ship nup=(unit ,@ud)] +:: ^- [(unit pimp) _+>] +:: ?~ nup +:: $(nup [~ num], +> ~(harp yo num you *sink)) +:: =+ yon=(yolk u.nup) +:: ?~ yon +:: =+ err=(bust 204 num) +:: [`(need (~(get by q.rey.err) num)) err] +:: [- abet:+]:(hark:u.yon num) +:: :: +:: ++ yoks :: subscribe +:: |= [num=@ud you=ship nap=@ud hap=hasp pax=path] +:: =+ yon=(yolk nap) +:: ?~ yon (bust 204 num) +:: abet:(scud:u.yon num hap pax) +:: :: +:: ++ yoku :: unsubscribe +:: |= [num=@ud you=ship nap=@ud hap=hasp pax=path] +:: ^- [(unit pimp) _+>] +:: =+ yon=(yolk nap) +:: ?~ yon [~ (bust 204 num)] +:: [- abet:+]:(scad:u.yon num hap pax) +:: :: +:: ++ yolk :: yo by instance +:: |= nap=@ud +:: =+ suy=(~(get by sok) nap) +:: ?~ suy ~ +:: (some ~(. yo nap=nap you=p.u.suy siq=q.u.suy)) +:: :: +:: ++ yo :: app instance +:: |_ $: nap=@ud :: instance number +:: you=ship :: client identity +:: siq=sink :: instance state +:: == +:: ++ abet :: resolve +:: %_ ..yo +:: sok (~(put by sok) nap [you siq]) +:: == +:: :: +:: ++ amok :: demolish +:: ^+ ..yo +:: =+ wuh=(~(tap by can.sub.siq)) +:: |- ^+ ..yo +:: ?~ wuh +:: %= ..yo +:: sok (~(del by sok) nap) +:: == +:: %= $ +:: wuh t.wuh +:: ..amok +:: (pass(hen hen.q.i.wuh) `p.i.wuh [%g %nuke [- + ~]:hap.q.i.wuh you]) +:: == +:: :: +:: ++ beat +:: |= [cnt=@ud num=@ud jon=json] +:: ^- [(unit pimp) _+>] +:: ?. =(cnt num.bet.siq) +:: [~ +>.$(..yo (bust 204 num))] +:: =. +>.$ hast +:: =. bet.siq bet.siq(num +(num.bet.siq), tim now, hen hen) +:: =. +>.$ hawa +:: =. +>.$ (hire:(yule %bet) cnt num) +:: =. +>.$ (hear:(yule %bet) ~ %& %json !>((joba %a-ok %b %&))) +:: [`(need (~(get by q.rey) num)) +>.$] +:: :: +:: ++ hark +:: |= num=@ud +:: ^- [(unit pimp) _+>] +:: =. +>.$ abet:(busk:(yule %nil) num *@ ~ %& %js !>((duty nap you))) +:: [`(need (~(get by q.rey) num)) +>.$] +:: :: +:: ++ harp +:: %* abet hawa +:: tim.bet.siq now +:: num.sub.siq 1 +:: == +:: :: +:: ++ hast +:: %_ . +:: mow +:: :_ mow +:: :- hen.bet.siq +:: :^ %pass +:: [%leep (scot %p our) ses (scot %ud nap) (scot %ud num.bet.siq) ~] +:: %t +:: :- %rest (add ~m2 tim.bet.siq) +:: == +:: :: +:: ++ hawa +:: %_ . +:: mow +:: :_ mow +:: ^- move +:: :- hen.bet.siq +:: :^ %pass +:: [%leep (scot %p our) ses (scot %ud nap) (scot %ud num.bet.siq) ~] +:: %t +:: :- %wait (add ~m2 now) +:: == +:: :: +:: ++ hoop :: request path +:: |= can=(each ,@ud hasp) +:: ^- path +:: :* %hoop +:: (scot %p our) +:: ses +:: (scot %ud nap) +:: ?- -.can +:: %& [%show (scot %ud p.can) ~] +:: %| [%mess (scot %p p.p.can) q.p.can ~] +:: == +:: == +:: :: +:: ++ pass :: pass +:: |= [can=(each ,@ud hasp) noh=note] +:: ^+ +> +:: +>(mow [[hen %pass (hoop can) noh] mow]) +:: :: +:: ++ post :: transmit +:: |= [cnt=@ud num=@ud hap=hasp for=mark jon=json] +:: ^+ +> +:: =. +>.$ +:: ?. =(cnt num.meg.siq) +>.$ +:: %+ pass(num.meg.siq +(num.meg.siq)) [%| hap] +:: `note`[%f %exec our ~ %cast for %done ~ %json !>(jon)] +:: ?. =(+(cnt) num.meg.siq) +:: +>.$(..yo (bust 204 num)) +:: (hire:(yule %meg) cnt num) +:: :: +:: ++ scad +:: |= [num=@ud hap=hasp pax=path] +:: ^- [(unit pimp) _+>] +:: =. +>.$ +:: %- ~(rep by can.sub.siq) +:: =+ [*p=[p=@ud q=stem] q=+>.$] |. +:: ?. =([hap pax] [hap.q.p pax.q.p]) q +:: =. q q(can.sub.siq (~(del by can.sub.siq:q) p.p)) +:: ([-(hen +)]:[pass:q hen.q.p] `p.p %g %nuke [- + ~]:hap you) +:: =+ huq=[~ %& %json !>((joba %ok %b %&))] +:: =. +>.$ abet:(busk:(yule %nil) num 0 huq) +:: [`(need (~(get by q.rey) num)) +>.$] +:: :: +:: ++ scud :: subscribe +:: |= [num=@ud hap=hasp pax=path] +:: =. can.sub.siq +:: (~(put by can.sub.siq) num.sub.siq [hap pax hen `[%| num]]) +:: =. +>.$ (pass `num.sub.siq `note`[%g %show [- + ~]:hap you pax]) +:: =. num.sub.siq +(num.sub.siq) +:: +>.$ +:: :: +:: ++ self :: request main +:: |= [app=term pax=path] +:: ^+ +> +:: =. tim.bet.siq now +:: =. can.sub.siq +:: (~(put by can.sub.siq) 0 [[our app] pax hen `[%& nap]]) +:: =. num.sub.siq +(num.sub.siq) +:: =. hen.bet.siq hen +:: =. +>.$ hawa +:: (pass `0 [%g %show [our app ~] you pax]) +:: :: +:: ++ yule +:: |= pla=?(%bet %meg %sub %nil) +:: %~ . yu :- pla +:: =< wig +:: ?-(pla %bet bet.siq, %meg meg.siq, %sub sub.siq, %nil [wig=*swig ~]) +:: :: +:: ++ yu :: swig state +:: |_ [pla=?(%bet %meg %sub %nil) wig=swig] +:: ++ abet +:: ^+ ..yu +:: ?- pla +:: %bet %_(..yu wig.bet.siq wig) +:: %meg %_(..yu wig.meg.siq wig) +:: %sub %_(..yu wig.sub.siq wig) +:: %nil ..yu +:: == +:: :: +:: ++ busk :: seam result +:: |= $: num=@ud +:: cnt=@ud +:: huq=(unit (each cage cage)) +:: == +:: ^+ +> +:: =+ pup=(~(get by q.rey) num) +:: ?~ pup +>.$ :: XX a hack +:: =. wig ?: ?=(%nil pla) wig +:: ?. =(toy.wig cnt) +:: ?>(=(toy.wig +(cnt)) wig) +:: %= wig +:: toy +(toy.wig) +:: red +:: ?: =(0 toy.wig) red.wig +:: :: ~& [%busk [%sent cnt] [%lost (dec toy.wig)]] +:: (~(del by red.wig) (dec toy.wig)) +:: == +:: =+ pip=u.pup +:: =+ ^= sip +:: ?. ?=(%apg -.som.pip) sip.pip +:: =* his q.som.pip +:: =+ mef=?:(=(our his) "gop" "gip/{|1:}") :: e.g. "gip/zod" +:: =+ hat="/{mef}/{(pojo (jone nap))}/hart.js" +:: [;script(src hat); ;meta(charset "utf-8"); sip.pip] +:: ?~ huq +>.$(..yo (bust 404 num)) +:: %= +>.$ +:: q.rey +:: %+ ~(put by q.rey) num +:: ^- pimp +:: %= pip +:: pez %new +:: sip sip +:: som ^- seam +:: :+ %sil +:: ?:(-.u.huq 200 203) +:: =+ don=`silk`[%done ~ `cage`p.u.huq] +:: ^- silk +:: :+ %cast %mime +:: ?~ fur.pip don +:: `silk`[%cast u.fur.pip don] +:: == +:: == +:: :: +:: ++ dumb :: reset +:: ^+ ..yu +:: =+ dum=(~(tap by wan.wig) ~) +:: |- ^+ ..yu +:: ?~ dum ..yu :: XX drop stream +:: $(dum t.dum, ..yo (bust 404 q.i.dum)) +:: :: +:: ++ hear :: produce +:: |= huq=(unit (each cage cage)) +:: ^+ ..yu +:: =< abet +:: =+ cnt=cnt.wig +:: =+ dul=(~(get by wan.wig) cnt) +:: :: ~& :~ %yu-hear +:: :: [%instance nap] +:: :: [%produced cnt] +:: :: ?~(dul %unrequested [%requester u.dul]) +:: :: == +:: =: cnt.wig +(cnt.wig) +:: wan.wig ?~(dul wan.wig (~(del by wan.wig) cnt.wig)) +:: red.wig (~(put by red.wig) cnt.wig huq) +:: == +:: ?~(dul +>.$ (busk u.dul cnt huq)) +:: :: +:: ++ hire :: consume +:: |= [cnt=@ud num=@ud] +:: ^+ ..yu +:: =< abet +:: :: ~& :~ %yu-hire +:: :: [%instance nap] +:: :: [%produced cnt.wig] +:: :: [%request cnt] +:: :: [%dispatched toy.wig] +:: :: [%requester num] +:: :: == +:: ?: |((lth +(cnt) toy.wig) (gth cnt toy.wig)) +:: ~& [%hire-improper [%request cnt] [%dispatched toy.wig]] +:: +>.$(..yo (bust 204 num)) +:: ?: (gte cnt cnt.wig) +:: :: ~& %hire-wait +:: =+ old=(~(get by wan.wig) cnt) +:: =. wan.wig (~(put by wan.wig) cnt num) +:: +>.$(..yo ?~(old ..yo (bust 204 u.old))) +:: =+ rud=(~(get by red.wig) cnt) +:: ?~ rud +:: :: ~& %hire-bust +:: +>.$(..yo (bust 204 num)) +:: :: ~& %hire-send +:: (busk num cnt u.rud) +:: -- +:: -- -- -- -- diff --git a/arvo/zuse.hoon b/arvo/zuse.hoon index a3b358efa3..adc851b79d 100644 --- a/arvo/zuse.hoon +++ b/arvo/zuse.hoon @@ -508,8 +508,7 @@ :: ++ moon :: mime type to text |= myn=mite - %+ rap - 3 + %- crip |- ^- tape ?~ myn ~ ?: =(~ t.myn) (trip i.myn) @@ -2080,17 +2079,11 @@ =+ dyb=(slay i.t.but) ?> ?& ?=([~ %many *] dyb) ?=([* * *] p.u.dyb) - :: ?=([%$ %tas *] i.p.u.dyb) - ?=([%many *] i.p.u.dyb) + ?=([%$ %ta *] i.p.u.dyb) ?=([%blob *] i.t.p.u.dyb) == =+ ced=((hard cred) p.i.t.p.u.dyb) :: =+ nep=q.p.i.p.u.dyb - =+ ^= nyp ^- path - %+ turn p.i.p.u.dyb - |= a=coin ^- @ta - ?> ?=([%$ %ta @] a) - ?>(((sane %ta) q.p.a) q.p.a) =+ ^= gut ^- (list ,@t) %+ turn t.t.p.u.dyb |= a=coin ^- @t @@ -2105,7 +2098,6 @@ ced bem t.t.but - nyp == :: ++ sifo :: 64-bit encode @@ -2823,7 +2815,6 @@ ced=cred :: client credentials bem=beam :: original path but=path :: ending - nyp=path :: request model == :: ++ flap ,@uvH :: network packet id ++ flow :: packet connection @@ -3032,7 +3023,7 @@ $% [& q=soba] :: delta [| p=@tas] :: label == :: -++ octs ,[p=@ud q=@] :: octet-stream +++ octs ,[p=@ud q=@t] :: octet-stream ++ oryx ,@t :: CSRF secret ++ pact path :: routed path ++ pail ?(%none %warm %cold) :: connection status diff --git a/main/app/shell/core.hook b/main/app/shell/core.hook index 4db900f351..a6f01ff319 100644 --- a/main/app/shell/core.hook +++ b/main/app/shell/core.hook @@ -83,7 +83,7 @@ [%vega p=path] :: == == == :: -- -!: +:: :::: parsers :: |% @@ -129,9 +129,9 @@ == :: ++ expg (rais ;~(pfix ace expr(tol %1)) ;~(pfix gap expr)) - ++ expr (rais [wide tall]:(vang & pax)) - ++ loca %+ sear ;~(biff plex:(vang & pax) vabe) :: path in %clay - [;~(pose rood ;~(simu cen scat))]:(vang & pax) + ++ expr (rais [wide tall]:(vang | pax)) + ++ loca %+ sear ;~(biff plex:(vang | pax) vabe) :: path in %clay + [;~(pose rood ;~(simu cen scat))]:(vang | pax) ++ vabe |=(a=path ?~((tome a) ~ (some a))) :: check valid beam ++ args :: task arguments %^ rail @@ -143,7 +143,7 @@ :: -- -- -!: +:: :::: per event :: |% @@ -503,7 +503,7 @@ !>([%rush %term-line `term-line`[pro(r a) ~ ~]]) -- -- -!: +:: :::: formal interface :: |_ [hid=hide vat=axle] diff --git a/main/mar/md/door.hook b/main/mar/md/door.hook index dab26d9dd1..829cc14f42 100644 --- a/main/mar/md/door.hook +++ b/main/mar/md/door.hook @@ -4,4 +4,8 @@ /? 314 |_ mud=@t ++ garb [%down ~] +++ grow + |% + ++ mime [text//x-markdown (taco mud)] + -- -- diff --git a/main/mar/psal/door.hook b/main/mar/psal/door.hook index 22cb9a9e50..4caea31451 100644 --- a/main/mar/psal/door.hook +++ b/main/mar/psal/door.hook @@ -10,6 +10,7 @@ ++ html (crip (poxo hymn)) :: convert to %html ++ mime [/text/html (taco html)] :: convert to %mime -- +++ garb [%react ~] ++ grab |% :: convert from ++ noun manx :: clam from %noun -- -- diff --git a/main/mar/tang/door.hook b/main/mar/tang/door.hook index df4cd69b2e..157ea2c0b8 100644 --- a/main/mar/tang/door.hook +++ b/main/mar/tang/door.hook @@ -1,9 +1,17 @@ :: -:::: /hoon/core/zing/mar +:::: /hoon/core/psal/mar :: /? 314 +!: |_ tan=(list tank) :: +++ grow + |% + ++ psal + =- ;pre:code:"{(trip (role (turn - crip)))}" :: XX + ^- wall %- zing ^- (list wall) + (turn tan |=(a=tank (wash 0^160 a))) + -- ++ grab :: convert from |% ++ noun (list tank) :: clam from %noun From 8afeb67157620542f99ca2b77e737c43286b8941 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Sat, 7 Feb 2015 23:40:09 -0800 Subject: [PATCH 002/219] Factored out errors, unnecessary h/h !>ing --- arvo/eyre.hoon | 45 +++++++++++++++++++++++++-------------------- arvo/hoon.hoon | 11 +++++------ 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index cb81b7bf47..3f96d4cc87 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -427,10 +427,7 @@ :: ~& e/ford/hen =+ our=(slav %p i.t.tea) ?- -.p.sih - | :: (back our tea %tang !>(p.p.sih)) :: XX broken tang door - =- (muff (tuff text//plain (role (turn - crip)))) - ^- wall %- zing ^- (list wall) - (turn p.p.sih |=(a=tank (wash 0^160 a))) + | (fail 404 p.p.sih) & =* cag q.p.p.sih ?> ?=(%mime p.cag) =+ ((hard ,[mit=mite rez=octs]) q.q.cag) :: XX @@ -608,14 +605,14 @@ ?. &(?=(& -.hot) ?=(^ p.hot)) ~ (rush -:(flop p.hot) fed:ag) :: -:: ++ fail :: request failed -:: |= [sas=@ud str=tape] -:: ^+ +> -:: %- muff -:: :- %thou -:: ^- httr -:: [sas ~[content-type/'text/plain'] [~ (tact str)]] -:: :: + ++ fail :: request failed + |= [sas=@ud mez=tang] + ^+ +> + :: (back our tea %tang !>(mez)) :: XX broken tang door + =- (muff (tuff text//plain (role (turn - crip)))) + ^- wall %- zing ^- (list wall) + (turn mez |=(a=tank (wash 0^160 a))) + :: :: ++ gale :: ya from response :: |= [our=ship ses=hole] :: =+ sef=(need (~(get by own) our)) @@ -681,6 +678,15 @@ :: =+ boy=(myth our (need ((sand %ta) ((hard ,@) hez)))) :: ?~(boy +>.$ abet:(auth:u.boy him)) :: :: + ++ heck :: regular request + |= [oar=ship pok=pork] + ^- (unit beam) + ?~ q.pok + $(q.pok /index) + ?. ((sane %tas) i.q.pok) + (tome q.pok) + `[[oar i.q.pok da/now] (flop t.q.pok)] + :: ++ hell :: request, no ship |= [pul=purl hyx=httx moh=moth] ^+ +> @@ -695,14 +701,13 @@ :: =+ oar=`(unit ship)`?^(wiq wiq (doss r.p.pul)) =+ oar=(fall (doss r.p.pul) (need hov)) =+ ext=(fall p.q.pul %html) - =+ ^- bem=beam - |- - ?~ q.q.pul $(q.q.pul /index) - :- [oar i.q.q.pul [%da now]] - :+ %web - ~(rent co (flux:ya /'' r.pul)) - (flop t.q.q.pul) - (honk oar [%cast %mime %boil ext bem ~]) + =+ hek=(heck oar q.pul) + ?^ hek + =: s.u.hek [%web ~(rent co (flux:ya /'' r.pul)) s.u.hek] + r.u.hek ?+(r.u.hek r.u.hek [%ud %0] da/now) + == + (honk oar [%cast %mime %boil ext u.hek ~]) + (fail 404 >%irregular-path< (smyt q.q.pul) ~) :: ?. (home oar) :: (hork oar hyx) :: (huff oar q.hyx pul moh) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index d89f91aed5..f35e8ddd4d 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -6067,8 +6067,9 @@ :: ++ seed :: hoon/hoon core vase ^- vase - ~+ - !;(*type ..seed) + !! + :: ~+ :: trimmed + :: !;(*type ..seed) :: ++ seem |=(toy=typo `type`toy) :: promote typo ++ seer |=(vix=vise `vase`vix) :: promote vise @@ -7092,9 +7093,7 @@ [[%leaf (rip 3 -.lum)] $(lum +.lum)] :: %type - =+ reb=(slap [p:!>(.) .(sut lum)] %cnzy %duck) - =+ cis=(tank q.reb) - ?. =(cis q.reb) ~ + =+ cis=((hard tank) .*(.(sut lum) !=(duck))) :: type bypass :^ ~ %palm [~ ~ ~ ~] [[%leaf '#' 't' '/' ~] cis ~] @@ -8869,7 +8868,7 @@ ;~ pose (stag %wtzp ;~(pfix zap wide)) (stag %zpzp (cold ~ ;~(plug zap zap))) - (stag %zpcn (cold ~ ;~(plug zap cen))) + :: (stag %zpcn (cold ~ ;~(plug zap cen))) == :- '$' rump From 866faaf865d7139b5d2b31e9fc291c494ce8b6f5 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Sun, 8 Feb 2015 13:22:33 -0800 Subject: [PATCH 003/219] Check in some testing stuff. --- arvo/dill.hoon | 967 ++++++++++-------------------------- arvo/hoon.hoon | 7 +- main/app/seat/core.hook | 293 +++++++++++ main/app/tease/core.hook | 31 ++ main/lib/console/core.hook | 89 ++++ main/lib/sh-utils/core.hook | 4 +- main/sur/console/core.hook | 65 +++ 7 files changed, 741 insertions(+), 715 deletions(-) create mode 100644 main/app/seat/core.hook create mode 100644 main/app/tease/core.hook create mode 100644 main/lib/console/core.hook create mode 100644 main/sur/console/core.hook diff --git a/arvo/dill.hoon b/arvo/dill.hoon index a38c75f88a..09d4bb3e78 100644 --- a/arvo/dill.hoon +++ b/arvo/dill.hoon @@ -3,697 +3,242 @@ :: |= pit=vase => |% :: interface tiles -++ gift :: out result <-$ - $% [%bbye ~] :: reset prompt - [%blit p=(list blit)] :: terminal output - [%init p=@p] :: report install - [%logo @] :: logout - [%veer p=@ta q=path r=@t] :: install vane - [%vega p=path] :: reboot by path - [%verb ~] :: - == :: -++ kiss :: in request ->$ - $% [%belt p=belt] :: terminal input - [%blew p=blew] :: terminal config - [%boot p=*] :: weird %dill boot - [%crud p=@tas q=(list tank)] :: error with trace - [%flog p=flog] :: wrapped error - [%hail ~] :: terminal refresh - [%hook ~] :: this term hung up - [%harm ~] :: all terms hung up - [%init p=ship] :: after gall ready - [%noop ~] :: no operation - [%talk p=tank] :: - [%text p=tape] :: - == :: -++ flog :: sent to %dill - $% [%crud p=@tas q=(list tank)] :: - [%text p=tape] :: - == :: -++ mess :: message to terminal - $% [%term-ctrl p=(hypo ,%hail)] :: - [%term-in p=(hypo term-in)] :: - == :: -++ move ,[p=duct q=(mold note gift)] :: local move -++ note :: out request $-> - $% $: %a :: - $% [%make p=(unit ,@t) q=@ud r=@ s=?] :: - [%sith p=@p q=@uw r=?] :: - == == :: - $: %c :: - $% [%warp p=sock q=riff] :: - == == :: - $: %d :: - $% [%crud p=@tas q=(list tank)] :: - [%text p=tape] :: - == == :: - $: %g :: - $% [%mess p=[p=ship q=path] q=ship r=mess] :: - [%nuke p=[p=ship q=path] q=ship] :: - [%show p=[p=ship q=path] q=ship r=path] :: - [%took p=[p=ship q=path] q=ship] :: - == == :: - $: %t :: - $% [%wait p=@da] :: - == == == :: -++ riff ,[p=desk q=(unit rave)] :: see %clay -++ sign :: in result $<- - $? - $: %c :: - $% [%writ p=riot] :: - == == :: - $: %g :: - $% [%logo p=@] :: - [%mean p=ares] :: - [%nice ~] :: - $: %rush :: - $% [%term-line q=term-line] :: - [%hymn q=manx] :: - == == :: - [%verb ~] :: - [%sage p=path q=*] :: - [%veer p=@ta q=path r=@t] :: - [%vega p=path] :: - == == :: - $: %t :: - $% [%wake ~] :: - == == - $: @tas :: by any - $% [%crud p=@tas q=(list tank)] :: - [%init p=@p] :: - [%note p=@tD q=tank] :: - == == == :: -++ term-in :: - $: pax=path :: - $= jof :: - $% [%line p=cord] :: - [%res p=span] :: - [%cmd p=char] :: - [%type p=?] :: - == == :: -++ term-line ,[p=[p=cord q=prom r=cord] q=(list cord) r=(list tark)] -++ tark ?(tank [%stem p=@da q=tank r=tank]) :: -:::::::: :: dill tiles -++ bein :: terminal control - $: $: bul=@ud :: buffer length - bus=@ud :: cursor in buffer - but=(list ,@c) :: buffer text - buy=prom :: input style - == :: - $: hiz=@ud :: history depth - hux=path :: history path - hym=(map ,@ud (list ,@c)) :: history overlay - hyt=hist :: history object - hyr=(unit (list ,@c)) :: history search - == :: - $: pol=@ud :: length of prompt - pot=tape :: prompt text - == :: - == :: +++ axle :: all dill state + $: %2 :: + ore=(unit ship) :: identity once set + hey=(unit duct) :: default duct + dug=(map duct axon) :: conversations + == :: +++ axon :: dill per duct + $: ram=term :: console program + wid=_80 :: terminal width + see=(list ,@c) :: current line + == :: +-- :: +=> |% :: console protocol +++ console-action :: console to app + $% [%det console-change] :: edit prompt line + [%inn ~] :: enter session + [%out ~] :: exit session + [%ret ~] :: submit and clear + == :: +++ console-buffer (list ,@c) :: command state +++ console-change :: network change + $: ler=console-clock :: destination clock + haw=@uvH :: source hash + ted=console-edit :: state change + == :: +++ console-clock ,[own=@ud his=@ud] :: vector clock +++ console-edit :: shared state change + $% [%del p=@ud] :: delete one at + [%ins p=@ud q=@c] :: insert at + [%mor p=(list console-edit)] :: combination + [%nop ~] :: no-op + [%set p=console-buffer] :: discontinuity + == :: +++ console-effect :: app to console + $% [%bel ~] :: beep + [%blk p=@ud q=@c] :: blink/match char at + [%clr ~] :: clear screen + [%det console-change] :: edit input + [%tan p=(list tank)] :: classic tank + :: [%taq p=tanq] :: modern tank + [%txt p=tape] :: text line + == :: +++ dill-belt :: console input + $% [%aro p=?(%d %l %r %u)] :: arrow key + [%bac ~] :: true backspace + [%cru p=@tas q=(list tank)] :: echo error + [%ctl p=@ud] :: control-key + [%del ~] :: true delete + [%met p=@ud] :: meta-key + [%ret ~] :: return + [%rez p=@ud q=@ud] :: resize, cols, rows + [%txt p=(list ,@c)] :: utf32 text + [%yow p=gill] :: connect to app + == :: +++ dill-blit :: console output + $% [%bel ~] :: make a noise + [%clr ~] :: clear the screen + [%hop p=@ud] :: set cursor position + [%pro p=(list ,@c)] :: show as cursor/line + [%out p=(list ,@c)] :: send output line + [%sag p=path q=*] :: save to jamfile + [%sav p=path q=@] :: save to file + == :: +++ gill ,@tas :: general contact +-- => :: +|% :: protocol below ++ blew ,[p=@ud q=@ud] :: columns rows ++ belt :: raw console input - $% [%aro p=?(%d %l %r %u)] :: arrow key - [%bac ~] :: true backspace - [%ctl p=@ud] :: control-key - [%del ~] :: true delete - [%met p=@ud] :: meta-key - [%ret ~] :: return - [%txt p=(list ,@c)] :: utf32 text - == :: + $% [%aro p=?(%d %l %r %u)] :: arrow key + [%bac ~] :: true backspace + [%ctl p=@ud] :: control-key + [%del ~] :: true delete + [%met p=@ud] :: meta-key + [%ret ~] :: return + [%txt p=(list ,@c)] :: utf32 text + == :: ++ blit :: raw console output - $% [%bel ~] :: make a noise - [%clr ~] :: clear the screen - [%hop p=@ud] :: set cursor position - [%lin p=(list ,@c)] :: set current line - [%mor ~] :: newline - [%sag p=path q=*] :: save to jamfile - [%sav p=path q=@] :: save to file - == :: -++ blot :: kill ring - $: p=@ud :: length - q=@ud :: depth - r=(list (list ,@c)) :: kills - == :: -++ blur ,[p=@ud q=(unit bein) r=blot] :: columns, prompt -++ kyev :: - $: p=(set ?(%ctrl %shift %alt %meta)) :: - q=$|(cord [%act speck]) :: - == :: -++ speck :: - $? %ctrl %shift %alt %meta %entr %esc :: - %caps %uncap %pgup %pgdn %home %end :: - %baxp %del %ins %up %down %left :: - %right :: - == :: -++ yard :: terminal state - $: p=? :: verbose - q=blur :: display state - r=(map path hist) :: history - s=[p=? q=@da] :: typing?/last typed - == :: - :: XX LEGACY 12-16-2014 -++ yord :: old terminal state - $: p=? :: verbose - q=blur :: display state - r=(map path hist) :: history - == :: --- => -|% -++ dy - |= [hen=duct our=ship now=@da def=(unit duct) dug=(map duct yard)] - =+ ^= yar ^- yard - =+ yur=(~(get by dug) hen) - ?^ yur u.yur - ?^ def (~(got by dug) u.def) - [& [80 ~ *blot] ~ | *@da] - =| mos=(list move) - |% - ++ beep (curb [[%bel ~] ~]) :: send beep - ++ curb :: send blits - |= wab=(list blit) - ^+ +> - ?~ wab +> - +>(mos [[hen [%give %blit (flop wab)]] mos]) - :: - ++ wod :: word forward - |= bed=bein - ^- @ud - ?: =(bul.bed bus.bed) - bus.bed - ?: =(' ' (snag bus.bed but.bed)) - $(bus.bed +(bus.bed)) - |- - ^- @ud - ?: =(bul.bed bus.bed) - bus.bed - ?: =(' ' (snag bus.bed but.bed)) - bus.bed - $(bus.bed +(bus.bed)) - :: - ++ wob :: word backward - |= bed=bein - ^- @ud - ?: =(0 bus.bed) - bus.bed - ?: =(' ' (snag (dec bus.bed) but.bed)) - $(bus.bed (dec bus.bed)) - |- - ^- @ud - ?: =(0 bus.bed) - bus.bed - ?: =(' ' (snag (dec bus.bed) but.bed)) - bus.bed - $(bus.bed (dec bus.bed)) - :: - ++ edit :: change the bed - |= bed=bein - ^+ +> - =. q.q.yar [~ bed] - ?> ?=(^ q.q.yar) - %- curb - |- ^- (list blit) - ?^ hyr.u.q.q.yar - =+ ris=:(weld "(reverse-i-search)'" (tufa u.hyr.u.q.q.yar) "': ") - %= $ - pot.bed ris - pol.bed (lent ris) - hyr.u.q.q.yar ~ - == - :~ [%hop (add pol.bed bus.bed)] - :- %lin - %+ weld pot.bed - ?- buy.bed - %none but.bed - %text but.bed - %pass `(list ,@)`(runt [(lent but.bed) '*'] ~) - == - == - :: - ++ fume :: print tank, prefix - |= [pef=@tD tac=tank] - ^+ +> - =+ wol=(~(win re tac) 2 p.q.yar) - %- furl - %+ turn wol - |= a=tape ^- tape - ?> ?=([@ @ *] a) - [pef ' ' t.t.a] - :: - ++ furl :: print wall - |= wol=(list tape) - ^+ +> - =. +> - %- curb - %- flop - |- ^- (list blit) - ?~ wol ~ - [[%lin (tuba i.wol)] [%mor ~] $(wol t.wol)] - ?~ q.q.yar +> - (edit(q.q.yar ~) u.q.q.yar) - :: - ++ gore :: move in history - |= hup=@ud - ^+ +> - =+ but=(goth hup) - =+ bul=(lent but) - %- edit - ?> ?=(^ q.q.yar) - %= u.q.q.yar - hiz hup - hym %+ ~(put by hym.u.q.q.yar) - hiz.u.q.q.yar - but.u.q.q.yar - bus bul - bul bul - but but - == - :: - ++ goth :: extract history - |= hup=@ud - ?> ?=(^ q.q.yar) - =+ byt=(~(get by hym.u.q.q.yar) hup) - ?^ byt u.byt - (tuba (rip 3 (snag hup q.hyt.u.q.q.yar))) - :: - ++ kill :: add to kill ring - |= txt=(list ,@c) - ^+ +> - => ?. =(16 p.r.q.yar) . - .(p.r.q.yar 15, r.r.q.yar (scag 15 r.r.q.yar)) - %= +> - p.r.q.yar +(p.r.q.yar) - q.r.q.yar 0 - r.r.q.yar [txt r.r.q.yar] - == - :: - ++ look :: search in history - |= [hup=@ud txt=(list ,@c)] - ^+ +> - =+ ^= beg - |= [a=(list ,@c) b=(list ,@c)] ^- ? - ?~(a & ?~(b | &(=(i.a i.b) $(a t.a, b t.b)))) - =+ ^= mid - |= [a=(list ,@c) b=(list ,@c)] ^- ? - ?~(a & ?~(b | |((beg a b) $(b t.b)))) - ?> ?=(^ q.q.yar) - ?: =(hup p.hyt.u.q.q.yar) - beep - =+ but=(goth hup) - ?: (mid txt but) - (gore(hyr.u.q.q.yar [~ txt]) hup) - $(hup +(hup)) - :: - ++ leap :: accept response - |= [tea=wire sih=sign] - ^+ +> - ?- -.+.sih - %crud :: error trace - =. q.+.sih [[%leaf (trip p.+.sih)] q.+.sih] - |- ^+ +>.^$ - ?~ q.+.sih +>.^$ - (fume:$(q.+.sih t.q.+.sih) '!' `tank`i.q.+.sih) - :: - %mean ~& %dill-mean +>.$ - %nice +>.$ - %note ?.(p.yar +>.$ (fume p.+.sih q.+.sih)) :: debug message - ?(%rush %rust) :: XX reset prompt - =. mos :_(mos [hen %pass tea %g %took [our /terminal] our]) - ?> ?=(%term-line +>-.sih) - =. +>.$ - =+ lis=(scag 1.000 r.q.sih) - =- (furl (zing (turn (flop lis) -))) - |= a=tark - ^- wall - ?+ -.a (~(win re a) 0 p.q.yar) - %stem - ?: =(q.s.yar p.a) ~ - ~[(welp ~(ram re q.a) ~(ram re r.a))] - == - ?. (levy r.q.sih |=(a=tark ?=(%stem -.a))) - +>.$ :: XX separate prompt/history messages - %- edit - =| bed=bein - =+ ^= hyt ^- hist - =+ hyt=(~(get by r.yar) /) - ?~(hyt *hist u.hyt) - ?: &(?=(^ q.q.yar) =(/ hux.u.q.q.yar)) - =+ bun=(rip 5 (turf r.p.q.sih)) - %= u.q.q.yar - bul ?~ r.p.q.sih bul.u.q.q.yar (lent bun) - bus ?~ r.p.q.sih bus.u.q.q.yar (lent bun) - but ?~ r.p.q.sih but.u.q.q.yar bun - hyt [+(p.hyt) [%$ q.hyt]] - pot (trip p.p.q.sih) - pol (met 3 p.p.q.sih) - buy q.p.q.sih - == - %_ bed - bul (met 3 r.p.q.sih) - bus (met 3 r.p.q.sih) - but (rip 3 r.p.q.sih) - buy q.p.q.sih - hux / - hiz 0 - hyt [+(p.hyt) [%$ q.hyt]] - pot (trip p.p.q.sih) - pol (met 3 p.p.q.sih) - == - :: - %sage :: write a jamfile - %= +>.$ - mos :_(mos [hen [%give %blit [%sag p.+.sih q.+.sih] ~]]) - == - ?(%init %logo %veer %vega %verb) :: drop-throughs - +>(mos :_(mos [hen %give +.sih])) - %writ :: file exists - %_ +>.$ - mos - :_ mos - [hen %pass /term-show %g %show [our /terminal] our /lines] - == - :: - %wake - ?: (lte (sub now ~s15) q.s.yar) - %_ +>.$ - mos - :_ mos - [hen %pass /activity %t %wait (add q.s.yar ~s15)] - == - %_ +>.$ - p.s.yar | - mos :_(mos (poke %term-in -:!>(*term-in) / %type %|)) - == - == - :: - ++ lear :: handle request - |= kyz=kiss - ^+ +> - ?- -.kyz - %flog !! - %noop +> - %belt :: terminal input - =. +>.$ - ?. ?=(?(%bac %del %ret %txt) -.p.kyz) +>.$ - ?: p.s.yar +>.$(s.yar [& now]) - %_ +>.$ - s.yar [& now] - mos - :_ :_ mos - [hen %pass /activity %t %wait (add ?:(p.s.yar q.s.yar now) ~s15)] - (poke %term-in -:!>(*term-in) / %type %&) - == - ?~ q.q.yar - %^ furl - "Downloading files from ticketing ship, please wait until" - "a prompt shows up. This could take several minutes." - ~ - ?^ hyr.u.q.q.yar :: live search - ?+ p.kyz $(hiz.u.q.q.yar 0, hyr.u.q.q.yar ~) - [%bac *] - ?: =(~ u.hyr.u.q.q.yar) - (curb [[%bel ~] ~]) - %- edit - %= u.q.q.yar - hyr [~ (scag (dec (lent u.hyr.u.q.q.yar)) u.hyr.u.q.q.yar)] - == - :: - [%txt *] (look hiz.u.q.q.yar (weld u.hyr.u.q.q.yar p.p.kyz)) - [%ctl %g] (edit u.q.q.yar(bul 0, bus 0, but ~, hiz 0, hyr ~)) - [%ctl %r] - ?: =(p.hyt.u.q.q.yar hiz.u.q.q.yar) - beep - (look +(hiz.u.q.q.yar) u.hyr.u.q.q.yar) - == - ?- -.p.kyz - %aro :: arrow - ?- p.p.kyz - %d :: down - ?: =(0 hiz.u.q.q.yar) - beep - (gore (dec hiz.u.q.q.yar)) - :: - %l :: left - ?: =(0 bus.u.q.q.yar) - beep - (edit u.q.q.yar(bus (dec bus.u.q.q.yar))) - :: - %r :: right - ?: =(bul.u.q.q.yar bus.u.q.q.yar) - beep - (edit u.q.q.yar(bus +(bus.u.q.q.yar))) - :: - %u - =+ hup=+(hiz.u.q.q.yar) - ?: =(hup p.hyt.u.q.q.yar) - beep - (gore hup) - == - :: - %bac :: backspace - ^+ +>.$ - ?: =(0 bus.u.q.q.yar) - (curb `(list blit)`[[%bel ~] ~]) - %- edit - %= u.q.q.yar - bus (dec bus.u.q.q.yar) - bul (dec bul.u.q.q.yar) - but - %+ weld - (scag (dec bus.u.q.q.yar) but.u.q.q.yar) - (slag bus.u.q.q.yar but.u.q.q.yar) - == - :: - %ctl :: control - ?+ p.p.kyz - beep - %a (edit u.q.q.yar(bus 0)) - %b $(kyz [%belt %aro %l]) - %d ?: ?& =(0 bul.u.q.q.yar) - =(0 bus.u.q.q.yar) - == - +>.$(mos :_(mos (poke %term-in -:!>(*term-in) / %cmd %d))) - $(kyz [%belt %del ~]) - %e (edit u.q.q.yar(bus bul.u.q.q.yar)) - %f $(kyz [%belt %aro %r]) - %g +>.$(mos :_(mos (poke %term-in -:!>(*term-in) / %cmd %g))) - %k ?: =(bul.u.q.q.yar bus.u.q.q.yar) - beep - => .(+>.$ (kill (slag bus.u.q.q.yar but.u.q.q.yar))) - %- edit - ?> ?=(^ q.q.yar) - %= u.q.q.yar - bul bus.u.q.q.yar - but (scag bus.u.q.q.yar but.u.q.q.yar) - == - %t ?: (lth bul.u.q.q.yar 2) - beep - =+ ^= pos - ?: =(bul.u.q.q.yar bus.u.q.q.yar) - (sub bus.u.q.q.yar 2) - ?: =(0 bus.u.q.q.yar) - bus.u.q.q.yar - (dec bus.u.q.q.yar) - %- edit - %= u.q.q.yar - bus (add 2 pos) - but %+ weld - %+ weld - (scag pos but.u.q.q.yar) - ^- (list ,@c) :+ - (snag +(pos) but.u.q.q.yar) - (snag pos but.u.q.q.yar) - ~ - (slag (add 2 pos) but.u.q.q.yar) - == - %l +>.$(mos :_(mos [hen %give %blit [[%clr ~] ~]])) - %n $(kyz [%belt %aro %d]) - %o %_ +>.$ - mos - :_ :_ mos - [hen %pass /term-show %g %nuke [our /terminal] our] - [hen %pass /term-show %g %show [our /terminal] our /lines] - == - %p $(kyz [%belt %aro %u]) - %u ?: =(0 bus.u.q.q.yar) - beep - => .(+>.$ (kill (scag bus.u.q.q.yar but.u.q.q.yar))) - %- edit - ?> ?=(^ q.q.yar) - %= u.q.q.yar - bus 0 - bul (sub bul.u.q.q.yar bus.u.q.q.yar) - but (slag bus.u.q.q.yar but.u.q.q.yar) - == - %r (edit u.q.q.yar(hyr [~ ~])) - %w ?: =(0 bus.u.q.q.yar) - beep - =+ bow=(wob u.q.q.yar) - =+ sow=(sub bus.u.q.q.yar bow) - => .(+>.$ (kill (swag [bow sow] but.u.q.q.yar))) - %- edit - ?> ?=(^ q.q.yar) - %= u.q.q.yar - bus bow - bul (sub bul.u.q.q.yar sow) - but %+ welp - (scag bow but.u.q.q.yar) - (slag bus.u.q.q.yar but.u.q.q.yar) - == - %x +>.$(mos :_(mos (poke %term-in -:!>(*term-in) / %cmd %x))) - %y ?: =(0 p.r.q.yar) - beep - $(kyz [%belt %txt (snag q.r.q.yar r.r.q.yar)]) - == - :: - %del :: delete - ?: =(bul.u.q.q.yar bus.u.q.q.yar) - beep - %- edit - %= u.q.q.yar - bul (dec bul.u.q.q.yar) - but - %+ weld - (scag bus.u.q.q.yar but.u.q.q.yar) - (slag +(bus.u.q.q.yar) but.u.q.q.yar) - == - :: - %met :: meta - ?+ p.p.kyz - beep - %f - ?: =(bul.u.q.q.yar bus.u.q.q.yar) - beep - (edit u.q.q.yar(bus (wod u.q.q.yar))) - :: - %b - ?: =(0 bus.u.q.q.yar) - beep - (edit u.q.q.yar(bus (wob u.q.q.yar))) - :: - %y - ?: =(0 p.r.q.yar) - beep - =+ dol=(snag q.r.q.yar r.r.q.yar) - =+ leo=(lent dol) - ?. (gte bus.u.q.q.yar leo) - beep - =+ pey=(sub bus.u.q.q.yar leo) - ?. =(dol (swag [pey leo] but.u.q.q.yar)) - beep - =. q.r.q.yar ?:(=(p.r.q.yar +(q.r.q.yar)) 0 +(q.r.q.yar)) - =+ ney=(snag q.r.q.yar r.r.q.yar) - =+ lye=(lent ney) - %- edit - %= u.q.q.yar - bus (sub (add bus.u.q.q.yar lye) leo) - bul (sub (add bul.u.q.q.yar lye) leo) - but %+ weld - (scag pey but.u.q.q.yar) - %+ weld - `(list ,@c)`ney :: XX weird fuse-loop - (slag bus.u.q.q.yar but.u.q.q.yar) - == - == - :: - %ret :: return - ?: =(%none buy.u.q.q.yar) beep - =+ jab=(rap 3 (tufa but.u.q.q.yar)) - %= +>.$ - q.q.yar ~ - r.yar - ?: |(=(%$ jab) =(%pass buy.u.q.q.yar)) - r.yar - %+ ~(put by r.yar) - hux.u.q.q.yar - [p.hyt.u.q.q.yar [jab ?~(q.hyt.u.q.q.yar ~ +.q.hyt.u.q.q.yar)]] - :: - mos - :* (poke %term-ctrl -:!>(%hail) %hail) - [hen %give [%bbye ~]] - (poke %term-in -:!>(*term-in) / %line jab) - [hen %give [%blit [[%mor ~] ~]]] - mos - == - == - :: - %txt :: text keys - ?: =(%none buy.u.q.q.yar) beep - =+ let=(lent p.p.kyz) - %- edit - %= u.q.q.yar - bus (add let bus.u.q.q.yar) - bul (add let bul.u.q.q.yar) - but - ;: weld - (scag bus.u.q.q.yar but.u.q.q.yar) - p.p.kyz - (slag bus.u.q.q.yar but.u.q.q.yar) - == - == - == - :: - %blew +>.$(p.q.yar p.p.kyz) :: window size - %boot - %= +>.$ - mos - :_(mos [hen %pass ~ (note %a p.kyz)]) - == - :: - %crud :: error trace - =. q.kyz [[%leaf (trip p.kyz)] q.kyz] - |- ^+ +>.^$ - ?~ q.kyz +>.^$ - (fume:$(q.kyz t.q.kyz) '!' `tank`i.q.kyz) - :: - %hail :: refresh - +>.$ - ::+>.$(mos :_(mos (poke %term-ctrl -:!>(%hail) %hail))) - :: - %harm :: all terms hung up - =+ nug=((map duct yard) [[hen (~(get by dug) hen)] ~ ~]) - ^+ +>.$ - %= +>.$ - dug nug - ::S mos :_(mos [hen %pass ~ %b kyz]) - == - :: - %hook :: this term hung up - ~& %dill-hook-not-implemented - +>.$ - ::S +>.$(dug (~(del by dug) hen), mos :_(mos [hen %pass ~ %b kyz])) - :: - %init - =. def `(fall def +.hen) - %= +>.$ - our p.kyz - mos - :_ mos - [(need def) %pass / %c %warp [p.kyz p.kyz] %main `[%& %y [%ud 1] /]] - == - :: - %talk (furl (~(win re p.kyz) 0 p.q.yar)) :: program output - %text $(kyz [%talk %leaf p.kyz]) :: simple message - == - :: - ++ poke - |= msg=mess - ^- move - :^ hen %pass /term-mess - :^ %g %mess [our /terminal] - :- our msg - :: - ++ yerk :: complete core - ^- [p=(list move) q=ship r=(unit duct) s=(map duct yard)] - :^ (flop mos) our def - (~(put by dug) hen yar) - -- + $% [%bel ~] :: make a noise + [%clr ~] :: clear the screen + [%hop p=@ud] :: set cursor position + [%lin p=(list ,@c)] :: set current line + [%mor ~] :: newline + [%sag p=path q=*] :: save to jamfile + [%sav p=path q=@] :: save to file + == :: +++ flog :: sent to %dill + $% [%crud p=@tas q=(list tank)] :: + [%text p=tape] :: + == :: +++ gift :: out result <-$ + $% [%bbye ~] :: reset prompt + [%blit p=(list blit)] :: terminal output + [%init p=@p] :: set owner + [%logo @] :: logout + [%veer p=@ta q=path r=@t] :: install vane + [%vega p=path] :: reboot by path + [%verb ~] :: + == :: +++ kiss :: in request ->$ + $% [%belt p=belt] :: terminal input + [%blew p=blew] :: terminal config + [%boot p=*] :: weird %dill boot + [%crud p=@tas q=(list tank)] :: error with trace + [%flog p=flog] :: wrapped error + [%flow p=@tas q=(list gill)] :: terminal config + [%hail ~] :: terminal refresh + [%hook ~] :: this term hung up + [%harm ~] :: all terms hung up + [%init p=ship] :: after gall ready + [%noop ~] :: no operation + [%talk p=tank] :: + [%text p=tape] :: + == :: +-- => :: +|% :: protocol outward +++ mess :: + $% [%dill-belt p=(hypo dill-belt)] :: + == :: +++ move ,[p=duct q=(mold note gift)] :: local move +++ note-ames :: weird ames move + $% [%make p=(unit ,@t) q=@ud r=@ s=?] :: + [%sith p=@p q=@uw r=?] :: + == :: +++ note-dill :: note to self, odd + $% [%crud p=@tas q=(list tank)] :: + [%text p=tape] :: + == :: +++ note-gall :: outbound message + $% [%mess p=[ship q=path] q=ship r=mess] :: + [%nuke p=[p=ship q=path] q=ship] :: + [%show p=[p=ship q=path] q=ship r=path] :: + [%took p=[p=ship q=path] q=ship] :: + == :: +++ note :: + $% [%a note-ames] :: out request $-> + [%d note-dill] :: + [%g note-gall] :: + == :: +++ riff ,[p=desk q=(unit rave)] :: see %clay +++ sign-gall :: + $% [%mean p=ares] :: + [%nice ~] :: + [%rush %dill-blit dill-blit] :: + == :: +++ sign-time :: + $% [%wake ~] :: + == :: +++ sign :: in result $<- + $% [%g sign-gall] :: + [%t sign-time] :: + == :: +:::::::: :: dill tiles -- -=| $: %1 :: - our=ship :: - def=(unit duct) :: - dug=(map duct yard) :: - == :: +=| all=axle |= [now=@da eny=@ ski=sled] :: current invocation +=> |% + ++ as :: per cause + |_ $: [moz=(list move) hen=duct our=ship] + axon + == + ++ abet :: resolve + ^- [(list move) axle] + [(flop moz) all(dug (~(put by dug.all) hen +<+))] + :: + ++ call :: receive input + |= kyz=kiss + ^+ +> + ?+ -.kyz ~& [%strange-kiss -.kyz] +> + %belt (send `dill-belt`p.kyz) + %blew (send %rez p.p.kyz q.p.kyz) + == + :: + ++ done :: return gift + |= git=gift + +>(moz :_(moz [hen %give git])) + :: + ++ from :: receive belt + |= bit=dill-blit + ^+ +> + ?: ?=(%out -.bit) + %+ done %blit + :~ [%lin p.bit] + [%mor ~] + [%lin see] + == + ?: ?=(%pro -.bit) + (done(see p.bit) %blit `(list blit)`[%lin p.bit]~) + (done %blit `(list blit)`[bit ~]) + :: + ++ init :: initialize + |= gyl=(list gill) + ^+ +> + =. moz :_(moz [hen %pass ~ %g %show [our [ram ~]] our ~]) + ?~ gyl +> + $(gyl t.gyl, +> (send %yow i.gyl)) + :: + ++ send :: send action + |= bet=dill-belt + %_ +> + moz + :_ moz + [hen %pass ~ %g %mess [our [ram ~]] our [%dill-belt -:!>(bet) bet]] + == + :: + ++ take :: receive + |= sih=sign + ^+ +> + ?- sih + [%g %mean *] + ~& [%take-mean sih] + +> + :: + [%g %nice *] + ~& [%take-nice sih] + +> + :: + [%g %rush %dill-blit *] + =. moz :_(moz `move`[hen %pass ~ %g %took [our [ram ~]] our]) + (from +>+.sih) + :: + [%t %wake *] + ~& %dill-wake + +> + == + -- + :: + ++ ax :: make as + |= [hen=duct kyz=kiss] :: + ~& [%ax-kiss kyz] + ?~ ore.all ~ + =+ nux=(~(get by dug.all) hen) + ?^ nux (some ~(. as [~ hen u.ore.all] u.nux)) + ?. ?=(%flow -.kyz) ~ + %- some + (~(init as [~ hen u.ore.all] [p.kyz 80 (tuba "<{(trip p.kyz)}>")]) q.kyz) + -- |% :: poke/peek pattern ++ call :: handle request |= $: hen=duct @@ -710,44 +255,44 @@ ~& [%dill-call-flub (,@tas `*`-.q.hic)] ((hard kiss) q.hic) == + ?: ?=(%boot -.q.hic) + :_(..^$ [hen %pass ~ (note %a p.q.hic)]~) ?: ?=(%flog -.q.hic) - :_ ..^$ - %+ turn (~(tap by dug) *(list ,[p=duct q=yard])) - |=([a=duct b=yard] [a %slip %d p.q.hic]) - =+ res=yerk:(lear:(dy hen our now def dug) q.hic) - [-.res ..^$(our +<.res, dug +>+.res, def +>-.res)] + :_(..^$ ?~(hey.all ~ [u.hey.all %slip %d p.q.hic]~)) + ?: ?=(%init -.q.hic) + [~ ..^$(ore.all `p.q.hic)] + =. hey.all ?^(hey.all hey.all `hen) + =+ nus=(ax hen q.hic) + ?~ nus + ~& [%dill-no-flow q.hic] + [~ ..^$] + =^ moz all abet:(call:u.nus q.hic) + [moz ..^$] :: ++ doze |= [now=@da hen=duct] ^- (unit ,@da) ~ :: -++ load :: XX LEGACY 12-16-2014 - |= $= old - $% [%0 our=ship def=(unit duct) dug=(map duct yord)] - [%1 our=ship def=(unit duct) dug=(map duct yard)] - == - ^+ ..^$ - ?- -.old - %1 %_(..^$ our our.old, def def.old, dug dug.old) - %0 %= $ - old - %= old - - %1 - dug (~(run by dug.old) |=(yor=yord [p q r | *@da]:yor)) - == - == - == +++ load :: totally disabled + |= old=* + ..^$(ore.all `~zod) :: ++ scry |= [fur=(unit (set monk)) ren=@tas his=ship syd=desk lot=coin tyl=path] ^- (unit (unit (pair mark ,*))) - [~ ~ [%tank >dug<]] + [~ ~] +:: +++ stay all :: -++ stay [%1 our def dug] ++ take :: process move |= [tea=wire hen=duct hin=(hypo sign)] ^- [p=(list move) q=_..^$] - =+ res=yerk:(leap:(dy hen our now def dug) tea q.hin) - [-.res ..^$(our +<.res, dug +>+.res, def +>-.res)] + ?: =(~ ore.all) + ~& [%take-back q.hin] + [~ ..^$] + =+ our=?>(?=(^ ore.all) u.ore.all) + =^ moz all + abet:(~(take as [~ hen our] (~(got by dug.all) hen)) q.hin) + [moz ..^$] -- diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index d89f91aed5..b3e1fc5edf 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -156,7 +156,12 @@ p=[p=tape q=tape r=tape] :: mid open close q=(list tank) :: == :: - == + == :: +++ tanq :: modern tank + $? [~ p=(list tanq)] :: list of printables + [~ ~ p=tape] :: simple string + (pair ,@tas tanq) :: captioned + == :: ++ tape (list char) :: like a string ++ term ,@tas :: Hoon ASCII subset ++ tiki :: test case diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook new file mode 100644 index 0000000000..9a22acaf8d --- /dev/null +++ b/main/app/seat/core.hook @@ -0,0 +1,293 @@ +:: :: :: +:::: /hook/core/seat/app :: :: + :: :: :: +/? 314 :: zuse version +/- *console :: console structures +/+ console :: console library +:: :: :: +:::: :: :: + !: :: :: +=> |% :: data structures + ++ house :: all state + $: bin=(map bone source) :: input devices + == :: + ++ source :: input device + $: edg=@ud :: terminal columns + apt=(list term) :: application ring + feg=(map term target) :: live applications + mir=(pair ,@ud (list ,@c)) :: mirrored state + == :: + ++ target :: application target + $: pom=console-prompt :: static prompt + inp=console-input :: input state + == :: + ++ message :: message to app + $% [%console-action console-action] :: + == :: + ++ gift :: out result <-$ + $% [%mean p=ares] :: + [%nice ~] :: + [%rush %dill-blit dill-blit] :: + == :: + ++ sign-gall :: sign from %gall + $% [%mean p=ares] :: + [%nice ~] :: + [%rush %console-effect console-effect] :: + ++ sign :: in result $<- + $% [%g sign-gall] :: + $% [%mean p=ares] :: + [%nice ~] :: + [%rush %console-effect console-effect] :: + == == == :: + ++ move ,[p=bone q=(mold note gift)] :: + ++ note-gall :: note to %gall + $% [%mess p=[p=ship q=path] q=ship r=message] :: + [%nuke p=[p=ship q=path] q=ship] :: + [%show p=[p=ship q=path] q=ship r=path] :: + [%took p=[p=ship q=path] q=ship] :: + == :: + ++ note :: out request $-> + $% [%g note-gall] :: + == :: + -- :: +|_ $: hid=hide :: system state + house :: program state + == :: +++ se :: per source + |_ [moz=(list move) [her=ship ost=bone] source] + ++ se-abet :: resolve + [(flop moz) %_(+> bin (~(put by bin) ost +<+>))] + :: + ++ se-belt :: handle input + |= bet=belt + ^+ +> + ?: =(%rez -.bet) + +>(wid q.rez) + ?: =(%yow -.bet) + (se-link p.bet) + ?~ apt + ~& %console-no-terminal + (se-blit %bel ~) + =+ nam=i.apt + =+ taz=~(. ta & nam (~(got by feg) nam)) + =< ta-abet + ?- -.bet + %aro (ta-aro:taz p.bet) + %bac ta-bac:taz + %ctl (ta-ctl:taz p.bet) + %del (ta-del:taz p.bet) + %met (ta-met:taz p.bet) + %ret (ta-ret:taz p.bet) + %txt (ta-txt:taz p.bet) + == + :: + ++ se-drop :: passive drop + |= nam=term + ^+ +> + ?> (~(has by feg) nam) + %_ +> + feg (~(del by feg) nam) + apt (skip apt |=(a=term =(nam a))) + == + :: + ++ se-join :: add connection + |= nam=term + ^+ +> + ?< (~(has by feg) nam) + +>(apt [nam apt], feg (~(put by feg) nam *target)) + :: + ++ se-nuke :: active drop + |= nam=term + se-drop:(se-send nam %nuke [her ~[nam]]) + :: + ++ se-link :: connect to app + |= nam=term + ^+ +> + %. nam + =< se-join + (se-send nam %show [her ~[nam]] her /console) + :: + ++ se-blit :: give output + |= bil=blit + (se-emit ost %give %rush %dill-blit bil) + :: + ++ se-view :: flush buffer + ^+ . + =+ ^= lin ^- (pair ,@ud (list ,@c)) + ?~ apt [0 ~] + ~(ta-vew ta & i.apt (~(got by feg) i.apt)) + ?: =(mir lin) + + =. + ?:(=(q.mir q.lin) + (se-blit %pro q.lin)) + =. + ?:(=(p.mir p.lin) + (se-blit %hop p.lin)) + +(mir lin) + :: + ++ se-kill :: kill a source + |- ^+ + + ?~ apt + + $(apt +.apt, + (se-nuke i.apt)) + :: + ++ se-emit :: emit move + |= mov=move + %_(+> moz [mov moz]) + :: + ++ se-send :: send a message + |= [nam=term nog=note-gall] + (se-emit ost %pass [(scot %p her) nam ~] %g nog) + :: + ++ se-tame + |= nam=term + ~(. ta & nam (~(got by feg) nam)) + :: + ++ se-pour :: receive results + |= [nam=term sil=sign-gall] + ^+ +> + ?- -.sil + %mean + ~& [%se-pour-mean sil] + +>.$ + :: + %nice + +>.$ + :: + %rush + ta-abet:(ta-got:(se-tame nam) +>.sih) + == + :: + ++ ta :: per target + |_ $: $: liv=? :: don't delete + nam=term :: target app + == :: + target :: target state + == :: + ++ ta-abet :: resolve + ?. liv (se-nuke nam) + %_(+> feg (~(put by feg) nam +<+)) + :: + ++ ta-act :: send action + |= act=console-action + %_(+> +> (se-send nam %mess %console-action act)) + :: + ++ ta-det :: send edit + |= ted=console-edit + (ta-act [[q.ven p.ven] (sham buf.say) ted) + :: + ++ ta-aro :: hear arrow + |= key=?(%d %l %r %u) + ^+ +> + ?- key + %d (sa-blit %bel ~) + %l ?: =(0 pos.inp) + (sa-blit bel ~) + +>(pos.inp (dec pos.inp))) + %r ?: =((lent buf.say.inp) pos.inp) + (sa-blit bel ~) + +>(pos.inp +(pos.inp)))) + %u (sa-blit %bel ~) + == + :: + ++ ta-bac :: hear backspace + ^+ . + ?: =(0 pos.inp) + (sa-blit bel ~) + (ta-hom %del (dec pos.inp)) + :: + ++ ta-ctl :: hear control + |= key=@ud + ~& [%ta-ctl key] + +> + :: + ++ ta-del :: hear delete + ^+ . + ?: =((lent buf.say.inp) pos.inp) + (sa-blit bel ~) + (ta-hom %del pos.inp) + :: + ++ ta-fec + |= fec=console-effect + ^+ +> + ?- -.fec + %bel (blit %bel ~) + %blk +> + %clr (blit %clr ~) + %det (ta-det p.fec q.fec) + %tan (ta-tan p.fec) + %txt $(fec %tan ~[%leaf p.fec]) + == + :: + ++ ta-got + |= [ler=console-clock haw=@uvH ted=console-edit] + +>(inp abet:(~(receive cs inp) ler haw ted)) + :: + ++ ta-hom :: local edit + |= ted=console-edit + ^+ +> + =. +> (ta-det ted) + %_(+> inp abet:(~(commit cs inp) ted)) + :: + ++ ta-met :: meta key + |= key=@ud + ~& [%ta-met key] + +> + :: + ++ ta-ret (ta-act ret ~) :: hear return + ++ ta-tan :: print tanks + |= tac=(list tank) + =+ wol=`wall`(zing (turn tac |=(a=tank (~(win re [0 edg]) a)))) + |- ^+ +>.^$ + ?~ wol +>.^$ + $(wol t.wol, +>.^$ (dill-blit %out (tuba i.wol))) + :: + ++ ta-txt :: hear text + |= txt=(list ,@c) + %- ta-hom + :- %mor + |- ^- (list console-edit) + ?~ txt ~ + [[%ins pos.inp i.txt] $(pos.inp +(pos.inp), txt t.txt)] + :: + ++ ta-vew :: computed prompt + ^- (pair ,@ud (list ,@c)) + =- [(add pos (lent p.vew)) (weld p.vew q.vew)] + ^= vew ^- (pair (list ,@c) (list ,@c)) + ?: vis.pom [cap.pom buf.say.inp] + :- ;: welp + cap.pom + ?~ buf.say.inp "" + ;: welp + "{" + (scow %p (end 4 1 (sham buf.say.inp))) + "} " + == + == + =+ len=(lent buf.say.inp) + |- ^- (list ,@c) + ?:(=(0 len) ~ ['*' $(len (dec len))]) + -- + -- +++ peer + |= [ost=bone her=ship pax=path] + ^- [(list move) _+>] + ?< (~(has by bin) ost) + [~ (~(put by bin) [her 80 ~ ~])] + [~ +>] +:: +++ poke-dill-belt + |= [ost=bone her=ship bet=dill-belt] + ^- [(list move) _+>] + se-abet:se-view:(~(se-belt se ~ [her ost] (~(got by bin) ost)) bet) +:: +++ pour + |= [ost=bone pax=path sih=*] + ^- [(list move) _+>] + =+ sih=((hard sign) sih) + ?> ?=([@ @ ~] pax) + =< se-abet + =< se-view + (~(se-pour se ~ [(slav %p i.pax) ost] (~(got by bin) ost)) i.t.pax sih) +:: +++ pull + |= ost=bone + ^- [(list move) _+>] + =^ moz +> se-abet:se-view:~(se-kill ~ [our.hid ost] (~(got by bin) ost)) + [moz +>.$(bin (~(del by bin) ost))] +-- diff --git a/main/app/tease/core.hook b/main/app/tease/core.hook new file mode 100644 index 0000000000..bd42538f93 --- /dev/null +++ b/main/app/tease/core.hook @@ -0,0 +1,31 @@ +:: :: :: +:::: /hook/core/tease/app :: :: + :: :: :: +/? 314 :: zuse version +/- *console :: console structures +/+ console :: console library +!: :: :: +:::: :: :: + :: :: :: +|_ [hid=hide town] +++ peer ,_`. +++ tease + ^- [(list move) _.] + :_ . + :_ ~ + :* 0 %pass ~ + %g %show + [our.hid /seat] our.hid + / + == +++ poke--args + |= [ost=bone you=ship *] + ^- [(list move) _+>] + tease +:: +++ prep + |= old=(unit (unit house-any)) + ^- [(list move) _+>] + ~& %tease-prep + tease +-- diff --git a/main/lib/console/core.hook b/main/lib/console/core.hook new file mode 100644 index 0000000000..648c0c8f23 --- /dev/null +++ b/main/lib/console/core.hook @@ -0,0 +1,89 @@ +:: +:::: /hook/core/console/lib + :: + :: This file is in the public domain. + :: +/? 310 +/- *console +:: +:::: + :: +|% +++ cs :: shared-state engine + |_ [pos=@ud console-share] + ++ abet +< + ++ apply + |= ted=console-edit + ^+ +> + ?- -.ted + %del +>.$(buf (weld (scag p.ted buf) (slag 1 buf))) + %ins +>.$(buf (weld (scag p.ted buf) `_buf`[q.ted buf])) + %mor |- ^+ +>.^$ + ?~ p.ted + +>.^$ + $(p.ted t.p.ted, +>.$ ^$(ted i.p.ted)) + %nop +>.$ + %set +>.$(buf p.ted, pos (lent p.ted)) + == + :: + :: symmetric operational transformation. for any console state, obeys + :: + :: =+ [x=(transmute a b) y=(transmute b a)] + :: .= (edit-apply:(edit-apply x) b) + :: (edit-apply:(edit-apply a) y) + :: + ++ transmute :: dex as after sin + |= [sin=console-edit dex=console-edit] + ^- console-edit + ?: ?=(%mor -.sin) + |- ^- console-edit + ?~ p.sin dex + $(p.sin t.p.sin, dex ^$(sin i.p.sin)) + :: + ?: ?=(%mor -.dex) + :- %mor + |- ^- (list console-edit) + ?~ p.dex ~ + [^$(dex i.p.dex) $(p.dex t.p.dex)] + :: + ?: |(?=(%nop -.sin) ?=(%nop -.dex)) dex + ?: ?=(%set -.sin) [%nop ~] + ?: ?=(%set -.dex) dex + :: + ?- -.sin + %del + ?- -.dex + %del ?: =(p.sin p.dex) [%nop ~] + ?:((lth p.sin p.dex) dex(p (dec p.dex)) dex) + %ins ?:((lte p.sin p.dex) dex(p (dec p.dex)) dex) + == + :: + %ins + ?- -.dex + %del ?:((lte p.sin p.dex) dex(p (inc p.dex)) dex) + %ins ?: =(p.sin p.dex) + ?:((gth q.sin q.dex) dex dex(p (inc p.dex))) + ?:((lte p.sin p.dex) dex(p (inc p.dex)) dex) + == + == + :: + ++ commit + |= ted=console-edit + ^+ +> + (apply(own.ven +(own.ven)) ted) + :: + ++ receive :: edit from other + |= $: ler=console-clock :: other's clock view + haw=@uvH :: hash at edit + ted=console-edit :: edit content + == + ^+ +> + ?> &(=(his.ler his.ven) (lte own.ler own.ven)) + ?> |(!=(own.ler own.ven) =(haw (sham buf))) + =: his.ven +(his.ven) + own.ven +(own.ven) + leg (scag (sub own.ven own.ler) leg) + == + (apply (transmute [%mor leg] ted)) + -- +-- diff --git a/main/lib/sh-utils/core.hook b/main/lib/sh-utils/core.hook index 2b9ce5a456..5f222c1f86 100644 --- a/main/lib/sh-utils/core.hook +++ b/main/lib/sh-utils/core.hook @@ -28,9 +28,7 @@ :: ++ add-subs :: add gall subscription |* [hat=[hapt ship path] ref=_,[(list) ^]] - =+ `[hapt ship path]`hat :: typecheck - %+ add-resp [%pass /show %g %show hat] - ref + (add-resp [%pass /show %g %show hat] ref) :: ++ args-into-gate :: poke--args from gate: output and exit |* [con=[* [hide *] *] gat=_,[@ *]] diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook new file mode 100644 index 0000000000..f20752ddb6 --- /dev/null +++ b/main/sur/console/core.hook @@ -0,0 +1,65 @@ +:: +:::: /hook/core/console/sur + !: +|% +++ console-action :: console to app + $% [%det console-change] :: edit prompt line + [%inn ~] :: enter session + [%out ~] :: exit session + [%ret ~] :: submit and clear + == :: +++ console-buffer (list ,@c) :: command state +++ console-change :: network change + $: ler=console-clock :: destination clock + haw=@uvH :: source hash + ted=console-edit :: state change + == :: +++ console-clock ,[own=@ud his=@ud] :: vector clock +++ console-edit :: shared state change + $% [%del p=@ud] :: delete one at + [%ins p=@ud q=@c] :: insert at + [%mor p=(list console-edit)] :: combination + [%nop ~] :: no-op + [%set p=console-buffer] :: discontinuity + == :: +++ console-effect :: app to console + $% [%bel ~] :: beep + [%blk p=@ud q=@c] :: blink/match char at + [%clr ~] :: clear screen + [%det console-change] :: edit input + [%tan p=(list tank)] :: classic tank + :: [%taq p=tanq] :: modern tank + [%txt p=tape] :: text line + == :: +++ console-input :: input state + $: pos=@ud :: cursor position + say=console-share :: cursor + == +++ console-share :: symmetric state + $: ven=console-clock :: our vector clock + leg=(list console-edit) :: unmerged edits + buf=console-buffer :: console state + == :: +++ dill-belt :: console input + $% [%aro p=?(%d %l %r %u)] :: arrow key + [%bac ~] :: true backspace + [%cru p=@tas q=(list tank)] :: echo error + [%ctl p=@ud] :: control-key + [%del ~] :: true delete + [%met p=@ud] :: meta-key + [%ret ~] :: return + [%rez p=@ud q=@ud] :: resize, cols, rows + [%txt p=(list ,@c)] :: utf32 text + [%yow p=gill] :: connect to app + == :: +++ dill-blit :: console output + $% [%bel ~] :: make a noise + [%clr ~] :: clear the screen + [%hop p=@ud] :: set cursor position + [%pro p=(list ,@c)] :: show as cursor/line + [%out p=(list ,@c)] :: send output line + [%sag p=path q=*] :: save to jamfile + [%sav p=path q=@] :: save to file + == :: +++ gill ,@tas :: general contact +-- From 0600aaa111fdb987f2b71407e171927a527fd5a2 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Sun, 8 Feb 2015 22:25:00 -0800 Subject: [PATCH 004/219] :seat compiles. --- arvo/gall.hoon | 2 +- main/app/seat/core.hook | 114 ++++++++++++++++++++++--------------- main/app/tease/core.hook | 19 ++----- main/lib/console/core.hook | 10 ++-- main/sur/console/core.hook | 7 ++- 5 files changed, 84 insertions(+), 68 deletions(-) diff --git a/arvo/gall.hoon b/arvo/gall.hoon index 430989c610..69edd4a990 100644 --- a/arvo/gall.hoon +++ b/arvo/gall.hoon @@ -261,7 +261,7 @@ ^- [p=(list move) q=_..^$] ?: ?=(%crud +<.q.hin) ~& [%gall-crud-error pax hen] - ~& [%gall-crud-data (,[@tas (list tank)] +>.q.hin)] + :: ~& [%gall-crud-data (,[@tas (list tank)] +>.q.hin)] ?> ?=(%g -.q.hin) ?~ pax ~& %strange-path [~ ..^$] =+ lum=(lump t.pax) diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index 9a22acaf8d..7ce77248c8 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -12,7 +12,7 @@ $: bin=(map bone source) :: input devices == :: ++ source :: input device - $: edg=@ud :: terminal columns + $: edg=_80 :: terminal columns apt=(list term) :: application ring feg=(map term target) :: live applications mir=(pair ,@ud (list ,@c)) :: mirrored state @@ -33,12 +33,10 @@ $% [%mean p=ares] :: [%nice ~] :: [%rush %console-effect console-effect] :: + == :: ++ sign :: in result $<- $% [%g sign-gall] :: - $% [%mean p=ares] :: - [%nice ~] :: - [%rush %console-effect console-effect] :: - == == == :: + == :: ++ move ,[p=bone q=(mold note gift)] :: ++ note-gall :: note to %gall $% [%mess p=[p=ship q=path] q=ship r=message] :: @@ -59,25 +57,26 @@ [(flop moz) %_(+> bin (~(put by bin) ost +<+>))] :: ++ se-belt :: handle input - |= bet=belt + |= bet=dill-belt ^+ +> - ?: =(%rez -.bet) - +>(wid q.rez) - ?: =(%yow -.bet) + ?: ?=(%rez -.bet) + +>(edg q.bet) + ?: ?=(%yow -.bet) (se-link p.bet) ?~ apt ~& %console-no-terminal (se-blit %bel ~) =+ nam=i.apt - =+ taz=~(. ta & nam (~(got by feg) nam)) + =+ taz=~(. ta [& nam] (~(got by feg) nam)) =< ta-abet ?- -.bet %aro (ta-aro:taz p.bet) %bac ta-bac:taz + %cru (ta-cru:taz p.bet q.bet) %ctl (ta-ctl:taz p.bet) - %del (ta-del:taz p.bet) + %del ta-del:taz %met (ta-met:taz p.bet) - %ret (ta-ret:taz p.bet) + %ret ta-ret:taz %txt (ta-txt:taz p.bet) == :: @@ -98,7 +97,8 @@ :: ++ se-nuke :: active drop |= nam=term - se-drop:(se-send nam %nuke [her ~[nam]]) + ^+ +> + (se-drop:(se-send nam %nuke [her ~[nam]] her) nam) :: ++ se-link :: connect to app |= nam=term @@ -108,23 +108,24 @@ (se-send nam %show [her ~[nam]] her /console) :: ++ se-blit :: give output - |= bil=blit + |= bil=dill-blit (se-emit ost %give %rush %dill-blit bil) :: ++ se-view :: flush buffer ^+ . =+ ^= lin ^- (pair ,@ud (list ,@c)) ?~ apt [0 ~] - ~(ta-vew ta & i.apt (~(got by feg) i.apt)) + ~(ta-vew ta [& i.apt] (~(got by feg) i.apt)) ?: =(mir lin) + =. + ?:(=(q.mir q.lin) + (se-blit %pro q.lin)) =. + ?:(=(p.mir p.lin) + (se-blit %hop p.lin)) +(mir lin) :: ++ se-kill :: kill a source - |- ^+ + - ?~ apt + - $(apt +.apt, + (se-nuke i.apt)) + =+ tup=apt + |- ^+ +> + ?~ tup +>(apt ~) + $(tup +.tup, +> (se-nuke i.tup)) :: ++ se-emit :: emit move |= mov=move @@ -136,7 +137,7 @@ :: ++ se-tame |= nam=term - ~(. ta & nam (~(got by feg) nam)) + ~(. ta [& nam] (~(got by feg) nam)) :: ++ se-pour :: receive results |= [nam=term sil=sign-gall] @@ -150,7 +151,7 @@ +>.$ :: %rush - ta-abet:(ta-got:(se-tame nam) +>.sih) + ta-abet:(ta-fec:(se-tame nam) +>.sil) == :: ++ ta :: per target @@ -160,35 +161,39 @@ target :: target state == :: ++ ta-abet :: resolve + ^+ ..ta ?. liv (se-nuke nam) %_(+> feg (~(put by feg) nam +<+)) :: ++ ta-act :: send action |= act=console-action - %_(+> +> (se-send nam %mess %console-action act)) + ^+ +> + %_(+> +> (se-send nam %mess [her ~[nam]] her %console-action act)) :: + ++ ta-bel .(+> (se-blit %bel ~)) :: beep ++ ta-det :: send edit |= ted=console-edit - (ta-act [[q.ven p.ven] (sham buf.say) ted) + ^+ +> + (ta-act %det [[his.ven.say.inp own.ven.say.inp] (sham buf.say.inp) ted]) :: ++ ta-aro :: hear arrow |= key=?(%d %l %r %u) ^+ +> ?- key - %d (sa-blit %bel ~) + %d ta-bel %l ?: =(0 pos.inp) - (sa-blit bel ~) - +>(pos.inp (dec pos.inp))) + ta-bel + +>(pos.inp (dec pos.inp)) %r ?: =((lent buf.say.inp) pos.inp) - (sa-blit bel ~) - +>(pos.inp +(pos.inp)))) - %u (sa-blit %bel ~) + ta-bel + +>(pos.inp +(pos.inp)) + %u ta-bel == :: ++ ta-bac :: hear backspace ^+ . ?: =(0 pos.inp) - (sa-blit bel ~) + .(+> (se-blit %bel ~)) (ta-hom %del (dec pos.inp)) :: ++ ta-ctl :: hear control @@ -196,22 +201,28 @@ ~& [%ta-ctl key] +> :: + ++ ta-cru :: hear crud + |= [lab=@tas tac=(list tank)] + =. +>+> (se-blit %out (tuba (trip lab))) + (ta-tan tac) + :: ++ ta-del :: hear delete ^+ . ?: =((lent buf.say.inp) pos.inp) - (sa-blit bel ~) + .(+> (se-blit %bel ~)) (ta-hom %del pos.inp) :: ++ ta-fec |= fec=console-effect ^+ +> ?- -.fec - %bel (blit %bel ~) + %bel ta-bel %blk +> - %clr (blit %clr ~) - %det (ta-det p.fec q.fec) + %clr +>(+> (se-blit %clr ~)) + %det (ta-got +.fec) + %pro (ta-pro +.fec) %tan (ta-tan p.fec) - %txt $(fec %tan ~[%leaf p.fec]) + %txt $(fec [%tan [%leaf p.fec]~]) == :: ++ ta-got @@ -229,13 +240,17 @@ ~& [%ta-met key] +> :: - ++ ta-ret (ta-act ret ~) :: hear return + ++ ta-pro :: set prompt + |= pom=console-prompt + +>(pom pom) + :: + ++ ta-ret (ta-act %ret ~) :: hear return ++ ta-tan :: print tanks |= tac=(list tank) - =+ wol=`wall`(zing (turn tac |=(a=tank (~(win re [0 edg]) a)))) + =+ wol=`wall`(zing (turn tac |=(a=tank (~(win re a) [0 edg])))) |- ^+ +>.^$ ?~ wol +>.^$ - $(wol t.wol, +>.^$ (dill-blit %out (tuba i.wol))) + $(wol t.wol, +>+>.^$ (se-blit %out (tuba i.wol))) :: ++ ta-txt :: hear text |= txt=(list ,@c) @@ -247,34 +262,36 @@ :: ++ ta-vew :: computed prompt ^- (pair ,@ud (list ,@c)) - =- [(add pos (lent p.vew)) (weld p.vew q.vew)] + =- [(add pos.inp (lent p.vew)) (weld p.vew q.vew)] ^= vew ^- (pair (list ,@c) (list ,@c)) ?: vis.pom [cap.pom buf.say.inp] :- ;: welp cap.pom - ?~ buf.say.inp "" + ?~ buf.say.inp ~ + %- tuba ;: welp - "{" + "<" (scow %p (end 4 1 (sham buf.say.inp))) - "} " + "> " == == =+ len=(lent buf.say.inp) |- ^- (list ,@c) - ?:(=(0 len) ~ ['*' $(len (dec len))]) + ?:(=(0 len) ~ [`@c`'*' $(len (dec len))]) -- -- ++ peer |= [ost=bone her=ship pax=path] ^- [(list move) _+>] ?< (~(has by bin) ost) - [~ (~(put by bin) [her 80 ~ ~])] - [~ +>] + [~ +>(bin (~(put by bin) ost *source))] :: ++ poke-dill-belt |= [ost=bone her=ship bet=dill-belt] ^- [(list move) _+>] - se-abet:se-view:(~(se-belt se ~ [her ost] (~(got by bin) ost)) bet) + =< se-abet + =< se-view + (~(se-belt se ~ [her ost] (~(got by bin) ost)) bet) :: ++ pour |= [ost=bone pax=path sih=*] @@ -283,11 +300,14 @@ ?> ?=([@ @ ~] pax) =< se-abet =< se-view - (~(se-pour se ~ [(slav %p i.pax) ost] (~(got by bin) ost)) i.t.pax sih) + (~(se-pour se ~ [(slav %p i.pax) ost] (~(got by bin) ost)) i.t.pax +.sih) :: ++ pull |= ost=bone ^- [(list move) _+>] - =^ moz +> se-abet:se-view:~(se-kill ~ [our.hid ost] (~(got by bin) ost)) + =^ moz +> + =< se-abet + =< se-view + ~(se-kill se ~ [our.hid ost] (~(got by bin) ost)) [moz +>.$(bin (~(del by bin) ost))] -- diff --git a/main/app/tease/core.hook b/main/app/tease/core.hook index bd42538f93..9d662e4b58 100644 --- a/main/app/tease/core.hook +++ b/main/app/tease/core.hook @@ -7,25 +7,16 @@ !: :: :: :::: :: :: :: :: :: -|_ [hid=hide town] +|_ [hid=hide ~] ++ peer ,_`. -++ tease - ^- [(list move) _.] - :_ . +++ poke--args + |= [ost=bone you=ship ~] + ~& %tease + :_ +>.$ :_ ~ :* 0 %pass ~ %g %show [our.hid /seat] our.hid / == -++ poke--args - |= [ost=bone you=ship *] - ^- [(list move) _+>] - tease -:: -++ prep - |= old=(unit (unit house-any)) - ^- [(list move) _+>] - ~& %tease-prep - tease -- diff --git a/main/lib/console/core.hook b/main/lib/console/core.hook index 648c0c8f23..5160479a04 100644 --- a/main/lib/console/core.hook +++ b/main/lib/console/core.hook @@ -5,7 +5,7 @@ :: /? 310 /- *console -:: +!: :::: :: |% @@ -21,7 +21,7 @@ %mor |- ^+ +>.^$ ?~ p.ted +>.^$ - $(p.ted t.p.ted, +>.$ ^$(ted i.p.ted)) + $(p.ted t.p.ted, +>.^$ ^$(ted i.p.ted)) %nop +>.$ %set +>.$(buf p.ted, pos (lent p.ted)) == @@ -60,10 +60,10 @@ :: %ins ?- -.dex - %del ?:((lte p.sin p.dex) dex(p (inc p.dex)) dex) + %del ?:((lte p.sin p.dex) dex(p +(p.dex)) dex) %ins ?: =(p.sin p.dex) - ?:((gth q.sin q.dex) dex dex(p (inc p.dex))) - ?:((lte p.sin p.dex) dex(p (inc p.dex)) dex) + ?:((gth q.sin q.dex) dex dex(p +(p.dex))) + ?:((lte p.sin p.dex) dex(p +(p.dex)) dex) == == :: diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook index f20752ddb6..32180e807c 100644 --- a/main/sur/console/core.hook +++ b/main/sur/console/core.hook @@ -27,6 +27,7 @@ [%blk p=@ud q=@c] :: blink/match char at [%clr ~] :: clear screen [%det console-change] :: edit input + [%pro console-prompt] :: set prompt [%tan p=(list tank)] :: classic tank :: [%taq p=tanq] :: modern tank [%txt p=tape] :: text line @@ -34,7 +35,11 @@ ++ console-input :: input state $: pos=@ud :: cursor position say=console-share :: cursor - == + == :: +++ console-prompt :: prompt definition + $: vis=? :: input visible + cap=(list ,@c) :: caption + == :: ++ console-share :: symmetric state $: ven=console-clock :: our vector clock leg=(list console-edit) :: unmerged edits From a0f9950026dadc1613aa69df600efbcf8775c301 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Mon, 9 Feb 2015 12:40:44 -0800 Subject: [PATCH 005/219] Full test pathway. --- main/app/seat/core.hook | 5 ++++- main/app/tease/core.hook | 16 +++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index 7ce77248c8..97be360968 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -59,6 +59,7 @@ ++ se-belt :: handle input |= bet=dill-belt ^+ +> + ~& [%se-belt bet] ?: ?=(%rez -.bet) +>(edg q.bet) ?: ?=(%yow -.bet) @@ -289,14 +290,16 @@ ++ poke-dill-belt |= [ost=bone her=ship bet=dill-belt] ^- [(list move) _+>] + ~& [%dill-belt bet] =< se-abet =< se-view - (~(se-belt se ~ [her ost] (~(got by bin) ost)) bet) + (~(se-belt se [ost %give %nice ~]~ [her ost] (~(got by bin) ost)) bet) :: ++ pour |= [ost=bone pax=path sih=*] ^- [(list move) _+>] =+ sih=((hard sign) sih) + ~& [%seat-pour sih] ?> ?=([@ @ ~] pax) =< se-abet =< se-view diff --git a/main/app/tease/core.hook b/main/app/tease/core.hook index 9d662e4b58..ca76d0e9f1 100644 --- a/main/app/tease/core.hook +++ b/main/app/tease/core.hook @@ -13,10 +13,16 @@ |= [ost=bone you=ship ~] ~& %tease :_ +>.$ - :_ ~ - :* 0 %pass ~ - %g %show - [our.hid /seat] our.hid - / + :~ :* 0 %pass ~ + %g %show + [our.hid /seat] our.hid + / + == + :* 0 %pass ~ + %g %mess + [our.hid /seat] our.hid + %dill-belt + !>(`dill-belt`[%yow %galk]) + == == -- From 73e3fce860dc10f8a9d7f22f26ebdd04464184ab Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Mon, 9 Feb 2015 14:58:45 -0800 Subject: [PATCH 006/219] Revert to old dill, fix some strange bone-0 ness. --- arvo/dill.hoon | 967 +++++++++++++++++++++++++++++----------- arvo/dull.hoon | 316 +++++++++++++ arvo/gall.hoon | 4 +- main/app/seat/core.hook | 1 + 4 files changed, 1030 insertions(+), 258 deletions(-) create mode 100644 arvo/dull.hoon diff --git a/arvo/dill.hoon b/arvo/dill.hoon index 09d4bb3e78..a38c75f88a 100644 --- a/arvo/dill.hoon +++ b/arvo/dill.hoon @@ -3,242 +3,697 @@ :: |= pit=vase => |% :: interface tiles -++ axle :: all dill state - $: %2 :: - ore=(unit ship) :: identity once set - hey=(unit duct) :: default duct - dug=(map duct axon) :: conversations - == :: -++ axon :: dill per duct - $: ram=term :: console program - wid=_80 :: terminal width - see=(list ,@c) :: current line - == :: --- :: -=> |% :: console protocol -++ console-action :: console to app - $% [%det console-change] :: edit prompt line - [%inn ~] :: enter session - [%out ~] :: exit session - [%ret ~] :: submit and clear - == :: -++ console-buffer (list ,@c) :: command state -++ console-change :: network change - $: ler=console-clock :: destination clock - haw=@uvH :: source hash - ted=console-edit :: state change - == :: -++ console-clock ,[own=@ud his=@ud] :: vector clock -++ console-edit :: shared state change - $% [%del p=@ud] :: delete one at - [%ins p=@ud q=@c] :: insert at - [%mor p=(list console-edit)] :: combination - [%nop ~] :: no-op - [%set p=console-buffer] :: discontinuity - == :: -++ console-effect :: app to console - $% [%bel ~] :: beep - [%blk p=@ud q=@c] :: blink/match char at - [%clr ~] :: clear screen - [%det console-change] :: edit input - [%tan p=(list tank)] :: classic tank - :: [%taq p=tanq] :: modern tank - [%txt p=tape] :: text line - == :: -++ dill-belt :: console input - $% [%aro p=?(%d %l %r %u)] :: arrow key - [%bac ~] :: true backspace - [%cru p=@tas q=(list tank)] :: echo error - [%ctl p=@ud] :: control-key - [%del ~] :: true delete - [%met p=@ud] :: meta-key - [%ret ~] :: return - [%rez p=@ud q=@ud] :: resize, cols, rows - [%txt p=(list ,@c)] :: utf32 text - [%yow p=gill] :: connect to app - == :: -++ dill-blit :: console output - $% [%bel ~] :: make a noise - [%clr ~] :: clear the screen - [%hop p=@ud] :: set cursor position - [%pro p=(list ,@c)] :: show as cursor/line - [%out p=(list ,@c)] :: send output line - [%sag p=path q=*] :: save to jamfile - [%sav p=path q=@] :: save to file - == :: -++ gill ,@tas :: general contact --- => :: -|% :: protocol below +++ gift :: out result <-$ + $% [%bbye ~] :: reset prompt + [%blit p=(list blit)] :: terminal output + [%init p=@p] :: report install + [%logo @] :: logout + [%veer p=@ta q=path r=@t] :: install vane + [%vega p=path] :: reboot by path + [%verb ~] :: + == :: +++ kiss :: in request ->$ + $% [%belt p=belt] :: terminal input + [%blew p=blew] :: terminal config + [%boot p=*] :: weird %dill boot + [%crud p=@tas q=(list tank)] :: error with trace + [%flog p=flog] :: wrapped error + [%hail ~] :: terminal refresh + [%hook ~] :: this term hung up + [%harm ~] :: all terms hung up + [%init p=ship] :: after gall ready + [%noop ~] :: no operation + [%talk p=tank] :: + [%text p=tape] :: + == :: +++ flog :: sent to %dill + $% [%crud p=@tas q=(list tank)] :: + [%text p=tape] :: + == :: +++ mess :: message to terminal + $% [%term-ctrl p=(hypo ,%hail)] :: + [%term-in p=(hypo term-in)] :: + == :: +++ move ,[p=duct q=(mold note gift)] :: local move +++ note :: out request $-> + $% $: %a :: + $% [%make p=(unit ,@t) q=@ud r=@ s=?] :: + [%sith p=@p q=@uw r=?] :: + == == :: + $: %c :: + $% [%warp p=sock q=riff] :: + == == :: + $: %d :: + $% [%crud p=@tas q=(list tank)] :: + [%text p=tape] :: + == == :: + $: %g :: + $% [%mess p=[p=ship q=path] q=ship r=mess] :: + [%nuke p=[p=ship q=path] q=ship] :: + [%show p=[p=ship q=path] q=ship r=path] :: + [%took p=[p=ship q=path] q=ship] :: + == == :: + $: %t :: + $% [%wait p=@da] :: + == == == :: +++ riff ,[p=desk q=(unit rave)] :: see %clay +++ sign :: in result $<- + $? + $: %c :: + $% [%writ p=riot] :: + == == :: + $: %g :: + $% [%logo p=@] :: + [%mean p=ares] :: + [%nice ~] :: + $: %rush :: + $% [%term-line q=term-line] :: + [%hymn q=manx] :: + == == :: + [%verb ~] :: + [%sage p=path q=*] :: + [%veer p=@ta q=path r=@t] :: + [%vega p=path] :: + == == :: + $: %t :: + $% [%wake ~] :: + == == + $: @tas :: by any + $% [%crud p=@tas q=(list tank)] :: + [%init p=@p] :: + [%note p=@tD q=tank] :: + == == == :: +++ term-in :: + $: pax=path :: + $= jof :: + $% [%line p=cord] :: + [%res p=span] :: + [%cmd p=char] :: + [%type p=?] :: + == == :: +++ term-line ,[p=[p=cord q=prom r=cord] q=(list cord) r=(list tark)] +++ tark ?(tank [%stem p=@da q=tank r=tank]) :: +:::::::: :: dill tiles +++ bein :: terminal control + $: $: bul=@ud :: buffer length + bus=@ud :: cursor in buffer + but=(list ,@c) :: buffer text + buy=prom :: input style + == :: + $: hiz=@ud :: history depth + hux=path :: history path + hym=(map ,@ud (list ,@c)) :: history overlay + hyt=hist :: history object + hyr=(unit (list ,@c)) :: history search + == :: + $: pol=@ud :: length of prompt + pot=tape :: prompt text + == :: + == :: ++ blew ,[p=@ud q=@ud] :: columns rows ++ belt :: raw console input - $% [%aro p=?(%d %l %r %u)] :: arrow key - [%bac ~] :: true backspace - [%ctl p=@ud] :: control-key - [%del ~] :: true delete - [%met p=@ud] :: meta-key - [%ret ~] :: return - [%txt p=(list ,@c)] :: utf32 text - == :: + $% [%aro p=?(%d %l %r %u)] :: arrow key + [%bac ~] :: true backspace + [%ctl p=@ud] :: control-key + [%del ~] :: true delete + [%met p=@ud] :: meta-key + [%ret ~] :: return + [%txt p=(list ,@c)] :: utf32 text + == :: ++ blit :: raw console output - $% [%bel ~] :: make a noise - [%clr ~] :: clear the screen - [%hop p=@ud] :: set cursor position - [%lin p=(list ,@c)] :: set current line - [%mor ~] :: newline - [%sag p=path q=*] :: save to jamfile - [%sav p=path q=@] :: save to file - == :: -++ flog :: sent to %dill - $% [%crud p=@tas q=(list tank)] :: - [%text p=tape] :: - == :: -++ gift :: out result <-$ - $% [%bbye ~] :: reset prompt - [%blit p=(list blit)] :: terminal output - [%init p=@p] :: set owner - [%logo @] :: logout - [%veer p=@ta q=path r=@t] :: install vane - [%vega p=path] :: reboot by path - [%verb ~] :: - == :: -++ kiss :: in request ->$ - $% [%belt p=belt] :: terminal input - [%blew p=blew] :: terminal config - [%boot p=*] :: weird %dill boot - [%crud p=@tas q=(list tank)] :: error with trace - [%flog p=flog] :: wrapped error - [%flow p=@tas q=(list gill)] :: terminal config - [%hail ~] :: terminal refresh - [%hook ~] :: this term hung up - [%harm ~] :: all terms hung up - [%init p=ship] :: after gall ready - [%noop ~] :: no operation - [%talk p=tank] :: - [%text p=tape] :: - == :: --- => :: -|% :: protocol outward -++ mess :: - $% [%dill-belt p=(hypo dill-belt)] :: - == :: -++ move ,[p=duct q=(mold note gift)] :: local move -++ note-ames :: weird ames move - $% [%make p=(unit ,@t) q=@ud r=@ s=?] :: - [%sith p=@p q=@uw r=?] :: - == :: -++ note-dill :: note to self, odd - $% [%crud p=@tas q=(list tank)] :: - [%text p=tape] :: - == :: -++ note-gall :: outbound message - $% [%mess p=[ship q=path] q=ship r=mess] :: - [%nuke p=[p=ship q=path] q=ship] :: - [%show p=[p=ship q=path] q=ship r=path] :: - [%took p=[p=ship q=path] q=ship] :: - == :: -++ note :: - $% [%a note-ames] :: out request $-> - [%d note-dill] :: - [%g note-gall] :: - == :: -++ riff ,[p=desk q=(unit rave)] :: see %clay -++ sign-gall :: - $% [%mean p=ares] :: - [%nice ~] :: - [%rush %dill-blit dill-blit] :: - == :: -++ sign-time :: - $% [%wake ~] :: - == :: -++ sign :: in result $<- - $% [%g sign-gall] :: - [%t sign-time] :: - == :: -:::::::: :: dill tiles --- -=| all=axle -|= [now=@da eny=@ ski=sled] :: current invocation -=> |% - ++ as :: per cause - |_ $: [moz=(list move) hen=duct our=ship] - axon - == - ++ abet :: resolve - ^- [(list move) axle] - [(flop moz) all(dug (~(put by dug.all) hen +<+))] - :: - ++ call :: receive input - |= kyz=kiss - ^+ +> - ?+ -.kyz ~& [%strange-kiss -.kyz] +> - %belt (send `dill-belt`p.kyz) - %blew (send %rez p.p.kyz q.p.kyz) + $% [%bel ~] :: make a noise + [%clr ~] :: clear the screen + [%hop p=@ud] :: set cursor position + [%lin p=(list ,@c)] :: set current line + [%mor ~] :: newline + [%sag p=path q=*] :: save to jamfile + [%sav p=path q=@] :: save to file + == :: +++ blot :: kill ring + $: p=@ud :: length + q=@ud :: depth + r=(list (list ,@c)) :: kills + == :: +++ blur ,[p=@ud q=(unit bein) r=blot] :: columns, prompt +++ kyev :: + $: p=(set ?(%ctrl %shift %alt %meta)) :: + q=$|(cord [%act speck]) :: + == :: +++ speck :: + $? %ctrl %shift %alt %meta %entr %esc :: + %caps %uncap %pgup %pgdn %home %end :: + %baxp %del %ins %up %down %left :: + %right :: + == :: +++ yard :: terminal state + $: p=? :: verbose + q=blur :: display state + r=(map path hist) :: history + s=[p=? q=@da] :: typing?/last typed + == :: + :: XX LEGACY 12-16-2014 +++ yord :: old terminal state + $: p=? :: verbose + q=blur :: display state + r=(map path hist) :: history + == :: +-- => +|% +++ dy + |= [hen=duct our=ship now=@da def=(unit duct) dug=(map duct yard)] + =+ ^= yar ^- yard + =+ yur=(~(get by dug) hen) + ?^ yur u.yur + ?^ def (~(got by dug) u.def) + [& [80 ~ *blot] ~ | *@da] + =| mos=(list move) + |% + ++ beep (curb [[%bel ~] ~]) :: send beep + ++ curb :: send blits + |= wab=(list blit) + ^+ +> + ?~ wab +> + +>(mos [[hen [%give %blit (flop wab)]] mos]) + :: + ++ wod :: word forward + |= bed=bein + ^- @ud + ?: =(bul.bed bus.bed) + bus.bed + ?: =(' ' (snag bus.bed but.bed)) + $(bus.bed +(bus.bed)) + |- + ^- @ud + ?: =(bul.bed bus.bed) + bus.bed + ?: =(' ' (snag bus.bed but.bed)) + bus.bed + $(bus.bed +(bus.bed)) + :: + ++ wob :: word backward + |= bed=bein + ^- @ud + ?: =(0 bus.bed) + bus.bed + ?: =(' ' (snag (dec bus.bed) but.bed)) + $(bus.bed (dec bus.bed)) + |- + ^- @ud + ?: =(0 bus.bed) + bus.bed + ?: =(' ' (snag (dec bus.bed) but.bed)) + bus.bed + $(bus.bed (dec bus.bed)) + :: + ++ edit :: change the bed + |= bed=bein + ^+ +> + =. q.q.yar [~ bed] + ?> ?=(^ q.q.yar) + %- curb + |- ^- (list blit) + ?^ hyr.u.q.q.yar + =+ ris=:(weld "(reverse-i-search)'" (tufa u.hyr.u.q.q.yar) "': ") + %= $ + pot.bed ris + pol.bed (lent ris) + hyr.u.q.q.yar ~ + == + :~ [%hop (add pol.bed bus.bed)] + :- %lin + %+ weld pot.bed + ?- buy.bed + %none but.bed + %text but.bed + %pass `(list ,@)`(runt [(lent but.bed) '*'] ~) == - :: - ++ done :: return gift - |= git=gift - +>(moz :_(moz [hen %give git])) - :: - ++ from :: receive belt - |= bit=dill-blit - ^+ +> - ?: ?=(%out -.bit) - %+ done %blit - :~ [%lin p.bit] - [%mor ~] - [%lin see] - == - ?: ?=(%pro -.bit) - (done(see p.bit) %blit `(list blit)`[%lin p.bit]~) - (done %blit `(list blit)`[bit ~]) - :: - ++ init :: initialize - |= gyl=(list gill) - ^+ +> - =. moz :_(moz [hen %pass ~ %g %show [our [ram ~]] our ~]) - ?~ gyl +> - $(gyl t.gyl, +> (send %yow i.gyl)) - :: - ++ send :: send action - |= bet=dill-belt - %_ +> - moz - :_ moz - [hen %pass ~ %g %mess [our [ram ~]] our [%dill-belt -:!>(bet) bet]] - == - :: - ++ take :: receive - |= sih=sign - ^+ +> - ?- sih - [%g %mean *] - ~& [%take-mean sih] - +> - :: - [%g %nice *] - ~& [%take-nice sih] - +> - :: - [%g %rush %dill-blit *] - =. moz :_(moz `move`[hen %pass ~ %g %took [our [ram ~]] our]) - (from +>+.sih) - :: - [%t %wake *] - ~& %dill-wake - +> - == - -- + == + :: + ++ fume :: print tank, prefix + |= [pef=@tD tac=tank] + ^+ +> + =+ wol=(~(win re tac) 2 p.q.yar) + %- furl + %+ turn wol + |= a=tape ^- tape + ?> ?=([@ @ *] a) + [pef ' ' t.t.a] + :: + ++ furl :: print wall + |= wol=(list tape) + ^+ +> + =. +> + %- curb + %- flop + |- ^- (list blit) + ?~ wol ~ + [[%lin (tuba i.wol)] [%mor ~] $(wol t.wol)] + ?~ q.q.yar +> + (edit(q.q.yar ~) u.q.q.yar) + :: + ++ gore :: move in history + |= hup=@ud + ^+ +> + =+ but=(goth hup) + =+ bul=(lent but) + %- edit + ?> ?=(^ q.q.yar) + %= u.q.q.yar + hiz hup + hym %+ ~(put by hym.u.q.q.yar) + hiz.u.q.q.yar + but.u.q.q.yar + bus bul + bul bul + but but + == + :: + ++ goth :: extract history + |= hup=@ud + ?> ?=(^ q.q.yar) + =+ byt=(~(get by hym.u.q.q.yar) hup) + ?^ byt u.byt + (tuba (rip 3 (snag hup q.hyt.u.q.q.yar))) + :: + ++ kill :: add to kill ring + |= txt=(list ,@c) + ^+ +> + => ?. =(16 p.r.q.yar) . + .(p.r.q.yar 15, r.r.q.yar (scag 15 r.r.q.yar)) + %= +> + p.r.q.yar +(p.r.q.yar) + q.r.q.yar 0 + r.r.q.yar [txt r.r.q.yar] + == + :: + ++ look :: search in history + |= [hup=@ud txt=(list ,@c)] + ^+ +> + =+ ^= beg + |= [a=(list ,@c) b=(list ,@c)] ^- ? + ?~(a & ?~(b | &(=(i.a i.b) $(a t.a, b t.b)))) + =+ ^= mid + |= [a=(list ,@c) b=(list ,@c)] ^- ? + ?~(a & ?~(b | |((beg a b) $(b t.b)))) + ?> ?=(^ q.q.yar) + ?: =(hup p.hyt.u.q.q.yar) + beep + =+ but=(goth hup) + ?: (mid txt but) + (gore(hyr.u.q.q.yar [~ txt]) hup) + $(hup +(hup)) + :: + ++ leap :: accept response + |= [tea=wire sih=sign] + ^+ +> + ?- -.+.sih + %crud :: error trace + =. q.+.sih [[%leaf (trip p.+.sih)] q.+.sih] + |- ^+ +>.^$ + ?~ q.+.sih +>.^$ + (fume:$(q.+.sih t.q.+.sih) '!' `tank`i.q.+.sih) :: - ++ ax :: make as - |= [hen=duct kyz=kiss] :: - ~& [%ax-kiss kyz] - ?~ ore.all ~ - =+ nux=(~(get by dug.all) hen) - ?^ nux (some ~(. as [~ hen u.ore.all] u.nux)) - ?. ?=(%flow -.kyz) ~ - %- some - (~(init as [~ hen u.ore.all] [p.kyz 80 (tuba "<{(trip p.kyz)}>")]) q.kyz) - -- + %mean ~& %dill-mean +>.$ + %nice +>.$ + %note ?.(p.yar +>.$ (fume p.+.sih q.+.sih)) :: debug message + ?(%rush %rust) :: XX reset prompt + =. mos :_(mos [hen %pass tea %g %took [our /terminal] our]) + ?> ?=(%term-line +>-.sih) + =. +>.$ + =+ lis=(scag 1.000 r.q.sih) + =- (furl (zing (turn (flop lis) -))) + |= a=tark + ^- wall + ?+ -.a (~(win re a) 0 p.q.yar) + %stem + ?: =(q.s.yar p.a) ~ + ~[(welp ~(ram re q.a) ~(ram re r.a))] + == + ?. (levy r.q.sih |=(a=tark ?=(%stem -.a))) + +>.$ :: XX separate prompt/history messages + %- edit + =| bed=bein + =+ ^= hyt ^- hist + =+ hyt=(~(get by r.yar) /) + ?~(hyt *hist u.hyt) + ?: &(?=(^ q.q.yar) =(/ hux.u.q.q.yar)) + =+ bun=(rip 5 (turf r.p.q.sih)) + %= u.q.q.yar + bul ?~ r.p.q.sih bul.u.q.q.yar (lent bun) + bus ?~ r.p.q.sih bus.u.q.q.yar (lent bun) + but ?~ r.p.q.sih but.u.q.q.yar bun + hyt [+(p.hyt) [%$ q.hyt]] + pot (trip p.p.q.sih) + pol (met 3 p.p.q.sih) + buy q.p.q.sih + == + %_ bed + bul (met 3 r.p.q.sih) + bus (met 3 r.p.q.sih) + but (rip 3 r.p.q.sih) + buy q.p.q.sih + hux / + hiz 0 + hyt [+(p.hyt) [%$ q.hyt]] + pot (trip p.p.q.sih) + pol (met 3 p.p.q.sih) + == + :: + %sage :: write a jamfile + %= +>.$ + mos :_(mos [hen [%give %blit [%sag p.+.sih q.+.sih] ~]]) + == + ?(%init %logo %veer %vega %verb) :: drop-throughs + +>(mos :_(mos [hen %give +.sih])) + %writ :: file exists + %_ +>.$ + mos + :_ mos + [hen %pass /term-show %g %show [our /terminal] our /lines] + == + :: + %wake + ?: (lte (sub now ~s15) q.s.yar) + %_ +>.$ + mos + :_ mos + [hen %pass /activity %t %wait (add q.s.yar ~s15)] + == + %_ +>.$ + p.s.yar | + mos :_(mos (poke %term-in -:!>(*term-in) / %type %|)) + == + == + :: + ++ lear :: handle request + |= kyz=kiss + ^+ +> + ?- -.kyz + %flog !! + %noop +> + %belt :: terminal input + =. +>.$ + ?. ?=(?(%bac %del %ret %txt) -.p.kyz) +>.$ + ?: p.s.yar +>.$(s.yar [& now]) + %_ +>.$ + s.yar [& now] + mos + :_ :_ mos + [hen %pass /activity %t %wait (add ?:(p.s.yar q.s.yar now) ~s15)] + (poke %term-in -:!>(*term-in) / %type %&) + == + ?~ q.q.yar + %^ furl + "Downloading files from ticketing ship, please wait until" + "a prompt shows up. This could take several minutes." + ~ + ?^ hyr.u.q.q.yar :: live search + ?+ p.kyz $(hiz.u.q.q.yar 0, hyr.u.q.q.yar ~) + [%bac *] + ?: =(~ u.hyr.u.q.q.yar) + (curb [[%bel ~] ~]) + %- edit + %= u.q.q.yar + hyr [~ (scag (dec (lent u.hyr.u.q.q.yar)) u.hyr.u.q.q.yar)] + == + :: + [%txt *] (look hiz.u.q.q.yar (weld u.hyr.u.q.q.yar p.p.kyz)) + [%ctl %g] (edit u.q.q.yar(bul 0, bus 0, but ~, hiz 0, hyr ~)) + [%ctl %r] + ?: =(p.hyt.u.q.q.yar hiz.u.q.q.yar) + beep + (look +(hiz.u.q.q.yar) u.hyr.u.q.q.yar) + == + ?- -.p.kyz + %aro :: arrow + ?- p.p.kyz + %d :: down + ?: =(0 hiz.u.q.q.yar) + beep + (gore (dec hiz.u.q.q.yar)) + :: + %l :: left + ?: =(0 bus.u.q.q.yar) + beep + (edit u.q.q.yar(bus (dec bus.u.q.q.yar))) + :: + %r :: right + ?: =(bul.u.q.q.yar bus.u.q.q.yar) + beep + (edit u.q.q.yar(bus +(bus.u.q.q.yar))) + :: + %u + =+ hup=+(hiz.u.q.q.yar) + ?: =(hup p.hyt.u.q.q.yar) + beep + (gore hup) + == + :: + %bac :: backspace + ^+ +>.$ + ?: =(0 bus.u.q.q.yar) + (curb `(list blit)`[[%bel ~] ~]) + %- edit + %= u.q.q.yar + bus (dec bus.u.q.q.yar) + bul (dec bul.u.q.q.yar) + but + %+ weld + (scag (dec bus.u.q.q.yar) but.u.q.q.yar) + (slag bus.u.q.q.yar but.u.q.q.yar) + == + :: + %ctl :: control + ?+ p.p.kyz + beep + %a (edit u.q.q.yar(bus 0)) + %b $(kyz [%belt %aro %l]) + %d ?: ?& =(0 bul.u.q.q.yar) + =(0 bus.u.q.q.yar) + == + +>.$(mos :_(mos (poke %term-in -:!>(*term-in) / %cmd %d))) + $(kyz [%belt %del ~]) + %e (edit u.q.q.yar(bus bul.u.q.q.yar)) + %f $(kyz [%belt %aro %r]) + %g +>.$(mos :_(mos (poke %term-in -:!>(*term-in) / %cmd %g))) + %k ?: =(bul.u.q.q.yar bus.u.q.q.yar) + beep + => .(+>.$ (kill (slag bus.u.q.q.yar but.u.q.q.yar))) + %- edit + ?> ?=(^ q.q.yar) + %= u.q.q.yar + bul bus.u.q.q.yar + but (scag bus.u.q.q.yar but.u.q.q.yar) + == + %t ?: (lth bul.u.q.q.yar 2) + beep + =+ ^= pos + ?: =(bul.u.q.q.yar bus.u.q.q.yar) + (sub bus.u.q.q.yar 2) + ?: =(0 bus.u.q.q.yar) + bus.u.q.q.yar + (dec bus.u.q.q.yar) + %- edit + %= u.q.q.yar + bus (add 2 pos) + but %+ weld + %+ weld + (scag pos but.u.q.q.yar) + ^- (list ,@c) :+ + (snag +(pos) but.u.q.q.yar) + (snag pos but.u.q.q.yar) + ~ + (slag (add 2 pos) but.u.q.q.yar) + == + %l +>.$(mos :_(mos [hen %give %blit [[%clr ~] ~]])) + %n $(kyz [%belt %aro %d]) + %o %_ +>.$ + mos + :_ :_ mos + [hen %pass /term-show %g %nuke [our /terminal] our] + [hen %pass /term-show %g %show [our /terminal] our /lines] + == + %p $(kyz [%belt %aro %u]) + %u ?: =(0 bus.u.q.q.yar) + beep + => .(+>.$ (kill (scag bus.u.q.q.yar but.u.q.q.yar))) + %- edit + ?> ?=(^ q.q.yar) + %= u.q.q.yar + bus 0 + bul (sub bul.u.q.q.yar bus.u.q.q.yar) + but (slag bus.u.q.q.yar but.u.q.q.yar) + == + %r (edit u.q.q.yar(hyr [~ ~])) + %w ?: =(0 bus.u.q.q.yar) + beep + =+ bow=(wob u.q.q.yar) + =+ sow=(sub bus.u.q.q.yar bow) + => .(+>.$ (kill (swag [bow sow] but.u.q.q.yar))) + %- edit + ?> ?=(^ q.q.yar) + %= u.q.q.yar + bus bow + bul (sub bul.u.q.q.yar sow) + but %+ welp + (scag bow but.u.q.q.yar) + (slag bus.u.q.q.yar but.u.q.q.yar) + == + %x +>.$(mos :_(mos (poke %term-in -:!>(*term-in) / %cmd %x))) + %y ?: =(0 p.r.q.yar) + beep + $(kyz [%belt %txt (snag q.r.q.yar r.r.q.yar)]) + == + :: + %del :: delete + ?: =(bul.u.q.q.yar bus.u.q.q.yar) + beep + %- edit + %= u.q.q.yar + bul (dec bul.u.q.q.yar) + but + %+ weld + (scag bus.u.q.q.yar but.u.q.q.yar) + (slag +(bus.u.q.q.yar) but.u.q.q.yar) + == + :: + %met :: meta + ?+ p.p.kyz + beep + %f + ?: =(bul.u.q.q.yar bus.u.q.q.yar) + beep + (edit u.q.q.yar(bus (wod u.q.q.yar))) + :: + %b + ?: =(0 bus.u.q.q.yar) + beep + (edit u.q.q.yar(bus (wob u.q.q.yar))) + :: + %y + ?: =(0 p.r.q.yar) + beep + =+ dol=(snag q.r.q.yar r.r.q.yar) + =+ leo=(lent dol) + ?. (gte bus.u.q.q.yar leo) + beep + =+ pey=(sub bus.u.q.q.yar leo) + ?. =(dol (swag [pey leo] but.u.q.q.yar)) + beep + =. q.r.q.yar ?:(=(p.r.q.yar +(q.r.q.yar)) 0 +(q.r.q.yar)) + =+ ney=(snag q.r.q.yar r.r.q.yar) + =+ lye=(lent ney) + %- edit + %= u.q.q.yar + bus (sub (add bus.u.q.q.yar lye) leo) + bul (sub (add bul.u.q.q.yar lye) leo) + but %+ weld + (scag pey but.u.q.q.yar) + %+ weld + `(list ,@c)`ney :: XX weird fuse-loop + (slag bus.u.q.q.yar but.u.q.q.yar) + == + == + :: + %ret :: return + ?: =(%none buy.u.q.q.yar) beep + =+ jab=(rap 3 (tufa but.u.q.q.yar)) + %= +>.$ + q.q.yar ~ + r.yar + ?: |(=(%$ jab) =(%pass buy.u.q.q.yar)) + r.yar + %+ ~(put by r.yar) + hux.u.q.q.yar + [p.hyt.u.q.q.yar [jab ?~(q.hyt.u.q.q.yar ~ +.q.hyt.u.q.q.yar)]] + :: + mos + :* (poke %term-ctrl -:!>(%hail) %hail) + [hen %give [%bbye ~]] + (poke %term-in -:!>(*term-in) / %line jab) + [hen %give [%blit [[%mor ~] ~]]] + mos + == + == + :: + %txt :: text keys + ?: =(%none buy.u.q.q.yar) beep + =+ let=(lent p.p.kyz) + %- edit + %= u.q.q.yar + bus (add let bus.u.q.q.yar) + bul (add let bul.u.q.q.yar) + but + ;: weld + (scag bus.u.q.q.yar but.u.q.q.yar) + p.p.kyz + (slag bus.u.q.q.yar but.u.q.q.yar) + == + == + == + :: + %blew +>.$(p.q.yar p.p.kyz) :: window size + %boot + %= +>.$ + mos + :_(mos [hen %pass ~ (note %a p.kyz)]) + == + :: + %crud :: error trace + =. q.kyz [[%leaf (trip p.kyz)] q.kyz] + |- ^+ +>.^$ + ?~ q.kyz +>.^$ + (fume:$(q.kyz t.q.kyz) '!' `tank`i.q.kyz) + :: + %hail :: refresh + +>.$ + ::+>.$(mos :_(mos (poke %term-ctrl -:!>(%hail) %hail))) + :: + %harm :: all terms hung up + =+ nug=((map duct yard) [[hen (~(get by dug) hen)] ~ ~]) + ^+ +>.$ + %= +>.$ + dug nug + ::S mos :_(mos [hen %pass ~ %b kyz]) + == + :: + %hook :: this term hung up + ~& %dill-hook-not-implemented + +>.$ + ::S +>.$(dug (~(del by dug) hen), mos :_(mos [hen %pass ~ %b kyz])) + :: + %init + =. def `(fall def +.hen) + %= +>.$ + our p.kyz + mos + :_ mos + [(need def) %pass / %c %warp [p.kyz p.kyz] %main `[%& %y [%ud 1] /]] + == + :: + %talk (furl (~(win re p.kyz) 0 p.q.yar)) :: program output + %text $(kyz [%talk %leaf p.kyz]) :: simple message + == + :: + ++ poke + |= msg=mess + ^- move + :^ hen %pass /term-mess + :^ %g %mess [our /terminal] + :- our msg + :: + ++ yerk :: complete core + ^- [p=(list move) q=ship r=(unit duct) s=(map duct yard)] + :^ (flop mos) our def + (~(put by dug) hen yar) + -- +-- +=| $: %1 :: + our=ship :: + def=(unit duct) :: + dug=(map duct yard) :: + == :: +|= [now=@da eny=@ ski=sled] :: current invocation |% :: poke/peek pattern ++ call :: handle request |= $: hen=duct @@ -255,44 +710,44 @@ ~& [%dill-call-flub (,@tas `*`-.q.hic)] ((hard kiss) q.hic) == - ?: ?=(%boot -.q.hic) - :_(..^$ [hen %pass ~ (note %a p.q.hic)]~) ?: ?=(%flog -.q.hic) - :_(..^$ ?~(hey.all ~ [u.hey.all %slip %d p.q.hic]~)) - ?: ?=(%init -.q.hic) - [~ ..^$(ore.all `p.q.hic)] - =. hey.all ?^(hey.all hey.all `hen) - =+ nus=(ax hen q.hic) - ?~ nus - ~& [%dill-no-flow q.hic] - [~ ..^$] - =^ moz all abet:(call:u.nus q.hic) - [moz ..^$] + :_ ..^$ + %+ turn (~(tap by dug) *(list ,[p=duct q=yard])) + |=([a=duct b=yard] [a %slip %d p.q.hic]) + =+ res=yerk:(lear:(dy hen our now def dug) q.hic) + [-.res ..^$(our +<.res, dug +>+.res, def +>-.res)] :: ++ doze |= [now=@da hen=duct] ^- (unit ,@da) ~ :: -++ load :: totally disabled - |= old=* - ..^$(ore.all `~zod) +++ load :: XX LEGACY 12-16-2014 + |= $= old + $% [%0 our=ship def=(unit duct) dug=(map duct yord)] + [%1 our=ship def=(unit duct) dug=(map duct yard)] + == + ^+ ..^$ + ?- -.old + %1 %_(..^$ our our.old, def def.old, dug dug.old) + %0 %= $ + old + %= old + - %1 + dug (~(run by dug.old) |=(yor=yord [p q r | *@da]:yor)) + == + == + == :: ++ scry |= [fur=(unit (set monk)) ren=@tas his=ship syd=desk lot=coin tyl=path] ^- (unit (unit (pair mark ,*))) - [~ ~] -:: -++ stay all + [~ ~ [%tank >dug<]] :: +++ stay [%1 our def dug] ++ take :: process move |= [tea=wire hen=duct hin=(hypo sign)] ^- [p=(list move) q=_..^$] - ?: =(~ ore.all) - ~& [%take-back q.hin] - [~ ..^$] - =+ our=?>(?=(^ ore.all) u.ore.all) - =^ moz all - abet:(~(take as [~ hen our] (~(got by dug.all) hen)) q.hin) - [moz ..^$] + =+ res=yerk:(leap:(dy hen our now def dug) tea q.hin) + [-.res ..^$(our +<.res, dug +>+.res, def +>-.res)] -- diff --git a/arvo/dull.hoon b/arvo/dull.hoon new file mode 100644 index 0000000000..44f7d21408 --- /dev/null +++ b/arvo/dull.hoon @@ -0,0 +1,316 @@ +!: +:: dill (4d), terminal handling +:: +|= pit=vase +=> |% :: interface tiles +++ axle :: all dill state + $: %2 :: + ore=(unit ship) :: identity once set + hey=(unit duct) :: default duct + dug=(map duct axon) :: conversations + == :: +++ axon :: dill per duct + $: ram=term :: console program + wid=_80 :: terminal width + see=(list ,@c) :: current line + == :: +-- :: +=> |% :: console protocol +++ console-action :: console to app + $% [%det console-change] :: edit prompt line + [%inn ~] :: enter session + [%out ~] :: exit session + [%ret ~] :: submit and clear + == :: +++ console-buffer (list ,@c) :: command state +++ console-change :: network change + $: ler=console-clock :: destination clock + haw=@uvH :: source hash + ted=console-edit :: state change + == :: +++ console-clock ,[own=@ud his=@ud] :: vector clock +++ console-edit :: shared state change + $% [%del p=@ud] :: delete one at + [%ins p=@ud q=@c] :: insert at + [%mor p=(list console-edit)] :: combination + [%nop ~] :: no-op + [%set p=console-buffer] :: discontinuity + == :: +++ console-effect :: app to console + $% [%bel ~] :: beep + [%blk p=@ud q=@c] :: blink/match char at + [%clr ~] :: clear screen + [%det console-change] :: edit input + [%tan p=(list tank)] :: classic tank + :: [%taq p=tanq] :: modern tank + [%txt p=tape] :: text line + == :: +++ dill-belt :: console input + $% [%aro p=?(%d %l %r %u)] :: arrow key + [%bac ~] :: true backspace + [%cru p=@tas q=(list tank)] :: echo error + [%ctl p=@ud] :: control-key + [%del ~] :: true delete + [%met p=@ud] :: meta-key + [%ret ~] :: return + [%rez p=@ud q=@ud] :: resize, cols, rows + [%txt p=(list ,@c)] :: utf32 text + [%yow p=gill] :: connect to app + == :: +++ dill-blit :: console output + $% [%bel ~] :: make a noise + [%clr ~] :: clear the screen + [%hop p=@ud] :: set cursor position + [%pro p=(list ,@c)] :: show as cursor/line + [%out p=(list ,@c)] :: send output line + [%sag p=path q=*] :: save to jamfile + [%sav p=path q=@] :: save to file + == :: +++ gill ,@tas :: general contact +-- => :: +|% :: protocol below +++ blew ,[p=@ud q=@ud] :: columns rows +++ belt :: raw console input + $% [%aro p=?(%d %l %r %u)] :: arrow key + [%bac ~] :: true backspace + [%ctl p=@ud] :: control-key + [%del ~] :: true delete + [%met p=@ud] :: meta-key + [%ret ~] :: return + [%txt p=(list ,@c)] :: utf32 text + == :: +++ blit :: raw console output + $% [%bel ~] :: make a noise + [%clr ~] :: clear the screen + [%hop p=@ud] :: set cursor position + [%lin p=(list ,@c)] :: set current line + [%mor ~] :: newline + [%sag p=path q=*] :: save to jamfile + [%sav p=path q=@] :: save to file + == :: +++ flog :: sent to %dill + $% [%crud p=@tas q=(list tank)] :: + [%text p=tape] :: + == :: +++ gift :: out result <-$ + $% [%bbye ~] :: reset prompt + [%blit p=(list blit)] :: terminal output + [%init p=@p] :: set owner + [%logo @] :: logout + [%veer p=@ta q=path r=@t] :: install vane + [%vega p=path] :: reboot by path + [%verb ~] :: + == :: +++ kiss :: in request ->$ + $% [%belt p=belt] :: terminal input + [%blew p=blew] :: terminal config + [%boot p=*] :: weird %dill boot + [%crud p=@tas q=(list tank)] :: error with trace + [%flog p=flog] :: wrapped error + [%flow p=@tas q=(list gill)] :: terminal config + [%hail ~] :: terminal refresh + [%hook ~] :: this term hung up + [%harm ~] :: all terms hung up + [%init p=ship] :: after gall ready + [%noop ~] :: no operation + [%talk p=tank] :: + [%text p=tape] :: + == :: +-- => :: +|% :: protocol outward +++ mess :: + $% [%dill-belt p=(hypo dill-belt)] :: + == :: +++ move ,[p=duct q=(mold note gift)] :: local move +++ note-ames :: weird ames move + $% [%make p=(unit ,@t) q=@ud r=@ s=?] :: + [%sith p=@p q=@uw r=?] :: + == :: +++ note-dill :: note to self, odd + $% [%crud p=@tas q=(list tank)] :: + [%text p=tape] :: + == :: +++ note-gall :: outbound message + $% [%mess p=[ship q=path] q=ship r=mess] :: + [%nuke p=[p=ship q=path] q=ship] :: + [%show p=[p=ship q=path] q=ship r=path] :: + [%took p=[p=ship q=path] q=ship] :: + == :: +++ note :: + $% [%a note-ames] :: out request $-> + [%d note-dill] :: + [%g note-gall] :: + == :: +++ riff ,[p=desk q=(unit rave)] :: see %clay +++ sign-ames :: + $% [%nice ~] :: + == :: +++ sign-gall :: + $% [%crud p=@tas q=(list tank)] :: + [%mean p=ares] :: + [%nice ~] :: + [%rush %dill-blit dill-blit] :: + == :: +++ sign-time :: + $% [%wake ~] :: + == :: +++ sign :: in result $<- + $% [%a sign-ames] :: + [%g sign-gall] :: + [%t sign-time] :: + == :: +:::::::: :: dill tiles +-- +=| all=axle +|= [now=@da eny=@ ski=sled] :: current invocation +=> |% + ++ as :: per cause + |_ $: [moz=(list move) hen=duct our=ship] + axon + == + ++ abet :: resolve + ^- [(list move) axle] + [(flop moz) all(dug (~(put by dug.all) hen +<+))] + :: + ++ call :: receive input + |= kyz=kiss + ^+ +> + ?+ -.kyz ~& [%strange-kiss -.kyz] +> + %flow +> + %belt (send `dill-belt`p.kyz) + %blew (send %rez p.p.kyz q.p.kyz) + == + :: + ++ done :: return gift + |= git=gift + +>(moz :_(moz [hen %give git])) + :: + ++ from :: receive belt + |= bit=dill-blit + ^+ +> + ?: ?=(%out -.bit) + %+ done %blit + :~ [%lin p.bit] + [%mor ~] + [%lin see] + == + ?: ?=(%pro -.bit) + (done(see p.bit) %blit `(list blit)`[%lin p.bit]~) + (done %blit `(list blit)`[bit ~]) + :: + ++ init :: initialize + |= gyl=(list gill) + ^+ +> + ~& [%as-init ram gyl] + =. moz :_(moz [hen %pass ~ %g %show [our [ram ~]] our ~]) + |- ^+ +>.^$ + ?~ gyl +>.^$ + $(gyl t.gyl, +>.^$ (send %yow i.gyl)) + :: + ++ send :: send action + |= bet=dill-belt + %_ +> + moz + :_ moz + [hen %pass ~ %g %mess [our [ram ~]] our [%dill-belt -:!>(bet) bet]] + == + :: + ++ take :: receive + |= sih=sign + ^+ +> + ?- sih + [%a %nice *] + ~& [%take-nice-ames sih] + +> + :: + [%g %crud *] + ~& [%take-crud sih] + +> + :: + [%g %mean *] + ~& [%take-mean sih] + +> + :: + [%g %nice *] + ~& [%take-nice sih] + +> + :: + [%g %rush %dill-blit *] + =. moz :_(moz `move`[hen %pass ~ %g %took [our [ram ~]] our]) + (from +>+.sih) + :: + [%t %wake *] + ~& %dill-wake + +> + == + -- + :: + ++ ax :: make as + |= [hen=duct kyz=kiss] :: + ~& [%ax-kiss kyz] + ?~ ore.all ~ + =+ nux=(~(get by dug.all) hen) + ?^ nux (some ~(. as [~ hen u.ore.all] u.nux)) + ?. ?=(%flow -.kyz) ~ + %- some + (~(init as [~ hen u.ore.all] [p.kyz 80 (tuba "<{(trip p.kyz)}>")]) q.kyz) + -- +|% :: poke/peek pattern +++ call :: handle request + |= $: hen=duct + hic=(hypo (hobo kiss)) + == + ^- [p=(list move) q=_..^$] + => %= . :: XX temporary + q.hic + ^- kiss + ?: ?=(%soft -.q.hic) + :: ~& [%dill-call-soft (,@tas `*`-.p.q.hic)] + ((hard kiss) p.q.hic) + ?: (~(nest ut -:!>(*kiss)) | p.hic) q.hic + ~& [%dill-call-flub (,@tas `*`-.q.hic)] + ((hard kiss) q.hic) + == + ?: ?=(%boot -.q.hic) + :_(..^$ [hen %pass ~ (note %a p.q.hic)]~) + ?: ?=(%flog -.q.hic) + :_(..^$ ?~(hey.all ~ [u.hey.all %slip %d p.q.hic]~)) + ?: ?=(%init -.q.hic) + [~ ..^$(ore.all `p.q.hic)] + =. hey.all ?^(hey.all hey.all `hen) + =+ nus=(ax hen q.hic) + ?~ nus + ~& [%dill-no-flow q.hic] + [~ ..^$] + =^ moz all abet:(call:u.nus q.hic) + ~& [%call-moves moz] + [moz ..^$] +:: +++ doze + |= [now=@da hen=duct] + ^- (unit ,@da) + ~ +:: +++ load :: totally disabled + |= old=* + ..^$(ore.all `~zod) +:: +++ scry + |= [fur=(unit (set monk)) ren=@tas his=ship syd=desk lot=coin tyl=path] + ^- (unit (unit (pair mark ,*))) + [~ ~] +:: +++ stay all +:: +++ take :: process move + |= [tea=wire hen=duct hin=(hypo sign)] + ^- [p=(list move) q=_..^$] + ?: =(~ ore.all) + ~& [%take-back q.hin] + [~ ..^$] + =+ our=?>(?=(^ ore.all) u.ore.all) + =^ moz all + abet:(~(take as [~ hen our] (~(got by dug.all) hen)) q.hin) + ~& [%take-moves moz] + [moz ..^$] +-i diff --git a/arvo/gall.hoon b/arvo/gall.hoon index 69edd4a990..74e11ea23e 100644 --- a/arvo/gall.hoon +++ b/arvo/gall.hoon @@ -571,8 +571,8 @@ :: ++ able :: bone to duct |= ost=bone ^- duct - ?: =(0 ost) - [(away ~) ~] + :: ?: =(0 ost) + :: hun.mat (~(got by r.zam.sat) ost) :: ++ away :: application path diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index 97be360968..60910ca0a7 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -284,6 +284,7 @@ ++ peer |= [ost=bone her=ship pax=path] ^- [(list move) _+>] + ~& [%seat-peer ost her pax] ?< (~(has by bin) ost) [~ +>(bin (~(put by bin) ost *source))] :: From a3383bd740e71ec83867cdaa4f09e823d8f3ec74 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 9 Feb 2015 17:52:29 -0800 Subject: [PATCH 007/219] Long poll v1 --- arvo/eyre.hoon | 378 ++++++++++++++++++++++++++----------------------- arvo/zuse.hoon | 73 +++++----- 2 files changed, 239 insertions(+), 212 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 3f96d4cc87..22abd96e9d 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -11,7 +11,7 @@ [%thus p=@ud q=(unit hiss)] :: http request/cancel [%veer p=@ta q=path r=@t] :: drop-through [%vega p=path] :: drop-through - == :: + == :: ++ hasp ,[p=ship q=term] :: don't see %gall ++ hapt ,[p=ship q=path] :: do see %gall ++ kiss :: in request ->$ @@ -26,34 +26,36 @@ == :: ++ move ,[p=duct q=(mold note gift)] :: local move ++ note :: out request $-> - $% $: %a :: to %ames - $% [%want p=sock q=path r=*] :: - == == :: + $% +:: $: %a :: to %ames +:: $% [%want p=sock q=path r=*] :: +:: == == :: $: %c :: to %clay $% [%warp p=sock q=riff] :: == == :: $: %d :: to %dill $% [%flog p=[%crud p=@tas q=(list tank)]] :: == == :: - $: %e :: to %eyre - $% [%this p=? q=clip r=httq] :: - [%thud ~] :: - == == :: +:: $: %e :: to %eyre +:: $% [%this p=? q=clip r=httq] :: +:: [%thud ~] :: +:: == == :: $: %f :: to %ford $% [%exec p=@p q=(unit silk)] :: == == :: - $: %g :: to %gall - $% [%mess p=hapt q=ship r=cage] :: - [%nuke p=hapt q=ship] :: - [%show p=hapt q=ship r=path] :: - [%took p=hapt q=ship] :: - == == :: - $: %t :: to %temp - $% [%wait p=@da] :: - [%rest p=@da] :: - == == == :: +:: $: %g :: to %gall +:: $% [%mess p=hapt q=ship r=cage] :: +:: [%nuke p=hapt q=ship] :: +:: [%show p=hapt q=ship r=path] :: +:: [%took p=hapt q=ship] :: +:: == == :: +:: $: %t :: to %temp +:: $% [%wait p=@da] :: +:: [%rest p=@da] :: +:: == == + == :: ++ rave :: see %clay - $% [| p=moat] :: + $% [& p=mood] :: == :: ++ riff ,[p=desk q=(unit rave)] :: see %clay ++ silk :: see %ford @@ -105,91 +107,92 @@ ged=duct :: client interface ney=@uvI :: rolling entropy dop=(map host ship) :: host aliasing - own=(map ship serf) :: domestic servers - fon=(map ship rote) :: foreign servers - ask=[p=@ud q=(map ,@ud ,[p=duct q=hiss])] :: outgoing by number - kes=(map duct ,@ud) :: outgoing by duct - lor=(map duct dual) :: incoming by duct - == :: -++ clue :: console - $: ino=@ud :: input sequence - ono=@ud :: (lent out) - voy=(map ,@ud (list ,@ud)) :: waiters (q.rey) - out=(list json) :: output commands - == :: -++ cyst :: client session - $: ced=cred :: credential - cow=(map ,@ud clue) :: consoles - cug=(list ,@t) :: unacked cookies - lax=@da :: last used - sok=(map ,@ud (pair ship sink)) :: live apps by reqno - rey=[p=@ud q=(map ,@ud pimp)] :: live requests - == :: -++ dual ,[p=@ud q=(each ,[p=ship q=hole] ship)] :: request handle -++ dude ,[p=@tas q=@] :: client identity -++ pest :: request in progress - $| $? %new :: virgin - %way :: waiting - == :: - $% [%err p=@ud q=(list tank)] :: error report - [%fin p=love] :: ready to send - [%fud p=(each bead (list tank))] :: function finished - [%haz p=riot] :: clay responded - [%raw p=hiss] :: wild url - [%who p=@tas q=@ta] :: awaiting auth - == :: -++ pimp :: traced request - $: ful=? :: | === HEAD - fur=(unit mark) :: type goal - hen=duct :: event trace - som=seam :: logical request - pez=pest :: request state - sip=marl :: injected scripts - == :: -++ rote :: remote server - $: cnt=@ud :: number served - sor=@p :: home sponsor - rem=[p=@ud q=(map ,@ud duct)] :: active requests - == :: -++ seam :: logical request - $% [%ape p=ship q=@ud r=@ud] :: subscribe pull - [%aph p=ship q=@ud r=@ud s=json] :: app heartbeat - [%apg p=term q=ship r=mark s=path] :: app get/start - [%apm p=ship q=@ud r=@ud s=hasp for=mark t=json] :: message send - [%app p=ship q=(unit ,@ud)] :: script by port - [%aps p=ship q=@ud s=hasp t=path] :: subscribe - [%apu p=ship q=@ud s=hasp t=path] :: unsubscribe - [%cog p=@ud q=@ud] :: console get - [%con p=@ud] :: console face - [%cop p=@ud q=@ud r=json] :: console put - [%det p=desk q=moat] :: load changes - [%fun p=term q=tube r=(list manx)] :: functional - [%lon p=seal] :: authentication flow - [%red p=purl] :: redirect - [%sil p=@ud q=silk] :: status and silk - == :: -++ serf :: local server - $: pef=@t :: server prefix - wup=(map hole cyst) :: secure sessions - cah=(map cash vase) :: compilation cache - == :: -++ sink :: page push system - $: bet=[wig=swig num=@ud tim=@da hen=duct] :: heartbeat - meg=[wig=swig num=@ud] :: messages - sub=[wig=swig num=@ud can=(map ,@ud stem)] :: subscriptions - == :: -++ stem :: subscription - $: hap=hasp :: - pax=path :: - hen=duct :: - num=(unit (each ,@ud ,@ud)) :: - == :: -++ swig :: update channel - $: cnt=@ud :: updates produced - toy=@ud :: updates sent - wan=(map ,@ud ,@ud) :: upno to reqno - red=(map ,@ud (unit (each cage cage))) :: ready for pickup + liz=(jug beak (each duct oryx)) +:: own=(map ship serf) :: domestic servers +:: fon=(map ship rote) :: foreign servers +:: ask=[p=@ud q=(map ,@ud ,[p=duct q=hiss])] :: outgoing by number +:: kes=(map duct ,@ud) :: outgoing by duct +:: lor=(map duct dual) :: incoming by duct == :: +:: ++ clue :: console +:: $: ino=@ud :: input sequence +:: ono=@ud :: (lent out) +:: voy=(map ,@ud (list ,@ud)) :: waiters (q.rey) +:: out=(list json) :: output commands +:: == :: +:: ++ cyst :: client session +:: $: ced=cred :: credential +:: cow=(map ,@ud clue) :: consoles +:: cug=(list ,@t) :: unacked cookies +:: lax=@da :: last used +:: sok=(map ,@ud (pair ship sink)) :: live apps by reqno +:: rey=[p=@ud q=(map ,@ud pimp)] :: live requests +:: == :: +:: ++ dual ,[p=@ud q=(each ,[p=ship q=hole] ship)] :: request handle +:: ++ dude ,[p=@tas q=@] :: client identity +:: ++ pest :: request in progress +:: $| $? %new :: virgin +:: %way :: waiting +:: == :: +:: $% [%err p=@ud q=(list tank)] :: error report +:: [%fin p=love] :: ready to send +:: [%fud p=(each bead (list tank))] :: function finished +:: [%haz p=riot] :: clay responded +:: [%raw p=hiss] :: wild url +:: [%who p=@tas q=@ta] :: awaiting auth +:: == :: +:: ++ pimp :: traced request +:: $: ful=? :: | === HEAD +:: fur=(unit mark) :: type goal +:: hen=duct :: event trace +:: som=seam :: logical request +:: pez=pest :: request state +:: sip=marl :: injected scripts +:: == :: +:: ++ rote :: remote server +:: $: cnt=@ud :: number served +:: sor=@p :: home sponsor +:: rem=[p=@ud q=(map ,@ud duct)] :: active requests +:: == :: +:: ++ seam :: logical request +:: $% [%ape p=ship q=@ud r=@ud] :: subscribe pull +:: [%aph p=ship q=@ud r=@ud s=json] :: app heartbeat +:: [%apg p=term q=ship r=mark s=path] :: app get/start +:: [%apm p=ship q=@ud r=@ud s=hasp for=mark t=json] :: message send +:: [%app p=ship q=(unit ,@ud)] :: script by port +:: [%aps p=ship q=@ud s=hasp t=path] :: subscribe +:: [%apu p=ship q=@ud s=hasp t=path] :: unsubscribe +:: [%cog p=@ud q=@ud] :: console get +:: [%con p=@ud] :: console face +:: [%cop p=@ud q=@ud r=json] :: console put +:: [%det p=desk q=moat] :: load changes +:: [%fun p=term q=tube r=(list manx)] :: functional +:: [%lon p=seal] :: authentication flow +:: [%red p=purl] :: redirect +:: [%sil p=@ud q=silk] :: status and silk +:: == :: +:: ++ serf :: local server +:: $: pef=@t :: server prefix +:: wup=(map hole cyst) :: secure sessions +:: cah=(map cash vase) :: compilation cache +:: == :: +:: ++ sink :: page push system +:: $: bet=[wig=swig num=@ud tim=@da hen=duct] :: heartbeat +:: meg=[wig=swig num=@ud] :: messages +:: sub=[wig=swig num=@ud can=(map ,@ud stem)] :: subscriptions +:: == :: +:: ++ stem :: subscription +:: $: hap=hasp :: +:: pax=path :: +:: hen=duct :: +:: num=(unit (each ,@ud ,@ud)) :: +:: == :: +:: ++ swig :: update channel +:: $: cnt=@ud :: updates produced +:: toy=@ud :: updates sent +:: wan=(map ,@ud ,@ud) :: upno to reqno +:: red=(map ,@ud (unit (each cage cage))) :: ready for pickup +:: == :: -- :: |% :: ++ coss :: cookie search @@ -255,7 +258,7 @@ |= [a=[p=cord cord] b=math] =. p.a (cass (trip p.a)) (~(add ja b) a) -:: :: +:: :: ++ eccu :: [hasp json] :: |= [orx=oryx moh=moth] :: ^- (unit ,[hasp mark json]) @@ -366,6 +369,29 @@ ?- -.+.sih %crud +>.$(mow [[hen %slip %d %flog +.sih] mow]) + :: + %made + ?+ tea +>.$ + [%neu @ ~] + :: ~& e/ford/hen + =+ our=(slav %p i.t.tea) + ?- -.p.sih + | (fail 404 p.p.sih) + & =* cag q.p.p.sih + ?> ?=(%mime p.cag) + =+ ((hard ,[mit=mite rez=octs]) q.q.cag) :: XX + (muff %thou 200 [content-type/(moon mit)]~ ~ rez) + == + == + :: + %writ + ?^ tea ~&(e/missed/writ/tea=tea +>.$) + ?~ p.sih +>.$ + =+ caz=`case`q.p.u.p.sih + ?> ?=(%ud -.caz) + (jive (jone p.caz)) +:: %- gout +:: [(slav %p i.t.tea) i.t.t.tea (slav %ud i.t.t.t.tea) p.+.sih] :: :: :: ?(%dumb %mean %nice %rush %rust) :: ?> ?=([%hoop @ @ @ ?([%mess @ @ ~] [%show @ ~])] tea) @@ -420,19 +446,7 @@ :: =< abet =< work =< abet :: (soon ?=(%rust -.+.sih) sem u.ouy can %show (wrap sem (json q.+.sih))) :: == - :: - %made - ?+ tea +>.$ - [%neu @ ~] - :: ~& e/ford/hen - =+ our=(slav %p i.t.tea) - ?- -.p.sih - | (fail 404 p.p.sih) - & =* cag q.p.p.sih - ?> ?=(%mime p.cag) - =+ ((hard ,[mit=mite rez=octs]) q.q.cag) :: XX - (muff %thou 200 [content-type/(moon mit)]~ ~ rez) - == +:: :: :: :: :: [%honk @ @ @ ~] :: %- galt @@ -477,7 +491,6 @@ :: %^ hear:(yule:u.ouy %meg) ~ %& :: [%json !>((rong ~ %from-json-fail p.p.+.sih))] :: == - == :: :: :: %thou :: remote return :: ?> ?=([@ @ *] tea) @@ -502,12 +515,6 @@ :: :: :: %went :: +>.$ - :: - %writ - ?< ?=([%hoot @ @ @ ~] tea) - +>.$ -:: %- gout -:: [(slav %p i.t.tea) i.t.t.tea (slav %ud i.t.t.t.tea) p.+.sih] == :: ++ apex @@ -520,14 +527,15 @@ %init :: register ownership %_ +>.$ hov ?~(hov [~ p.kyz] [~ (min u.hov p.kyz)]) - own - %+ ~(put by own) - p.kyz - ^- serf - :* (cat 3 gub (rsh 3 1 (scot %p p.kyz))) - ~ - ~ - == +:: :: +:: own +:: %+ ~(put by own) +:: p.kyz +:: ^- serf +:: :* (cat 3 gub (rsh 3 1 (scot %p p.kyz))) +:: ~ +:: ~ +:: == == :: :: :: %them :: outbound request @@ -553,7 +561,7 @@ :: mow :_(mow [p.kas [%give %thou q.kyz]]) :: q.ask (~(del by q.ask) p.kas) :: == - :: +:: :: %this :: inbound request =* sec p.kyz :: ? :: https bit =* heq r.kyz :: httq :: request content @@ -677,7 +685,7 @@ :: ^+ +> :: =+ boy=(myth our (need ((sand %ta) ((hard ,@) hez)))) :: ?~(boy +>.$ abet:(auth:u.boy him)) -:: :: + :: ++ heck :: regular request |= [oar=ship pok=pork] ^- (unit beam) @@ -701,13 +709,37 @@ :: =+ oar=`(unit ship)`?^(wiq wiq (doss r.p.pul)) =+ oar=(fall (doss r.p.pul) (need hov)) =+ ext=(fall p.q.pul %html) + %- |=(a=(each ,_..hell tang) ?~(-.a p.a (fail 404 >%exit< p.a))) + %- mule |. ^+ ..hell =+ hek=(heck oar q.pul) ?^ hek =: s.u.hek [%web ~(rent co (flux:ya /'' r.pul)) s.u.hek] r.u.hek ?+(r.u.hek r.u.hek [%ud %0] da/now) == (honk oar [%cast %mime %boil ext u.hek ~]) - (fail 404 >%irregular-path< (smyt q.q.pul) ~) + =+ hem=(hemp oar [q r]:pul) + ?~ hem + ~|(strange-path/(smyt q.q.pul) !!) + %+ hoot oar + =- [q.u.hem ~ %& %y ud/+(`@ud`-) /] + ?: ?=(%ud -.r.u.hem) + p.r.u.hem + ;;(@ (need (sky %cw (tope u.hem /)))) + :: + ++ hemp :: auxillary(/~) request + |= [oar=ship pok=pork quy=quay] + ^- (unit beak) + ?. ?=([%'~' @ *] q.pok) ~ + :- ~ + =* pef i.t.q.pok + =+ but=t.t.q.pok :: XX =* + ?+ pef ~|(pfix-lost/`path`/~/[pef] !!) + %on ?~ but !! :: XX look by query string + ?> ?=([@ @ $|(~ [@ ~])] but) + =- -:(need (tome -)) + ?^ t.t.but but(i (cat 3 '~' i.but)) + [(scot %p oar) but] + == :: ?. (home oar) :: (hork oar hyx) :: (huff oar q.hyx pul moh) @@ -718,33 +750,20 @@ :: ?: (~(has by own) who) & :: ?: (~(has by fon) who) | :: !=(~ (sky /a/(scot %p who)/buck/(scot %da now))) -:: :: -:: ++ hoot :: clay request -:: |= [our=ship num=@ud ses=hole rif=riff] -:: %_ +> -:: mow -:: :_ mow -:: :+ hen %pass -:: [[%hoot (scot %p our) ses (scot %ud num) ~] %c [%warp [our our] rif]] -:: == -:: :: + :: + ++ hoot :: clay request + |= [our=ship rif=riff] + (miff ~ %c [%warp [our our] rif]) + :: ++ hone :: kill ford - |= [our=ship num=@ud ses=hole] - %_ +> - mow - :_ mow - [hen %pass [%honk (scot %p our) ses (scot %ud num) ~] %f [%exec our ~]] - == + |= [our=ship ses=hole] + (miff [%neu (scot %p our) ~] %f [%exec our ~]) :: ++ honk :: ford request |= [our=ship kas=silk] :: ~& [%honk our num ses -.kas] - %_ +> - mow - :_ mow - [hen %pass [%neu (scot %p our) ~] %f [%exec our `kas]] - == -:: :: + (miff [%neu (scot %p our) ~] %f [%exec our `kas]) + :: :: ++ hooj :: ford json request :: |= [our=ship ses=hole nap=@ud can=@ud ful=? kas=silk] :: %_ +> @@ -802,7 +821,7 @@ :: q.rem (~(put by q.rem.rot) num hen) :: == :: == -:: :: + :: ++ horn :: irregular request |= [pul=purl cip=clip moh=moth] ^- (unit gift) @@ -867,15 +886,22 @@ :: == :: abet:work:(~(into ya [our p.saw] sef q.saw) pul moh) :: + ++ jive :: success json + |= jon=json + (muff (tuff application//json (crip (pojo jon)))) ++ muff :: return card |= gef=gift +>(mow :_(mow [hen %give gef])) :: + ++ miff :: pass card + |= noe=[wire note] + +>(mow :_(mow [hen %pass noe])) + :: ++ tuff |= [mit=mite rez=@] :: success response ^- gift [%thou 200 ~[content-type/(moon mit)] [~ (taco rez)]] -:: :: + :: :: ++ myth :: load session :: |= [our=ship ses=hole] :: =+ suf=(~(get by own) our) @@ -1101,12 +1127,21 @@ :: [%path %s (crip )] :: [%data `json`jon] :: == -:: :: + :: ++ ya :: session engine - =| [[our=ship ses=hole] serf cyst] - =* sef ->- - =* cyz ->+ + =| [[our=ship ses=hole] ~] ::serf cyst] +:: =* sef ->- +:: =* cyz ->+ |% + ++ flux :: credential caboose + |= [nyp=path quy=quay] ^- coin + :* %many + [%$ %ta ~] + [%blob *cred] ::ced] + |- ^- (list coin) + ?~ quy ~ + [[%$ %t p.i.quy] [%$ %t q.i.quy] $(quy t.quy)] + == :: ++ abet :: resolve engine :: ^+ ..ya :: %= ..ya @@ -1470,15 +1505,6 @@ :: ~ :: [~ %cop u.fee u.fum u.jun] :: :: - ++ flux :: credential caboose - |= [nyp=path quy=quay] ^- coin - :* %many - [%$ %ta ~] - [%blob ced] - |- ^- (list coin) - ?~ quy ~ - [[%$ %t p.i.quy] [%$ %t q.i.quy] $(quy t.quy)] - == :: :: :: ++ foin :: version request :: |= [fur=(unit term) you=@p paw=(list ,@t) quy=quay] @@ -1797,7 +1823,7 @@ :: =+ pot=`(list ,[p=@ud q=pimp])`?~(top ~ [[p.n.yub u.top] ~]) :: [:(weld pot dex sid) +.^$] :: +.$(q.rey (~(gas by `_q.rey`~) zib)) - :: + :: ++ wink :: advance request :: |= [num=@ud pip=pimp] :: ^- [(unit pimp) _+>] @@ -1982,7 +2008,7 @@ :: :_ +>.$ :: ?.((~(has ju aut.ced) p.pez.pip q.pez.pip) [~ pip] [~ pip(pez %new)]) :: == - :: + :: ++ work :: |- ^+ + :: =+ sez=step @@ -2333,9 +2359,9 @@ ~ :: ++ load - |= old=bolo + |= old=_[%0 gub hov ged ney dop **] ^+ ..^$ - ..^$(+>- old) + ..^$(+>- (bolo old)) :: ++ scry |= [our=(unit (set monk)) ren=@tas who=ship syd=desk lot=coin tyl=path] diff --git a/arvo/zuse.hoon b/arvo/zuse.hoon index adc851b79d..0d6f907dc1 100644 --- a/arvo/zuse.hoon +++ b/arvo/zuse.hoon @@ -2065,12 +2065,13 @@ [~ ~] ?^ t.rax [p.pok [i.rax q.pok]]:[pok=$(rax t.rax) .] - =+ ^- raf=(unit ,[p=term q=(unit term)]) - %+ rush i.rax - ;~(plug sym ;~((bend) (easy ~) ;~(pfix dot sym))) - ?~ raf + =+ ^- raf=(like tape) + %. [1^1 (flop (trip i.rax))] + ;~(sfix (plus ;~(less dot next)) dot) + ?~ q.raf [~ [i.rax ~]] - [q.u.raf [p.u.raf ~]] + =+ `[ext=tape [@ @] fyl=tape]`u.q.raf + [[~ (crip (flop ext))] [(crip (flop fyl)) ~]] :: ++ fuel :: parse fcgi |= [bem=beam but=path] @@ -2602,22 +2603,22 @@ ?~ two one ?:((lth u.one u.two) one two) :: -++ mojo :: compiling load - |= [pax=path src=*] - ^- (each twig (list tank)) - ?. ?=(@ src) - [%| ~[[leaf/"musk: malformed: {}"]]] - =+ ^= mud - %- mule |. - ((full vest) [1 1] (trip src)) - ?: ?=(| -.mud) mud - ?~ q.p.mud - :~ %| - leaf/"musk: syntax error: {}" - leaf/"musk: line {}, column {}" - == - [%& p.u.q.p.mud] -:: +:: ++ mojo :: compiling load +:: |= [pax=path src=*] +:: ^- (each twig (list tank)) +:: ?. ?=(@ src) +:: [%| ~[[leaf/"musk: malformed: {}"]]] +:: =+ ^= mud +:: %- mule |. +:: ((full vest) [1 1] (trip src)) +:: ?: ?=(| -.mud) mud +:: ?~ q.p.mud +:: :~ %| +:: leaf/"musk: syntax error: {}" +:: leaf/"musk: line {}, column {}" +:: == +:: [%& p.u.q.p.mud] +:: :: ++ mole :: new to old sky |= ska=$+(* (unit (unit))) |= a=* @@ -2626,21 +2627,21 @@ ?~ b ~ ?~ u.b ~ [~ u.u.b] -:: -++ much :: constructing load - |= [pax=path src=*] - ^- gank - =+ moj=(mojo pax src) - ?: ?=(| -.moj) moj - (mule |.((slap !>(+>.$) `twig`p.moj))) -:: -++ musk :: compiling apply - |= [pax=path src=* sam=vase] - ^- gank - =+ mud=(much pax src) - ?: ?=(| -.mud) mud - (mule |.((slam p.mud sam))) -:: +:: :: +:: ++ much :: constructing load +:: |= [pax=path src=*] +:: ^- gank +:: =+ moj=(mojo pax src) +:: ?: ?=(| -.moj) moj +:: (mule |.((slap !>(+>.$) `twig`p.moj))) +:: :: +:: ++ musk :: compiling apply +:: |= [pax=path src=* sam=vase] +:: ^- gank +:: =+ mud=(much pax src) +:: ?: ?=(| -.mud) mud +:: (mule |.((slam p.mud sam))) +:: :: ++ pack :: light path encoding |= [a=term b=path] ^- span %+ rap 3 :- (wack a) From 28c15bdc09adf36706ee51dda7ea8a6c246eedb4 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 11 Feb 2015 11:26:42 -0800 Subject: [PATCH 008/219] on.js polling --- arvo/eyre.hoon | 125 +++++++++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 55 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 22abd96e9d..e3788462a6 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -342,12 +342,38 @@ :: ~[content-type/'text/html'] :: [~ (tact (poxo (loga "server error" ~ q.luv)))] :: == +++ js :: static javascript + |% + ++ poll + ''' + urb.tries = 0; + urb.call = function() { + xhr = new XMLHttpRequest(); + xhr.open('GET', urb.poll, true); + xhr.addEventListener('load', function() { + if(this.status !== 200) { + return urb.keep(); + } + document.location.reload(); + }); + xhr.addEventListener('error', urb.keep); + xhr.addEventListener('abort', urb.keep); + xhr.send(); + } + urb.keep = function() { + setTimeout(urb.call,1000*urb.tries); + urb.tries++; + } + urb.call(); + ''' + -- -- |% :: functions ++ ye :: per event =| $: $: hen=duct :: event floor $: now=@da :: event date eny=@ :: unique entropy + our=ship :: current ship sky=$+(* (unit)) :: system namespace == :: mow=(list move) :: pending actions @@ -372,13 +398,13 @@ :: %made ?+ tea +>.$ - [%neu @ ~] + ~ :: ~& e/ford/hen - =+ our=(slav %p i.t.tea) ?- -.p.sih | (fail 404 p.p.sih) & =* cag q.p.p.sih ?> ?=(%mime p.cag) + ~| q.q.cag =+ ((hard ,[mit=mite rez=octs]) q.q.cag) :: XX (muff %thou 200 [content-type/(moon mit)]~ ~ rez) == @@ -570,9 +596,9 @@ =+ ^= pul ^- purl ?- -.ryp & ?>(=(sec p.p.p.ryp) p.ryp) - | =+ hot=(~(get by mah) %host) - ?> ?=([~ @ ~] hot) - [[sec (rash i.u.hot thor:epur)] p.ryp q.ryp] + | =+ hot=(~(get ja mah) %host) + ?> ?=([@ ~] hot) + [[sec (rash i.hot thor:epur)] p.ryp q.ryp] == =. p.p.pul |(p.p.pul ?=(hoke r.p.pul)) (hell pul +.kyz [p.heq mah s.heq]) @@ -601,10 +627,8 @@ :: ++ back :: %ford bounce |= [our=ship tea=wire cag=cage] - =+ sil=[%cast %mime %done ~ cag] - %_ +>.$ - mow :_(mow [hen %pass tea %f %exec our ~ sil]) - == + (miff tea %f %exec our `[%cast %mime %done `cag]) + :: ++ doss :: host to ship |= hot=host ^- (unit ship) @@ -616,7 +640,7 @@ ++ fail :: request failed |= [sas=@ud mez=tang] ^+ +> - :: (back our tea %tang !>(mez)) :: XX broken tang door + :: (back our ~ %tang !>(mez)) :: XX broken tang->mime door in ford =- (muff (tuff text//plain (role (turn - crip)))) ^- wall %- zing ^- (list wall) (turn mez |=(a=tank (wash 0^160 a))) @@ -686,7 +710,18 @@ :: =+ boy=(myth our (need ((sand %ta) ((hard ,@) hez)))) :: ?~(boy +>.$ abet:(auth:u.boy him)) :: - ++ heck :: regular request + ++ heck :: extract err beak + |= [oar=ship pul=purl] + ^- (unit beak) + %- bind :_ |=(a=$&(beam beak) ?^(-.a -.a a)) + ^- (unit $&(beam beak)) + ?. ?=([%'~' ^] q.q.pul) + (heft oar q.pul) + ?+ i.t.q.q.pul ~ + %as ?~(t.t.q.q.pul ~ $(q.q.pul t.t.t.q.q.pul)) + %on ~ ::(tome (scot %p oar) + == + ++ heft :: regular request |= [oar=ship pok=pork] ^- (unit beam) ?~ q.pok @@ -711,15 +746,21 @@ =+ ext=(fall p.q.pul %html) %- |=(a=(each ,_..hell tang) ?~(-.a p.a (fail 404 >%exit< p.a))) %- mule |. ^+ ..hell - =+ hek=(heck oar q.pul) - ?^ hek - =: s.u.hek [%web ~(rent co (flux:ya /'' r.pul)) s.u.hek] - r.u.hek ?+(r.u.hek r.u.hek [%ud %0] da/now) + =+ hev=(heft oar q.pul) + ?^ hev + =: s.u.hev [%web ~(rent co (flux:ya /'' r.pul)) s.u.hev] + r.u.hev ?+(r.u.hev r.u.hev [%ud %0] da/now) == - (honk oar [%cast %mime %boil ext u.hek ~]) + (honk oar [%cast %mime %boil ext u.hev ~]) =+ hem=(hemp oar [q r]:pul) ?~ hem ~|(strange-path/(smyt q.q.pul) !!) + ?: ?=([~ %js] p.q.pul) :: XX treat non-json cases? + =- (muff (tuff text//javascript (crip -))) + """ + window.urb = \{poll: "/{(body:earn q.pul(u.p %json))}"} + {(trip poll:js)} + """ %+ hoot oar =- [q.u.hem ~ %& %y ud/+(`@ud`-) /] ?: ?=(%ud -.r.u.hem) @@ -757,12 +798,12 @@ :: ++ hone :: kill ford |= [our=ship ses=hole] - (miff [%neu (scot %p our) ~] %f [%exec our ~]) + (miff ~ %f [%exec our ~]) :: ++ honk :: ford request |= [our=ship kas=silk] :: ~& [%honk our num ses -.kas] - (miff [%neu (scot %p our) ~] %f [%exec our `kas]) + (miff ~ %f [%exec our `kas]) :: :: ++ hooj :: ford json request :: |= [our=ship ses=hole nap=@ud can=@ud ful=? kas=silk] @@ -1563,41 +1604,13 @@ :: toe(s (weld s.toe `path`[(flux nyp quy) %web ~])) :: ?. won ~ :: :_ ~ -:: =- =+ pey="{(scag 2 (trip nep))}v" -:: =. pey %+ weld pey -:: ?. =(%i (snag 1 pey)) -:: "" -:: "/{(slag 1 (scow %p you))}" -:: =+ ven=+((,@ (need (sky %cw p.toe q.toe r.toe ~)))) -:: =+ ^= cal :/ -:: "path='". -:: "/{pey}". -:: "/{(scow %ud ven)}". -:: "/{(trip q.toe)}';" -:: [-.sac [cal +.sac]] -:: ^= sac -:: ;script -:: ; -:: ; tries = 0; -:: ; call = function() { -:: ; xhr = new XMLHttpRequest(); -:: ; xhr.open('GET', path, true); -:: ; xhr.addEventListener('load', function() { -:: ; if(this.status !== 200) { -:: ; return keep(); -:: ; } -:: ; document.location.reload(); -:: ; }); -:: ; xhr.addEventListener('error', keep); -:: ; xhr.addEventListener('abort', keep); -:: ; xhr.send(); -:: ; } -:: ; keep = function() { -:: ; setTimeout(call,1000*tries); -:: ; tries++; -:: ; } -:: ; call(); -:: == +:: =+ pey="{(scag 2 (trip nep))}v" +:: =. pey %+ weld pey +:: ?. =(%i (snag 1 pey)) +:: "" +:: "/{(slag 1 (scow %p you))}" +:: =+ ven=+((,@ (need (sky %cw p.toe q.toe r.toe ~)))) +:: ;script@"/~/on/{pey}/{(scow %ud ven)}/{(trip q.toe)}.js"; :: :: :: ++ holt :: login redirect :: |= [whu=(unit ship) pul=purl] @@ -2344,13 +2357,14 @@ ((hard kiss) q.hic) == ^- [p=(list move) q=_..^$] + =| our=ship :: XX =+ ska=(slod ski) =+ sky=|=(* `(unit)`=+(a=(ska +<) ?~(a ~ ?~(u.a ~ [~ u.u.a])))) =. ney (shax :(mix (shax now) +(eny) ney)) :: XX!! shd not need ^- [p=(list move) q=_..^$] =. gub ?.(=(0 gub) gub (cat 3 (rsh 3 1 (scot %p (end 6 1 eny))) '-')) =^ mos bol - abet:(apex:~(adit ye [hen [now eny sky] ~] bol) q.hic) + abet:(apex:~(adit ye [hen [now eny our sky] ~] bol) q.hic) [mos ..^$] :: ++ doze @@ -2376,6 +2390,7 @@ [[hen %give +.q.hin]~ ..^$] ?: ?=(%vega +<.q.hin) :: vomit [[hen %give +.q.hin]~ ..^$] + =| our=ship :: XX =+ ska=(slod ski) =+ sky=|=(* `(unit)`=+(a=(ska +<) ?~(a ~ ?~(u.a ~ [~ u.u.a])))) =. ney (shax :(mix (shax now) +(eny) ney)) :: XX!! shd not need @@ -2383,7 +2398,7 @@ =. gub ?.(=(0 gub) gub (cat 3 (rsh 3 1 (scot %p (end 6 1 eny))) '-')) =^ mos bol =< abet - %^ axon:~(adit ye [hen [now eny sky] ~] bol) tea + %^ axon:~(adit ye [hen [now eny our sky] ~] bol) tea (~(peek ut p.hin) %free 3) q.hin [mos ..^$] From 8263491a7038adad59526d486d82ee385f194d62 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 11 Feb 2015 13:10:07 -0800 Subject: [PATCH 009/219] Added (set beam) to %| ford %made --- arvo/eyre.hoon | 8 ++++---- arvo/ford.hoon | 42 +++++++++++++++++++------------------ arvo/gall.hoon | 56 +++++++++++++++++++++++++------------------------- 3 files changed, 54 insertions(+), 52 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index e3788462a6..97f7622cbd 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -83,7 +83,7 @@ :: $% [%thou p=httr] :: :: == == :: $: %f :: by %ford - $% [%made p=(each bead (list tank))] :: + $% [%made p=(set beam) q=(each cage tang)] :: :: == == :: :: $: %g :: by %gall :: $% [%dumb ~] :: @@ -400,9 +400,9 @@ ?+ tea +>.$ ~ :: ~& e/ford/hen - ?- -.p.sih - | (fail 404 p.p.sih) - & =* cag q.p.p.sih + ?- -.q.sih + | (fail 404 p.q.sih) + & =* cag p.q.sih ?> ?=(%mime p.cag) ~| q.q.cag =+ ((hard ,[mit=mite rez=octs]) q.q.cag) :: XX diff --git a/arvo/ford.hoon b/arvo/ford.hoon index 196fa81226..94356e0d72 100644 --- a/arvo/ford.hoon +++ b/arvo/ford.hoon @@ -9,7 +9,7 @@ :: ++ bead ,[p=(set beam) q=cage] :: computed result ++ gift :: out result <-$ - $% [%made p=(each bead (list tank))] :: computed result + $% [%made p=(set beam) q=(each cage tang)] :: computed result == :: ++ heel path :: functional ending ++ hock :: standard label @@ -95,8 +95,8 @@ $: p=cafe :: cache $= q :: $% [%0 p=(set beam) q=a] :: depends/product - [%1 p=(set ,[p=care q=beam r=(list tank)])] :: blocks - [%2 p=(list tank)] :: error + [%1 p=(set ,[p=care q=beam r=tang])] :: blocks + [%2 p=(set beam) q=tang] :: depends/error == :: == :: :: :: @@ -161,7 +161,8 @@ ++ fest |*([a=cafe b=*] (fine a [~ u=b])) :: bolt to unit ++ fine |* [a=cafe b=*] :: bolt from data [p=`cafe`a q=[%0 p=*(set beam) q=b]] :: -++ flaw |=([a=cafe b=(list tank)] [p=a q=[%2 p=b]]) :: bolt from error +++ flaw |= [a=cafe b=tang] + [p=a q=[%2 p=*(set beam) q=b]] :: bolt from error :: ++ grom :: merge sets |* [one=(set) two=(set)] @@ -315,7 +316,7 @@ ++ cool :: error caption |* [cyt=trap hoc=(bolt)] ?. ?=(%2 -.q.hoc) hoc - [p.hoc [%2 *cyt p.q.hoc]] + [p.hoc [%2 p.q.hoc *cyt q.q.hoc]] :: ++ cope :: bolt along |* [hoc=(bolt) fun=(burg)] @@ -337,7 +338,7 @@ :- p=cof ^= q ?- -.ton - %2 [%2 p=p.ton] + %2 [%2 p=*(set beam) q=p.ton] %0 [%0 p=*(set beam) q=(fun p.ton)] %1 :: ~& [%coup-need ((list path) p.ton)] =- ?- -.faw @@ -345,23 +346,24 @@ ^= p %- sa %+ turn p.faw - |=(a=[care beam] [-.a +.a *(list tank)]) - | [%2 p=p.faw] + |=(a=[care beam] [-.a +.a *tang]) + | [%2 p=*(set beam) q=p.faw] == ^= faw - |- ^- (each (list (pair care beam)) (list tank)) + |- ^- (each (list (pair care beam)) tang) ?~ p.ton [%& ~] =+ nex=$(p.ton t.p.ton) + =+ err=|=(a=tape [%| leaf/a ?:(?=(& -.nex) ~ p.nex)]) =+ pax=(path i.p.ton) - ?~ pax [%| (smyt pax) ?:(?=(& -.nex) ~ p.nex)] + ?~ pax (err "blocking empty") ?. ?=(%c (end 3 1 i.pax)) - [%| leaf/"blocking not clay" (smyt pax) ?:(?=(& -.nex) ~ p.nex)] + (err "blocking not clay") =+ ren=((soft care) (rsh 3 1 i.pax)) ?~ ren - [%| leaf/"blocking not care" (smyt pax) ?:(?=(& -.nex) ~ p.nex)] + (err "blocking not care") =+ zis=(tome t.pax) ?~ zis - [%| leaf/"blocking not beam" (smyt pax) ?:(?=(& -.nex) ~ p.nex)] + (err "blocking not beam") ?- -.nex & [%& [u.ren u.zis] p.nex] | nex @@ -370,7 +372,7 @@ :: ++ cowl :: each to bolt |= cof=cafe - |* [tod=(each ,* (list tank)) fun=$+(* *)] + |* [tod=(each ,* tang) fun=$+(* *)] %+ (coup cof) ?- -.tod %& [%0 p=p.tod] @@ -388,8 +390,8 @@ =+ bot=(make [~ jav.bay] kas) :: =. ..exec (dash p.bot) ?- -.q.bot - %0 `[%made %& p.q.bot q.q.bot] - %2 `[%made %| p.q.bot] + %0 `[%made p.q.bot %& q.q.bot] + %2 `[%made p.q.bot %| q.q.bot] %1 ~ == :: @@ -399,8 +401,8 @@ =+ bot=(make [~ jav.bay] kas) =. ..exec (dash p.bot) ?- -.q.bot - %0 amok:(expo [%made %& p.q.bot q.q.bot]) - %2 amok:(expo [%made %| p.q.bot]) + %0 amok:(expo [%made p.q.bot %& q.q.bot]) + %2 amok:(expo [%made p.q.bot %| q.q.bot]) %1 =+ zuk=(~(tap by p.q.bot) ~) =< abet |- ^+ ..exec @@ -902,7 +904,7 @@ %done [cof %0 p.kas q.kas] %dude (cool |.(p.kas) $(kas q.kas)) %dune - ?~ q.kas [cof [%2 [%leaf "no data"]~]] + ?~ q.kas [cof [%2 p.kas [%leaf "no data"]~]] $(kas [%done p.kas u.q.kas]) :: %mute (kale cof p.kas q.kas) @@ -1236,7 +1238,7 @@ ?> (~(has by q.kig) tik) ?~ rot =+ `[ren=care bem=beam]`(~(got by q.kig) tik) - amok:(expo [%made %| (smyt ren (tope bem)) ~]) + amok:(expo [%made ~ %| (smyt ren (tope bem)) ~]) :: dependencies? exec(q.kig (~(del by q.kig) tik)) -- -- diff --git a/arvo/gall.hoon b/arvo/gall.hoon index 430989c610..c0814d794e 100644 --- a/arvo/gall.hoon +++ b/arvo/gall.hoon @@ -160,7 +160,7 @@ [%vega p=path] :: == == :: $: %f :: by %ford - $% [%made p=(each bead (list tank))] :: + $% [%made p=(set beam) q=(each cage tang)] :: == == == :: ++ toil (pair duct knob) :: work in progress -- :::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -407,12 +407,12 @@ :_ ..^$ :_ ~ :- hen - ?- -.p.+.sih + ?- -.q.+.sih %| - [%give %crud %gasp-crud p.p.+.sih] + [%give %crud %gasp-crud p.q.+.sih] :: %& - =+ cay=`cage`q.p.p.+.sih + =+ cay=`cage`p.q.+.sih ?+ -.pax !! %d [%give (best %rush cay)] %f [%give (best %rust cay)] @@ -436,9 +436,9 @@ ?+ -.sih ~& [%gall-gave-m -.sih] !! %f :_ ~ :- hen - ?- -.p.+.sih - %| [%give %mean ~ %ford-fail p.p.+.sih] - %& [%pass [%r pax] %g %mess [our imp] you `cage`q.p.p.+.sih] + ?- -.q.+.sih + %| [%give %mean ~ %ford-fail p.q.+.sih] + %& [%pass [%r pax] %g %mess [our imp] you `cage`p.q.+.sih] == :: %g @@ -790,54 +790,54 @@ |= sih=sign ?> ?=(%f -.sih) ^- [(unit (list tank)) _+>] - ?- -.p.+.sih + ?- -.q.+.sih & :- ~ - %- obey:(morn (slot 3 q.q.p.p.+.sih)) - (slot 2 q.q.p.p.+.sih) - | [`p.p.+.sih (give %crud %mack-made p.p.+.sih)] + %- obey:(morn (slot 3 q.p.q.+.sih)) + (slot 2 q.p.q.+.sih) + | [`p.q.+.sih (give %crud %mack-made p.q.+.sih)] == :: ++ meek :: apply peek |= sih=sign ^- [(unit cage) _+>] ?> ?=(%f -.sih) - ?- -.p.+.sih - & =+ vax=`vase`q.q.p.p.+.sih + ?- -.q.+.sih + & =+ vax=`vase`q.p.q.+.sih ?. &(?=(^ q.vax) ?=(@ -.q.vax)) [~ (give %crud %peek-lame *(list tank))] :: ~> %slog.[0 (skol p:(slot 3 vax))] :- `[((hard mark) -.q.vax) (slot 3 vax)] +>.$ - | [~ (give %crud %meek-made p.p.+.sih)] + | [~ (give %crud %meek-made p.q.+.sih)] == :: ++ mick :: apply w/depends |= sih=sign ?> ?=(%f -.sih) - ^- [(unit (set beam)) _+>] - ?- -.p.+.sih - & :- `p.p.p.+.sih - %- obey:(morn (slot 3 q.q.p.p.+.sih)) - (slot 2 q.q.p.p.+.sih) - | [~ (give %crud %mick-made p.p.+.sih)] + ^- [[p=? q=(set beam)] _+>] + :- [-.q.+.sih p.+.sih] + ?- -.q.+.sih + & %- obey:(morn (slot 3 q.p.q.+.sih)) + (slot 2 q.p.q.+.sih) + | (give %crud %mick-made p.q.+.sih) == :: ++ muck :: apply part |= sih=sign ^- [(unit (list tank)) _+>] ?> ?=(%f -.sih) - ?- -.p.+.sih - & [~ (obey q.q.p.p.+.sih)] - | [`p.p.+.sih (give %crud %muck-made p.p.+.sih)] + ?- -.q.+.sih + & [~ (obey q.p.q.+.sih)] + | [`p.q.+.sih (give %crud %muck-made p.q.+.sih)] == :: ++ murk :: apply park |= sih=sign ^- [(unit cage) _+>] ?> ?=(%f -.sih) - ?- -.p.+.sih - & [`q.p.p.+.sih +>.$] - | [~ (give %crud %murk-made p.p.+.sih)] + ?- -.q.+.sih + & [`p.q.+.sih +>.$] + | [~ (give %crud %murk-made p.q.+.sih)] == :: ++ moar :: foreign take @@ -926,8 +926,8 @@ :: %prep =^ gad +>.$ (mick q.hin) - ?~ gad (drum ~) - deal:(drum u.gad) + ?. p.gad (drum q.gad) + deal:(drum q.gad) :: %pull =^ gud +>.$ (mack q.hin) From 9ace9847c440129fc919406b908d8341fcf19148 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Wed, 11 Feb 2015 18:57:33 -0800 Subject: [PATCH 010/219] Reverse i search --- arvo/dull.hoon | 31 +++++--- arvo/gall.hoon | 1 - main/app/seat/core.hook | 148 +++++++++++++++++++++++++++++++------ main/lib/console/core.hook | 17 +++-- main/sur/console/core.hook | 2 + 5 files changed, 158 insertions(+), 41 deletions(-) diff --git a/arvo/dull.hoon b/arvo/dull.hoon index 44f7d21408..db62c2feae 100644 --- a/arvo/dull.hoon +++ b/arvo/dull.hoon @@ -12,6 +12,7 @@ ++ axon :: dill per duct $: ram=term :: console program wid=_80 :: terminal width + pos=@ud :: cursor position see=(list ,@c) :: current line == :: -- :: @@ -41,6 +42,7 @@ [%blk p=@ud q=@c] :: blink/match char at [%clr ~] :: clear screen [%det console-change] :: edit input + [%nex ~] :: save and clear input [%tan p=(list tank)] :: classic tank :: [%taq p=tanq] :: modern tank [%txt p=tape] :: text line @@ -193,10 +195,13 @@ :~ [%lin p.bit] [%mor ~] [%lin see] + [%hop pos] == ?: ?=(%pro -.bit) - (done(see p.bit) %blit `(list blit)`[%lin p.bit]~) - (done %blit `(list blit)`[bit ~]) + (done(see p.bit) %blit [[%lin p.bit] [%hop pos] ~]) + ?: ?=(%hop -.bit) + (done(pos p.bit) %blit [bit ~]) + (done %blit [bit ~]) :: ++ init :: initialize |= gyl=(list gill) @@ -220,19 +225,19 @@ ^+ +> ?- sih [%a %nice *] - ~& [%take-nice-ames sih] + :: ~& [%take-nice-ames sih] +> :: [%g %crud *] - ~& [%take-crud sih] + :: ~& [%take-crud sih] +> :: [%g %mean *] - ~& [%take-mean sih] + :: ~& [%take-mean sih] +> :: [%g %nice *] - ~& [%take-nice sih] + :: ~& [%take-nice sih] +> :: [%g %rush %dill-blit *] @@ -240,20 +245,20 @@ (from +>+.sih) :: [%t %wake *] - ~& %dill-wake + :: ~& %dill-wake +> == -- :: ++ ax :: make as |= [hen=duct kyz=kiss] :: - ~& [%ax-kiss kyz] ?~ ore.all ~ =+ nux=(~(get by dug.all) hen) ?^ nux (some ~(. as [~ hen u.ore.all] u.nux)) ?. ?=(%flow -.kyz) ~ %- some - (~(init as [~ hen u.ore.all] [p.kyz 80 (tuba "<{(trip p.kyz)}>")]) q.kyz) + %. q.kyz + ~(init as [~ hen u.ore.all] [p.kyz 80 0 (tuba "<{(trip p.kyz)}>")]) -- |% :: poke/peek pattern ++ call :: handle request @@ -283,7 +288,6 @@ ~& [%dill-no-flow q.hic] [~ ..^$] =^ moz all abet:(call:u.nus q.hic) - ~& [%call-moves moz] [moz ..^$] :: ++ doze @@ -308,9 +312,12 @@ ?: =(~ ore.all) ~& [%take-back q.hin] [~ ..^$] + ?. (~(has by dug.all) hen) + ~& [%take-weird-sign q.hin] + ~& [%take-weird-hen hen] + [~ ..^$] =+ our=?>(?=(^ ore.all) u.ore.all) =^ moz all abet:(~(take as [~ hen our] (~(got by dug.all) hen)) q.hin) - ~& [%take-moves moz] [moz ..^$] --i +-- diff --git a/arvo/gall.hoon b/arvo/gall.hoon index 74e11ea23e..8c77664185 100644 --- a/arvo/gall.hoon +++ b/arvo/gall.hoon @@ -19,7 +19,6 @@ [%meta p=vase] :: meta-gift [%nice ~] :: message success == :: -::++ hasp ,[p=ship q=term] :: app identity ++ hapt ,[p=ship q=path] :: app instance ++ hath ,[p=ship q=term] :: app identity ++ kiss :: in request ->$ diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index 60910ca0a7..1008cc4246 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -17,12 +17,21 @@ feg=(map term target) :: live applications mir=(pair ,@ud (list ,@c)) :: mirrored state == :: - ++ target :: application target - $: pom=console-prompt :: static prompt - inp=console-input :: input state + ++ history :: past input + $: pos=@ud :: input position + num=@ud :: number of entries + ris=(unit search) :: reverse-i-search + lay=(map ,@ud (list ,@c)) :: editing overlay + old=(list (list ,@c)) :: entries proper == :: - ++ message :: message to app - $% [%console-action console-action] :: + ++ search :: reverse-i-search + $: pos=@ud :: search position + str=(list ,@c) :: search string + == + ++ target :: application target + $: hit=history :: all past input + pom=console-prompt :: static prompt + inp=console-input :: input state == :: ++ gift :: out result <-$ $% [%mean p=ares] :: @@ -39,7 +48,7 @@ == :: ++ move ,[p=bone q=(mold note gift)] :: ++ note-gall :: note to %gall - $% [%mess p=[p=ship q=path] q=ship r=message] :: + $% [%mess p=[p=ship q=path] q=ship r=cage] :: [%nuke p=[p=ship q=path] q=ship] :: [%show p=[p=ship q=path] q=ship r=path] :: [%took p=[p=ship q=path] q=ship] :: @@ -59,7 +68,6 @@ ++ se-belt :: handle input |= bet=dill-belt ^+ +> - ~& [%se-belt bet] ?: ?=(%rez -.bet) +>(edg q.bet) ?: ?=(%yow -.bet) @@ -169,7 +177,7 @@ ++ ta-act :: send action |= act=console-action ^+ +> - %_(+> +> (se-send nam %mess [her ~[nam]] her %console-action act)) + %_(+> +> (se-send nam %mess [her ~[nam]] her %console-action !>(act))) :: ++ ta-bel .(+> (se-blit %bel ~)) :: beep ++ ta-det :: send edit @@ -181,26 +189,61 @@ |= key=?(%d %l %r %u) ^+ +> ?- key - %d ta-bel + %d ?. =(num.hit pos.hit) + (ta-mov +(pos.hit)) + ?: =(0 (lent buf.say.inp)) + ta-bel + (ta-hom:ta-nex %set ~) %l ?: =(0 pos.inp) ta-bel +>(pos.inp (dec pos.inp)) %r ?: =((lent buf.say.inp) pos.inp) ta-bel +>(pos.inp +(pos.inp)) - %u ta-bel + %u ?:(=(0 pos.hit) ta-bel (ta-mov (dec pos.hit))) == :: ++ ta-bac :: hear backspace ^+ . + ?^ ris.hit + ?: =(~ str.u.ris.hit) + ta-bel + .(str.u.ris.hit (scag (dec (lent str.u.ris.hit)) str.u.ris.hit)) ?: =(0 pos.inp) .(+> (se-blit %bel ~)) - (ta-hom %del (dec pos.inp)) + =+ pre=(dec pos.inp) + (ta-hom(pos.inp pre) %del pre) :: ++ ta-ctl :: hear control |= key=@ud - ~& [%ta-ctl key] - +> + ^+ +> + ?+ key ta-bel + %a +>(pos.inp 0) + %b (ta-aro %l) + %d ?: &(=(0 pos.inp) =(0 (lent buf.say.inp))) + +>(liv |) + ta-del + %e +>(pos.inp (lent buf.say.inp)) + %f (ta-aro %r) + %l +>(+> (se-blit %clr ~)) + %n (ta-aro %d) + %p (ta-aro %u) + %r ?~(ris.hit +>(ris.hit `[pos.hit ~]) (ta-ser ~)) + %t =+ len=(lent buf.say.inp) + ?: |(=(0 pos.inp) (lth len 2)) + ta-bel + =+ sop=?:(=(len pos.inp) (dec pos.inp) pos.inp) + =. pos.inp +(sop) + %- ta-hom + :~ %mor + [%del sop] + [%ins (dec sop) (snag sop buf.say.inp)] + == + %u %- ta-hom(pos.inp 0) + :- %mor + =+ ded=0 + |-(?:(=(ded pos.inp) ~ [[%del 0] $(ded +(ded))])) + == :: ++ ta-cru :: hear crud |= [lab=@tas tac=(list tank)] @@ -213,7 +256,7 @@ .(+> (se-blit %bel ~)) (ta-hom %del pos.inp) :: - ++ ta-fec + ++ ta-fec :: apply effect |= fec=console-effect ^+ +> ?- -.fec @@ -221,31 +264,84 @@ %blk +> %clr +>(+> (se-blit %clr ~)) %det (ta-got +.fec) + %nex ta-nex %pro (ta-pro +.fec) %tan (ta-tan p.fec) %txt $(fec [%tan [%leaf p.fec]~]) == :: - ++ ta-got - |= [ler=console-clock haw=@uvH ted=console-edit] - +>(inp abet:(~(receive cs inp) ler haw ted)) + ++ ta-dog :: correct position + |= ted=console-edit + ?. ?=(%set -.ted) +> + +>(pos.inp (lent buf.say.inp)) + :: + ++ ta-got :: apply change + |= cal=console-change + =. +> (ta-dog:+>(say.inp abet:(~(receive cs say.inp) cal)) ted.cal) + +> :: ++ ta-hom :: local edit |= ted=console-edit ^+ +> =. +> (ta-det ted) - %_(+> inp abet:(~(commit cs inp) ted)) + =. +> (ta-dog:+>(say.inp abet:(~(commit cs say.inp) ted)) ted) + +> :: ++ ta-met :: meta key |= key=@ud ~& [%ta-met key] +> :: + ++ ta-mov :: move in history + |= sop=@ud + ^+ +> + ?: =(sop pos.hit) +> + %+ %= ta-hom + pos.hit sop + lay.hit %+ ~(put by lay.hit) + pos.hit + buf.say.inp + == + %set + %- (bond |.((snag (sub num.hit +(sop)) old.hit))) + (~(get by lay.hit) sop) + :: + ++ ta-nex :: advance history + %_ . + num.hit +(num.hit) + pos.hit +(num.hit) + ris.hit ~ + lay.hit ~ + old.hit [buf.say.inp old.hit] + == + :: ++ ta-pro :: set prompt |= pom=console-prompt +>(pom pom) :: ++ ta-ret (ta-act %ret ~) :: hear return + ++ ta-ser :: reverse search + |= ext=(list ,@c) + ^+ +> + ?: |(?=(~ ris.hit) =(0 pos.u.ris.hit)) ta-bel + =+ tot=(weld str.u.ris.hit ext) + =+ dol=(slag (sub num.hit pos.u.ris.hit) old.hit) + =+ sop=pos.u.ris.hit + =+ ^= ser + =+ ^= beg + |= [a=(list ,@c) b=(list ,@c)] ^- ? + ?~(a & ?~(b | &(=(i.a i.b) $(a t.a, b t.b)))) + |= [a=(list ,@c) b=(list ,@c)] ^- ? + ?~(a & ?~(b | |((beg a b) $(b t.b)))) + =+ ^= sup + |- ^- (unit ,@ud) + ?~ dol ~ + ?: (ser tot i.dol) + `sop + $(sop (dec sop), dol t.dol) + ?~ sup ta-bel + (ta-mov(str.u.ris.hit tot) (dec u.sup)) + :: ++ ta-tan :: print tanks |= tac=(list tank) =+ wol=`wall`(zing (turn tac |=(a=tank (~(win re a) [0 edg])))) @@ -255,14 +351,23 @@ :: ++ ta-txt :: hear text |= txt=(list ,@c) - %- ta-hom + ^+ +> + ?^ ris.hit + (ta-ser txt) + %- ta-hom(pos.inp (add (lent txt) pos.inp)) :- %mor |- ^- (list console-edit) ?~ txt ~ [[%ins pos.inp i.txt] $(pos.inp +(pos.inp), txt t.txt)] :: ++ ta-vew :: computed prompt - ^- (pair ,@ud (list ,@c)) + |- ^- (pair ,@ud (list ,@c)) + ?^ ris.hit + %= $ + ris.hit ~ + cap.pom + `(list ,@)`:(welp "(reverse-i-search)'" str.u.ris.hit "': ") + == =- [(add pos.inp (lent p.vew)) (weld p.vew q.vew)] ^= vew ^- (pair (list ,@c) (list ,@c)) ?: vis.pom [cap.pom buf.say.inp] @@ -284,14 +389,12 @@ ++ peer |= [ost=bone her=ship pax=path] ^- [(list move) _+>] - ~& [%seat-peer ost her pax] ?< (~(has by bin) ost) [~ +>(bin (~(put by bin) ost *source))] :: ++ poke-dill-belt |= [ost=bone her=ship bet=dill-belt] ^- [(list move) _+>] - ~& [%dill-belt bet] =< se-abet =< se-view (~(se-belt se [ost %give %nice ~]~ [her ost] (~(got by bin) ost)) bet) @@ -300,7 +403,6 @@ |= [ost=bone pax=path sih=*] ^- [(list move) _+>] =+ sih=((hard sign) sih) - ~& [%seat-pour sih] ?> ?=([@ @ ~] pax) =< se-abet =< se-view diff --git a/main/lib/console/core.hook b/main/lib/console/core.hook index 5160479a04..152161e8cf 100644 --- a/main/lib/console/core.hook +++ b/main/lib/console/core.hook @@ -10,20 +10,20 @@ :: |% ++ cs :: shared-state engine - |_ [pos=@ud console-share] + |_ console-share ++ abet +< ++ apply |= ted=console-edit ^+ +> ?- -.ted - %del +>.$(buf (weld (scag p.ted buf) (slag 1 buf))) - %ins +>.$(buf (weld (scag p.ted buf) `_buf`[q.ted buf])) + %del +>.$(buf (weld (scag p.ted buf) (slag +(p.ted) buf))) + %ins +>.$(buf (weld (scag p.ted buf) `_buf`[q.ted (slag p.ted buf)])) %mor |- ^+ +>.^$ ?~ p.ted +>.^$ $(p.ted t.p.ted, +>.^$ ^$(ted i.p.ted)) %nop +>.$ - %set +>.$(buf p.ted, pos (lent p.ted)) + %set +>.$(buf p.ted) == :: :: symmetric operational transformation. for any console state, obeys @@ -72,16 +72,23 @@ ^+ +> (apply(own.ven +(own.ven)) ted) :: + ++ transmit + |= ted=console-edit + ^- [console-change _+>] + [[[his.ven own.ven] (sham buf) ted] (commit ted)] + :: ++ receive :: edit from other |= $: ler=console-clock :: other's clock view haw=@uvH :: hash at edit ted=console-edit :: edit content == ^+ +> + ?. &(=(his.ler his.ven) (lte own.ler own.ven)) + ~& [%receive-mismatch ler/ler ven/ven ~] + !! ?> &(=(his.ler his.ven) (lte own.ler own.ven)) ?> |(!=(own.ler own.ven) =(haw (sham buf))) =: his.ven +(his.ven) - own.ven +(own.ven) leg (scag (sub own.ven own.ler) leg) == (apply (transmute [%mor leg] ted)) diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook index 32180e807c..a3c892fecf 100644 --- a/main/sur/console/core.hook +++ b/main/sur/console/core.hook @@ -27,6 +27,7 @@ [%blk p=@ud q=@c] :: blink/match char at [%clr ~] :: clear screen [%det console-change] :: edit input + [%nex ~] :: save and clear input [%pro console-prompt] :: set prompt [%tan p=(list tank)] :: classic tank :: [%taq p=tanq] :: modern tank @@ -38,6 +39,7 @@ == :: ++ console-prompt :: prompt definition $: vis=? :: input visible + tag=term :: terminal mode cap=(list ,@c) :: caption == :: ++ console-share :: symmetric state From 60a85e329c48093d302a0423c28a6c60dea8c128 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 12 Feb 2015 13:03:54 -0800 Subject: [PATCH 011/219] Ford dependency tracking up --- arvo/eyre.hoon | 20 +++++++++++--------- arvo/ford.hoon | 36 +++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 97f7622cbd..312f7c825e 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -4,7 +4,6 @@ |= pit=vase => =~ |% :: interfaces -++ bead ,[p=(set beam) q=cage] :: computed result ++ chop ,[p=@ud q=@da] :: see ++ gift :: out result <-$ $% [%thou p=httr] :: raw http response @@ -401,8 +400,9 @@ ~ :: ~& e/ford/hen ?- -.q.sih - | (fail 404 p.q.sih) - & =* cag p.q.sih + | (fail 404 p.sih p.q.sih) + & ~& e/deps/p.sih + =* cag p.q.sih ?> ?=(%mime p.cag) ~| q.q.cag =+ ((hard ,[mit=mite rez=octs]) q.q.cag) :: XX @@ -626,8 +626,8 @@ == :: ++ back :: %ford bounce - |= [our=ship tea=wire cag=cage] - (miff tea %f %exec our `[%cast %mime %done `cag]) + |= [our=ship tea=wire dep=(set beam) cag=cage] + (miff tea %f %exec our `[%cast %mime %done dep cag]) :: ++ doss :: host to ship |= hot=host @@ -638,10 +638,11 @@ (rush -:(flop p.hot) fed:ag) :: ++ fail :: request failed - |= [sas=@ud mez=tang] + |= [sas=@ud dep=(set beam) mez=tang] ^+ +> - :: (back our ~ %tang !>(mez)) :: XX broken tang->mime door in ford + :: (back our ~ ~ %tang !>(mez)) :: XX broken tang->mime door in ford =- (muff (tuff text//plain (role (turn - crip)))) + =. mez [>dep< mez] ^- wall %- zing ^- (list wall) (turn mez |=(a=tank (wash 0^160 a))) :: @@ -744,7 +745,8 @@ :: =+ oar=`(unit ship)`?^(wiq wiq (doss r.p.pul)) =+ oar=(fall (doss r.p.pul) (need hov)) =+ ext=(fall p.q.pul %html) - %- |=(a=(each ,_..hell tang) ?~(-.a p.a (fail 404 >%exit< p.a))) + =+ dez=[[*beak q.q.pul] `~] + %- |=(a=(each ,_..hell tang) ?~(-.a p.a (fail 404 dez >%exit< p.a))) %- mule |. ^+ ..hell =+ hev=(heft oar q.pul) ?^ hev @@ -754,7 +756,7 @@ (honk oar [%cast %mime %boil ext u.hev ~]) =+ hem=(hemp oar [q r]:pul) ?~ hem - ~|(strange-path/(smyt q.q.pul) !!) + ~|(strange-path/q.q.pul !!) ?: ?=([~ %js] p.q.pul) :: XX treat non-json cases? =- (muff (tuff text//javascript (crip -))) """ diff --git a/arvo/ford.hoon b/arvo/ford.hoon index 94356e0d72..1db61e3235 100644 --- a/arvo/ford.hoon +++ b/arvo/ford.hoon @@ -158,12 +158,18 @@ :: :: ++ faun |=([a=cafe b=vase] (fine a `cage`noun/b)) :: vase to cage ++ feel |=([a=cafe b=cage] (fine a q.b)) :: cage to vase -++ fest |*([a=cafe b=*] (fine a [~ u=b])) :: bolt to unit +++ fest :: bolt to success + |= a=beam :: + |* [b=cafe c=*] :: + [p=`cafe`b q=[%0 p=`(set beam)`[a ~ ~] q=[~ u=c]]] :: +:: :: ++ fine |* [a=cafe b=*] :: bolt from data [p=`cafe`a q=[%0 p=*(set beam) q=b]] :: -++ flaw |= [a=cafe b=tang] - [p=a q=[%2 p=*(set beam) q=b]] :: bolt from error -:: +:: :: +++ flaw |= [a=cafe b=tang] :: bolt from error + [p=a q=[%2 p=*(set beam) q=b]] :: +:: :: +++ flue |=(a=cafe (fine a ~)) :: cafe to empty ++ grom :: merge sets |* [one=(set) two=(set)] ^+ one @@ -602,7 +608,7 @@ ^- (bolt cage) %+ cope |- ^- (bolt (list (pair wing vase))) - ?~ muy (fine cof ~) + ?~ muy (flue cof) %+ cope (make cof q.i.muy) |= [cof=cafe cay=cage] %+ cope ^$(muy t.muy) @@ -638,12 +644,12 @@ %+ cope (lend cof bem) |= [cof=cafe arc=arch] ?^ q.arc - (cope (cope (liar cof bem) (lake for bek)) fest) + (cope (cope (liar cof bem) (lake for bek)) (fest bem)) ?: (~(has by r.arc) %hook) %+ cope (fade cof %hook bem) |= [cof=cafe hyd=hood] - (cope (cope (abut:(meow bem arg) cof hyd) (lake for bek)) fest) - (fine cof ~) + (cope (cope (abut:(meow bem arg) cof hyd) (lake for bek)) (fest bem)) + (flue cof) :: ++ lake :: check/coerce |= [for=mark bek=beak] @@ -739,16 +745,16 @@ ?: (~(has by r.arc) for) (lace cof for bem(s [for s.bem]) arg) =+ haz=(turn (~(tap by r.arc) ~) |=([a=@tas b=~] a)) - ?~ haz (fine cof ~) + ?~ haz (flue cof) %+ cope (lion cof for -.bem haz) |= [cof=cafe wuy=(unit (list ,@tas))] - ?~ wuy (fine cof ~) + ?~ wuy (flue cof) ?> ?=(^ u.wuy) %+ cope (make cof %bake i.u.wuy bem arg) |= [cof=cafe hoc=cage] %+ cope (lope cof i.u.wuy t.u.wuy -.bem q.hoc) |= [cof=cafe vax=vase] - (fine cof ~ vax) + ((fest bem) cof vax) :: ++ lime :: load beam |= [cof=cafe for=mark bem=beam arg=heel] @@ -808,7 +814,7 @@ ^- [(bolt (unit (list ,@tas))) _+>] ?: =(for too) [(fine cof [~ too ~]) +>.$] - ?: (~(has in war) for) [(fine cof ~) +>] + ?: (~(has in war) for) [(flue cof) +>] =. war (~(put in war) for) =^ hoc +>.$ (apex (lily cof for bek)) :_ +>.$ @@ -1024,7 +1030,7 @@ |=([a=[@ *] b=[@ *]] (lth -.a -.b)) %+ cope |- ^- (bolt (list (pair ,@ vase))) - ?~ poy (fine cof ~) + ?~ poy (flue cof) %+ cope $(poy t.poy) |= [cof=cafe nex=(list (pair ,@ vase))] %+ cope (chap(s.how [q.i.poy s.how]) cof bax hon) @@ -1043,7 +1049,7 @@ |= [cof=cafe arc=arch] %+ cope |- ^- (bolt (map ,@ vase)) - ?~ r.arc (fine cof ~) + ?~ r.arc (flue cof) %+ cope $(r.arc l.r.arc) |= [cof=cafe lef=(map ,@ vase)] %+ cope `(bolt (map ,@ vase))`^$(cof cof, r.arc r.r.arc) @@ -1078,7 +1084,7 @@ %fan %+ cope |- ^- (bolt (list vase)) - ?~ p.hon (fine cof ~) + ?~ p.hon (flue cof) %+ cope ^$(hon i.p.hon) |= [cof=cafe vax=vase] %+ cope ^$(cof cof, p.hon t.p.hon) From 12508568af89cf1ae8fb580633e8a0dfce218cdd Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 12 Feb 2015 13:04:33 -0800 Subject: [PATCH 012/219] Shell : edit path inference --- main/app/shell/core.hook | 15 ++++++++++----- main/mar/hymn/door.hook | 8 ++++++++ main/mar/json/door.hook | 4 +++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/main/app/shell/core.hook b/main/app/shell/core.hook index a6f01ff319..2c2baabcfc 100644 --- a/main/app/shell/core.hook +++ b/main/app/shell/core.hook @@ -4,7 +4,7 @@ :: /? 314 /- term-line, kyev -/= pit /~ !>(.) :: kernel vase +/= pit /~ !>(+) :: kernel vase :: :::: structures :: @@ -239,12 +239,17 @@ |= [paf=path gen=(unit twig)] ^+ +> =+ fel=(file paf) - ?~ fel - (chew-file paf '! none') - ?^ gen + ?^ fel + ?~ gen + (blab (stray (crip ": {(spud paf)} {<(,@t u.fel)>}"))) %+ with u.gen |= new=vase (chew-file paf (foal paf q.new)) - (blab (stray (crip ": {(spud paf)} {<(,@t u.fel)>}"))) + =+ ark=;;(arch .^(%cy paf)) + ?- r.ark + ~ (chew-file paf '! none') + [^ ~ ~] $(paf (welp paf /[p.n.r.ark])) + * (chew-file paf '! many') + == :: ++ eat-help |= app=term diff --git a/main/mar/hymn/door.hook b/main/mar/hymn/door.hook index 43153b94f4..e7bafa0b89 100644 --- a/main/mar/hymn/door.hook +++ b/main/mar/hymn/door.hook @@ -8,6 +8,14 @@ |% ++ html (crip (poxo own)) :: convert to %html ++ mime [/text/html (taco html)] :: convert to %mime + ++ urb + ~| hymn//mal-formed + ?> ?=([[%html ~] [[%head ~] *] [[%body ~] ^] ~] own) + %_ own + c.i.c + :_ c.i.c.own + ;script@"/~/on/try/0.js"; :: XX + == -- ++ grab |% :: convert from ++ noun manx :: clam from %noun diff --git a/main/mar/json/door.hook b/main/mar/json/door.hook index 212b8fa745..e345cd08c7 100644 --- a/main/mar/json/door.hook +++ b/main/mar/json/door.hook @@ -10,9 +10,11 @@ ++ grow :: convert to |% ++ mime :: convert to %mime - [/text/json (taco (crip (pojo jon)))] + [/text/json (tact (pojo jon))] -- ++ grab |% :: convert from ++ noun json :: clam from %noun + ++ numb jone + ++ time jode -- -- From 89908035e365b0599a3d512dab7033ceb5ebc8fa Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Thu, 12 Feb 2015 14:50:12 -0800 Subject: [PATCH 013/219] Basic "readline" functionality. --- main/app/seat/core.hook | 53 +++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index 1008cc4246..f0f11d22a2 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -13,6 +13,7 @@ == :: ++ source :: input device $: edg=_80 :: terminal columns + kil=(unit (list ,@c)) apt=(list term) :: application ring feg=(map term target) :: live applications mir=(pair ,@ud (list ,@c)) :: mirrored state @@ -179,12 +180,6 @@ ^+ +> %_(+> +> (se-send nam %mess [her ~[nam]] her %console-action !>(act))) :: - ++ ta-bel .(+> (se-blit %bel ~)) :: beep - ++ ta-det :: send edit - |= ted=console-edit - ^+ +> - (ta-act %det [[his.ven.say.inp own.ven.say.inp] (sham buf.say.inp) ted]) - :: ++ ta-aro :: hear arrow |= key=?(%d %l %r %u) ^+ +> @@ -203,6 +198,26 @@ %u ?:(=(0 pos.hit) ta-bel (ta-mov (dec pos.hit))) == :: + ++ ta-bel .(+> (se-blit %bel ~)) :: beep + ++ ta-cat :: mass insert + |= [pos=@ud txt=(list ,@c)] + ^- console-edit + :- %mor + |- ^- (list console-edit) + ?~ txt ~ + [[%ins pos i.txt] $(pos +(pos), txt t.txt)] + :: + ++ ta-cut :: mass delete + |= [pos=@ud num=@ud] + ^- console-edit + :- %mor + |-(?:(=(0 num) ~ [[%del pos] $(num (dec num))])) + :: + ++ ta-det :: send edit + |= ted=console-edit + ^+ +> + (ta-act %det [[his.ven.say.inp own.ven.say.inp] (sham buf.say.inp) ted]) + :: ++ ta-bac :: hear backspace ^+ . ?^ ris.hit @@ -220,15 +235,26 @@ ?+ key ta-bel %a +>(pos.inp 0) %b (ta-aro %l) + %c ta-bel(ris.hit ~) %d ?: &(=(0 pos.inp) =(0 (lent buf.say.inp))) +>(liv |) ta-del %e +>(pos.inp (lent buf.say.inp)) %f (ta-aro %r) + %g ta-bel(ris.hit ~) + %k =+ len=(lent buf.say.inp) + ?: =(pos.inp len) + ta-bel + %- ta-hom(kil `(slag pos.inp buf.say.inp)) + (ta-cut pos.inp (sub len pos.inp)) %l +>(+> (se-blit %clr ~)) %n (ta-aro %d) %p (ta-aro %u) - %r ?~(ris.hit +>(ris.hit `[pos.hit ~]) (ta-ser ~)) + %r ?~ ris.hit + +>(ris.hit `[pos.hit ~]) + ?: =(0 pos.u.ris.hit) + ta-bel + (ta-ser ~) %t =+ len=(lent buf.say.inp) ?: |(=(0 pos.inp) (lth len 2)) ta-bel @@ -239,10 +265,13 @@ [%del sop] [%ins (dec sop) (snag sop buf.say.inp)] == - %u %- ta-hom(pos.inp 0) - :- %mor - =+ ded=0 - |-(?:(=(ded pos.inp) ~ [[%del 0] $(ded +(ded))])) + %u ?: =(0 pos.inp) + ta-bel + %- ta-hom(pos.inp 0, kil `(scag pos.inp buf.say.inp)) + (ta-cut 0 pos.inp) + %y ?~ kil ta-bel + %- ta-hom(pos.inp (add pos.inp (lent u.kil))) + (ta-cat pos.inp u.kil) == :: ++ ta-cru :: hear crud @@ -340,7 +369,7 @@ `sop $(sop (dec sop), dol t.dol) ?~ sup ta-bel - (ta-mov(str.u.ris.hit tot) (dec u.sup)) + (ta-mov(str.u.ris.hit tot, pos.u.ris.hit (dec u.sup)) (dec u.sup)) :: ++ ta-tan :: print tanks |= tac=(list tank) From 3b16d32200249b40defd490a27d8a73432c3a850 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 12 Feb 2015 15:06:45 -0800 Subject: [PATCH 014/219] Error deps tracking --- arvo/ford.hoon | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/arvo/ford.hoon b/arvo/ford.hoon index 1db61e3235..d1b25f7ae6 100644 --- a/arvo/ford.hoon +++ b/arvo/ford.hoon @@ -160,14 +160,18 @@ ++ feel |=([a=cafe b=cage] (fine a q.b)) :: cage to vase ++ fest :: bolt to success |= a=beam :: - |* [b=cafe c=*] :: - [p=`cafe`b q=[%0 p=`(set beam)`[a ~ ~] q=[~ u=c]]] :: + |*([b=cafe c=*] (flag a (fine b [~ u=c]))) :: :: :: ++ fine |* [a=cafe b=*] :: bolt from data [p=`cafe`a q=[%0 p=*(set beam) q=b]] :: :: :: ++ flaw |= [a=cafe b=tang] :: bolt from error [p=a q=[%2 p=*(set beam) q=b]] :: +++ flag :: beam into deps + |* [a=beam b=(bolt)] :: + ?: ?=(%1 -.q.b) b + =. p.q.b (~(put in p.q.b) a) + b :: :: ++ flue |=(a=cafe (fine a ~)) :: cafe to empty ++ grom :: merge sets @@ -327,14 +331,14 @@ ++ cope :: bolt along |* [hoc=(bolt) fun=(burg)] ?- -.q.hoc - %2 hoc %1 hoc + %2 hoc %0 =+ nuf=(fun p.hoc q.q.hoc) :- p=p.nuf ^= q ?- -.q.nuf - %2 q.nuf %1 q.nuf + %2 [%2 p=(grom `_p.q.nuf`p.q.hoc p.q.nuf) q=q.q.nuf] %0 [%0 p=(grom `_p.q.nuf`p.q.hoc p.q.nuf) q=q.q.nuf] == == :: @@ -747,12 +751,11 @@ =+ haz=(turn (~(tap by r.arc) ~) |=([a=@tas b=~] a)) ?~ haz (flue cof) %+ cope (lion cof for -.bem haz) - |= [cof=cafe wuy=(unit (list ,@tas))] + |= [cof=cafe wuy=(list ,@tas)] ?~ wuy (flue cof) - ?> ?=(^ u.wuy) - %+ cope (make cof %bake i.u.wuy bem arg) + %+ cope (make cof %bake i.wuy bem arg) |= [cof=cafe hoc=cage] - %+ cope (lope cof i.u.wuy t.u.wuy -.bem q.hoc) + %+ cope (lope cof i.wuy t.wuy -.bem q.hoc) |= [cof=cafe vax=vase] ((fest bem) cof vax) :: @@ -764,7 +767,7 @@ |= [cof=cafe vux=(unit vase)] ?^ vux (fine cof u.vux) ?~ s.mob - (flaw cof (smyt (tope bem)) ~) + (flag mob (flaw cof (smyt (tope bem)) ~)) ^$(s.mob t.s.mob, mer [i.s.mob mer]) :: ++ link :: translate @@ -792,13 +795,13 @@ :: ++ lion :: translation search |= [cof=cafe too=@tas bek=beak fro=(list ,@tas)] - ^- (bolt (unit (list ,@tas))) + ^- (bolt (list ,@tas)) =| war=(set ,@tas) =< -:(apex (fine cof fro)) |% ++ apex |= rof=(bolt (list ,@tas)) - ^- [(bolt (unit (list ,@tas))) _+>] + ^- [(bolt (list ,@tas)) _+>] ?. ?=(%0 -.q.rof) [rof +>.$] ?~ q.q.rof [[p.rof [%0 p.q.rof ~]] +>.$] @@ -811,16 +814,16 @@ :: ++ apse |= [cof=cafe for=@tas] - ^- [(bolt (unit (list ,@tas))) _+>] + ^- [(bolt (list ,@tas)) _+>] ?: =(for too) - [(fine cof [~ too ~]) +>.$] + [(fine cof [too ~]) +>.$] ?: (~(has in war) for) [(flue cof) +>] =. war (~(put in war) for) =^ hoc +>.$ (apex (lily cof for bek)) :_ +>.$ %+ cope hoc - |= [cof=cafe ked=(unit (list ,@tas))] - (fine cof ?~(ked ~ [~ for u.ked])) + |= [cof=cafe ked=(list ,@tas)] + (fine cof ?~(ked ~ [for ked])) -- :: ++ lope :: translation pipe From 47045e3b6f99bd3a42cc475cae71650c06642d34 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 12 Feb 2015 18:11:18 -0800 Subject: [PATCH 015/219] slab -> slob --- arvo/ford.hoon | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/arvo/ford.hoon b/arvo/ford.hoon index d1b25f7ae6..76f3aeeaa3 100644 --- a/arvo/ford.hoon +++ b/arvo/ford.hoon @@ -195,6 +195,10 @@ =+ gib=(wox p.n.r.arc) ?~(gib rac [[u.gib p.n.r.arc] rac]) :: +++ slob :: XX belongs in h/h + |= [cog=@tas typ=type] + (~(has in (sa (sloe typ))) cog) +:: ++ za :: per event =| $: $: $: our=ship :: computation owner hen=duct :: event floor @@ -668,10 +672,10 @@ =+ bob=(slot 6 tux) ?: (~(nest ut p.bob) | p.sam) (fine cof sam) - ?. (slab %grab p.tux) + ?. (slob %grab p.tux) (flaw cof [%leaf "ford: no grab: {<[for bek]>}"]~) =+ gab=(slap tux [%cnzy %grab]) - ?. (slab %noun p.gab) + ?. (slob %noun p.gab) (flaw cof [%leaf "ford: no noun: {<[for bek]>}"]~) %+ cope (maul cof (slap gab [%cnzy %noun]) [%noun q.sam]) |= [cof=cafe pro=vase] @@ -733,10 +737,10 @@ %+ fine cof %+ weld ^- (list ,@tas) - ?. (slab %garb p.vax) ~ + ?. (slob %garb p.vax) ~ =+ gav=((soft (list ,@tas)) q:(slap vax [%cnzy %garb])) ?~(gav ~ u.gav) - ?. (slab %grow p.vax) ~ + ?. (slob %grow p.vax) ~ =+ gow=(slap vax [%cnzy %grow]) (sloe p.gow) :: @@ -778,16 +782,16 @@ ((lake too bek) cof vax) %+ cope (fang cof for bek) |= [cof=cafe pro=vase] - ?: &((slab %grow p.pro) (slab too p:(slap pro [%cnzy %grow]))) + ?: &((slob %grow p.pro) (slob too p:(slap pro [%cnzy %grow]))) %+ cope (keel cof pro [[%& 6]~ vax]~) |= [cof=cafe pox=vase] (maim cof pox [%tsgr [%cnzy %grow] [%cnzy too]]) %+ cope (fang cof too bek) |= [cof=cafe pro=vase] =+ ^= zat ^- (unit vase) - ?. (slab %grab p.pro) ~ + ?. (slob %grab p.pro) ~ =+ gab=(slap pro [%cnzy %grab]) - ?. (slab for p.gab) ~ + ?. (slob for p.gab) ~ `(slap gab [%cnzy for]) ?~ zat (flaw cof [%leaf "ford: no link: {<[for too]>}"]~) @@ -906,9 +910,17 @@ %+ cool |.(leaf/"ford: cast {}") %+ cope $(kas q.kas) |= [cof=cafe cay=cage] - %+ cope (link cof p.kas p.cay [our %main %da now] q.cay) + =+ bek=[our %main %da now] :: XX + :: VV :: + %+ cope (link cof p.kas p.cay bek q.cay) |= [cof=cafe vax=vase] (fine cof [p.kas vax]) +:: %+ cope (lion cof p.kas bek [p.cay]~) +:: |= [cof=cafe wuy=(list ,@tas)] +:: ?~ wuy (flaw cof [%leaf "ford: no path: {<[p.cay p.kas]>}"]~) +:: %+ cope (lope cof i.wuy t.wuy bek q.cay) +:: |= [cof=cafe vax=vase] +:: (fine cof [p.kas vax]) :: %done [cof %0 p.kas q.kas] %dude (cool |.(p.kas) $(kas q.kas)) From c2dd928a0cad97af47ed89886ec8a6e46212d1e3 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Fri, 13 Feb 2015 16:37:40 -0800 Subject: [PATCH 016/219] Various fixes and improvements. --- main/app/rodeo/core.hook | 5 +- main/app/talk/core.hook | 114 ++++++++++++++++++++++----------------- main/app/tease/core.hook | 2 +- 3 files changed, 66 insertions(+), 55 deletions(-) diff --git a/main/app/rodeo/core.hook b/main/app/rodeo/core.hook index 0a7856cfff..5ca44a2a41 100644 --- a/main/app/rodeo/core.hook +++ b/main/app/rodeo/core.hook @@ -144,7 +144,6 @@ ++ ra-apply :: apply command |= [her=ship cod=command] ^+ +> - ~& [%ra-apply cod] ?- -.cod %design ?. =(her our.hid) @@ -572,7 +571,6 @@ :: ++ pa-refresh :: update stream |= [num=@ud gam=telegram] - ~& [%pa-refresh man num gam guests] =+ ^= moy |- ^- (pair (list bone) (list move)) ?~ guests [~ ~] @@ -706,10 +704,9 @@ ?~ u.old =+ paf=/(scot %p our.hid)/try/(scot %da lat.hid)/rodeo/backlog/jam ?. ?=([%0 %0 %0] [.^(%cy paf)]) + ~& %rodeo-prep-restore $(u.old (some ((hard house-any) (cue ((hard ,@) .^(%cx paf)))))) - ~& %rodeo-prep-new ra-abet:~(ra-init ra 0 moz) - ~& %rodeo-prep-old :- moz |- ?- -.u.u.old diff --git a/main/app/talk/core.hook b/main/app/talk/core.hook index 327fd3d1be..2812a4e61d 100644 --- a/main/app/talk/core.hook +++ b/main/app/talk/core.hook @@ -2,16 +2,17 @@ :::: /hook/core/talk/app :: /? 314 -/- *rodeo -/+ rodeo +/- *console, *rodeo +/+ console, rodeo :: :::: :: !: => |% :: structures ++ town :: all client state - $: live=(unit span) :: present story - console=terminal :: controlling terminal + $: %0 :: version + seat=console-share :: command lines + live=(unit span) :: present story stories=(map span story) :: all stories == :: ++ grip :: subscription state @@ -58,15 +59,10 @@ [%raze p=span] :: destroy story [%tune p=span] :: switch to story == :: - ++ iron :: terminal output - $% [%prompt p=cord q=prom r=cord] :: prompt - [%tang p=(list tank)] :: prettyprintable - [%txt p=cord] :: simple text - == ++ gift $% [%mean ares] [%nice ~] - [%rush iron] + [%rush %console-effect console-effect] == ++ hapt ,[p=ship q=path] ++ move ,[p=bone q=(mold note gift)] @@ -103,21 +99,21 @@ ++ hy :: messenger |_ [moz=(list move) hide] ++ hy-abet moz :: resolve core - ++ hy-transmit :: send command + ++ hy-transmit :: send to radio |= cod=command %_ +> moz :_ moz [0 %pass /command %g %mess [our /rodeo] our [%rodeo-command !>(cod)]] == :: - ++ hy-render :: return to console - |= rod=iron + ++ hy-effect :: return to seat + |= fec=console-effect %_ +> moz - =+ oss=(~(tap in (~(get ju pus) /out))) + =+ oss=(~(tap in (~(get ju pus) /console))) |- ^- (list move) ?~ oss moz - [`move`[i.oss %give %rush rod] $(oss t.oss)] + [`move`[i.oss %give %rush %console-effect fec] $(oss t.oss)] == :: ++ hy-subscribe :: send %show @@ -129,13 +125,13 @@ %_(+> moz :_(moz [0 %pass way %g %nuke [our /rodeo] our])) :: ++ hy-display :: print to console - |=(tay=(list tank) (hy-render %tang tay)) + |=(tay=(list tank) (hy-effect %tan tay)) :: ++ hy-print :: simple print |=(tep=tape (hy-display [%leaf tep]~)) :: ++ hy-accept :: set prompt - |=(asq=cord (hy-render [%prompt asq %text ''])) + |=(asq=cord (hy-effect %pro & %gar (tuba (trip asq)))) -- :: ++ parse :: command parser @@ -284,7 +280,7 @@ link %cool moz =< hy-abet %+ hy-subscribe:(hype moz) - /fm/[man] + /story/[man] :~ %afx man ?: =(0 count) @@ -298,7 +294,7 @@ ?: =(& ?=(?(%cold %dead) link)) . %_ . link %cold - moz hy-abet:(hy-unsubscribe:(hype moz) /fm/[man]) + moz hy-abet:(hy-unsubscribe:(hype moz) /story/[man]) == :: ++ sy-serial :: make serial no @@ -310,6 +306,22 @@ %+ turn `(list partner)`[[%& our.hid man] (~(tap in q.mike))] |=(a=partner [a *envelope %pending]) :: + ++ sy-awake :: introduce prompt + %_ . + moz + =< hy-abet + :- hy-accept:(hype moz) + (crip (sy-prompt q.mike)) + == + :: + ++ sy-voice :: set targets + |= [pas=? tou=(set partner)] + ?: &(!p.mike pas) +> + %_ +>.$ + mike [pas tou] + moz hy-abet:(hy-accept:(hype moz) (crip (sy-prompt tou))) + == + :: ++ sy-message :: print message |= msg=tape %_(+> moz hy-abet:(hy-print:(hype moz) ":{(trip man)}: {msg}")) @@ -386,12 +398,13 @@ %= +> moz =< hy-abet - %- hy-render:(hype moz) + %- hy-effect:(hype moz) =* sta r.q.gam ?+ -.r.sta ~|([%strange-gram -.r.sta] !!) :: %lin :- %txt + %- trip %+ rap 3 :~ (scot %ud num) ')' (scot %p p.gam) ?:(p.r.sta ': ' ' ') @@ -511,7 +524,7 @@ ++ ny-amid :: integrate story |= nov=_sy =^ zom +>+> sy-abet:nov - +>.$(moz (flop zom)) + +>.$(moz (weld (flop zom) moz)) :: ++ ny-tune :: connect to story |= man=span @@ -523,7 +536,7 @@ =. +> ny-stop =. live `man :: ~& [%tune-start man] - (ny-amid sy-subscribe:(need (novel moz))) + (ny-amid sy-subscribe:sy-awake:(need (novel moz))) :: ++ ny-stop :: disconnect story ^+ . @@ -578,9 +591,13 @@ ++ peer |= [ost=bone you=ship pax=path] ^- [(list move) _+>] - [~ +>.$] + =+ nuv=(novel ~) + ?~ nuv + :_ +>.$ + [ost %give %rush %console-effect %pro & %$ (tuba "no story ")]~ + sy-abet:sy-awake:u.nuv :: -++ pour-shell +++ submit |= txt=cord ^- [(list move) _+>] =+ jub=(rush txt work:(parse our.hid)) @@ -605,26 +622,7 @@ %command ?+ +<.sih !! %nice [~ +>.$] - %mean ~|([%pour-mean-cmd-in +>.sih] !!) - == - %cmd-in - ?+ +<.sih !! - %nice [~ +>.$] - %mean ~|([%pour-mean-cmd-in +>.sih] !!) - %rush - ?> ?=(%txt -.p.sih) - =^ moz +>.$ (pour-shell p.p.sih) - :_ +>.$ - :_(moz [ost %pass pax %g %took [our.hid +.imp.hid] our.hid]) - == - :: - %cmd-ac - ?+ +<.sih !! - %nice [~ +>.$] - %mean ~|([%pour-mean-cmd-ac +>.sih] !!) - %rush - :_ +>.$ - [ost %pass pax %g %took [our.hid +.imp.hid] our.hid]~ + %mean ~|([%pour-mean-command +>.sih] !!) == :: %server @@ -644,7 +642,7 @@ :~ [0 %pass /time %t %wait (add ~s10 lat.hid)] == :: - %fm + %story ?> ?=([@ *] t.pax) ?. =(& &(?=(^ live) =(u.live i.t.pax))) ~& [%talk-wrong-story live i.t.pax] @@ -655,13 +653,13 @@ :_(moz `move`[ost %pass pax %g %took [our.hid /rodeo] our.hid]) == :: -++ poke-talk-args - |= [ost=bone you=ship arg=~] +++ prep + |= old=(unit (unit town)) ^- [(list move) _+>] + ?: ?=([~ ~ *] old) + [~ +>(+<+ u.u.old)] :_ +> - :~ [0 %pass /cmd-in %g %show [our.hid +.imp.hid] you /in/[-.imp.hid]] - [0 %pass /time %t %wait (add ~s10 lat.hid)] - [0 %pass /cmd-ac %g %show [our.hid +.imp.hid] you /active/[-.imp.hid]] + :~ [0 %pass /time %t %wait (add ~s10 lat.hid)] ^- move :* 0 %pass /server %g %show @@ -669,4 +667,20 @@ / == == +:: +++ poke-console-action + |= [ost=bone her=ship act=console-action] + =+ moz=`(list move)`[ost %give %nice ~]~ + ?+ -.act [moz +>.$] + %det [moz +>.$(seat abet:(~(receive cs seat) `console-change`+.act))] + %ret =+ sed=buf.seat + =^ zom +>.$ (submit (crip (tufa sed))) + =^ cal seat =<([- abet:+] (~(transmit cs seat) [%set ~])) + :_ +>.$ + :* [ost %give %rush %console-effect %nex ~] + [ost %give %rush %console-effect %det cal] + [ost %give %rush %console-effect %txt (tufa sed)] + (weld zom moz) + == + == -- diff --git a/main/app/tease/core.hook b/main/app/tease/core.hook index ca76d0e9f1..dbb20bb2a6 100644 --- a/main/app/tease/core.hook +++ b/main/app/tease/core.hook @@ -22,7 +22,7 @@ %g %mess [our.hid /seat] our.hid %dill-belt - !>(`dill-belt`[%yow %galk]) + !>(`dill-belt`[%yow %talk]) == == -- From 6ea8322432b3f5898915683fd8c9267dc5094403 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 13 Feb 2015 19:41:37 -0800 Subject: [PATCH 017/219] Minor mark tweaks --- main/mar/hymn/door.hook | 9 +-------- main/mar/react-snip/door.hook | 2 +- main/mar/react/door.hook | 2 +- main/mar/snip/door.hook | 12 ++++++++---- main/mar/txt/door.hook | 1 + 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/main/mar/hymn/door.hook b/main/mar/hymn/door.hook index e7bafa0b89..4a7c18f657 100644 --- a/main/mar/hymn/door.hook +++ b/main/mar/hymn/door.hook @@ -8,15 +8,8 @@ |% ++ html (crip (poxo own)) :: convert to %html ++ mime [/text/html (taco html)] :: convert to %mime - ++ urb - ~| hymn//mal-formed - ?> ?=([[%html ~] [[%head ~] *] [[%body ~] ^] ~] own) - %_ own - c.i.c - :_ c.i.c.own - ;script@"/~/on/try/0.js"; :: XX - == -- +++ garb [%urb ~] ++ grab |% :: convert from ++ noun manx :: clam from %noun -- -- diff --git a/main/mar/react-snip/door.hook b/main/mar/react-snip/door.hook index 1e8dc1a870..cfac2ecc53 100644 --- a/main/mar/react-snip/door.hook +++ b/main/mar/react-snip/door.hook @@ -53,7 +53,7 @@ ")" == ++ react-snip-js (crip tape) - ++ js react-snip-js :: convert to %js +:: ++ js react-snip-js :: convert to %js ++ mime [/text/javascript (taco js)] :: convert to %mime -- ++ grab |% :: convert from diff --git a/main/mar/react/door.hook b/main/mar/react/door.hook index 3967c0f90f..92fcf6b9e0 100644 --- a/main/mar/react/door.hook +++ b/main/mar/react/door.hook @@ -53,7 +53,7 @@ ")" == ++ react-js (crip tape) - ++ js react-js :: convert to %js +:: ++ js react-js :: convert to %js ++ mime [/text/javascript (taco js)] :: convert to %mime -- ++ grab |% :: convert from diff --git a/main/mar/snip/door.hook b/main/mar/snip/door.hook index 6a2deae421..0d7206f3b3 100644 --- a/main/mar/snip/door.hook +++ b/main/mar/snip/door.hook @@ -50,10 +50,14 @@ :: ++ grow :: convert to |% - ++ psal own - ++ hymn ;html:(head:title:"snip" body:"+{psal}") :: convert to %hymn - ++ html (crip (poxo hymn)) :: convert to %html - ++ mime [/text/html (taco html)] :: convert to %mime + ++ mime + =< mime + |% + ++ psal own + ++ hymn ;html:(head:title:"snip" body:"+{psal}") :: convert to %hymn + ++ html (crip (poxo hymn)) :: convert to %html + ++ mime [/text/html (taco html)] :: convert to %mime + -- -- ++ garb [%react-snip ~] ++ grab |% :: convert from diff --git a/main/mar/txt/door.hook b/main/mar/txt/door.hook index fe6784bca3..ed031a9483 100644 --- a/main/mar/txt/door.hook +++ b/main/mar/txt/door.hook @@ -12,5 +12,6 @@ ++ grow |% ++ psal ;div: {(trip txt)} + ++ mime [text//plain (taco txt)] -- -- From dbc02e074969e2e364504f8229773ba39650a7a2 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 13 Feb 2015 19:43:17 -0800 Subject: [PATCH 018/219] Pass dependencies as mark /$ --- arvo/eyre.hoon | 91 ++++++++++++++++++++++++++---------------- arvo/ford.hoon | 63 +++++++++++++++++++---------- main/mar/urb/door.hook | 37 +++++++++++++++++ 3 files changed, 134 insertions(+), 57 deletions(-) create mode 100644 main/mar/urb/door.hook diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 312f7c825e..b398fd0f58 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -345,25 +345,25 @@ |% ++ poll ''' - urb.tries = 0; + urb.tries = 0 urb.call = function() { - xhr = new XMLHttpRequest(); - xhr.open('GET', urb.poll, true); + xhr = new XMLHttpRequest() + xhr.open('GET', urb.poll, true) xhr.addEventListener('load', function() { if(this.status !== 200) { - return urb.keep(); + return urb.keep() } - document.location.reload(); - }); - xhr.addEventListener('error', urb.keep); - xhr.addEventListener('abort', urb.keep); - xhr.send(); + document.location.reload() + }) + xhr.addEventListener('error', urb.keep) + xhr.addEventListener('abort', urb.keep) + xhr.send() } urb.keep = function() { - setTimeout(urb.call,1000*urb.tries); - urb.tries++; + setTimeout(urb.call,1000*urb.tries) + urb.tries++ } - urb.call(); + urb.call() ''' -- -- @@ -400,13 +400,20 @@ ~ :: ~& e/ford/hen ?- -.q.sih - | (fail 404 p.sih p.q.sih) + | ~& e/daps/p.sih + (fail 404 p.sih p.q.sih) & ~& e/deps/p.sih =* cag p.q.sih - ?> ?=(%mime p.cag) - ~| q.q.cag - =+ ((hard ,[mit=mite rez=octs]) q.q.cag) :: XX - (muff %thou 200 [content-type/(moon mit)]~ ~ rez) + ?+ p.cag (back ~ p.sih cag) + %hipo :: hacks! + ?> ?=(@tas -.q.q.cag) + $(p.q.sih [-.q.q.cag (slot 3 q.cag)]) + :: + %mime + ~| q.q.cag + =+ ((hard ,[mit=mite rez=octs]) q.q.cag) :: XX + (muff %thou 200 [content-type/(moon mit)]~ ~ rez) + == == == :: @@ -626,7 +633,7 @@ == :: ++ back :: %ford bounce - |= [our=ship tea=wire dep=(set beam) cag=cage] + |= [tea=wire dep=(set beam) cag=cage] (miff tea %f %exec our `[%cast %mime %done dep cag]) :: ++ doss :: host to ship @@ -640,11 +647,19 @@ ++ fail :: request failed |= [sas=@ud dep=(set beam) mez=tang] ^+ +> - :: (back our ~ ~ %tang !>(mez)) :: XX broken tang->mime door in ford - =- (muff (tuff text//plain (role (turn - crip)))) - =. mez [>dep< mez] - ^- wall %- zing ^- (list wall) - (turn mez |=(a=tank (wash 0^160 a))) + :: (back ~ ~ %tang !>(mez)) :: XX broken tang->mime door in ford + =+ bek=(sa (turn (~(tap in dep)) |=(a=beam (tope a(s ~))))) + =- (resp text//html (poxo -)) + =+ rolt=|=(a=wall `tape`?~(a ~ :(weld i.a "\0a" $(a t.a)))) + =+ mec=(rolt (turn mez |=(a=tank (rolt (wash 0^160 a))))) + ;html + ;head + ;meta(charset "utf-8"); + ;* %+ turn (~(tap by bek)) + |=(loc=path ;script@"/~/on{(spud loc)}.js";) + == + ;body:pre:code:"{mec}" + == :: :: ++ gale :: ya from response :: |= [our=ship ses=hole] @@ -744,30 +759,31 @@ :: ?~(gow [~ q.q.pul] [gow t.q.q.pul]) :: =+ oar=`(unit ship)`?^(wiq wiq (doss r.p.pul)) =+ oar=(fall (doss r.p.pul) (need hov)) - =+ ext=(fall p.q.pul %html) - =+ dez=[[*beak q.q.pul] `~] - %- |=(a=(each ,_..hell tang) ?~(-.a p.a (fail 404 dez >%exit< p.a))) + =+ ext=(fall p.q.pul %hymn) + %- |=(a=(each ,_..hell tang) ?~(-.a p.a (fail 404 ~ >%exit< p.a))) %- mule |. ^+ ..hell =+ hev=(heft oar q.pul) ?^ hev =: s.u.hev [%web ~(rent co (flux:ya /'' r.pul)) s.u.hev] r.u.hev ?+(r.u.hev r.u.hev [%ud %0] da/now) == - (honk oar [%cast %mime %boil ext u.hev ~]) + (honk oar [%boil ext u.hev ~]) =+ hem=(hemp oar [q r]:pul) ?~ hem ~|(strange-path/q.q.pul !!) ?: ?=([~ %js] p.q.pul) :: XX treat non-json cases? - =- (muff (tuff text//javascript (crip -))) + %+ resp text//javascript """ window.urb = \{poll: "/{(body:earn q.pul(u.p %json))}"} {(trip poll:js)} """ %+ hoot oar =- [q.u.hem ~ %& %y ud/+(`@ud`-) /] - ?: ?=(%ud -.r.u.hem) - p.r.u.hem - ;;(@ (need (sky %cw (tope u.hem /)))) + ?. ?=(%ud -.r.u.hem) + ;;(@ (need (sky %cw (tope u.hem /)))) + ?: =(0 p.r.u.hem) + ;;(@ (need (sky %cw (tope u.hem(r da/now) /)))) + p.r.u.hem :: ++ hemp :: auxillary(/~) request |= [oar=ship pok=pork quy=quay] @@ -780,7 +796,7 @@ %on ?~ but !! :: XX look by query string ?> ?=([@ @ $|(~ [@ ~])] but) =- -:(need (tome -)) - ?^ t.t.but but(i (cat 3 '~' i.but)) + ?^ t.t.but but [(scot %p oar) but] == :: ?. (home oar) @@ -931,7 +947,8 @@ :: ++ jive :: success json |= jon=json - (muff (tuff application//json (crip (pojo jon)))) + (resp application//json (pojo jon)) + :: ++ muff :: return card |= gef=gift +>(mow :_(mow [hen %give gef])) @@ -940,8 +957,12 @@ |= noe=[wire note] +>(mow :_(mow [hen %pass noe])) :: - ++ tuff - |= [mit=mite rez=@] :: success response + ++ resp :: mime response + |= [mit=mite bod=tape] + (muff (tuff mit (crip bod))) + :: + ++ tuff :: success response + |= [mit=mite rez=@] ^- gift [%thou 200 ~[content-type/(moon mit)] [~ (taco rez)]] :: diff --git a/arvo/ford.hoon b/arvo/ford.hoon index 76f3aeeaa3..05b3c6d94e 100644 --- a/arvo/ford.hoon +++ b/arvo/ford.hoon @@ -394,6 +394,10 @@ == fun :: + ++ coze :: pass dependencies + |* [hoc=(bolt) fon=$+((set beam) (burg))] + ?+(-.q.hoc hoc %0 (cope hoc (fon p.q.hoc))) + :: ++ dash :: process cache |= cof=cafe ^+ +> @@ -447,7 +451,7 @@ (fine cof p.u.q.vex) :: ++ fang :: protocol door - |= [cof=cafe for=mark bek=beak] + |= [cof=cafe dep=(set beam) for=mark bek=beak] ^- (bolt vase) =+ pax=/door/[for]/mar =+ ^= bem ^- beam @@ -457,7 +461,12 @@ ?: ?=([~ ~ *] (ska %cy (tope [oak pax]))) oak bek - (cope (fade cof %hook bem) abut:(meow bem ~)) + =+ ^= arg ^- spur + :- %dep + =- ?~(- /'' /(pack -)) + %+ turn (~(tap in dep)) + |=(a=beam =+((tope a) ?~(- !! (pack -)))) :: XX + (cope (fade cof %hook bem) abut:(meow bem arg)) :: ++ fair :: hood parsing rule |= bem=beam @@ -652,11 +661,12 @@ %+ cope (lend cof bem) |= [cof=cafe arc=arch] ?^ q.arc - (cope (cope (liar cof bem) (lake for bek)) (fest bem)) + (cope (cope (liar cof bem) (lake for bek)) (fest (norm bem))) ?: (~(has by r.arc) %hook) %+ cope (fade cof %hook bem) |= [cof=cafe hyd=hood] - (cope (cope (abut:(meow bem arg) cof hyd) (lake for bek)) (fest bem)) + %+ cope (cope (abut:(meow bem arg) cof hyd) (lake for bek)) + (fest (norm bem)) (flue cof) :: ++ lake :: check/coerce @@ -667,7 +677,7 @@ ?: ?=(?(%gate %core %door %hoon %hook) for) :: ~& [%lake-easy for bek] (fine cof sam) - %+ cope (fang cof for bek) + %+ cope (fang cof ~ for bek) |= [cof=cafe tux=vase] =+ bob=(slot 6 tux) ?: (~(nest ut p.bob) | p.sam) @@ -730,7 +740,7 @@ ++ lily :: translation targets |= [cof=cafe for=mark bek=beak] ^- (bolt (list ,@tas)) - =+ raf=(fang cof for bek) + =+ raf=(fang cof ~ for bek) ?: =(%2 -.q.raf) (fine p.raf ~) %+ cope raf |= [cof=cafe vax=vase] @@ -757,9 +767,9 @@ %+ cope (lion cof for -.bem haz) |= [cof=cafe wuy=(list ,@tas)] ?~ wuy (flue cof) - %+ cope (make cof %bake i.wuy bem arg) - |= [cof=cafe hoc=cage] - %+ cope (lope cof i.wuy t.wuy -.bem q.hoc) + %+ coze (make cof %bake i.wuy bem arg) + |= dep=(set beam) |= [cof=cafe hoc=cage] + %+ cope (lope cof dep i.wuy t.wuy -.bem q.hoc) |= [cof=cafe vax=vase] ((fest bem) cof vax) :: @@ -771,22 +781,22 @@ |= [cof=cafe vux=(unit vase)] ?^ vux (fine cof u.vux) ?~ s.mob - (flag mob (flaw cof (smyt (tope bem)) ~)) + (flag (norm mob) (flaw cof (smyt (tope bem)) ~)) ^$(s.mob t.s.mob, mer [i.s.mob mer]) :: ++ link :: translate - |= [cof=cafe too=mark for=mark bek=beak vax=vase] + |= [cof=cafe dep=(set beam) too=mark for=mark bek=beak vax=vase] ^- (bolt vase) ?: =(too for) (fine cof vax) ?: |(=(%noun for) =(%$ for)) ((lake too bek) cof vax) - %+ cope (fang cof for bek) + %+ cope (fang cof dep for bek) |= [cof=cafe pro=vase] ?: &((slob %grow p.pro) (slob too p:(slap pro [%cnzy %grow]))) %+ cope (keel cof pro [[%& 6]~ vax]~) |= [cof=cafe pox=vase] (maim cof pox [%tsgr [%cnzy %grow] [%cnzy too]]) - %+ cope (fang cof too bek) + %+ cope (fang cof dep too bek) |= [cof=cafe pro=vase] =+ ^= zat ^- (unit vase) ?. (slob %grab p.pro) ~ @@ -831,10 +841,10 @@ -- :: ++ lope :: translation pipe - |= [cof=cafe for=mark yaw=(list mark) bek=beak vax=vase] + |= [cof=cafe dep=(set beam) for=mark yaw=(list mark) bek=beak vax=vase] ^- (bolt vase) ?~ yaw (fine cof vax) - %+ cope (link cof i.yaw for bek vax) + %+ cope (link cof dep i.yaw for bek vax) |= [cof=cafe yed=vase] ^$(cof cof, for i.yaw, yaw t.yaw, vax yed) :: @@ -908,17 +918,17 @@ :: %cast %+ cool |.(leaf/"ford: cast {}") - %+ cope $(kas q.kas) - |= [cof=cafe cay=cage] + %+ coze $(kas q.kas) + |= dep=(set beam) |= [cof=cafe cay=cage] =+ bek=[our %main %da now] :: XX :: VV :: - %+ cope (link cof p.kas p.cay bek q.cay) + %+ cope (link cof dep p.kas p.cay bek q.cay) |= [cof=cafe vax=vase] (fine cof [p.kas vax]) -:: %+ cope (lion cof p.kas bek [p.cay]~) -:: |= [cof=cafe wuy=(list ,@tas)] +:: %+ coze (lion cof p.kas bek [p.cay]~) +:: |= dep=(set beam) |= [cof=cafe wuy=(list ,@tas)] :: ?~ wuy (flaw cof [%leaf "ford: no path: {<[p.cay p.kas]>}"]~) -:: %+ cope (lope cof i.wuy t.wuy bek q.cay) +:: %+ cope (lope cof dep i.wuy t.wuy bek q.cay) :: |= [cof=cafe vax=vase] :: (fine cof [p.kas vax]) :: @@ -982,7 +992,7 @@ ^- twig :+ %tsgr ?:(=(~ rop) [%$ 1] [%brcn (~(run by rop) |=([* a=twig] [%ash a]))]) - [%tssg (turn (flop lot) |=(a=term q:(need (~(get by bil) a))))] + [%tssg (turn (flop lot) |=(a=term q:(~(got by bil) a)))] :: ++ ably :: naked structure |= [cof=cafe for=mark hyd=hood] :: XX unused @@ -1253,6 +1263,15 @@ == -- :: + ++ norm :: normalize beam rev + |= bem=beam + %_ bem + r ?: ?=(%ud -.r.bem) r.bem + =+ num=(ska %cw (tope bem(s ~))) + ?. ?=([~ ~ @u] num) r.bem :: XX + [%ud u.u.num] + == + :: ++ resp |= [tik=@ud rot=riot] ^+ ..zo diff --git a/main/mar/urb/door.hook b/main/mar/urb/door.hook new file mode 100644 index 0000000000..ce18121774 --- /dev/null +++ b/main/mar/urb/door.hook @@ -0,0 +1,37 @@ +:: +:::: /hook/door/urb/mar + :: +/? 314 +/= dep /$ + !: + |= [^ but=path] + ^- (set path) + ?> ?=([%dep @ ~] but) + %- sa + %+ turn `path`(need (pick i.t.but)) + |=(a=span (scag 3 `path`(need (pick a)))) +!: +|_ own=manx +:: +++ grow :: convert to + |% + ++ html (crip (poxo own)) :: convert to %html + ++ mime [/text/html (taco html)] :: convert to %mime + -- +++ grab + |% :: convert from + ++ noun manx :: clam from %noun + ++ hymn :: inject into %hymn + |= old=manx + ~| hymn//mal-formed + ?> ?=([[%html ~] [[%head ~] *] [[%body ~] ^] ~] old) :: XX static +:: =+ bek=(sa (turn (turn dep) |=(a=beam (tope a(s ~))))) :: inject into %hymn + %_ old + c.i.c + :- ;meta(charset "utf-8", urb_injected ""); + %- welp :_ c.i.c.old + %+ turn (~(tap in dep)) + |=(loc=path ;script@"/~/on{(spud loc)}.js"(urb_injected "");) + == + -- +-- From d980b1da232005c52e5c3cb906717296e96ce3b0 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Sun, 15 Feb 2015 02:25:57 -0800 Subject: [PATCH 019/219] Abandon some experiments. --- arvo/gall.hoon | 7 ------- main/app/talk/core.hook | 44 ++++++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/arvo/gall.hoon b/arvo/gall.hoon index 8c77664185..b917d3fb5e 100644 --- a/arvo/gall.hoon +++ b/arvo/gall.hoon @@ -839,13 +839,6 @@ | [~ (give %crud %murk-made p.p.+.sih)] == :: - ++ moar :: foreign take - |= $: pax=path - sih=sign - == - ^+ +> - !! - :: ++ more :: domestic take |= $: pax=path :: internal position hin=(hypo sign) :: typed event diff --git a/main/app/talk/core.hook b/main/app/talk/core.hook index 2812a4e61d..951e045934 100644 --- a/main/app/talk/core.hook +++ b/main/app/talk/core.hook @@ -97,7 +97,7 @@ :: => |% :: tools ++ hy :: messenger - |_ [moz=(list move) hide] + |_ [[moz=(list move)] hide] ++ hy-abet moz :: resolve core ++ hy-transmit :: send to radio |= cod=command @@ -106,7 +106,7 @@ [0 %pass /command %g %mess [our /rodeo] our [%rodeo-command !>(cod)]] == :: - ++ hy-effect :: return to seat + ++ hy-general :: serve all peers |= fec=console-effect %_ +> moz @@ -125,13 +125,13 @@ %_(+> moz :_(moz [0 %pass way %g %nuke [our /rodeo] our])) :: ++ hy-display :: print to console - |=(tay=(list tank) (hy-effect %tan tay)) + |=(tay=(list tank) (hy-general %tan tay)) :: ++ hy-print :: simple print |=(tep=tape (hy-display [%leaf tep]~)) :: ++ hy-accept :: set prompt - |=(asq=cord (hy-effect %pro & %gar (tuba (trip asq)))) + |=(asq=cord (hy-general %pro & %gar (tuba (trip asq)))) -- :: ++ parse :: command parser @@ -260,9 +260,12 @@ :::: :: |_ [hid=hide town] -++ hype |=(moz=(list move) ~(. hy moz hid)) +++ hype :: global messenger + |=([moz=(list move)] ~(. hy moz hid)) +:: ++ sy - |_ $: $: man=span :: u.live + |_ $: $: ost=bone :: cause + man=span :: u.live moz=(list move) :: pending moves == :: story :: current story @@ -398,7 +401,7 @@ %= +> moz =< hy-abet - %- hy-effect:(hype moz) + %- hy-general:(hype moz) =* sta r.q.gam ?+ -.r.sta ~|([%strange-gram -.r.sta] !!) :: @@ -516,7 +519,7 @@ -- -- ++ ny :: top configuration - |_ moz=(list move) + |_ [ost=bone moz=(list move)] ++ ny-abet :: resolve core ^- [(list move) _+>] [(flop moz) +>] @@ -536,12 +539,12 @@ =. +> ny-stop =. live `man :: ~& [%tune-start man] - (ny-amid sy-subscribe:sy-awake:(need (novel moz))) + (ny-amid sy-subscribe:sy-awake:(need (novel ost moz))) :: ++ ny-stop :: disconnect story ^+ . ?~ live . - (ny-amid(live ~) sy-unsubscribe:(need (novel moz))) + (ny-amid(live ~) sy-unsubscribe:(need (novel ost moz))) :: ++ ny-tell :: hear from server |= sap=(map span (pair posture cord)) @@ -577,35 +580,36 @@ %make %= +> moz - hy-abet:(hy-transmit:(hype moz) [%design p.jaw [~ ~ %default %black ~]]) + =< hy-abet + (hy-transmit:(hype moz) [%design p.jaw [~ ~ %default %black ~]]) == == -- :: ++ novel :: live story - |= moz=(list move) + |= [ost=bone moz=(list move)] ^- (unit ,_sy) ?~ live ~ - `~(. sy [u.live moz] (~(got by stories) u.live)) + `~(. sy [ost u.live moz] (~(got by stories) u.live)) :: ++ peer |= [ost=bone you=ship pax=path] ^- [(list move) _+>] - =+ nuv=(novel ~) + =+ nuv=(novel ost ~) ?~ nuv :_ +>.$ [ost %give %rush %console-effect %pro & %$ (tuba "no story ")]~ sy-abet:sy-awake:u.nuv :: ++ submit - |= txt=cord + |= [ost=bone txt=cord] ^- [(list move) _+>] =+ jub=(rush txt work:(parse our.hid)) ?~ jub [hy-abet:(hy-print:(hype ~) "invalid input") +>.$] ?: ?=(%wry -.u.jub) - ny-abet:(ny-work:ny +.u.jub) - =+ nuv=(novel ~) + ny-abet:(~(ny-work ny ost ~) +.u.jub) + =+ nuv=(novel ost ~) ?~ nuv [hy-abet:(hy-print:(hype ~) "not tuned to any story") +>.$] sy-abet:(sy-work:u.nuv u.jub) :: @@ -631,7 +635,7 @@ %mean ~|(%talk-server-crash !!) %rush ?> ?=([%rodeo-report %house *] p.sih) - =^ moz +>.$ ny-abet:(ny-tell:ny +.p.p.sih) + =^ moz +>.$ ny-abet:(~(ny-tell ny ost ~) +.p.p.sih) :_ +>.$ :_(moz [ost %pass pax %g %took [our.hid /rodeo] our.hid]) == @@ -648,7 +652,7 @@ ~& [%talk-wrong-story live i.t.pax] [~ +>.$] ?> ?=(%g -.sih) - =^ moz +>.$ sy-abet:(sy-sign:(need (novel ~)) +.sih) + =^ moz +>.$ sy-abet:(sy-sign:(need (novel ost ~)) +.sih) :_ +>.$ :_(moz `move`[ost %pass pax %g %took [our.hid /rodeo] our.hid]) == @@ -674,7 +678,7 @@ ?+ -.act [moz +>.$] %det [moz +>.$(seat abet:(~(receive cs seat) `console-change`+.act))] %ret =+ sed=buf.seat - =^ zom +>.$ (submit (crip (tufa sed))) + =^ zom +>.$ (submit ost (crip (tufa sed))) =^ cal seat =<([- abet:+] (~(transmit cs seat) [%set ~])) :_ +>.$ :* [ost %give %rush %console-effect %nex ~] From f189282a45110aa5170753d30244bf063150a58d Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Mon, 16 Feb 2015 12:18:10 -0800 Subject: [PATCH 020/219] Various fixes and improvements. --- arvo/dill.hoon | 1 + arvo/dull.hoon | 5 +- arvo/ford.hoon | 2 +- main/app/seat/core.hook | 155 +++++++++++++++++++++++++++++----------- 4 files changed, 116 insertions(+), 47 deletions(-) diff --git a/arvo/dill.hoon b/arvo/dill.hoon index a38c75f88a..a5afa719de 100644 --- a/arvo/dill.hoon +++ b/arvo/dill.hoon @@ -46,6 +46,7 @@ $: %d :: $% [%crud p=@tas q=(list tank)] :: [%text p=tape] :: + [%logo ~] :: == == :: $: %g :: $% [%mess p=[p=ship q=path] q=ship r=mess] :: diff --git a/arvo/dull.hoon b/arvo/dull.hoon index db62c2feae..60862f546e 100644 --- a/arvo/dull.hoon +++ b/arvo/dull.hoon @@ -98,7 +98,7 @@ $% [%bbye ~] :: reset prompt [%blit p=(list blit)] :: terminal output [%init p=@p] :: set owner - [%logo @] :: logout + [%logo ~] :: logout [%veer p=@ta q=path r=@t] :: install vane [%vega p=path] :: reboot by path [%verb ~] :: @@ -233,8 +233,7 @@ +> :: [%g %mean *] - :: ~& [%take-mean sih] - +> + +>(moz [[hen %give %logo ~] moz]) :: [%g %nice *] :: ~& [%take-nice sih] diff --git a/arvo/ford.hoon b/arvo/ford.hoon index 5cff17b173..02b5ba1a07 100644 --- a/arvo/ford.hoon +++ b/arvo/ford.hoon @@ -37,7 +37,7 @@ [%dub p=term q=horn] :: /= apply face [%fan p=(list horn)] :: /. list [%for p=path q=horn] :: /, descend - [%hel p=horn] :: /% propogate heel + [%hel p=horn] :: /% propagate heel [%hub p=horn] :: /@ list by @ud [%man p=(map span horn)] :: /* hetero map [%nap p=horn] :: /_ homo map diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index f0f11d22a2..f3733b04b2 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -12,16 +12,21 @@ $: bin=(map bone source) :: input devices == :: ++ source :: input device - $: edg=_80 :: terminal columns - kil=(unit (list ,@c)) + $: edg=_79 :: terminal columns + off=@ud :: window offset + kil=(unit (list ,@c)) :: kill buffer apt=(list term) :: application ring + maz=(unit (list ,@c)) :: master window feg=(map term target) :: live applications mir=(pair ,@ud (list ,@c)) :: mirrored state == :: + ++ master :: master buffer + $: pos=@ud :: cursor position + buf=(list ,@c) :: text entry + == :: ++ history :: past input $: pos=@ud :: input position num=@ud :: number of entries - ris=(unit search) :: reverse-i-search lay=(map ,@ud (list ,@c)) :: editing overlay old=(list (list ,@c)) :: entries proper == :: @@ -30,7 +35,8 @@ str=(list ,@c) :: search string == ++ target :: application target - $: hit=history :: all past input + $: ris=(unit search) :: reverse-i-search + hit=history :: all past input pom=console-prompt :: static prompt inp=console-input :: input state == :: @@ -70,9 +76,27 @@ |= bet=dill-belt ^+ +> ?: ?=(%rez -.bet) - +>(edg q.bet) + +>(edg (dec p.bet)) ?: ?=(%yow -.bet) (se-link p.bet) + ?^ maz + ?+ -.bet (se-blit %bel ~) + :: + %bac + ?: =(0 (lent u.maz)) + (se-blit %bel ~) + +>(u.maz (scag (dec (lent u.maz)) u.maz)) + :: + %ctl + ?+ p.bet (se-blit %bel ~) + %d (se-emit ost %give %mean ~) + %v +>.$(maz ~) + %x $(maz ~) + == + :: + %ret (se-like(maz ~) u.maz) + %txt +>(u.maz (weld u.maz p.bet)) + == ?~ apt ~& %console-no-terminal (se-blit %bel ~) @@ -94,22 +118,28 @@ |= nam=term ^+ +> ?> (~(has by feg) nam) - %_ +> - feg (~(del by feg) nam) - apt (skip apt |=(a=term =(nam a))) - == + =: feg (~(del by feg) nam) + apt (skip apt |=(a=term =(nam a))) + == + ?^ apt +> + ?^ maz +> + +>(maz `~) :: ++ se-join :: add connection |= nam=term ^+ +> ?< (~(has by feg) nam) - +>(apt [nam apt], feg (~(put by feg) nam *target)) + +>(maz ~, apt [nam apt], feg (~(put by feg) nam *target)) :: ++ se-nuke :: active drop |= nam=term ^+ +> (se-drop:(se-send nam %nuke [her ~[nam]] her) nam) :: + ++ se-like :: act in master + |= buf=(list ,@c) + (se-link (crip (tufa buf))) + :: ++ se-link :: connect to app |= nam=term ^+ +> @@ -121,15 +151,35 @@ |= bil=dill-blit (se-emit ost %give %rush %dill-blit bil) :: + ++ se-show :: show buffer, raw + |= lin=(pair ,@ud (list ,@c)) + ^+ +> + ?: =(mir lin) +> + =. +> ?:(=(q.mir q.lin) +> (se-blit %pro q.lin)) + =. +> ?:(=(p.mir p.lin) +> (se-blit %hop p.lin)) + +>(mir lin) + :: + ++ se-just :: adjusted buffer + |= lin=(pair ,@ud (list ,@c)) + ^+ +> + =. off ?:((lth p.lin edg) 0 (sub p.lin edg)) + (se-show (sub p.lin off) (scag edg (slag off q.lin))) + :: ++ se-view :: flush buffer - ^+ . - =+ ^= lin ^- (pair ,@ud (list ,@c)) - ?~ apt [0 ~] - ~(ta-vew ta [& i.apt] (~(got by feg) i.apt)) - ?: =(mir lin) + - =. + ?:(=(q.mir q.lin) + (se-blit %pro q.lin)) - =. + ?:(=(p.mir p.lin) + (se-blit %hop p.lin)) - +(mir lin) + %- se-just + ?^ maz + =- [(lent zil) zil] + ^= zil ^- (list ,@c) + %- welp + :_ u.maz + |- ^- (list ,@c) + ?~ apt [`@c`0x23 `@c`0x20 ~] + =+ nex=$(apt t.apt) + %+ welp (tuba (trip i.apt)) + ?~(t.apt nex `_nex`[`@c`0x2c `@c`0x20 nex]) + ?~ apt + ~&(%se-no-view [0 ~]) + ~(ta-vew ta [& i.apt] (~(got by feg) i.apt)) :: ++ se-kill :: kill a source =+ tup=apt @@ -154,7 +204,6 @@ ^+ +> ?- -.sil %mean - ~& [%se-pour-mean sil] +>.$ :: %nice @@ -184,18 +233,21 @@ |= key=?(%d %l %r %u) ^+ +> ?- key - %d ?. =(num.hit pos.hit) + %d =. ris ~ + ?. =(num.hit pos.hit) (ta-mov +(pos.hit)) ?: =(0 (lent buf.say.inp)) ta-bel (ta-hom:ta-nex %set ~) - %l ?: =(0 pos.inp) - ta-bel + %l ?^ ris ta-bel + ?: =(0 pos.inp) ta-bel +>(pos.inp (dec pos.inp)) - %r ?: =((lent buf.say.inp) pos.inp) + %r ?^ ris ta-bel + ?: =((lent buf.say.inp) pos.inp) ta-bel +>(pos.inp +(pos.inp)) - %u ?:(=(0 pos.hit) ta-bel (ta-mov (dec pos.hit))) + %u =. ris ~ + ?:(=(0 pos.hit) ta-bel (ta-mov (dec pos.hit))) == :: ++ ta-bel .(+> (se-blit %bel ~)) :: beep @@ -220,10 +272,10 @@ :: ++ ta-bac :: hear backspace ^+ . - ?^ ris.hit - ?: =(~ str.u.ris.hit) + ?^ ris + ?: =(~ str.u.ris) ta-bel - .(str.u.ris.hit (scag (dec (lent str.u.ris.hit)) str.u.ris.hit)) + .(str.u.ris (scag (dec (lent str.u.ris)) str.u.ris)) ?: =(0 pos.inp) .(+> (se-blit %bel ~)) =+ pre=(dec pos.inp) @@ -235,13 +287,13 @@ ?+ key ta-bel %a +>(pos.inp 0) %b (ta-aro %l) - %c ta-bel(ris.hit ~) + %c ta-bel(ris ~) %d ?: &(=(0 pos.inp) =(0 (lent buf.say.inp))) +>(liv |) ta-del %e +>(pos.inp (lent buf.say.inp)) %f (ta-aro %r) - %g ta-bel(ris.hit ~) + %g ta-bel(ris ~) %k =+ len=(lent buf.say.inp) ?: =(pos.inp len) ta-bel @@ -250,9 +302,9 @@ %l +>(+> (se-blit %clr ~)) %n (ta-aro %d) %p (ta-aro %u) - %r ?~ ris.hit - +>(ris.hit `[pos.hit ~]) - ?: =(0 pos.u.ris.hit) + %r ?~ ris + +>(ris `[pos.hit ~]) + ?: =(0 pos.u.ris) ta-bel (ta-ser ~) %t =+ len=(lent buf.say.inp) @@ -269,6 +321,10 @@ ta-bel %- ta-hom(pos.inp 0, kil `(scag pos.inp buf.say.inp)) (ta-cut 0 pos.inp) + %v +>(maz `~) + %x ?: =(~ apt) ta-bel + ?^ maz ta-bel + +>(apt (welp (slag 1 apt) [(snag 0 apt) ~])) %y ?~ kil ta-bel %- ta-hom(pos.inp (add pos.inp (lent u.kil))) (ta-cat pos.inp u.kil) @@ -339,7 +395,7 @@ %_ . num.hit +(num.hit) pos.hit +(num.hit) - ris.hit ~ + ris ~ lay.hit ~ old.hit [buf.say.inp old.hit] == @@ -352,10 +408,10 @@ ++ ta-ser :: reverse search |= ext=(list ,@c) ^+ +> - ?: |(?=(~ ris.hit) =(0 pos.u.ris.hit)) ta-bel - =+ tot=(weld str.u.ris.hit ext) - =+ dol=(slag (sub num.hit pos.u.ris.hit) old.hit) - =+ sop=pos.u.ris.hit + ?: |(?=(~ ris) =(0 pos.u.ris)) ta-bel + =+ tot=(weld str.u.ris ext) + =+ dol=(slag (sub num.hit pos.u.ris) old.hit) + =+ sop=pos.u.ris =+ ^= ser =+ ^= beg |= [a=(list ,@c) b=(list ,@c)] ^- ? @@ -369,7 +425,7 @@ `sop $(sop (dec sop), dol t.dol) ?~ sup ta-bel - (ta-mov(str.u.ris.hit tot, pos.u.ris.hit (dec u.sup)) (dec u.sup)) + (ta-mov(str.u.ris tot, pos.u.ris (dec u.sup)) (dec u.sup)) :: ++ ta-tan :: print tanks |= tac=(list tank) @@ -381,7 +437,7 @@ ++ ta-txt :: hear text |= txt=(list ,@c) ^+ +> - ?^ ris.hit + ?^ ris (ta-ser txt) %- ta-hom(pos.inp (add (lent txt) pos.inp)) :- %mor @@ -391,11 +447,11 @@ :: ++ ta-vew :: computed prompt |- ^- (pair ,@ud (list ,@c)) - ?^ ris.hit + ?^ ris %= $ - ris.hit ~ + ris ~ cap.pom - `(list ,@)`:(welp "(reverse-i-search)'" str.u.ris.hit "': ") + `(list ,@)`:(welp "(reverse-i-search)'" str.u.ris "': ") == =- [(add pos.inp (lent p.vew)) (weld p.vew q.vew)] ^= vew ^- (pair (list ,@c) (list ,@c)) @@ -419,7 +475,20 @@ |= [ost=bone her=ship pax=path] ^- [(list move) _+>] ?< (~(has by bin) ost) - [~ +>(bin (~(put by bin) ost *source))] + :- [ost %give %rush %dill-blit %pro [`@c`0x23 `@c`0x20 ~]]~ + %= +> + bin + %+ ~(put by bin) ost + ^- source + :* 80 + 0 + ~ + ~ + `~ + ~ + [0 ~] + == + == :: ++ poke-dill-belt |= [ost=bone her=ship bet=dill-belt] From 8b7bd35055bc58ac9665d6fb008e3f4037ec11ef Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 16 Feb 2015 14:04:55 -0800 Subject: [PATCH 021/219] de-stack-trace !^ --- arvo/hoon.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index f35e8ddd4d..49d0d01537 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -8533,7 +8533,7 @@ =+ txt=(,@ta .^(%cx ruv)) ~| ruv %+ rash txt - (ifix [gay gay] tall(was (~(put in was) u.rev), wer u.rev)) + (ifix [gay gay] tall(was (~(put in was) u.rev), wer u.rev, bug |)) :: ++ prey |= gun=(list twig) ^- (unit twig) From c2497ae7357d37ce4446e83d417523a541b3227b Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 16 Feb 2015 14:06:58 -0800 Subject: [PATCH 022/219] Moved /~/on usage to query string --- arvo/eyre.hoon | 69 +++++++++++++++++++++++++++++--------------------- arvo/zuse.hoon | 18 ++++++++----- 2 files changed, 51 insertions(+), 36 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index b398fd0f58..db33cc5d57 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -106,7 +106,7 @@ ged=duct :: client interface ney=@uvI :: rolling entropy dop=(map host ship) :: host aliasing - liz=(jug beak (each duct oryx)) + liz=(jug beam (each duct oryx)) :: clay subscriptions :: own=(map ship serf) :: domestic servers :: fon=(map ship rote) :: foreign servers :: ask=[p=@ud q=(map ,@ud ,[p=duct q=hiss])] :: outgoing by number @@ -400,10 +400,8 @@ ~ :: ~& e/ford/hen ?- -.q.sih - | ~& e/daps/p.sih - (fail 404 p.sih p.q.sih) - & ~& e/deps/p.sih - =* cag p.q.sih + | (fail 404 p.sih p.q.sih) + & =* cag p.q.sih ?+ p.cag (back ~ p.sih cag) %hipo :: hacks! ?> ?=(@tas -.q.q.cag) @@ -418,11 +416,11 @@ == :: %writ - ?^ tea ~&(e/missed/writ/tea=tea +>.$) + :: ?^ tea ~&(e/missed/writ/tea=tea +>.$) ?~ p.sih +>.$ - =+ caz=`case`q.p.u.p.sih + =+ `[@ caz=case dez=desk]`p.u.p.sih ?> ?=(%ud -.caz) - (jive (jone p.caz)) + (jive (joba dez (jone p.caz))) :: %- gout :: [(slav %p i.t.tea) i.t.t.tea (slav %ud i.t.t.t.tea) p.+.sih] :: :: @@ -647,16 +645,17 @@ ++ fail :: request failed |= [sas=@ud dep=(set beam) mez=tang] ^+ +> - :: (back ~ ~ %tang !>(mez)) :: XX broken tang->mime door in ford - =+ bek=(sa (turn (~(tap in dep)) |=(a=beam (tope a(s ~))))) + :: (back ~ ~ %tang !>(mez)) :: XX broken tang->mime door in fo =- (resp text//html (poxo -)) =+ rolt=|=(a=wall `tape`?~(a ~ :(weld i.a "\0a" $(a t.a)))) =+ mec=(rolt (turn mez |=(a=tank (rolt (wash 0^160 a))))) + =+ det=`tang`(turn (~(tap in dep)) |=(a=beam leaf/+:(spud (tope a)))) + =+ pax=~(ram re %rose ["&" `~] det) ;html ;head ;meta(charset "utf-8"); - ;* %+ turn (~(tap by bek)) - |=(loc=path ;script@"/~/on{(spud loc)}.js";) + ;* ?~ dep ~ + [;script@"/~/on.js?{pax}";]~ == ;body:pre:code:"{mec}" == @@ -759,7 +758,7 @@ :: ?~(gow [~ q.q.pul] [gow t.q.q.pul]) :: =+ oar=`(unit ship)`?^(wiq wiq (doss r.p.pul)) =+ oar=(fall (doss r.p.pul) (need hov)) - =+ ext=(fall p.q.pul %hymn) + =+ ext=(fall p.q.pul %urb) %- |=(a=(each ,_..hell tang) ?~(-.a p.a (fail 404 ~ >%exit< p.a))) %- mule |. ^+ ..hell =+ hev=(heft oar q.pul) @@ -767,36 +766,48 @@ =: s.u.hev [%web ~(rent co (flux:ya /'' r.pul)) s.u.hev] r.u.hev ?+(r.u.hev r.u.hev [%ud %0] da/now) == - (honk oar [%boil ext u.hev ~]) + (honk oar [%cast %mime [%boil ext u.hev ~]]) =+ hem=(hemp oar [q r]:pul) ?~ hem ~|(strange-path/q.q.pul !!) ?: ?=([~ %js] p.q.pul) :: XX treat non-json cases? %+ resp text//javascript """ - window.urb = \{poll: "/{(body:earn q.pul(u.p %json))}"} + window.urb = \{poll: "/{(apex:earn %| q.pul(u.p %json) r.pul)}"} {(trip poll:js)} """ - %+ hoot oar - =- [q.u.hem ~ %& %y ud/+(`@ud`-) /] - ?. ?=(%ud -.r.u.hem) - ;;(@ (need (sky %cw (tope u.hem /)))) - ?: =(0 p.r.u.hem) - ;;(@ (need (sky %cw (tope u.hem(r da/now) /)))) - p.r.u.hem + =+ dep=(~(tap in u.hem)) + |- ^+ ..hell + ?~ dep ..hell + %^ hoot:$(dep t.dep) + oar [%y (tope i.dep)] + =- [q.i.dep ~ %& %y ud/+(`@ud`-) s.i.dep] + ?. ?=(%ud -.r.i.dep) + ;;(@ (need (sky %cw (tope -.i.dep /)))) + ?: =(0 p.r.i.dep) + ;;(@ (need (sky %cw (tope -.i.dep(r da/now) /)))) + p.r.i.dep :: ++ hemp :: auxillary(/~) request |= [oar=ship pok=pork quy=quay] - ^- (unit beak) + ^- (unit (set beam)) ?. ?=([%'~' @ *] q.pok) ~ :- ~ =* pef i.t.q.pok =+ but=t.t.q.pok :: XX =* ?+ pef ~|(pfix-lost/`path`/~/[pef] !!) - %on ?~ but !! :: XX look by query string - ?> ?=([@ @ $|(~ [@ ~])] but) - =- -:(need (tome -)) - ?^ t.t.but but + %on ?~ but + %- sa + %+ turn quy |= [a=cord b=@] ^- beam + ~| on/bad-query/quy + ?. =('' b) !! + %- need %- tome %- stab + ?: =('/' (end 3 1 a)) + a + (cat 3 '/' a) + =- ~|(on/bad-path/but [(need (tome -)) ~ ~]) + ?: =('~' (end 3 1 i.but)) + but [(scot %p oar) but] == :: ?. (home oar) @@ -811,8 +822,8 @@ :: !=(~ (sky /a/(scot %p who)/buck/(scot %da now))) :: ++ hoot :: clay request - |= [our=ship rif=riff] - (miff ~ %c [%warp [our our] rif]) + |= [our=ship wir=path rif=riff] + (miff wir %c [%warp [our our] rif]) :: ++ hone :: kill ford |= [our=ship ses=hole] diff --git a/arvo/zuse.hoon b/arvo/zuse.hoon index 0d6f907dc1..1ee99c3ca7 100644 --- a/arvo/zuse.hoon +++ b/arvo/zuse.hoon @@ -2154,9 +2154,14 @@ pul(q.q [(rsh 3 1 (scot %p who)) q.q.pul]) :: ++ earn :: purl to tape - |^ |= pul=purl - ^- tape - :(weld (head p.pul) "/" (body q.pul) (tail r.pul)) + =< |=(pul=purl `tape`(apex ~ pul)) + |% + ++ apex + |= qur=quri + ?- -.qur + %& (weld (head p.p.qur) `tape`['/' $(qur [%| +.p.qur])]) + %| (weld (body p.qur) (tail q.qur)) + == :: ++ body |= pok=pork ^- tape @@ -2190,10 +2195,9 @@ :- '?' |- ^- tape ?~ kay ~ - ;: weld + ;: welp (urle (trip p.i.kay)) - "=" - (urle (trip q.i.kay)) + ?~(q.i.kay ~ ['=' (urle (trip q.i.kay))]) ?~(t.kay ~ `tape`['&' $(kay t.kay)]) == -- @@ -2235,7 +2239,7 @@ ++ pesc ;~(pfix cen mes) :: 2396 escaped ++ pold (cold ' ' (just '+')) :: old space code ++ pque ;~(pose pcar fas wut) :: 3986 query char - ++ pquo ;~(pose pure pesc pold) :: normal query char + ++ pquo ;~(pose pure pesc pold fas wut) :: normal query char ++ pure ;~(pose aln hep dot cab sig) :: 2396 unreserved ++ psub ;~ pose :: 3986 sub-delims zap buc pam soq pel per From 8d15788f1f09619c8e538bab5f668868305ebc01 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 16 Feb 2015 15:19:58 -0800 Subject: [PATCH 023/219] status code refactoring --- arvo/eyre.hoon | 79 ++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 44 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index db33cc5d57..ea7c17db7c 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -282,27 +282,28 @@ :: ?> ?=(%mime p.cay) :: ((hard love) [%mid q.q.cay]) :: :: -:: ++ loga :: tanks to manx -:: |= [til=tape mog=(list manx) tac=(list tank)] -:: ^- manx -:: =+ ^= wol -:: |- ^- wall -:: ?~ tac ~ -:: (weld `wall`[~(ram re i.tac) ~] $(tac t.tac)) -:: =+ ^= tax -:: |- ^- (list manx) -:: (turn wol |=(a=tape [/p ;"{a}"])) -:: ;html -:: ;head -:: ;title: {til} -:: == -:: ;body -:: ;code -:: ;* (weld tax mog) -:: == -:: == -:: == -:: :: +++ loga :: tanks to manx + |= tac=(list tank) + ^- manx + =+ rolt=|=(a=wall `tape`?~(a ~ :(weld i.a "\0a" $(a t.a)))) + =+ mec=(rolt (turn tac |=(a=tank (rolt (wash 0^160 a))))) + ;html + ;head + ;meta(charset "utf-8"); + ;title: server error + == + ;body:pre:code:"{mec}" + == +:: +++ lode + |= [dep=(set beam) max=manx] + ^- manx + =+ det=`tang`(turn (~(tap in dep)) |=(a=beam leaf/+:(spud (tope a)))) + =+ pax=~(ram re %rose ["&" `~] det) + ?> ?=([[%html ~] [[%head ~] *] [[%body ~] ^] ~] max) :: XX static + ?~ dep max + max(c.i.c :_(c.i.c.max ;script@"/~/on.js?{pax}";)) +:: :: ++ lofa :: scripts in head :: |= [mog=(list manx) luv=love] :: ^- love @@ -350,7 +351,9 @@ xhr = new XMLHttpRequest() xhr.open('GET', urb.poll, true) xhr.addEventListener('load', function() { - if(this.status !== 200) { + // if(~~(this.status / 100) == 4) + // return document.write(xhr.responseText) + if(this.status !== 205) { return urb.keep() } document.location.reload() @@ -646,19 +649,7 @@ |= [sas=@ud dep=(set beam) mez=tang] ^+ +> :: (back ~ ~ %tang !>(mez)) :: XX broken tang->mime door in fo - =- (resp text//html (poxo -)) - =+ rolt=|=(a=wall `tape`?~(a ~ :(weld i.a "\0a" $(a t.a)))) - =+ mec=(rolt (turn mez |=(a=tank (rolt (wash 0^160 a))))) - =+ det=`tang`(turn (~(tap in dep)) |=(a=beam leaf/+:(spud (tope a)))) - =+ pax=~(ram re %rose ["&" `~] det) - ;html - ;head - ;meta(charset "utf-8"); - ;* ?~ dep ~ - [;script@"/~/on.js?{pax}";]~ - == - ;body:pre:code:"{mec}" - == + (resp sas text//html (poxo (lode dep (loga mez)))) :: :: ++ gale :: ya from response :: |= [our=ship ses=hole] @@ -771,7 +762,7 @@ ?~ hem ~|(strange-path/q.q.pul !!) ?: ?=([~ %js] p.q.pul) :: XX treat non-json cases? - %+ resp text//javascript + %^ resp 200 text//javascript """ window.urb = \{poll: "/{(apex:earn %| q.pul(u.p %json) r.pul)}"} {(trip poll:js)} @@ -898,7 +889,7 @@ ?+ [(fall p.q.pul %$) q.q.pul] ~ [?(%ico %png) %favicon ~] :- ~ - %+ tuff image//png + %^ tuff 200 image//png 0w89wg.GV4jA.l9000.00dPb.YzBT6.giO00.o100d.wZcqc.a9tg-.VTG0b. AUIvE.HBM3g.cK4SE.0aagi.l090p.I1P5g.Y-80r.y1YS9.1xE~Y.qgpFY. vKN1V.905y0.2UwvL.43TUw.uL406.0-31h.xwoJF.Ul454.ilk00.00Yps. @@ -907,7 +898,7 @@ :: [%txt %robots ~] :- ~ - %+ tuff text//plain + %^ tuff 200 text//plain %- role :~ 'User-agent: *' 'Disallow: /' @@ -958,7 +949,7 @@ :: ++ jive :: success json |= jon=json - (resp application//json (pojo jon)) + (resp 205 application//json (pojo jon)) :: ++ muff :: return card |= gef=gift @@ -969,13 +960,13 @@ +>(mow :_(mow [hen %pass noe])) :: ++ resp :: mime response - |= [mit=mite bod=tape] - (muff (tuff mit (crip bod))) + |= [sas=@uG mit=mite bod=tape] + (muff (tuff sas mit (crip bod))) :: - ++ tuff :: success response - |= [mit=mite rez=@] + ++ tuff :: mimed response + |= [sas=@uG mit=mite rez=@] ^- gift - [%thou 200 ~[content-type/(moon mit)] [~ (taco rez)]] + [%thou sas ~[content-type/(moon mit)] [~ (taco rez)]] :: :: ++ myth :: load session :: |= [our=ship ses=hole] From 8c1ce4fa55fc6a9462765056b7e557b42d9cde68 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 17 Feb 2015 13:05:28 -0800 Subject: [PATCH 024/219] Init auth --- arvo/eyre.hoon | 203 +++++++++++++++++++++++------------------ main/mar/urb/door.hook | 13 +-- 2 files changed, 119 insertions(+), 97 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index ea7c17db7c..7502f0f336 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -119,14 +119,14 @@ :: voy=(map ,@ud (list ,@ud)) :: waiters (q.rey) :: out=(list json) :: output commands :: == :: -:: ++ cyst :: client session -:: $: ced=cred :: credential +++ cyst :: client session + $: ced=cred :: credential :: cow=(map ,@ud clue) :: consoles -:: cug=(list ,@t) :: unacked cookies -:: lax=@da :: last used + cug=(list ,@t) :: unacked cookies + lax=@da :: last used :: sok=(map ,@ud (pair ship sink)) :: live apps by reqno :: rey=[p=@ud q=(map ,@ud pimp)] :: live requests -:: == :: + == :: :: ++ dual ,[p=@ud q=(each ,[p=ship q=hole] ship)] :: request handle :: ++ dude ,[p=@tas q=@] :: client identity :: ++ pest :: request in progress @@ -194,19 +194,19 @@ :: == :: -- :: |% -:: ++ coss :: cookie search -:: |= [nam=@t mah=math] -:: ^- (unit hole) -:: =+ ^= cok ^- (list ,@t) -:: =+ cok=(~(get by mah) 'cookie') -:: ?~(cok ~ u.cok) -:: |- ^- (unit hole) -:: ?~ cok ~ -:: =+ mar=`(unit (list ,[p=@t q=@t]))`(rush i.cok cock:epur) -:: ?~ mar $(cok t.cok) -:: |- ^- (unit hole) -:: ?~ u.mar ^$(cok t.cok) -:: ?:(=(nam p.i.u.mar) [~ q.i.u.mar] $(u.mar t.u.mar)) +++ coss :: cookie search + |= [nam=@t mah=math] + ^- (unit hole) + =+ ^= cok ^- (list ,@t) + =+ cok=(~(get by mah) 'cookie') + ?~(cok ~ u.cok) + |- ^- (unit hole) + ?~ cok ~ + =+ mar=`(unit (list ,[p=@t q=@t]))`(rush i.cok cock:epur) + ?~ mar $(cok t.cok) + |- ^- (unit hole) + ?~ u.mar ^$(cok t.cok) + ?:(=(nam p.i.u.mar) [~ q.i.u.mar] $(u.mar t.u.mar)) :: :: :: ++ ecca :: [hasp path] :: |= [orx=oryx moh=moth] @@ -595,7 +595,7 @@ :: mow :_(mow [p.kas [%give %thou q.kyz]]) :: q.ask (~(del by q.ask) p.kas) :: == -:: :: + :: %this :: inbound request =* sec p.kyz :: ? :: https bit =* heq r.kyz :: httq :: request content @@ -648,7 +648,7 @@ ++ fail :: request failed |= [sas=@ud dep=(set beam) mez=tang] ^+ +> - :: (back ~ ~ %tang !>(mez)) :: XX broken tang->mime door in fo + :: (back ~ ~ %tang !>(mez)) :: XX broken tang->mime door in ford (resp sas text//html (poxo (lode dep (loga mez)))) :: :: ++ gale :: ya from response @@ -715,7 +715,7 @@ :: ^+ +> :: =+ boy=(myth our (need ((sand %ta) ((hard ,@) hez)))) :: ?~(boy +>.$ abet:(auth:u.boy him)) - :: +:: :: ++ heck :: extract err beak |= [oar=ship pul=purl] ^- (unit beak) @@ -761,45 +761,44 @@ =+ hem=(hemp oar [q r]:pul) ?~ hem ~|(strange-path/q.q.pul !!) - ?: ?=([~ %js] p.q.pul) :: XX treat non-json cases? - %^ resp 200 text//javascript - """ - window.urb = \{poll: "/{(apex:earn %| q.pul(u.p %json) r.pul)}"} - {(trip poll:js)} - """ - =+ dep=(~(tap in u.hem)) - |- ^+ ..hell - ?~ dep ..hell - %^ hoot:$(dep t.dep) - oar [%y (tope i.dep)] - =- [q.i.dep ~ %& %y ud/+(`@ud`-) s.i.dep] - ?. ?=(%ud -.r.i.dep) - ;;(@ (need (sky %cw (tope -.i.dep /)))) - ?: =(0 p.r.i.dep) - ;;(@ (need (sky %cw (tope -.i.dep(r da/now) /)))) - p.r.i.dep + ?- -.u.hem + & (onto p.u.hem pul) + | ~|(aute/p.u.hem !!) + == :: ++ hemp :: auxillary(/~) request |= [oar=ship pok=pork quy=quay] - ^- (unit (set beam)) + ^- (unit (each (set beam) ,[p=ship q=pork])) ?. ?=([%'~' @ *] q.pok) ~ :- ~ =* pef i.t.q.pok =+ but=t.t.q.pok :: XX =* - ?+ pef ~|(pfix-lost/`path`/~/[pef] !!) - %on ?~ but - %- sa - %+ turn quy |= [a=cord b=@] ^- beam - ~| on/bad-query/quy - ?. =('' b) !! - %- need %- tome %- stab - ?: =('/' (end 3 1 a)) - a - (cat 3 '/' a) - =- ~|(on/bad-path/but [(need (tome -)) ~ ~]) - ?: =('~' (end 3 1 i.but)) - but - [(scot %p oar) but] + ?+ pef ~|(pfix-lost/`path`/~/[pef] !!) + %on + :- %& + ?^ but + ~| on/bad-path/but + =- [(need (tome -)) ~ ~] + ?: =('~' (end 3 1 i.but)) + but + [(scot %p oar) but] + %- sa + %+ turn quy |= [a=cord b=@] ^- beam + ~| on/bad-query/quy + ?. =('' b) !! + %- need %- tome %- stab + ?: =('/' (end 3 1 a)) + a + (cat 3 '/' a) + %as + :- %| + ~| bad-ship/?~(but ~ i.but) + ?~ but !! + :_ pok(q t.but) + ?+ i.but (slav %p i.but) + %anon (add our ^~((bex 64))) + %own our + == == :: ?. (home oar) :: (hork oar hyx) @@ -813,8 +812,8 @@ :: !=(~ (sky /a/(scot %p who)/buck/(scot %da now))) :: ++ hoot :: clay request - |= [our=ship wir=path rif=riff] - (miff wir %c [%warp [our our] rif]) + |= [our=ship wir=path his=ship rif=riff] + (miff wir %c [%warp [our his] rif]) :: ++ hone :: kill ford |= [our=ship ses=hole] @@ -882,7 +881,7 @@ :: q.rem (~(put by q.rem.rot) num hen) :: == :: == - :: +:: :: ++ horn :: irregular request |= [pul=purl cip=clip moh=moth] ^- (unit gift) @@ -905,46 +904,48 @@ == == :: -:: ++ huff :: request by ship -:: |= [our=ship cip=clip pul=purl moh=moth] -:: =* sec p.p.pul + ++ huff :: request by ship + |= [our=ship cip=clip pul=purl moh=moth] + ^- [p=hole q=cyst] + =* sec p.p.pul :: =+ ^= sef ^- serf :: =+ suf=(~(get by own) our) :: ?^ suf u.suf :: =+ sef=*serf :: sef(pef (cat 3 gub (rsh 3 1 (scot %p our)))) :: XX transitional :: =+ ^= saw ^- [p=hole q=cyst] -:: =+ lig=(coss pef.sef q.moh) -:: ?^ lig -:: =+ cyz=(need (~(get by wup.sef) u.lig)) -:: [u.lig cyz(cug ~)] -:: =+ ses=(rsh 3 1 (scot %p (end 6 1 ney))) -:: :- ses -:: ^- cyst -:: :* ^- cred -:: :* [sec q.p.pul r.p.pul] -:: ~ -:: (rsh 3 1 (scot %p (end 6 1 (shaf %oryx ses)))) -:: :: -:: =+ lag=(~(get by q.moh) %accept-language) -:: ?~(lag ~ ?~(u.lag ~ [~ i.u.lag])) -:: :: -:: cip -:: ~ -:: == -:: :: -:: ~ -:: :: -:: :_ ~ -:: %^ cat 3 -:: (cat 3 (cat 3 pef.sef '=') ses) -:: :: (cat 3 '; HttpOnly' ?.(sec '' '; Secure')) -:: '; Path=/; HttpOnly' -:: :: -:: now -:: ~ -:: [1 ~] -:: == + =+ pef=(cat 3 gub (rsh 3 1 (scot %p our))) + =+ lig=(coss pef q.moh) +:: ?^ lig +:: =+ cyz=(need (~(get by wup.sef) u.lig)) +:: [u.lig cyz(cug ~)] + =+ ses=(rsh 3 1 (scot %p (end 6 1 ney))) + :- ses + ^- cyst + :* ^- cred + :* [sec q.p.pul r.p.pul] + ~ + (rsh 3 1 (scot %p (end 6 1 (shaf %oryx ses)))) + :: + =+ lag=(~(get by q.moh) %accept-language) + ?~(lag ~ ?~(u.lag ~ [~ i.u.lag])) + :: + cip + ~ + == + :: +:: ~ + :: + :_ ~ + %^ cat 3 + (cat 3 (cat 3 pef '=') ses) + :: (cat 3 '; HttpOnly' ?.(sec '' '; Secure')) + '; Path=/; HttpOnly' + :: + now +:: ~ +:: [1 ~] + == :: abet:work:(~(into ya [our p.saw] sef q.saw) pul moh) :: ++ jive :: success json @@ -959,6 +960,26 @@ |= noe=[wire note] +>(mow :_(mow [hen %pass noe])) :: + ++ onto :: clay long-poll + |= [dep=(set beam) pul=purl] + ?: ?=([~ %js] p.q.pul) :: XX treat non-json cases? + %^ resp 200 text//javascript + """ + window.urb = \{poll: "/{(apex:earn %| q.pul(u.p %json) r.pul)}"} + {(trip poll:js)} + """ + =+ des=(~(tap in dep)) + |- ^+ ..onto + ?~ des ..onto + %^ hoot:$(des t.des) + our [%y (tope i.des)] + =- [p.i.des q.i.des ~ %& %y ud/+(`@ud`-) s.i.des] + ?. ?=(%ud -.r.i.des) + ;;(@ (need (sky %cw (tope -.i.des /)))) + ?: =(0 p.r.i.des) + ;;(@ (need (sky %cw (tope -.i.des(r da/now) /)))) + p.r.i.des + :: ++ resp :: mime response |= [sas=@uG mit=mite bod=tape] (muff (tuff sas mit (crip bod))) @@ -1193,7 +1214,7 @@ :: [%path %s (crip )] :: [%data `json`jon] :: == - :: +:: :: ++ ya :: session engine =| [[our=ship ses=hole] ~] ::serf cyst] :: =* sef ->- diff --git a/main/mar/urb/door.hook b/main/mar/urb/door.hook index ce18121774..763440a73c 100644 --- a/main/mar/urb/door.hook +++ b/main/mar/urb/door.hook @@ -7,9 +7,9 @@ |= [^ but=path] ^- (set path) ?> ?=([%dep @ ~] but) - %- sa + %- sa %+ turn `path`(need (pick i.t.but)) - |=(a=span (scag 3 `path`(need (pick a)))) + |=(a=span `path`(need (pick a))) !: |_ own=manx :: @@ -28,10 +28,11 @@ :: =+ bek=(sa (turn (turn dep) |=(a=beam (tope a(s ~))))) :: inject into %hymn %_ old c.i.c - :- ;meta(charset "utf-8", urb_injected ""); - %- welp :_ c.i.c.old - %+ turn (~(tap in dep)) - |=(loc=path ;script@"/~/on{(spud loc)}.js"(urb_injected "");) + :+ ;meta(charset "utf-8", urb_injected ""); + =+ det=`tang`(turn (~(tap in dep)) |=(a=path leaf/+:(spud a))) + =+ pax=~(ram re %rose ["&" `~] det) + ;script@"/~/on.js?{pax}"; + c.i.c.old == -- -- From e0cfa0fe396e7c408f61fa7d462e0c063262e5ae Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 17 Feb 2015 19:30:53 -0800 Subject: [PATCH 025/219] Before experiment in reversing arvo moves. --- arvo/dull.hoon | 3 +- arvo/gall.hoon | 2 +- main/app/seat/core.hook | 12 +++++- main/app/tease/core.hook | 2 +- main/lib/console/core.hook | 79 +++++++++++++++++++++++++++++--------- main/sur/console/core.hook | 1 + 6 files changed, 77 insertions(+), 22 deletions(-) diff --git a/arvo/dull.hoon b/arvo/dull.hoon index 60862f546e..d51757b47a 100644 --- a/arvo/dull.hoon +++ b/arvo/dull.hoon @@ -190,6 +190,7 @@ ++ from :: receive belt |= bit=dill-blit ^+ +> + ~& [%from bit hen] ?: ?=(%out -.bit) %+ done %blit :~ [%lin p.bit] @@ -229,7 +230,7 @@ +> :: [%g %crud *] - :: ~& [%take-crud sih] + ~& [%take-crud sih] +> :: [%g %mean *] diff --git a/arvo/gall.hoon b/arvo/gall.hoon index b917d3fb5e..12f70d229e 100644 --- a/arvo/gall.hoon +++ b/arvo/gall.hoon @@ -260,7 +260,7 @@ ^- [p=(list move) q=_..^$] ?: ?=(%crud +<.q.hin) ~& [%gall-crud-error pax hen] - :: ~& [%gall-crud-data (,[@tas (list tank)] +>.q.hin)] + ~& [%gall-crud-data (,[@tas (list tank)] +>.q.hin)] ?> ?=(%g -.q.hin) ?~ pax ~& %strange-path [~ ..^$] =+ lum=(lump t.pax) diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index f3733b04b2..7659af5bca 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -162,6 +162,7 @@ ++ se-just :: adjusted buffer |= lin=(pair ,@ud (list ,@c)) ^+ +> + ~& [%just lin mir] =. off ?:((lth p.lin edg) 0 (sub p.lin edg)) (se-show (sub p.lin off) (scag edg (slag off q.lin))) :: @@ -204,6 +205,7 @@ ^+ +> ?- -.sil %mean + ~& [%seat-mean sil] +>.$ :: %nice @@ -343,12 +345,16 @@ :: ++ ta-fec :: apply effect |= fec=console-effect + ~& [%ta-fec fec] ^+ +> ?- -.fec %bel ta-bel %blk +> %clr +>(+> (se-blit %clr ~)) %det (ta-got +.fec) + %mor |- ^+ +>.^$ + ?~ p.fec +>.^$ + $(p.fec t.p.fec, +>.^$ ^$(fec i.p.fec)) %nex ta-nex %pro (ta-pro +.fec) %tan (ta-tan p.fec) @@ -453,7 +459,8 @@ cap.pom `(list ,@)`:(welp "(reverse-i-search)'" str.u.ris "': ") == - =- [(add pos.inp (lent p.vew)) (weld p.vew q.vew)] + =- =. pos.inp (max pos.inp (lent q.vew)) + [(add pos.inp (lent p.vew)) (weld p.vew q.vew)] ^= vew ^- (pair (list ,@c) (list ,@c)) ?: vis.pom [cap.pom buf.say.inp] :- ;: welp @@ -500,6 +507,9 @@ ++ pour |= [ost=bone pax=path sih=*] ^- [(list move) _+>] + =- ~& [%pour-moves -.foo] + foo + ^= foo =+ sih=((hard sign) sih) ?> ?=([@ @ ~] pax) =< se-abet diff --git a/main/app/tease/core.hook b/main/app/tease/core.hook index dbb20bb2a6..6d9899d24e 100644 --- a/main/app/tease/core.hook +++ b/main/app/tease/core.hook @@ -22,7 +22,7 @@ %g %mess [our.hid /seat] our.hid %dill-belt - !>(`dill-belt`[%yow %talk]) + !>(`dill-belt`[%yow %dojo]) == == -- diff --git a/main/lib/console/core.hook b/main/lib/console/core.hook index 152161e8cf..4d1b2bce9d 100644 --- a/main/lib/console/core.hook +++ b/main/lib/console/core.hook @@ -26,11 +26,14 @@ %set +>.$(buf p.ted) == :: - :: symmetric operational transformation. for any console state, obeys + :::: + :: ++transmute: symmetric operational transformation. + :: + :: for any console state +>, obeys :: :: =+ [x=(transmute a b) y=(transmute b a)] - :: .= (edit-apply:(edit-apply x) b) - :: (edit-apply:(edit-apply a) y) + :: .= (apply:(apply b) x) + :: (apply:(apply a) y) :: ++ transmute :: dex as after sin |= [sin=console-edit dex=console-edit] @@ -67,30 +70,70 @@ == == :: - ++ commit + ++ commit :: local change |= ted=console-edit ^+ +> (apply(own.ven +(own.ven)) ted) :: - ++ transmit + :::: + :: ++inverse: inverse of change in context. + :: + :: for any console state +>, obeys + :: + :: =(+> (apply:(apply a) (inverse a))) + :: + ++ inverse :: relative inverse + |= ted=console-edit + ^- console-edit + ?- -.ted + %del [%ins p.ted (snag p.ted buf)] + %ins [%del p.ted] + %mor :- %mor + %- flop + |- ^- (list console-edit) + ?~ p.ted ~ + :- ^$(ted i.p.ted) + $(p.ted t.p.ted, +>.^$ (apply i.p.ted)) + %nop [%nop ~] + %set [%set buf] + == + :: + ++ transmit :: outgoing change |= ted=console-edit ^- [console-change _+>] [[[his.ven own.ven] (sham buf) ted] (commit ted)] :: - ++ receive :: edit from other - |= $: ler=console-clock :: other's clock view - haw=@uvH :: hash at edit - ted=console-edit :: edit content - == - ^+ +> - ?. &(=(his.ler his.ven) (lte own.ler own.ven)) - ~& [%receive-mismatch ler/ler ven/ven ~] - !! + ++ realize :: naturalize event + |= console-change + ^- [console-edit _+>] + ?> &(=(his.ler his.ven) (lte own.ler own.ven)) ?> &(=(his.ler his.ven) (lte own.ler own.ven)) ?> |(!=(own.ler own.ven) =(haw (sham buf))) - =: his.ven +(his.ven) - leg (scag (sub own.ven own.ler) leg) - == - (apply (transmute [%mor leg] ted)) + =. leg (scag (sub own.ven own.ler) leg) + [(transmute [%mor leg] ted) +>] + :: + ++ remit :: conditional accept + |= [cal=console-change ask=$+((list ,@c) ?)] + ^- [(unit console-change) _+>] + =+ old=+> + =^ dat +>.$ (realize cal) + =. +>.$ (apply(his.ven +(his.ven)) dat) + ?: (ask buf) + [~ +>.$] + =+ wad=(inverse dat) + :: ~& [%remit-old buf.old] + :: ~& [%remit-new buf] + :: ~& [%remit ted/ted.cal] + :: ~& [%remit dat/dat] + :: ~& [%remit wad/wad] + =^ lic +>.$ (transmit wad) + :: ~& [%remit-end [lic buf]] + [`lic +>.$] + :: + ++ receive :: accept change + |= cal=console-change + ^+ +> + =^ dat +> (realize cal) + (apply(his.ven +(his.ven)) dat) -- -- diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook index a3c892fecf..cfb47fdebe 100644 --- a/main/sur/console/core.hook +++ b/main/sur/console/core.hook @@ -27,6 +27,7 @@ [%blk p=@ud q=@c] :: blink/match char at [%clr ~] :: clear screen [%det console-change] :: edit input + [%mor p=(list console-effect)] :: multiple effects [%nex ~] :: save and clear input [%pro console-prompt] :: set prompt [%tan p=(list tank)] :: classic tank From 6fad37ed798ebf4057dcfdd6d2b7b86fd8eeb9e9 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 18 Feb 2015 13:35:22 -0800 Subject: [PATCH 026/219] Dependency hashes v1 --- arvo/eyre.hoon | 39 +++++++++------ arvo/ford.hoon | 129 ++++++++++++++++++++++++++++++++----------------- arvo/gall.hoon | 19 ++++---- 3 files changed, 120 insertions(+), 67 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 7502f0f336..5161c6740a 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -41,6 +41,7 @@ :: == == :: $: %f :: to %ford $% [%exec p=@p q=(unit silk)] :: + [%wasp p=@p q=@uvH] :: == == :: :: $: %g :: to %gall :: $% [%mess p=hapt q=ship r=cage] :: @@ -82,8 +83,9 @@ :: $% [%thou p=httr] :: :: == == :: $: %f :: by %ford - $% [%made p=(set beam) q=(each cage tang)] :: -:: == == :: + $% [%made p=@uvH q=(each cage tang)] :: + [%news ~] :: + == == :: :: $: %g :: by %gall :: $% [%dumb ~] :: :: [%mean p=ares] :: @@ -93,7 +95,7 @@ :: == == :: :: $: %t :: by %time :: $% [%wake ~] :: timer activate - == == :: +:: == == :: $: @tas :: by any $% [%crud p=@tas q=(list tank)] :: == == == :: @@ -296,13 +298,11 @@ == :: ++ lode - |= [dep=(set beam) max=manx] + |= [dep=@uvH max=manx] ^- manx - =+ det=`tang`(turn (~(tap in dep)) |=(a=beam leaf/+:(spud (tope a)))) - =+ pax=~(ram re %rose ["&" `~] det) ?> ?=([[%html ~] [[%head ~] *] [[%body ~] ^] ~] max) :: XX static ?~ dep max - max(c.i.c :_(c.i.c.max ;script@"/~/on.js?{pax}";)) + max(c.i.c :_(c.i.c.max ;script@"/~/on/{}.js";)) :: :: ++ lofa :: scripts in head :: |= [mog=(list manx) luv=love] @@ -418,6 +418,7 @@ == == :: + %news (jive %b &) :: dependency updated %writ :: ?^ tea ~&(e/missed/writ/tea=tea +>.$) ?~ p.sih +>.$ @@ -634,8 +635,8 @@ == :: ++ back :: %ford bounce - |= [tea=wire dep=(set beam) cag=cage] - (miff tea %f %exec our `[%cast %mime %done dep cag]) + |= [tea=wire dep=@uvH cag=cage] + (miff tea %f %exec our `[%cast %mime %done ~ cag]) :: XX deps :: ++ doss :: host to ship |= hot=host @@ -646,9 +647,9 @@ (rush -:(flop p.hot) fed:ag) :: ++ fail :: request failed - |= [sas=@ud dep=(set beam) mez=tang] + |= [sas=@ud dep=@uvH mez=tang] ^+ +> - :: (back ~ ~ %tang !>(mez)) :: XX broken tang->mime door in ford + :: (back ~ dep %tang !>(mez)) :: XX broken tang->mime door in ford (resp sas text//html (poxo (lode dep (loga mez)))) :: :: ++ gale :: ya from response @@ -750,7 +751,7 @@ :: =+ oar=`(unit ship)`?^(wiq wiq (doss r.p.pul)) =+ oar=(fall (doss r.p.pul) (need hov)) =+ ext=(fall p.q.pul %urb) - %- |=(a=(each ,_..hell tang) ?~(-.a p.a (fail 404 ~ >%exit< p.a))) + %- |=(a=(each ,_..hell tang) ?~(-.a p.a (fail 404 0v0 >%exit< p.a))) %- mule |. ^+ ..hell =+ hev=(heft oar q.pul) ?^ hev @@ -768,7 +769,7 @@ :: ++ hemp :: auxillary(/~) request |= [oar=ship pok=pork quy=quay] - ^- (unit (each (set beam) ,[p=ship q=pork])) + ^- (unit (each ?(~ @uvH (set beam)) ,[p=ship q=pork])) ?. ?=([%'~' @ *] q.pok) ~ :- ~ =* pef i.t.q.pok @@ -778,6 +779,8 @@ :- %& ?^ but ~| on/bad-path/but + ?~ t.but + (slav %uv i.but) =- [(need (tome -)) ~ ~] ?: =('~' (end 3 1 i.but)) but @@ -904,6 +907,10 @@ == == :: + ++ howa :: ford %wasp request + |= [tea=wire dep=@uvH] + (miff tea %f [%wasp our dep]) + :: ++ huff :: request by ship |= [our=ship cip=clip pul=purl moh=moth] ^- [p=hole q=cyst] @@ -961,14 +968,16 @@ +>(mow :_(mow [hen %pass noe])) :: ++ onto :: clay long-poll - |= [dep=(set beam) pul=purl] + |= [dep=?(~ @uvH (set beam)) pul=purl] ?: ?=([~ %js] p.q.pul) :: XX treat non-json cases? %^ resp 200 text//javascript """ window.urb = \{poll: "/{(apex:earn %| q.pul(u.p %json) r.pul)}"} {(trip poll:js)} """ - =+ des=(~(tap in dep)) + ?~ dep ..onto + ?@ dep (howa ~ dep) + =+ des=(~(tap in `(set beam)`dep)) |- ^+ ..onto ?~ des ..onto %^ hoot:$(des t.des) diff --git a/arvo/ford.hoon b/arvo/ford.hoon index 05b3c6d94e..40beba1636 100644 --- a/arvo/ford.hoon +++ b/arvo/ford.hoon @@ -9,7 +9,8 @@ :: ++ bead ,[p=(set beam) q=cage] :: computed result ++ gift :: out result <-$ - $% [%made p=(set beam) q=(each cage tang)] :: computed result + $% [%made p=@uvH q=(each cage tang)] :: computed result + [%news ~] :: fresh depends == :: ++ heel path :: functional ending ++ hock :: standard label @@ -49,6 +50,7 @@ == :: ++ kiss :: in request ->$ $% [%exec p=@p q=(unit silk)] :: make / kill + [%wasp p=@p q=@uvH] :: depends query == :: ++ move ,[p=duct q=(mold note gift)] :: local move ++ note :: out request $-> @@ -88,6 +90,7 @@ ++ baby :: state by ship $: tad=[p=@ud q=(map ,@ud task)] :: tasks by number dym=(map duct ,@ud) :: duct to task number + deh=(map ,@uvH (set beam)) :: hashed depends jav=(map ,* calx) :: cache == :: ++ bolt :: gonadic edge @@ -95,8 +98,8 @@ $: p=cafe :: cache $= q :: $% [%0 p=(set beam) q=a] :: depends/product - [%1 p=(set ,[p=care q=beam r=tang])] :: blocks - [%2 p=(set beam) q=tang] :: depends/error + [%1 p=(set ,[p=care q=beam r=tang])] :: blocks + [%2 p=(set beam) q=tang] :: depends/error == :: == :: :: :: @@ -233,12 +236,12 @@ == ~(exec zo [num `task`[hen u.kus 0 ~]]) :: - ++ apel :: stateless - |= [hen=duct kus=silk] - ^- (unit gift) - =+ num=0 :: XX - ~(exit zo [num `task`[hen kus 0 ~]]) - :: + ::++ apel :: stateless + :: |= [hen=duct kus=silk] + :: ^- (unit gift) + :: =+ num=0 :: XX + :: ~(exit zo [num `task`[hen kus 0 ~]]) + :::: ++ axon :: take |= [num=@ud tik=@ud sih=sign] ^+ +> @@ -251,6 +254,30 @@ (~(resp zo [num u.tus]) tik p.+.sih) == :: + ++ axun :: take rev update + |= [dep=@uvH sih=sign] + ^+ +> + ?- -.+.sih + %writ + +>.$(mow :_(mow [hen %give %news ~])) + == + :: + ++ awap :: get next revision + |= dep=@uvH + %_ +>.$ + mow + %- welp :_ mow + %+ turn (~(tap in (~(got by deh.bay) dep))) + |= a=beam + :^ hen %pass [(scot %p our) (scot %uv dep) ~] + =- [%c [%warp [our p.a] q.a ~ [%& %y ud/+(`@ud`-) s.a]]] + ?. ?=(%ud -.r.a) + ;;(@ (need (need (ska %cw (tope -.a /))))) + ?: =(0 p.r.a) + ;;(@ (need (need (ska %cw (tope -.a(r da/now) /))))) + p.r.a + == + :: ++ zo |_ [num=@ud task] ++ abet %_(..zo q.tad.bay (~(put by q.tad.bay) num +<+)) @@ -403,24 +430,32 @@ ^+ +> %_(+> jav.bay q.cof) :: - ++ exit :: stateless exec - ^- (unit gift) - =+ bot=(make [~ jav.bay] kas) - :: =. ..exec (dash p.bot) - ?- -.q.bot - %0 `[%made p.q.bot %& q.q.bot] - %2 `[%made p.q.bot %| q.q.bot] - %1 ~ - == - :: + ++ daze :: remember depends + |= dep=(set beam) + ^+ [*@uvH +>] + ?~ dep [0v0 +>] + =+ hap=(sham dep) + [hap %_(+>.$ deh.bay (~(put by deh.bay) hap dep))] + ::++ exit :: stateless exec + :: ^- (unit gift) + :: =+ bot=(make [~ jav.bay] kas) + :: :: =. ..exec (dash p.bot) + :: ?- -.q.bot + :: %0 `[%made p.q.bot %& q.q.bot] + :: %2 `[%made p.q.bot %| q.q.bot] + :: %1 ~ + :: == + :::: ++ exec :: execute app ^+ ..zo ?: !=(~ q.kig) ..zo =+ bot=(make [~ jav.bay] kas) =. ..exec (dash p.bot) ?- -.q.bot - %0 amok:(expo [%made p.q.bot %& q.q.bot]) - %2 amok:(expo [%made p.q.bot %| q.q.bot]) + %0 =^ dep ..exec (daze p.q.bot) + amok:(expo [%made dep %& q.q.bot]) + %2 =^ dep ..exec (daze p.q.bot) + amok:(expo [%made dep %| q.q.bot]) %1 =+ zuk=(~(tap by p.q.bot) ~) =< abet |- ^+ ..exec @@ -925,12 +960,13 @@ %+ cope (link cof dep p.kas p.cay bek q.cay) |= [cof=cafe vax=vase] (fine cof [p.kas vax]) -:: %+ coze (lion cof p.kas bek [p.cay]~) -:: |= dep=(set beam) |= [cof=cafe wuy=(list ,@tas)] -:: ?~ wuy (flaw cof [%leaf "ford: no path: {<[p.cay p.kas]>}"]~) -:: %+ cope (lope cof dep i.wuy t.wuy bek q.cay) -:: |= [cof=cafe vax=vase] -:: (fine cof [p.kas vax]) + :: + :: %+ coze (lion cof p.kas bek [p.cay]~) + :: |= dep=(set beam) |= [cof=cafe wuy=(list ,@tas)] + :: ?~ wuy (flaw cof [%leaf "ford: no path: {<[p.cay p.kas]>}"]~) + :: %+ cope (lope cof dep i.wuy t.wuy bek q.cay) + :: |= [cof=cafe vax=vase] + :: (fine cof [p.kas vax]) :: %done [cof %0 p.kas q.kas] %dude (cool |.(p.kas) $(kas q.kas)) @@ -1278,7 +1314,8 @@ ?> (~(has by q.kig) tik) ?~ rot =+ `[ren=care bem=beam]`(~(got by q.kig) tik) - amok:(expo [%made ~ %| (smyt ren (tope bem)) ~]) :: dependencies? + =^ dep ..resp (daze ~) :: dependencies? + amok:(expo [%made dep %| (smyt ren (tope bem)) ~]) exec(q.kig (~(del by q.kig) tik)) -- -- @@ -1295,15 +1332,18 @@ |= [hen=duct hic=(hypo (hobo kiss))] ^- [p=(list move) q=_..^$] => .(q.hic ?.(?=(%soft -.q.hic) q.hic ((hard kiss) p.q.hic))) - =+ ska=(slod ski) + =+ ska=(slod ski) :: XX depends =+ ^= our ^- @p ?- -.q.hic %exec p.q.hic + %wasp p.q.hic == =+ ^= bay ^- baby =+ buy=(~(get by pol.lex) our) ?~(buy *baby u.buy) =^ mos bay + ?: ?=(%wasp -.q.hic) + abet:(~(awap za [[our hen] [now eny ska] ~] bay) q.q.hic) abet:(~(apex za [[our hen] [now eny ska] ~] bay) q.q.hic) [mos ..^$(pol (~(put by pol) our bay))] :: @@ -1314,14 +1354,14 @@ :: ++ load :: highly forgiving |= old=* - =. old - ?. ?=([%0 *] old) old :: remove at 1 - :- %1 - |- ^- * - ?~ +.old ~ - ?> ?=([n=[p=* q=[tad=* dym=* jav=*]] l=* r=*] +.old) - :- [p.n.+.old [tad.q.n.+.old dym.q.n.+.old ~]] - [$(+.old l.+.old) $(+.old r.+.old)] + ::=. old + :: ?. ?=([%0 *] old) old :: remove at 1 + :: :- %1 + :: |- ^- * + :: ?~ +.old ~ + :: ?> ?=([n=[p=* q=[tad=* dym=* deh=* jav=*]] l=* r=*] +.old) + :: :- [p.n.+.old [tad.q.n.+.old dym.q.n.+.old deh.q.n.+.old ~]] + :: [$(+.old l.+.old) $(+.old r.+.old)] =+ lox=((soft axle) old) ^+ ..^$ ?~ lox @@ -1335,19 +1375,22 @@ [~ ~] :: ++ stay :: save w/o cache - `axle`+>-.$(pol (~(run by pol) |=(a=baby [tad.a dym.a ~]))) + `axle`+>-.$(pol (~(run by pol) |=(a=baby [tad.a dym.a deh.a ~]))) :: ++ take :: response |= [tea=wire hen=duct hin=(hypo sign)] ^- [p=(list move) q=_..^$] =+ ska=(slod ski) - ?> ?=([@ @ @ ~] tea) - =+ :* our=(need (slaw %p i.tea)) - num=(need (slaw %ud i.t.tea)) - tik=(need (slaw %ud i.t.t.tea)) - == + ?. ?=([@ @ $|(~ [@ ~])] tea) + [~ ..^$] + =+ our=(need (slaw %p i.tea)) =+ bay=(~(got by pol.lex) our) =^ mos bay + ?~ t.t.tea + abet:(~(axun za [[our hen] [now eny ska] ~] bay) (slav %uv i.t.tea) q.hin) + =+ :* num=(need (slaw %ud i.t.tea)) + tik=(need (slaw %ud i.t.t.tea)) + == abet:(~(axon za [[our hen] [now eny ska] ~] bay) num tik q.hin) [mos ..^$(pol (~(put by pol) our bay))] -- diff --git a/arvo/gall.hoon b/arvo/gall.hoon index c0814d794e..3875c0ab9d 100644 --- a/arvo/gall.hoon +++ b/arvo/gall.hoon @@ -160,7 +160,7 @@ [%vega p=path] :: == == :: $: %f :: by %ford - $% [%made p=(set beam) q=(each cage tang)] :: + $% [%made p=@uvH q=(each cage tang)] :: == == == :: ++ toil (pair duct knob) :: work in progress -- :::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -736,17 +736,18 @@ %_(+>.$ ped.sat pen, mow :(weld new old mow)) :: ++ drum :: raw dependencies - |= dep=(set beam) + |= dep=@uvH ^+ +> ?> ?=(^ orm.sat) %- drug =+ ped=`(set (pair ship desk))`[[our %main] ~ ~] - =+ mav=(~(tap by dep) ~) - |- ^+ ped - ?~ mav ped - ?: =(r.i.mav [%da u.orm.sat]) - $(mav t.mav, ped (~(put in ped) p.i.mav q.i.mav)) - $(mav t.mav) + ped + ::=+ mav=(~(tap by dep) ~) + ::|- ^+ ped + ::?~ mav ped + ::?: =(r.i.mav [%da u.orm.sat]) + :: $(mav t.mav, ped (~(put in ped) p.i.mav q.i.mav)) + ::$(mav t.mav) :: ++ ford :: exec to ford |= [pax=path kas=silk] @@ -814,7 +815,7 @@ ++ mick :: apply w/depends |= sih=sign ?> ?=(%f -.sih) - ^- [[p=? q=(set beam)] _+>] + ^- [[p=? q=@uvH] _+>] :- [-.q.+.sih p.+.sih] ?- -.q.+.sih & %- obey:(morn (slot 3 q.p.q.+.sih)) From 836dd6fa521021cfafa9764a50dd0657f48a1a8f Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 18 Feb 2015 15:15:27 -0800 Subject: [PATCH 027/219] Client-side hash update --- arvo/ford.hoon | 37 ++++++++++++++++++------------------- main/mar/urb/door.hook | 16 ++++------------ 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/arvo/ford.hoon b/arvo/ford.hoon index 40beba1636..685a2d705c 100644 --- a/arvo/ford.hoon +++ b/arvo/ford.hoon @@ -90,7 +90,7 @@ ++ baby :: state by ship $: tad=[p=@ud q=(map ,@ud task)] :: tasks by number dym=(map duct ,@ud) :: duct to task number - deh=(map ,@uvH (set beam)) :: hashed depends + deh=deps :: depends by hash jav=(map ,* calx) :: cache == :: ++ bolt :: gonadic edge @@ -110,6 +110,7 @@ ++ cafe :: live cache $: p=(set calx) :: used q=(map ,* calx) :: cache + r=deps :: dependencies == :: :: :: ++ calm :: cache metadata @@ -123,6 +124,7 @@ [%slap p=calm q=[p=vase q=twig] r=vase] :: compute [%slam p=calm q=[p=vase q=vase] r=vase] :: compute == :: +++ deps (map ,@uvH (set beam)) :: hashed depends ++ task :: problem in progress $: nah=duct :: cause kas=silk :: problem @@ -157,7 +159,7 @@ ++ chub :: cache merge |= [a=cafe b=cafe] :: ^- cafe :: - [(grom p.a p.b) (grum q.a q.b)] :: + [(grom p.a p.b) (grum q.a q.b) (grum r.a r.b)] :: :: :: ++ faun |=([a=cafe b=vase] (fine a `cage`noun/b)) :: vase to cage ++ feel |=([a=cafe b=cage] (fine a q.b)) :: cage to vase @@ -267,7 +269,7 @@ %_ +>.$ mow %- welp :_ mow - %+ turn (~(tap in (~(got by deh.bay) dep))) + %+ turn ~|(dep-missed/dep (~(tap in (~(got by deh.bay) dep)))) |= a=beam :^ hen %pass [(scot %p our) (scot %uv dep) ~] =- [%c [%warp [our p.a] q.a ~ [%& %y ud/+(`@ud`-) s.a]]] @@ -428,17 +430,17 @@ ++ dash :: process cache |= cof=cafe ^+ +> - %_(+> jav.bay q.cof) + %_(+> jav.bay q.cof, deh.bay r.cof) :: ++ daze :: remember depends |= dep=(set beam) - ^+ [*@uvH +>] - ?~ dep [0v0 +>] + ^+ [*@uvH deh.bay] + ?~ dep [0v0 deh.bay] =+ hap=(sham dep) - [hap %_(+>.$ deh.bay (~(put by deh.bay) hap dep))] + [hap (~(put by deh.bay) hap dep)] ::++ exit :: stateless exec :: ^- (unit gift) - :: =+ bot=(make [~ jav.bay] kas) + :: =+ bot=(make [~ jav.bay deh.bay] kas) :: :: =. ..exec (dash p.bot) :: ?- -.q.bot :: %0 `[%made p.q.bot %& q.q.bot] @@ -449,12 +451,12 @@ ++ exec :: execute app ^+ ..zo ?: !=(~ q.kig) ..zo - =+ bot=(make [~ jav.bay] kas) + =+ bot=(make [~ jav.bay deh.bay] kas) =. ..exec (dash p.bot) ?- -.q.bot - %0 =^ dep ..exec (daze p.q.bot) + %0 =^ dep deh.bay (daze p.q.bot) amok:(expo [%made dep %& q.q.bot]) - %2 =^ dep ..exec (daze p.q.bot) + %2 =^ dep deh.bay (daze p.q.bot) amok:(expo [%made dep %| q.q.bot]) %1 =+ zuk=(~(tap by p.q.bot) ~) =< abet @@ -496,11 +498,8 @@ ?: ?=([~ ~ *] (ska %cy (tope [oak pax]))) oak bek - =+ ^= arg ^- spur - :- %dep - =- ?~(- /'' /(pack -)) - %+ turn (~(tap in dep)) - |=(a=beam =+((tope a) ?~(- !! (pack -)))) :: XX + =^ deh r.cof (daze(deh.bay r.cof) dep) :: XX sanity + =+ arg=`spur`[%dep (scot %uv deh) ~] (cope (fade cof %hook bem) abut:(meow bem arg)) :: ++ fair :: hood parsing rule @@ -905,7 +904,7 @@ ++ make :: reduce silk |= [cof=cafe kas=silk] ^- (bolt cage) - :: ~& [%make -.kas] + :: ~& [%make -.kas] ?- -.kas ^ %. [cof p.kas q.kas] @@ -1314,7 +1313,7 @@ ?> (~(has by q.kig) tik) ?~ rot =+ `[ren=care bem=beam]`(~(got by q.kig) tik) - =^ dep ..resp (daze ~) :: dependencies? + =^ dep deh.bay (daze ~) :: dependencies? amok:(expo [%made dep %| (smyt ren (tope bem)) ~]) exec(q.kig (~(del by q.kig) tik)) -- @@ -1382,7 +1381,7 @@ ^- [p=(list move) q=_..^$] =+ ska=(slod ski) ?. ?=([@ @ $|(~ [@ ~])] tea) - [~ ..^$] + [~ ..^$] :: XX remove on breach =+ our=(need (slaw %p i.tea)) =+ bay=(~(got by pol.lex) our) =^ mos bay diff --git a/main/mar/urb/door.hook b/main/mar/urb/door.hook index 763440a73c..fe451e7e62 100644 --- a/main/mar/urb/door.hook +++ b/main/mar/urb/door.hook @@ -2,14 +2,7 @@ :::: /hook/door/urb/mar :: /? 314 -/= dep /$ - !: - |= [^ but=path] - ^- (set path) - ?> ?=([%dep @ ~] but) - %- sa - %+ turn `path`(need (pick i.t.but)) - |=(a=span `path`(need (pick a))) +/= dep /$ |=([^ but=path] `@uvH`?>(?=([%dep @ ~] but) (slav %uv i.t.but))) !: |_ own=manx :: @@ -28,10 +21,9 @@ :: =+ bek=(sa (turn (turn dep) |=(a=beam (tope a(s ~))))) :: inject into %hymn %_ old c.i.c - :+ ;meta(charset "utf-8", urb_injected ""); - =+ det=`tang`(turn (~(tap in dep)) |=(a=path leaf/+:(spud a))) - =+ pax=~(ram re %rose ["&" `~] det) - ;script@"/~/on.js?{pax}"; + :- ;meta(charset "utf-8", urb_injected ""); + ?~ dep c.i.c.old + :- ;script@"/~/on/{}.js"; c.i.c.old == -- From aef5bce1c73a241ffe76f2487c15211be4b12f80 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 18 Feb 2015 15:25:55 -0800 Subject: [PATCH 028/219] hash transition fin --- arvo/eyre.hoon | 54 +++++++++++++------------------------------------- 1 file changed, 14 insertions(+), 40 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 5161c6740a..0a0063eab4 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -763,13 +763,22 @@ ?~ hem ~|(strange-path/q.q.pul !!) ?- -.u.hem - & (onto p.u.hem pul) + & ?. ?=([~ %js] p.q.pul) :: XX treat non-json cases? + ~! hem + ?~ p.u.hem ..hell + (howa ~ p.u.hem) + %^ resp 200 text//javascript + """ + window.urb = \{poll: "/{(apex:earn %| q.pul(u.p %json) r.pul)}"} + {(trip poll:js)} + """ + :: | ~|(aute/p.u.hem !!) == :: ++ hemp :: auxillary(/~) request |= [oar=ship pok=pork quy=quay] - ^- (unit (each ?(~ @uvH (set beam)) ,[p=ship q=pork])) + ^- (unit (each ,@uvH ,[p=ship q=pork])) ?. ?=([%'~' @ *] q.pok) ~ :- ~ =* pef i.t.q.pok @@ -777,22 +786,9 @@ ?+ pef ~|(pfix-lost/`path`/~/[pef] !!) %on :- %& - ?^ but - ~| on/bad-path/but - ?~ t.but - (slav %uv i.but) - =- [(need (tome -)) ~ ~] - ?: =('~' (end 3 1 i.but)) - but - [(scot %p oar) but] - %- sa - %+ turn quy |= [a=cord b=@] ^- beam - ~| on/bad-query/quy - ?. =('' b) !! - %- need %- tome %- stab - ?: =('/' (end 3 1 a)) - a - (cat 3 '/' a) + ~| on/bad-path/but + ?> ?=([@ ~] but) + (slav %uv i.but) %as :- %| ~| bad-ship/?~(but ~ i.but) @@ -967,28 +963,6 @@ |= noe=[wire note] +>(mow :_(mow [hen %pass noe])) :: - ++ onto :: clay long-poll - |= [dep=?(~ @uvH (set beam)) pul=purl] - ?: ?=([~ %js] p.q.pul) :: XX treat non-json cases? - %^ resp 200 text//javascript - """ - window.urb = \{poll: "/{(apex:earn %| q.pul(u.p %json) r.pul)}"} - {(trip poll:js)} - """ - ?~ dep ..onto - ?@ dep (howa ~ dep) - =+ des=(~(tap in `(set beam)`dep)) - |- ^+ ..onto - ?~ des ..onto - %^ hoot:$(des t.des) - our [%y (tope i.des)] - =- [p.i.des q.i.des ~ %& %y ud/+(`@ud`-) s.i.des] - ?. ?=(%ud -.r.i.des) - ;;(@ (need (sky %cw (tope -.i.des /)))) - ?: =(0 p.r.i.des) - ;;(@ (need (sky %cw (tope -.i.des(r da/now) /)))) - p.r.i.des - :: ++ resp :: mime response |= [sas=@uG mit=mite bod=tape] (muff (tuff sas mit (crip bod))) From a6d26afc84545a959f4fa2ea0a5ea0326e0d5fa1 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 19 Feb 2015 15:33:39 -0800 Subject: [PATCH 029/219] Auth scaffolding --- arvo/ames.hoon | 6 +++--- arvo/eyre.hoon | 31 ++++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/arvo/ames.hoon b/arvo/ames.hoon index 62d6de61be..04ba95c5c1 100644 --- a/arvo/ames.hoon +++ b/arvo/ames.hoon @@ -440,7 +440,7 @@ vix=(bex +((cut 0 [25 2] mag))) :: width of sender tay=(cut 0 [27 5] mag) :: message type == - ?> =(2 vez) + ?> =(1 vez) ?> =(chk (end 0 20 (mug bod))) :+ [(end 3 wix bod) (cut 3 [wix vix] bod)] (kins tay) @@ -460,7 +460,7 @@ =+ tay=(ksin q.kec) %+ mix %+ can 0 - :~ [3 2] + :~ [3 1] [20 (mug bod)] [2 yax] [2 qax] @@ -1043,7 +1043,7 @@ ++ gnaw :: gnaw:am |= [kay=cape ryn=lane pac=rock] :: process packet ^- [p=(list boon) q=fort] - ?. =(2 (end 0 3 pac)) [~ fox] + ?. =(1 (end 0 3 pac)) [~ fox] =+ kec=(bite pac) ?: (goop p.p.kec) [~ fox] ?. (~(has by urb.ton.fox) q.p.kec) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 0a0063eab4..45026e627f 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -11,6 +11,11 @@ [%veer p=@ta q=path r=@t] :: drop-through [%vega p=path] :: drop-through == :: +++ gram :: inter-ship message + $? [[%lon ~] p=hole] :: login request + [[%aut ~] p=hole] :: login reply + [[%hat ~] p=hole q=hart] :: login redirect + == :: ++ hasp ,[p=ship q=term] :: don't see %gall ++ hapt ,[p=ship q=path] :: do see %gall ++ kiss :: in request ->$ @@ -21,7 +26,7 @@ :: [%they p=@ud q=httr] :: inbound response [%this p=? q=clip r=httq] :: inbound request [%thud ~] :: inbound cancel -:: [%wart p=sock q=@tas r=path s=*] :: urbit message + [%wart p=sock q=@tas r=_`[path *]`*gram] :: urbit message == :: ++ move ,[p=duct q=(mold note gift)] :: local move ++ note :: out request $-> @@ -623,15 +628,20 @@ :: ?~(boy +>.$ abet:(idle:u.boy p.u.dul)) :: | (hops p.q.u.dul p.u.dul) :: == -:: :: -:: %wart :: remote request -:: ?+ q.kyz -:: ~& [%strange-wart p.kyz q.kyz] -:: +>.$ + :: + %wart :: remote request + =+ mez=((soft gram) r.kyz) + ?~ mez + ~& [%strange-wart p.kyz q.kyz] + +>.$ + ?- -<.u.mez + %lon !! + %aut !! + %hat !! :: :: :: %pr (hare p.p.kyz r.kyz q.p.kyz s.kyz) :: %pc (here p.p.kyz q.p.kyz s.kyz) -:: == + == == :: ++ back :: %ford bounce @@ -1199,9 +1209,9 @@ :: == :: :: ++ ya :: session engine - =| [[our=ship ses=hole] ~] ::serf cyst] + =| [[our=ship ses=hole] cyst] ::serf cyst] :: =* sef ->- -:: =* cyz ->+ + =* cyz -> |% ++ flux :: credential caboose |= [nyp=path quy=quay] ^- coin @@ -1212,6 +1222,9 @@ ?~ quy ~ [[%$ %t p.i.quy] [%$ %t q.i.quy] $(quy t.quy)] == + ++ inte + ^- (unit $&([%lon purl] gram)) + ~ :: ++ abet :: resolve engine :: ^+ ..ya :: %= ..ya From efb31bd7f95a260653cacd2da452820575e19b7e Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 19 Feb 2015 19:55:18 -0800 Subject: [PATCH 030/219] Fixed ford ot anchor at current main revision, not time --- arvo/ford.hoon | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arvo/ford.hoon b/arvo/ford.hoon index 685a2d705c..bb51f251a1 100644 --- a/arvo/ford.hoon +++ b/arvo/ford.hoon @@ -494,7 +494,10 @@ =+ ^= bem ^- beam :_ pax ?: &(=(p.bek our) =(q.bek %main)) bek - =+ oak=[our %main %da now] + =+ ren=(ska %cw (tope [our %main %da now] ~)) :: XX at requested one + ?. ?=([~ ~ @u] ren) + bek + =+ oak=[our %main %ud u.u.ren] ?: ?=([~ ~ *] (ska %cy (tope [oak pax]))) oak bek From bdf3f1400a5c28a9c887f59d1f03cfeead8a27c5 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 19 Feb 2015 21:27:23 -0800 Subject: [PATCH 031/219] dbg wip --- arvo/ford.hoon | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/arvo/ford.hoon b/arvo/ford.hoon index bb51f251a1..bc409283f7 100644 --- a/arvo/ford.hoon +++ b/arvo/ford.hoon @@ -474,7 +474,12 @@ |= [cof=cafe for=mark bem=beam] ^- (bolt hood) %+ cool |.(leaf/"ford: fade {<[(tope bem)]>}") - %+ cope (make cof [%bake for bem ~]) + %+ cope ~& fade/bem + %- ~& %wat make + ~& %wut + =- ~& %wut-done - + [cof [%bake for bem ~]] + ~& %fade-clef |= [cof=cafe cay=cage] %+ (clef %hood) (fine cof bem cay) ^- (burg (pair beam cage) hood) @@ -493,7 +498,8 @@ =+ pax=/door/[for]/mar =+ ^= bem ^- beam :_ pax - ?: &(=(p.bek our) =(q.bek %main)) bek + ?: &(=(p.bek our) =(q.bek %main) !=(r.bek [%da now])) + bek =+ ren=(ska %cw (tope [our %main %da now] ~)) :: XX at requested one ?. ?=([~ ~ @u] ren) bek @@ -503,6 +509,7 @@ bek =^ deh r.cof (daze(deh.bay r.cof) dep) :: XX sanity =+ arg=`spur`[%dep (scot %uv deh) ~] + ~& [%fang for] (cope (fade cof %hook bem) abut:(meow bem arg)) :: ++ fair :: hood parsing rule @@ -905,9 +912,12 @@ |=(val=* `vase`[typ val]) :: ++ make :: reduce silk - |= [cof=cafe kas=silk] + ~& %make-wha-bunt + =| [cof=cafe kas=silk] + ~& %make-wha-trap + |. ^- (bolt cage) - :: ~& [%make -.kas] + ~& [%make -.kas] ?- -.kas ^ %. [cof p.kas q.kas] @@ -922,6 +932,7 @@ == :: %bake + ~& > (tope q.kas) %+ cool |.(leaf/"ford: bake {} {<(tope q.kas)>}") %+ cope (lima cof p.kas q.kas r.kas) |= [cof=cafe vux=(unit vase)] From d5b51d1842921f9e2a8cfc19e5743c36d9a961cf Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 20 Feb 2015 13:42:57 -0800 Subject: [PATCH 032/219] Cached %bake --- arvo/ford.hoon | 80 ++++++++++++++++++++++------------- arvo/hoon.hoon | 8 +++- main/mar/react-snip/door.hook | 2 +- main/mar/react/door.hook | 2 +- 4 files changed, 60 insertions(+), 32 deletions(-) diff --git a/arvo/ford.hoon b/arvo/ford.hoon index bc409283f7..1018eadf88 100644 --- a/arvo/ford.hoon +++ b/arvo/ford.hoon @@ -119,6 +119,7 @@ == :: ++ calx :: concrete cache line $% [%hood p=calm q=(pair beam cage) r=hood] :: compile + [%bake p=calm q=(trel mark beam heel) r=(unit vase)]:: load [%slit p=calm q=[p=type q=type] r=type] :: slam type [%slim p=calm q=[p=type q=twig] r=(pair type nock)]:: mint [%slap p=calm q=[p=vase q=twig] r=vase] :: compute @@ -137,6 +138,7 @@ |= cax=calx ?+ sem !! %hood ?>(?=(%hood -.cax) r.cax) + %bake ?>(?=(%bake -.cax) r.cax) %slap ?>(?=(%slap -.cax) r.cax) %slam ?>(?=(%slam -.cax) r.cax) %slim ?>(?=(%slim -.cax) r.cax) @@ -265,6 +267,7 @@ == :: ++ awap :: get next revision + ~% %ford-w ..is ~ |= dep=@uvH %_ +>.$ mow @@ -281,6 +284,19 @@ == :: ++ zo + ~% %ford-z + ..is + == + %fade fade + %fair fair + %fang fang + %lime lime + %lima lima + %link link + %lope lope + %make make + %meow meow + == |_ [num=@ud task] ++ abet %_(..zo q.tad.bay (~(put by q.tad.bay) num +<+)) ++ amok @@ -322,16 +338,16 @@ %1 hoc %0 =^ cux p.hoc ((calk p.hoc) sem q.q.hoc) - ?~ cux - =+ nuf=(cope hoc fun) - ?- -.q.nuf - %2 nuf - %1 nuf - %0 - :- p=(came p.nuf `calx`[sem `calm`[now p.q.nuf] q.q.hoc q.q.nuf]) - q=q.nuf - == - [p=p.hoc q=[%0 p=p.q.hoc q=((calf sem) u.cux)]] + ?^ cux + [p=p.hoc q=[%0 p=p.q.hoc q=((calf sem) u.cux)]] + =+ nuf=(cope hoc fun) + ?- -.q.nuf + %2 nuf + %1 nuf + %0 + :- p=(came p.nuf `calx`[sem `calm`[now p.q.nuf] q.q.hoc q.q.nuf]) + q=q.nuf + == == :: ++ coax :: bolt across @@ -474,16 +490,12 @@ |= [cof=cafe for=mark bem=beam] ^- (bolt hood) %+ cool |.(leaf/"ford: fade {<[(tope bem)]>}") - %+ cope ~& fade/bem - %- ~& %wat make - ~& %wut - =- ~& %wut-done - - [cof [%bake for bem ~]] - ~& %fade-clef + %+ cope (make cof [%bake for bem ~]) |= [cof=cafe cay=cage] %+ (clef %hood) (fine cof bem cay) ^- (burg (pair beam cage) hood) |= [cof=cafe bum=beam cay=cage] + :: ~& fade/clef-miss/bem =+ rul=(fair bem) ?. ?=(@ q.q.cay) (flaw cof ~) @@ -500,23 +512,19 @@ :_ pax ?: &(=(p.bek our) =(q.bek %main) !=(r.bek [%da now])) bek - =+ ren=(ska %cw (tope [our %main %da now] ~)) :: XX at requested one - ?. ?=([~ ~ @u] ren) - bek - =+ oak=[our %main %ud u.u.ren] + =+ oak=-:(norm [our %main %da now] ~) :: XX at requested one ?: ?=([~ ~ *] (ska %cy (tope [oak pax]))) oak bek =^ deh r.cof (daze(deh.bay r.cof) dep) :: XX sanity =+ arg=`spur`[%dep (scot %uv deh) ~] - ~& [%fang for] (cope (fade cof %hook bem) abut:(meow bem arg)) :: ++ fair :: hood parsing rule |= bem=beam =+ :* vez=(vang | (tope bem(r [%ud 0]))) voz=(vang | (tope bem)) - == + == =< hood |% ++ case @@ -799,6 +807,8 @@ (sloe p.gow) :: ++ lima :: load at depth + |= [cof=cafe for=mark bem=beam arg=heel] + %+ (clef %bake) (fine cof for bem arg) |= [cof=cafe for=mark bem=beam arg=heel] ^- (bolt (unit vase)) %+ cope (lend cof bem) @@ -912,12 +922,9 @@ |=(val=* `vase`[typ val]) :: ++ make :: reduce silk - ~& %make-wha-bunt - =| [cof=cafe kas=silk] - ~& %make-wha-trap - |. + |= [cof=cafe kas=silk] ^- (bolt cage) - ~& [%make -.kas] + :: ~& [%make (,@tas -.kas)] ?- -.kas ^ %. [cof p.kas q.kas] @@ -932,7 +939,7 @@ == :: %bake - ~& > (tope q.kas) + :: ~& > (tope q.kas) %+ cool |.(leaf/"ford: bake {} {<(tope q.kas)>}") %+ cope (lima cof p.kas q.kas r.kas) |= [cof=cafe vux=(unit vase)] @@ -1036,6 +1043,21 @@ zeg=(set term) :: library guard boy=(list twig) :: body stack == + ~% %meow ..meow + == + %able able + %ably ably + %abut abut + %apex apex + %body body + %chad chad + %chai chai + %chap chap + %head head + %hone hone + %neck neck + %wilt wilt + == |% ++ able :: assemble preamble ^- twig @@ -1339,7 +1361,7 @@ =* lex - |= [now=@da eny=@ ski=sled] :: activate ^? :: opaque core -~% %ford-d +>+>+>+>+>+> ~ +~% %ford-d ..is ~ |% :: ++ call :: request |= [hen=duct hic=(hypo (hobo kiss))] diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index 49d0d01537..7512ff2731 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -3276,6 +3276,7 @@ -- :: ++ co + ~% %co ..co ~ =< |_ lot=coin ++ rear |=(rom=tape =>(.(rex rom) rend)) ++ rent `@ta`(rap 3 rend) @@ -3487,6 +3488,7 @@ -- :: ++ so + ~% %so + ~ |% ++ bisk ;~ pose @@ -3555,6 +3557,7 @@ ;~(pfix hep (stag %c (cook turf (cook woad urs:ab)))) == ++ nuck + ~/ %nuck |= a=nail %. a %+ knee *coin |. ~+ %- stew ^. stet ^. limo @@ -3638,7 +3641,10 @@ :: ++ slay |= txt=@ta ^- (unit coin) - =+ vex=((full nuck:so) [[1 1] (trip txt)]) + =+ ^= vex + ?: (gth 0x7fff.ffff txt) :: XX petty cache + ~+ ((full nuck:so) [[1 1] (trip txt)]) + ((full nuck:so) [[1 1] (trip txt)]) ?~ q.vex ~ [~ p.u.q.vex] diff --git a/main/mar/react-snip/door.hook b/main/mar/react-snip/door.hook index cfac2ecc53..360368cba6 100644 --- a/main/mar/react-snip/door.hook +++ b/main/mar/react-snip/door.hook @@ -54,7 +54,7 @@ == ++ react-snip-js (crip tape) :: ++ js react-snip-js :: convert to %js - ++ mime [/text/javascript (taco js)] :: convert to %mime + ++ mime [/text/javascript (taco react-snip-js)] :: convert to %mime -- ++ grab |% :: convert from ++ noun manx :: clam from %noun diff --git a/main/mar/react/door.hook b/main/mar/react/door.hook index 92fcf6b9e0..458e47f699 100644 --- a/main/mar/react/door.hook +++ b/main/mar/react/door.hook @@ -54,7 +54,7 @@ == ++ react-js (crip tape) :: ++ js react-js :: convert to %js - ++ mime [/text/javascript (taco js)] :: convert to %mime + ++ mime [/text/javascript (taco react-js)] :: convert to %mime -- ++ grab |% :: convert from ++ noun manx :: clam from %noun From 0d511f2a596b20a8fc82ab7d29424ea6834ceb7e Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Fri, 20 Feb 2015 18:40:15 -0800 Subject: [PATCH 033/219] Various fixes and improvements. --- main/app/seat/core.hook | 4 ---- 1 file changed, 4 deletions(-) diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index 7659af5bca..f10cee4384 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -162,7 +162,6 @@ ++ se-just :: adjusted buffer |= lin=(pair ,@ud (list ,@c)) ^+ +> - ~& [%just lin mir] =. off ?:((lth p.lin edg) 0 (sub p.lin edg)) (se-show (sub p.lin off) (scag edg (slag off q.lin))) :: @@ -507,9 +506,6 @@ ++ pour |= [ost=bone pax=path sih=*] ^- [(list move) _+>] - =- ~& [%pour-moves -.foo] - foo - ^= foo =+ sih=((hard sign) sih) ?> ?=([@ @ ~] pax) =< se-abet From 22b43e2527ecdc79e698e58ca172228ca8a78e00 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Sat, 21 Feb 2015 14:37:35 -0800 Subject: [PATCH 034/219] Basic funktionality on :dojo. --- arvo/dull.hoon | 1 - main/app/seat/core.hook | 1 - main/sur/console/core.hook | 14 ++++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arvo/dull.hoon b/arvo/dull.hoon index d51757b47a..f5a3e85765 100644 --- a/arvo/dull.hoon +++ b/arvo/dull.hoon @@ -190,7 +190,6 @@ ++ from :: receive belt |= bit=dill-blit ^+ +> - ~& [%from bit hen] ?: ?=(%out -.bit) %+ done %blit :~ [%lin p.bit] diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index f10cee4384..fc92fd3b7f 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -344,7 +344,6 @@ :: ++ ta-fec :: apply effect |= fec=console-effect - ~& [%ta-fec fec] ^+ +> ?- -.fec %bel ta-bel diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook index cfb47fdebe..2240992a9d 100644 --- a/main/sur/console/core.hook +++ b/main/sur/console/core.hook @@ -3,8 +3,10 @@ !: |% ++ console-action :: console to app - $% [%det console-change] :: edit prompt line + $% [%abo ~] :: reset interaction + [%det console-change] :: command line edit [%inn ~] :: enter session + [%mut p=(list tape)] :: multiline input [%out ~] :: exit session [%ret ~] :: submit and clear == :: @@ -26,21 +28,21 @@ $% [%bel ~] :: beep [%blk p=@ud q=@c] :: blink/match char at [%clr ~] :: clear screen - [%det console-change] :: edit input + [%det console-change] :: edit command [%mor p=(list console-effect)] :: multiple effects - [%nex ~] :: save and clear input + [%nex ~] :: save, clear command [%pro console-prompt] :: set prompt [%tan p=(list tank)] :: classic tank :: [%taq p=tanq] :: modern tank [%txt p=tape] :: text line == :: -++ console-input :: input state +++ console-command :: command state $: pos=@ud :: cursor position say=console-share :: cursor == :: ++ console-prompt :: prompt definition - $: vis=? :: input visible - tag=term :: terminal mode + $: vis=? :: command visible + tag=term :: history mode cap=(list ,@c) :: caption == :: ++ console-share :: symmetric state From a1e015931f2f09dece36e18535969dd245575788 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Sat, 21 Feb 2015 14:42:36 -0800 Subject: [PATCH 035/219] Forgot to commit the dojo. --- main/app/dojo/core.hook | 331 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 331 insertions(+) create mode 100644 main/app/dojo/core.hook diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook new file mode 100644 index 0000000000..8e1061fff0 --- /dev/null +++ b/main/app/dojo/core.hook @@ -0,0 +1,331 @@ +:: :: :: +:::: /hook/core/dojo/app :: :: + :: :: :: +/? 314 :: zuse version +/- *console :: console structures +/+ console :: console library +:: :: :: +:::: :: :: + !: :: :: +=> |% :: external structures + ++ house :: all state + $: hoc=(map bone session) :: conversations + == :: + ++ session :: per conversation + $: say=console-share :: command-line state + duy=(unit tape) :: waiting + poy=(unit dojo-project) :: working + var=(map term cage) :: variable state + old=(set term) :: used TLVs + == :: + ++ dojo-command :: + $% [%poke p=hapt q=dojo-source] :: make and poke + [%save p=? q=term r=dojo-source] :: save/print + == :: + ++ dojo-source :: + $: inx=@ud :: index, assigned + mar=mark :: content type + mod=dojo-model :: + == :: + ++ dojo-model :: data source + $% [%& twig] :: + [%| (pair path dojo-config)] :: + == :: + ++ dojo-config :: configuration + $: ord=(list dojo-source) :: by order + key=(map term dojo-source) :: by keyword + == :: + ++ dojo-project :: construction state + $: mad=dojo-command :: operation + num=@ud :: number of tasks + cur=@ud :: currently solving + pro=(unit vase) :: prompting form + job=(map ,@ud dojo-source) :: problems + rez=(map ,@ud cage) :: results + == :: + ++ bead ,[p=(set beam) q=cage] :: computed result + ++ gift :: out result <-$ + $% [%mean p=ares] :: error + [%nice ~] :: acknowledge + [%rush %console-effect console-effect] :: + == :: + ++ hapt ,[p=ship q=path] :: + ++ move ,[p=bone q=(mold note gift)] :: + ++ hood :: assembly plan + $: zus=@ud :: zuse kelvin + sur=(list hoot) :: structures + lib=(list hoof) :: libraries + fan=(list horn) :: resources + src=(list hoop) :: program + == :: + ++ hoof (pair term (unit (pair case ship))) :: resource reference + ++ hoot (pair bean hoof) :: structure gate/core + ++ hoop :: source in hood + $% [%& p=twig] :: direct twig + [%| p=beam] :: resource location + == :: + ++ horn :: resource tree + $% [%ape p=twig] :: /~ twig by hand + [%arg p=twig] :: /$ argument + [%day p=horn] :: /| list by @dr + [%dub p=term q=horn] :: /= apply face + [%fan p=(list horn)] :: /. list + [%for p=path q=horn] :: /, descend + [%hel p=horn] :: /% propagate heel + [%hub p=horn] :: /@ list by @ud + [%man p=(map span horn)] :: /* hetero map + [%nap p=horn] :: /_ homo map + [%now p=horn] :: /& list by @da + [%saw p=twig q=horn] :: /; operate on + [%see p=beam q=horn] :: /: relative to + [%sic p=tile q=horn] :: /^ cast + [%toy p=mark] :: /mark/ static + == :: + ++ silk :: from %ford + $& [p=silk q=silk] :: cons + $% [%bake p=mark q=beam r=path] :: local synthesis + [%boil p=mark q=beam r=path] :: general synthesis + [%call p=silk q=silk] :: slam + [%cast p=mark q=silk] :: translate + [%done p=(set beam) q=cage] :: literal + [%dude p=tank q=silk] :: error wrap + [%dune p=(set beam) q=(unit cage)] :: unit literal + [%mute p=silk q=(list (pair wing silk))] :: mutant + [%plan p=beam q=spur r=hood] :: structured assembly + [%reef ~] :: kernel reef + [%ride p=twig q=silk] :: silk thru twig + [%vale p=mark q=ship r=*] :: validate [our his] + == :: + ++ note-ford :: note to ford + $% [%exec p=@p q=(unit silk)] :: make / kill + == :: + ++ note-gall :: note to %gall + $% [%mess p=[p=ship q=path] q=ship r=cage] :: + == :: + ++ sign-gall :: sign from %gall + $% [%mean p=ares] :: + [%nice ~] :: + == :: + ++ sign-ford :: sign from ford + $% [%made p=(each bead (list tank))] :: computed result + == :: + ++ note :: out request $-> + $% [%f note-ford] :: + [%g note-gall] :: + == :: + ++ sign :: in result $<- + $% [%f sign-ford] :: + [%g sign-gall] :: + == :: + -- :: +:: :: +:::: :: + :: :: +|_ $: hid=hide :: system state + house :: program state + == :: +++ he :: per session + |_ [[ost=bone moz=(list move)] session] :: + ++ dy :: project work + |_ dojo-project :: + ++ dy-abet +>(poy `+<) :: resolve + ++ dy-amok +>(poy ~) :: terminate + ++ dy-init-ordered :: prepare source list + |= ord=(list dojo-source) + ^+ [ord +>] + ?~ ord [~ +>.$] + =^ fir +>.$ (dy-init-source i.ord) + =^ mor +>.$ $(ord t.ord) + [[fir mor] +>.$] + :: + ++ dy-init-named :: prepare source map + |= key=(map term dojo-source) + ^+ [key +>.$] + ?~ key [~ +>.$] + =^ top +>.$ (dy-init-source q.n.key) + =^ lef +>.$ $(key l.key) + =^ rit +>.$ $(key r.key) + [[[p.n.key top] lef rit] +>.$] + :: + ++ dy-init-model :: prepare dojo-model + |= mod=dojo-model + ^+ [mod +>] + ?- -.mod + %& [mod +>] + %| =^ cig +> (dy-init-config q.mod) + [mod(q cig) +>.$] + == + :: + ++ dy-init-source :: prepare source + |= src=dojo-source + ^+ [src +>] + =^ mod +> (dy-init-model mod.src) + =: inx.src num + mod.src mod + == + [src +>.$(num +(num), job (~(put by job) num src))] + :: + ++ dy-init-config :: prepare config + |= cig=dojo-config + ^+ [cig +>] + =^ ord +>.$ (dy-init-ordered ord.cig) + =^ key +>.$ (dy-init-named key.cig) + [[ord key] +>.$] + :: + ++ dy-init + =+ dam=mad + ?- -.dam + %poke =^ src + (dy-init-source q.dam) + +>(mad dam(q src)) + %save =^ src + (dy-init-source r.dam) + +>(mad dam(r src)) + == + :: + ++ dy-made-hand + |= cag=cage + ^+ +>+> + dy-step(cur +(cur), rez (~(put by rez) cur cag)) + :: + ++ dy-over + ^+ +> + ?- -.mad + %poke + (he-pass(poy ~) /poke %g %mess p.mad our.hid (~(got by rez) inx.q.mad)) + :: + %save + =+ cag=(~(got by rez) inx.r.mad) + =. var (~(put by var) q.mad cag) + ?. p.mad +>+ + (he-rush(poy ~) [%tan (sell q.cag) ~]) + == + :: + ++ dy-step :: advance project + ^+ +> + ?: =(cur num) + dy-over + =+ src=(~(got by job) cur) + ?- -.mod.src + %& + %- he-pass(poy `+>-) + [/hand %f %exec our.hid `[%ride +.mod.src [%reef ~]]] + :: + %| !! + == + -- + :: + ++ he-abet :: resolve + [(flop moz) %_(+> hoc (~(put by hoc) ost +<+))] :: + :: :: + ++ he-give :: emit gift + |= git=gift + ^+ +> + %_(+> moz [[ost %give git] moz]) + :: + ++ he-pass + |= [pax=path noy=note] + %_(+> moz [[ost %pass pax noy] moz]) + :: + ++ he-rush :: emit update + |= fec=console-effect + ^+ +> + (he-give %rush %console-effect fec) + :: + ++ he-peer :: subscribe to + he-prom + :: + ++ he-prom :: send prompt + %- he-rush + :- %pro + ?^ duy + [& %$ (tuba u.duy)] + [& %$ (tuba (weld (scow %p our.hid) ":dojo> "))] + :: + ++ he-ford :: sign from ford + |= [pax=path rey=(each bead (list tank))] + ^+ +> + ?> ?=(^ poy) + ?- -.rey + %& ?+ pax ~&(%he-ford-path !!) + [%hand ~] + (~(dy-made-hand dy u.poy) q.p.rey) + == + %| (he-rush(poy ~) %tan p.rey) + == + :: + ++ he-like :: filter line + |= buf=(list ,@c) + ^- ? + =+ txt=(tufa buf) + =(+((lent txt)) q.p:(wide:(vang & ~) [1 1] txt)) + :: + ++ he-stir :: apply change + |= cal=console-change + ^+ +> + =^ dut say + =< [- abet:+] + %+ ~(remit cs say) cal + ?~(duy he-like |=((list ,@c) %|)) + ?~ dut + +>.$ + (he-rush %mor [%det u.dut] [%bel ~] ~) + :: + ++ he-plan :: execute command + |= mad=dojo-command + ^+ +> + ?> ?=(~ poy) + =< dy-step + ~(dy-init dy mad [0 0 ~ ~ ~]) + :: + ++ he-done :: parse command + |= txt=tape + ^+ +> + ?^ duy (he-rush %bel ~) + =+ foy=(rust txt wide:(vang & ~)) + ?~ foy + (he-rush %bel ~) + =+ old=(weld "> " (tufa buf.say)) + =^ cal say [- abet]:(~(transmit cs say) [%set ~]) + %- =< he-plan + %- he-rush + :~ %mor + [%txt old] + [%nex ~] + [%det cal] + == + `dojo-command`[%save & %foo 0 %noun %& u.foy] + :: + ++ he-work :: apply input + |= act=console-action + ^+ +> + ?- -.act + %inn +>.$ + %out +>.$ + %det (he-stir +.act) + %ret (he-done (tufa buf.say)) + == + -- +:: +++ peer + |= [ost=bone her=ship pax=path] + ^- [(list move) _+>] + ?< (~(has by hoc) ost) + ?> =(/console pax) + ?> =(her our.hid) + he-abet:~(he-peer he [ost ~] *session) +:: +++ poke-console-action + |= [ost=bone her=ship act=console-action] + ^- [(list move) _+>] + he-abet:(~(he-work he [ost [ost %give %nice ~]~] (~(got by hoc) ost)) act) +:: +++ pour + |= [ost=bone pax=path sih=*] + ^- [(list move) _+>] + =+ sih=((hard sign) sih) + ?- -.sih + %f + he-abet:(~(he-ford he [[ost ~] (~(got by hoc) ost)]) pax +>.sih) + :: + %g !! + == +-- From 24932f3b440fc20f33667f8896269001e6c212db Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 24 Feb 2015 10:57:47 -0800 Subject: [PATCH 036/219] Various fixes and improvements. --- arvo/hoon.hoon | 1 + main/app/began/core.hook | 1 - main/app/dojo/core.hook | 2 - main/app/helm/core.hook | 186 +++++++++++++++++++++++++++++++++++++ main/app/seat/core.hook | 8 +- main/app/tease/core.hook | 2 +- main/lib/console/core.hook | 46 +++++++++ main/sur/console/core.hook | 18 +++- 8 files changed, 253 insertions(+), 11 deletions(-) create mode 100644 main/app/helm/core.hook diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index b3e1fc5edf..67acb8d839 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -144,6 +144,7 @@ == :: ++ ring ,@ :: private key ++ rule |=(tub=nail `edge`[p.tub ~ ~ tub]) :: parsing rule +++ ruly |*(pro=$+(* *) $+(nail (like pro))) :: rule like ++ span ,@ta :: text-atom (ASCII) ++ spot ,[p=path q=pint] :: range in file ++ tang (list tank) :: general error diff --git a/main/app/began/core.hook b/main/app/began/core.hook index cf6174e18a..088cd98cc7 100644 --- a/main/app/began/core.hook +++ b/main/app/began/core.hook @@ -33,7 +33,6 @@ [ust %pass / %c %plug our.hid %try (sein our.hid) %try] [ust %give %nice ~] == - :: ++ pour |= [ost=bone pax=path sih=*] diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 8e1061fff0..0cade1026f 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -298,8 +298,6 @@ |= act=console-action ^+ +> ?- -.act - %inn +>.$ - %out +>.$ %det (he-stir +.act) %ret (he-done (tufa buf.say)) == diff --git a/main/app/helm/core.hook b/main/app/helm/core.hook new file mode 100644 index 0000000000..5a98efed00 --- /dev/null +++ b/main/app/helm/core.hook @@ -0,0 +1,186 @@ +:: :: :: +:::: /hook/core/helm/app :: :: + :: :: :: +/? 314 :: zuse version +/- *console :: structures +/+ console :: libraries +:: :: :: +:::: :: :: + !: :: :: +=> |% :: principal structures + ++ helm-house :: all state + $: %0 :: state version + hoc=(map bone helm-session) :: consoles + == :: + ++ helm-session :: + $: say=console-share :: + == :: + ++ helm-wish :: + $| $? %solid :: save kernel pill + %reset :: reset kernel + %verb :: verbose mode + == :: + $% [%reload p=(list term)] :: reload vanes + [%begin p=(qual @p @p @t gens)] :: start new ship + == :: + :: :: + ++ gift :: out result <-$ + $% [%mean p=ares] :: error + [%nice ~] :: acknowledge + [%rush %console-effect console-effect] :: effect + == :: + ++ hapt ,[p=ship q=path] :: + ++ move ,[p=bone q=(mold note gift)] :: + ++ note-gall :: note to %gall + $% [%mess p=[p=ship q=path] q=ship r=cage] :: + [%show p=[p=ship q=path] q=ship r=path] :: + [%took p=[p=ship q=path] q=ship] :: + == :: + ++ note-dill :: system command + $% [%veer p=@ta q=path r=@t] :: + [%vega p=path] :: + [%verb ~] :: + == :: + ++ note :: out request $-> + $% [%d note-dill] :: + [%g note-gall] :: + == :: + -- :: +=> |% :: parser + ++ parse-helm-wish + %+ cook |=(a=helm-wish a) + ;~ pose + (cold %solid (jest %solid)) + (cold %reset (jest %reset)) + == + -- +:: :: +:::: :: + :: :: +|_ $: hid=hide :: system state + helm-house :: program state + == :: +++ he :: per session + |_ [[ost=bone moz=(list move)] helm-session] :: + ++ he-abet :: resolve + [(flop moz) %_(+> hoc (~(put by hoc) ost +<+))] :: + :: :: + ++ he-give :: emit gift + |= git=gift + %_(+> moz [[ost %give git] moz]) + :: + ++ he-peer :: subscribe to + (he-rush [%pro %& %$ (tuba ":helm! ")]~) + :: + ++ he-rush :: emit changes + |= fes=(list console-effect) + ?~ fes +> + (he-give %rush %console-effect ?~(t.fes i.fes [%mor fes])) + :: + ++ he-wish-solid + ^+ . + =- %_ + + moz :_ moz + [ost %give %rush %console-effect %sag /urbit/pill pil] + == + ^= pil + =+ top=`path`/(scot %p our.hid)/arvo/(scot %da lat.hid) + =+ pax=`path`(weld top `path`[%hoon ~]) + ~& %solid-start + =+ gen=(reck pax) + ~& %solid-parsed + =+ ken=q:(~(mint ut %noun) %noun gen) + ~& %solid-compiled + :- ken + =+ all=.*(0 ken) + =+ ^= vay ^- (list ,[p=@tas q=@tas]) + :~ [%$ %zuse] + [%g %gall] + [%f %ford] + [%a %ames] + [%c %clay] + [%d %dill] + [%e %eyre] + [%t %time] + == + |- ^+ all + ?~ vay all + =+ pax=(weld top `path`[q.i.vay ~]) + =+ txt=((hard ,@) .^(%cx (weld pax `path`[%hoon ~]))) + =+ sam=[lat.hid `ovum`[[%gold ~] [%veer p.i.vay pax txt]]] + ~& [%solid-veer i.vay] + =+ gat=.*(all .*(all [0 42])) + =+ nex=+:.*([-.gat [sam +>.gat]] -.gat) + $(vay t.vay, all nex) + :: + ++ he-wish-reset + ^+ . + =- $_(+ moz (weld zum moz)) + ^= zum + =+ top=`path`/(scot %p our.hid)/arvo/(scot %da lat.hid) + :- [ost %pass /reset %d %vega (weld top `path`/hoon)] + %+ turn + ^- (list ,[p=@tas q=@tas]) + :~ [%$ %zuse] + [%a %ames] + [%c %clay] + [%d %dill] + [%e %eyre] + [%f %ford] + [%g %gall] + [%t %time] + == + |= [p=@tas q=@tas] + =+ pax=`path`(welp top /[q]) + =+ txt=((hard ,@) .^(%cx (welp pax /hoon))) + [ost %pass /reset %d %veer p pax txt] + :: + ++ he-wish-begin + |= mes=(qual @p @p @t gens) + %_ +> + moz + :_ moz + [ost %pass /begin %g %mess [our.hid /began] our.hid %began-args !>(mes)] + == + :: + ++ he-wish-verb + %_ . + moz + :_ moz + [ost %pass /verb %d %verb ~] + == + :: + ++ he-wish + |= wis + %_ +> + moz + %- weld + :_ moz + ?- wis + %verb he-wish-verb + %solid he-wish-solid + %reset he-wish-reset + [%reload *] (he-wish-reload +.wis) + [%begin *] (he-wish-begin +.wis) + == + :: + ++ he-work :: apply input + |= act=console-action + ^+ +> + =^ wig say ((~(apex cs say) parse-helm-wish) act) + (he-wish:(he-rush p.wig) q.wig) + -- +:: +++ peer + |= [ost=bone her=ship pax=path] + ^- [(list move) _+>] + ?< (~(has by hoc) ost) + ?> =(/console pax) + ?> =(her our.hid) + he-abet:~(he-peer he [ost ~] *helm-session) +:: +++ poke-console-action + |= [ost=bone her=ship act=console-action] + ^- [(list move) _+>] + he-abet:(~(he-work he [ost [ost %give %nice ~]~] (~(got by hoc) ost)) act) +-- diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index fc92fd3b7f..2b89fafa14 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -33,12 +33,12 @@ ++ search :: reverse-i-search $: pos=@ud :: search position str=(list ,@c) :: search string - == + == :: ++ target :: application target $: ris=(unit search) :: reverse-i-search hit=history :: all past input pom=console-prompt :: static prompt - inp=console-input :: input state + inp=console-command :: input state == :: ++ gift :: out result <-$ $% [%mean p=ares] :: @@ -348,7 +348,7 @@ ?- -.fec %bel ta-bel %blk +> - %clr +>(+> (se-blit %clr ~)) + %clr +>(+> (se-blit fec)) %det (ta-got +.fec) %mor |- ^+ +>.^$ ?~ p.fec +>.^$ @@ -356,6 +356,8 @@ %nex ta-nex %pro (ta-pro +.fec) %tan (ta-tan p.fec) + %sag +>(+> (se-blit fec)) + %sav +>(+> (se-blit fec)) %txt $(fec [%tan [%leaf p.fec]~]) == :: diff --git a/main/app/tease/core.hook b/main/app/tease/core.hook index 6d9899d24e..144ef4724d 100644 --- a/main/app/tease/core.hook +++ b/main/app/tease/core.hook @@ -22,7 +22,7 @@ %g %mess [our.hid /seat] our.hid %dill-belt - !>(`dill-belt`[%yow %dojo]) + !>(`dill-belt`[%yow %helm]) == == -- diff --git a/main/lib/console/core.hook b/main/lib/console/core.hook index 4d1b2bce9d..87a19cad66 100644 --- a/main/lib/console/core.hook +++ b/main/lib/console/core.hook @@ -12,6 +12,52 @@ ++ cs :: shared-state engine |_ console-share ++ abet +< + ++ apex :: engine by rule + |* sef=_rule + |= act=console-action + ^+ [[p=*(list console-effect) q=(rust ~ sef)] *console-share] + ?- -.act + %det + =^ dut +>+>.$ + %+ remit +.act + |= buf=(list ,@c) + =+ txt=(tufa buf) + =((lent txt) q.p:(sef [0 0] txt)) + [[?~(dut ~ [[%det u.dut] ~]) ~] +>+>+<.$] + :: + %ret + =+ dod=(rust (tufa buf) sef) + ?~ dod + [[[%bel ~]~ ~] +>+>+<.$] + =^ cal +>+>.$ (transmit [%set ~]) + :_ +>+>+<.$ + :_ dod + :~ [%det cal] + [%nex ~] + == + == + ++ apse :: engine by dialog + |* dog=_(console-dialog) + |= act=console-action + ^+ :_ *console-share + :_ *(list console-effect) + ?>(?=(%& -.god) *(each ,_p.god ,_+) + ?- -.act + %det + =^ dut +>+>.$ + %+ remit +.act + |= buf=(list ,@c) + !=(~ (nice:dog (tufa buf))) + + =+ foo=`(list console-effect)`?~(dut ~ [[%det u.dut] ~]) + :- :- foo + [%| dog] + `console-share`+>+>+<.$ + :: + %ret + ?. =(`& (nice:dog + == + :: ++ apply |= ted=console-edit ^+ +> diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook index 2240992a9d..204dc37c8b 100644 --- a/main/sur/console/core.hook +++ b/main/sur/console/core.hook @@ -3,11 +3,8 @@ !: |% ++ console-action :: console to app - $% [%abo ~] :: reset interaction + $% :: [%abo ~] :: reset interaction [%det console-change] :: command line edit - [%inn ~] :: enter session - [%mut p=(list tape)] :: multiline input - [%out ~] :: exit session [%ret ~] :: submit and clear == :: ++ console-buffer (list ,@c) :: command state @@ -16,6 +13,16 @@ haw=@uvH :: source hash ted=console-edit :: state change == :: +++ console-dialog :: standard dialog + |* out=$+(* *) :: output type + $_ ^? |% :: + ++ init =< $ :: initial response + %+ pair tanq :: + %+ each (unit out) :: + (pair console-prompt _.) :: + ++ kick |=(console-input init) :: next response + ++ nice $+(console-input (unit ,?)) :: legal/partial + -- :: ++ console-clock ,[own=@ud his=@ud] :: vector clock ++ console-edit :: shared state change $% [%del p=@ud] :: delete one at @@ -32,6 +39,8 @@ [%mor p=(list console-effect)] :: multiple effects [%nex ~] :: save, clear command [%pro console-prompt] :: set prompt + [%sag p=path q=*] :: save to jamfile + [%sav p=path q=@] :: save to file [%tan p=(list tank)] :: classic tank :: [%taq p=tanq] :: modern tank [%txt p=tape] :: text line @@ -45,6 +54,7 @@ tag=term :: history mode cap=(list ,@c) :: caption == :: +++ console-input tape :: prompt input ++ console-share :: symmetric state $: ven=console-clock :: our vector clock leg=(list console-edit) :: unmerged edits From 8b2dfedee2f4599d3a32f8f51eaac55152df26fb Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 24 Feb 2015 14:53:31 -0800 Subject: [PATCH 037/219] Barnaby, almost working. --- main/app/dojo/core.hook | 2 ++ main/app/helm/core.hook | 31 +++++++++++----------- main/app/seat/core.hook | 1 + main/lib/console/core.hook | 53 +++++++++++++++++++++++--------------- main/sur/console/core.hook | 4 +-- 5 files changed, 52 insertions(+), 39 deletions(-) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 0cade1026f..cfe16be5f9 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -267,6 +267,8 @@ ?~(duy he-like |=((list ,@c) %|)) ?~ dut +>.$ + ~& [%he-reject-cal cal] + ~& [%he-reject-dut u.dut] (he-rush %mor [%det u.dut] [%bel ~] ~) :: ++ he-plan :: execute command diff --git a/main/app/helm/core.hook b/main/app/helm/core.hook index 5a98efed00..2b75a469ab 100644 --- a/main/app/helm/core.hook +++ b/main/app/helm/core.hook @@ -21,7 +21,7 @@ %verb :: verbose mode == :: $% [%reload p=(list term)] :: reload vanes - [%begin p=(qual @p @p @t gens)] :: start new ship + [%begin p=(qual ,@p ,@p ,@t gens)] :: start new ship == :: :: :: ++ gift :: out result <-$ @@ -115,8 +115,8 @@ :: ++ he-wish-reset ^+ . - =- $_(+ moz (weld zum moz)) - ^= zum + =- %_(+ moz (weld zum moz)) + ^= zum ^- (list move) =+ top=`path`/(scot %p our.hid)/arvo/(scot %da lat.hid) :- [ost %pass /reset %d %vega (weld top `path`/hoon)] %+ turn @@ -136,7 +136,7 @@ [ost %pass /reset %d %veer p pax txt] :: ++ he-wish-begin - |= mes=(qual @p @p @t gens) + |= mes=(qual ,@p ,@p ,@t gens) %_ +> moz :_ moz @@ -151,18 +151,17 @@ == :: ++ he-wish - |= wis - %_ +> - moz - %- weld - :_ moz - ?- wis - %verb he-wish-verb - %solid he-wish-solid - %reset he-wish-reset - [%reload *] (he-wish-reload +.wis) - [%begin *] (he-wish-begin +.wis) - == + |= wus=(unit helm-wish) + ^+ +> + ?~ wus + ~&(%he-wish-aborted +>) + ?- u.wus + %verb he-wish-verb + %solid he-wish-solid + %reset he-wish-reset + [%reload *] !! :: (he-wish-reload +.u.wus) + [%begin *] (he-wish-begin +.u.wus) + == :: ++ he-work :: apply input |= act=console-action diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index 2b89fafa14..fe4a4236f1 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -161,6 +161,7 @@ :: ++ se-just :: adjusted buffer |= lin=(pair ,@ud (list ,@c)) + ~& [%se-just lin] ^+ +> =. off ?:((lth p.lin edg) 0 (sub p.lin edg)) (se-show (sub p.lin off) (scag edg (slag off q.lin))) diff --git a/main/lib/console/core.hook b/main/lib/console/core.hook index 87a19cad66..e95a722c15 100644 --- a/main/lib/console/core.hook +++ b/main/lib/console/core.hook @@ -36,27 +36,38 @@ [%nex ~] == == - ++ apse :: engine by dialog - |* dog=_(console-dialog) - |= act=console-action - ^+ :_ *console-share - :_ *(list console-effect) - ?>(?=(%& -.god) *(each ,_p.god ,_+) - ?- -.act - %det - =^ dut +>+>.$ - %+ remit +.act - |= buf=(list ,@c) - !=(~ (nice:dog (tufa buf))) - - =+ foo=`(list console-effect)`?~(dut ~ [[%det u.dut] ~]) - :- :- foo - [%| dog] - `console-share`+>+>+<.$ - :: - %ret - ?. =(`& (nice:dog - == + ++ apse :: dialog engine + |* dog=(console-dialog) + |% ++ abet `console-share`+>+>- :: resolve + ++ dole :: + =+ fov=^+(init:dog [[~ ~] [%& ~]]) + |- + =+ fex=[%tan p.fov] + ?- -.q.fov + %& [[p=fex q=[~ u=p.q.fov]] +>.$] + %| :- [p=[i=[%pro `console-prompt`p.p.q.fov] t=fex] q=~] + +>.$(dog q.p.q.fov) + == + :: + ++ init (dole init:dog) :: initialize + ++ work + |= act=console-action + ^+ init + ?- -.act + %det + =^ dut +>+>.$ + %+ remit +.act + |= buf=(list ,@c) + !=(~ (nice:dog (tufa buf))) + [[?~(dut ~ [[%det u.dut] ~]) ~] +>+>+<.$] + :: + %ret + =+ txt=(tufa buf) + ?. =(`& (nice:dog txt)) + [[[%bel ~]~ ~] +>+>+<.$] + (dole (kick:dog txt)) + == + -- :: ++ apply |= ted=console-edit diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook index 204dc37c8b..db3c41332f 100644 --- a/main/sur/console/core.hook +++ b/main/sur/console/core.hook @@ -17,9 +17,9 @@ |* out=$+(* *) :: output type $_ ^? |% :: ++ init =< $ :: initial response - %+ pair tanq :: + %+ pair (list tank) :: %+ each (unit out) :: - (pair console-prompt _.) :: + (pair console-prompt ,_.) :: ++ kick |=(console-input init) :: next response ++ nice $+(console-input (unit ,?)) :: legal/partial -- :: From e6f584023de80a04cef281c85b412bddd33a7386 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 24 Feb 2015 15:25:17 -0800 Subject: [PATCH 038/219] Don't reverse moves. --- arvo/hoon.hoon | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index 67acb8d839..532c94156d 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -144,7 +144,6 @@ == :: ++ ring ,@ :: private key ++ rule |=(tub=nail `edge`[p.tub ~ ~ tub]) :: parsing rule -++ ruly |*(pro=$+(* *) $+(nail (like pro))) :: rule like ++ span ,@ta :: text-atom (ASCII) ++ spot ,[p=path q=pint] :: range in file ++ tang (list tank) :: general error @@ -10188,7 +10187,7 @@ |- ^- [p=(list ovum) q=(pair worm (list ,[p=@tas q=vase]))] ?~ mor [(flop ova) niz] =^ nyx niz (jack lac i.mor) - $(ova (weld p.nyx ova), mor (weld q.nyx t.mor)) + $(ova (weld p.nyx ova), mor (weld t.mor q.nyx)) -- -- :::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::: From bd4eff0fbb90410fa65fab1229d16213718e215b Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 24 Feb 2015 15:31:58 -0800 Subject: [PATCH 039/219] Recover a BUNCH of old stuff from a stash. --- arvo/dull.hoon | 1 - main/app/seat/core.hook | 30 +++++++++++++++++++++--------- main/lib/console/core.hook | 38 ++++++++++++-------------------------- 3 files changed, 33 insertions(+), 36 deletions(-) diff --git a/arvo/dull.hoon b/arvo/dull.hoon index f5a3e85765..7b0a9e85b8 100644 --- a/arvo/dull.hoon +++ b/arvo/dull.hoon @@ -206,7 +206,6 @@ ++ init :: initialize |= gyl=(list gill) ^+ +> - ~& [%as-init ram gyl] =. moz :_(moz [hen %pass ~ %g %show [our [ram ~]] our ~]) |- ^+ +>.^$ ?~ gyl +>.^$ diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index fe4a4236f1..ba6a67c219 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -362,21 +362,34 @@ %txt $(fec [%tan [%leaf p.fec]~]) == :: - ++ ta-dog :: correct position - |= ted=console-edit - ?. ?=(%set -.ted) +> - +>(pos.inp (lent buf.say.inp)) + ++ ta-dog :: change cursor + |= ted=console-edit + %_ +> + pos.inp + =+ len=(lent buf.say.inp) + %+ min len + |- ^- @ud + ?- -.ted + %del ?:((gth pos.inp p.ted) (dec pos.inp) pos.inp) + %ins ?:((lte pos.inp p.ted) +(pos.inp) pos.inp) + %mor |- ^- @ud + ?~ p.ted pos.inp + $(p.ted t.p.ted, pos.inp ^$(ted i.p.ted)) + %nop pos.inp + %set len + == + == :: ++ ta-got :: apply change |= cal=console-change - =. +> (ta-dog:+>(say.inp abet:(~(receive cs say.inp) cal)) ted.cal) - +> + =^ ted say.inp (~(receive cs say.inp) cal) + (ta-dog ted) :: ++ ta-hom :: local edit |= ted=console-edit ^+ +> =. +> (ta-det ted) - =. +> (ta-dog:+>(say.inp abet:(~(commit cs say.inp) ted)) ted) + =. +> (ta-dog(say.inp (~(commit cs say.inp) ted)) ted) +> :: ++ ta-met :: meta key @@ -460,8 +473,7 @@ cap.pom `(list ,@)`:(welp "(reverse-i-search)'" str.u.ris "': ") == - =- =. pos.inp (max pos.inp (lent q.vew)) - [(add pos.inp (lent p.vew)) (weld p.vew q.vew)] + =- [(add pos.inp (lent p.vew)) (weld p.vew q.vew)] ^= vew ^- (pair (list ,@c) (list ,@c)) ?: vis.pom [cap.pom buf.say.inp] :- ;: welp diff --git a/main/lib/console/core.hook b/main/lib/console/core.hook index e95a722c15..f6bdcdd69e 100644 --- a/main/lib/console/core.hook +++ b/main/lib/console/core.hook @@ -129,8 +129,8 @@ :: ++ commit :: local change |= ted=console-edit - ^+ +> - (apply(own.ven +(own.ven)) ted) + ^- console-share + abet:(apply(own.ven +(own.ven)) ted) :: :::: :: ++inverse: inverse of change in context. @@ -157,40 +157,26 @@ :: ++ transmit :: outgoing change |= ted=console-edit - ^- [console-change _+>] + ^- [console-change console-share] [[[his.ven own.ven] (sham buf) ted] (commit ted)] :: - ++ realize :: naturalize event + ++ receive :: naturalize event |= console-change - ^- [console-edit _+>] + ^- [console-edit console-share] ?> &(=(his.ler his.ven) (lte own.ler own.ven)) ?> &(=(his.ler his.ven) (lte own.ler own.ven)) ?> |(!=(own.ler own.ven) =(haw (sham buf))) =. leg (scag (sub own.ven own.ler) leg) - [(transmute [%mor leg] ted) +>] + =+ dat=(transmute [%mor leg] ted) + [dat abet:(apply(his.ven +(his.ven)) dat)] :: ++ remit :: conditional accept |= [cal=console-change ask=$+((list ,@c) ?)] - ^- [(unit console-change) _+>] - =+ old=+> - =^ dat +>.$ (realize cal) - =. +>.$ (apply(his.ven +(his.ven)) dat) + ^- [(unit console-change) console-share] + =^ dat +>+<.$ (receive cal) ?: (ask buf) - [~ +>.$] - =+ wad=(inverse dat) - :: ~& [%remit-old buf.old] - :: ~& [%remit-new buf] - :: ~& [%remit ted/ted.cal] - :: ~& [%remit dat/dat] - :: ~& [%remit wad/wad] - =^ lic +>.$ (transmit wad) - :: ~& [%remit-end [lic buf]] - [`lic +>.$] - :: - ++ receive :: accept change - |= cal=console-change - ^+ +> - =^ dat +> (realize cal) - (apply(his.ven +(his.ven)) dat) + [~ +>+<.$] + =^ lic +>+<.$ (transmit (inverse dat)) + [`lic +>+<.$] -- -- From 7b56bcfe0679c95e3b5af0d49cef2b98cb38652f Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 24 Feb 2015 15:42:28 -0800 Subject: [PATCH 040/219] Back to where I thought I was. --- main/app/dojo/core.hook | 5 +---- main/app/seat/core.hook | 1 - main/app/tease/core.hook | 2 +- main/lib/console/core.hook | 6 +++--- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index cfe16be5f9..9df12ce867 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -262,13 +262,10 @@ |= cal=console-change ^+ +> =^ dut say - =< [- abet:+] %+ ~(remit cs say) cal ?~(duy he-like |=((list ,@c) %|)) ?~ dut +>.$ - ~& [%he-reject-cal cal] - ~& [%he-reject-dut u.dut] (he-rush %mor [%det u.dut] [%bel ~] ~) :: ++ he-plan :: execute command @@ -286,7 +283,7 @@ ?~ foy (he-rush %bel ~) =+ old=(weld "> " (tufa buf.say)) - =^ cal say [- abet]:(~(transmit cs say) [%set ~]) + =^ cal say (~(transmit cs say) [%set ~]) %- =< he-plan %- he-rush :~ %mor diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index ba6a67c219..be097f6511 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -161,7 +161,6 @@ :: ++ se-just :: adjusted buffer |= lin=(pair ,@ud (list ,@c)) - ~& [%se-just lin] ^+ +> =. off ?:((lth p.lin edg) 0 (sub p.lin edg)) (se-show (sub p.lin off) (scag edg (slag off q.lin))) diff --git a/main/app/tease/core.hook b/main/app/tease/core.hook index 144ef4724d..6d9899d24e 100644 --- a/main/app/tease/core.hook +++ b/main/app/tease/core.hook @@ -22,7 +22,7 @@ %g %mess [our.hid /seat] our.hid %dill-belt - !>(`dill-belt`[%yow %helm]) + !>(`dill-belt`[%yow %dojo]) == == -- diff --git a/main/lib/console/core.hook b/main/lib/console/core.hook index f6bdcdd69e..f4c498181b 100644 --- a/main/lib/console/core.hook +++ b/main/lib/console/core.hook @@ -18,7 +18,7 @@ ^+ [[p=*(list console-effect) q=(rust ~ sef)] *console-share] ?- -.act %det - =^ dut +>+>.$ + =^ dut +>+>+<.$ %+ remit +.act |= buf=(list ,@c) =+ txt=(tufa buf) @@ -29,7 +29,7 @@ =+ dod=(rust (tufa buf) sef) ?~ dod [[[%bel ~]~ ~] +>+>+<.$] - =^ cal +>+>.$ (transmit [%set ~]) + =^ cal +>+>+<.$ (transmit [%set ~]) :_ +>+>+<.$ :_ dod :~ [%det cal] @@ -55,7 +55,7 @@ ^+ init ?- -.act %det - =^ dut +>+>.$ + =^ dut +<.apse %+ remit +.act |= buf=(list ,@c) !=(~ (nice:dog (tufa buf))) From 82f89036e2d8be3676b234f5e0d24a22fedc8c29 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 24 Feb 2015 18:08:20 -0800 Subject: [PATCH 041/219] BTC base58check @uc odour v1 --- arvo/hoon.hoon | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index 7512ff2731..dd254cfcf4 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -1151,6 +1151,30 @@ ++ tos ~/ %tos :: fetch suffix |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] sis))) -- +:: +++ fa :: base58check + =+ key='123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' + =+ ^- yek=@ux ~+ + =- yek:(roll (trip key) -) + |= [a=char b=@ yek=_`@ux`(fil 3 256 0xff)] + [+(b) (mix yek (lsh 3 `@u`a (~(inv fe 3) b)))] + |% + ++ cha |=(a=char `(unit ,@uF)`=+(b=(cut 3 [`@`a 1] yek) ?:(=(b 0xff) ~ `b))) + ++ tok + |= a=@ux ^- @ux + =+ b=(pad a) + =- (~(net fe 5) (end 3 4 (shay 32 -))) + (shay (add b (met 3 a)) (lsh 3 b (swap 3 a))) + :: + ++ pad |=(a=@ =+(b=(met 3 a) ?:((gte b 21) 0 (sub 21 b)))) + ++ enc |=(a=@ux `@ux`(mix (lsh 3 4 a) (tok a))) + ++ den + |= a=@ux ^- (unit ,@ux) + =+ b=(rsh 3 4 a) + ?. =((tok b) (end 3 4 a)) + ~ + `b + -- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: section 2cF, signed and modular ints :: :: @@ -3208,6 +3232,7 @@ ++ ab |% ++ bix (bass 16 (stun [2 2] six)) + ++ fem (sear |=(a=@ (cha:fa a)) aln) ++ hif (boss 256 ;~(plug tip tiq (easy ~))) ++ huf %+ cook |=([a=@ b=@] (wred:un ~(zug mu ~(zag mu [a b])))) @@ -3267,6 +3292,7 @@ hif:ab tiq:ab == + ++ fim (sear den:fa (bass 58 (plus fem:ab))) ++ hex (ape (bass 0x1.0000 ;~(plug qex:ab (star ;~(pfix dog qix:ab))))) ++ lip =+ tod=(ape ted:ab) (bass 256 ;~(plug tod (stun [3 3] ;~(pfix dog tod)))) @@ -3388,6 +3414,7 @@ ^= gam ^- [p=tape q=tape] ?+ hay [~ ((ox-co [10 3] |=(a=@ ~(d ne a))) q.p.lot)] %b [['0' 'b' ~] ((ox-co [2 4] |=(a=@ ~(d ne a))) q.p.lot)] + %c [['0' 'c' (reap (pad:fa q.p.lot) '1')] (c-co (enc:fa q.p.lot))] %i [['0' 'i' ~] ((d-co 1) q.p.lot)] %x [['0' 'x' ~] ((ox-co [16 4] |=(a=@ ~(x ne a))) q.p.lot)] %v [['0' 'v' ~] ((ox-co [32 5] |=(a=@ ~(x ne a))) q.p.lot)] @@ -3410,6 +3437,7 @@ =+ rex=*tape =< |% ++ a-co |=(dat=@ ((d-co 1) dat)) + ++ c-co (em-co [58 1] |=([? b=@ c=tape] [~(c ne b) c])) ++ d-co |=(min=@ (em-co [10 min] |=([? b=@ c=tape] [~(d ne b) c]))) ++ r-co |= [syn=? nub=@ der=@ ign=(unit tape) ne=?] @@ -3474,6 +3502,7 @@ :: ++ ne |_ tig=@ + ++ c (cut 3 [tig 1] key:fa) ++ d (add tig '0') ++ x ?:((gte tig 10) (add tig 87) d) ++ v ?:((gte tig 10) (add tig 87) d) @@ -3495,6 +3524,7 @@ ;~ pfix (just '0') ;~ pose (stag %ub ;~(pfix (just 'b') bay:ag)) + (stag %uc ;~(pfix (just 'c') fim:ag)) (stag %ui ;~(pfix (just 'i') dim:ag)) (stag %ux ;~(pfix (just 'x') hex:ag)) (stag %uv ;~(pfix (just 'v') viz:ag)) @@ -5329,10 +5359,16 @@ ++ shax :: sha-256 ~/ %shax |= ruz=@ ^- @ + (shay [(met 3 ruz) ruz]) +:: +++ shay :: sha-256 with length + ~/ %shay + |= [len=@u ruz=@] ^- @ ~| %sha + => .(ruz (cut 3 [0 len] ruz)) =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))] =+ [sum=sum.few ror=ror.few net=net.few inv=inv.few] - =+ ral=(lsh 0 3 (met 3 ruz)) + =+ ral=(lsh 0 3 len) =+ ^= ful %+ can 0 :~ [ral ruz] From 25bbc1c67fd0a6c55652e662924024d7b027caa6 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Wed, 25 Feb 2015 08:57:43 -0800 Subject: [PATCH 042/219] Basic dialog workings. --- arvo/hoon.hoon | 6 +++ main/app/helm/core.hook | 50 ++++++++++++++++++++-- main/app/tease/core.hook | 2 +- main/lib/console/core.hook | 85 +++++++++++++++++++++++--------------- main/sur/console/core.hook | 19 +++++---- 5 files changed, 114 insertions(+), 48 deletions(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index 532c94156d..5184d1a4e5 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -2855,6 +2855,12 @@ :: section 2eI, parsing (external) :: :: ++ rash |*([naf=@ sab=_rule] (scan (trip naf) sab)) :: +++ ruse |* [los=tape sab=_rule] + =+ vex=(sab [[0 0] los]) + ?. =((lent los) q.p.vex) ~ + ?~ q.vex + [~ u=~] + [~ u=[~ u=p.u.q.vex]] ++ rush |*([naf=@ sab=_rule] (rust (trip naf) sab)) ++ rust |* [los=tape sab=_rule] =+ vex=((full sab) [[1 1] los]) diff --git a/main/app/helm/core.hook b/main/app/helm/core.hook index 2b75a469ab..18c002cac7 100644 --- a/main/app/helm/core.hook +++ b/main/app/helm/core.hook @@ -14,10 +14,12 @@ == :: ++ helm-session :: $: say=console-share :: + mud=(unit (console-dialog ,@ud)) :: == :: ++ helm-wish :: $| $? %solid :: save kernel pill %reset :: reset kernel + %test :: fun test %verb :: verbose mode == :: $% [%reload p=(list term)] :: reload vanes @@ -50,6 +52,7 @@ ++ parse-helm-wish %+ cook |=(a=helm-wish a) ;~ pose + (cold %test (jest %test)) (cold %solid (jest %solid)) (cold %reset (jest %reset)) == @@ -69,6 +72,23 @@ |= git=gift %_(+> moz [[ost %give git] moz]) :: + ++ he-test + ^- (console-dialog ,@) + |= fin=(unit console-input) + ?^ fin !! + :- ~ :- ~ + :- [%leaf "a number..."]~ + :- %| + :- `console-prompt`[& %$ (tuba "number one> ")] + he-test-two + :: + ++ he-test-two + |= fin=(unit console-input) + =+ uno=?~(fin ~ (ruse u.fin dem:ag)) + ?~ uno ~ + ?~ u.uno [~ ~] + [~ ~ ~ %& ~ u.u.uno] + :: ++ he-peer :: subscribe to (he-rush [%pro %& %$ (tuba ":helm! ")]~) :: @@ -150,13 +170,31 @@ [ost %pass /verb %d %verb ~] == :: + ++ he-proceed + |= res=(unit (unit ,@)) + ^+ +> + ?~ res + ~& %abort + +>.$(mud ~) + ?~ u.res + +>.$ + ~& [%result u.u.res] + +>.$(mud ~) + :: + ++ he-wish-test + |- ^+ + + =+ cow=he-test + =^ nib say ((~(apse cs say) cow) ~) + =^ don cow nib + (he-proceed:(he-rush(mud `cow) p.don) q.don) + :: ++ he-wish |= wus=(unit helm-wish) ^+ +> - ?~ wus - ~&(%he-wish-aborted +>) + ?~ wus +> ?- u.wus %verb he-wish-verb + %test he-wish-test %solid he-wish-solid %reset he-wish-reset [%reload *] !! :: (he-wish-reload +.u.wus) @@ -166,8 +204,12 @@ ++ he-work :: apply input |= act=console-action ^+ +> - =^ wig say ((~(apex cs say) parse-helm-wish) act) - (he-wish:(he-rush p.wig) q.wig) + ?~ mud + =^ wig say ((~(apex cs say) parse-helm-wish) act) + (he-wish:(he-rush p.wig) q.wig) + =^ nib say ((~(apse cs say) u.mud) `act) + =^ don u.mud nib + (he-proceed:(he-rush p.don) q.don) -- :: ++ peer diff --git a/main/app/tease/core.hook b/main/app/tease/core.hook index 6d9899d24e..144ef4724d 100644 --- a/main/app/tease/core.hook +++ b/main/app/tease/core.hook @@ -22,7 +22,7 @@ %g %mess [our.hid /seat] our.hid %dill-belt - !>(`dill-belt`[%yow %dojo]) + !>(`dill-belt`[%yow %helm]) == == -- diff --git a/main/lib/console/core.hook b/main/lib/console/core.hook index f4c498181b..e9958fece0 100644 --- a/main/lib/console/core.hook +++ b/main/lib/console/core.hook @@ -18,19 +18,19 @@ ^+ [[p=*(list console-effect) q=(rust ~ sef)] *console-share] ?- -.act %det - =^ dut +>+>+<.$ + =^ dut +<.apex %+ remit +.act |= buf=(list ,@c) =+ txt=(tufa buf) =((lent txt) q.p:(sef [0 0] txt)) - [[?~(dut ~ [[%det u.dut] ~]) ~] +>+>+<.$] + [[?~(dut ~ [[%det u.dut] [%bel ~] ~]) ~] +<.apex] :: %ret =+ dod=(rust (tufa buf) sef) ?~ dod - [[[%bel ~]~ ~] +>+>+<.$] - =^ cal +>+>+<.$ (transmit [%set ~]) - :_ +>+>+<.$ + [[[%bel ~]~ ~] +<.apex] + =^ cal +<.apex (transmit [%set ~]) + :_ +<.apex :_ dod :~ [%det cal] [%nex ~] @@ -38,35 +38,52 @@ == ++ apse :: dialog engine |* dog=(console-dialog) - |% ++ abet `console-share`+>+>- :: resolve - ++ dole :: - =+ fov=^+(init:dog [[~ ~] [%& ~]]) - |- - =+ fex=[%tan p.fov] - ?- -.q.fov - %& [[p=fex q=[~ u=p.q.fov]] +>.$] - %| :- [p=[i=[%pro `console-prompt`p.p.q.fov] t=fex] q=~] - +>.$(dog q.p.q.fov) - == - :: - ++ init (dole init:dog) :: initialize - ++ work - |= act=console-action - ^+ init - ?- -.act - %det - =^ dut +<.apse - %+ remit +.act - |= buf=(list ,@c) - !=(~ (nice:dog (tufa buf))) - [[?~(dut ~ [[%det u.dut] ~]) ~] +>+>+<.$] - :: - %ret - =+ txt=(tufa buf) - ?. =(`& (nice:dog txt)) - [[[%bel ~]~ ~] +>+>+<.$] - (dole (kick:dog txt)) - == + |= act=(unit console-action) + =< abet |% + ++ abet + ?~ act (ajar ~) + ?- -.u.act + %det + =^ dut +<.apse + %+ remit +.u.act + |= buf=(list ,@c) + !=(~ (dog `(tufa buf))) + :_ +<.apse + :_ dog + :_ q=[~ u=~] + ^= p ^- (list console-effect) + ?~(dut ~ [[%det u.dut] [%bel ~] ~]) + :: + %ret (ajar `(tufa buf)) + == + ++ ajar + |= unp=(unit console-input) + =+ god=(dog unp) + ?: |(?=(~ god) ?=(~ u.god)) + :_ +<.apse + :_ dog + :- p=`(list console-effect)`[%bel ~]~ + q=[~ u=~] + =+ fex=`(list console-effect)`[%tan p.u.u.god]~ + ?- -.q.u.u.god + %& + :_ +<.apse + :_ dog + :- p=fex + q=?~(p.q.u.u.god ~ [~ u=p.q.u.u.god]) + :: + %| + =^ cal +<.apse (transmit [%set ~]) + :_ +<.apse + :_ q.p.q.u.u.god + :_ q=[~ u=~] + ^= p ^+ fex + :* [%det cal] + [%nex ~] + [%pro p.p.q.u.u.god] + fex + == + == -- :: ++ apply diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook index db3c41332f..a10793f18c 100644 --- a/main/sur/console/core.hook +++ b/main/sur/console/core.hook @@ -14,15 +14,16 @@ ted=console-edit :: state change == :: ++ console-dialog :: standard dialog - |* out=$+(* *) :: output type - $_ ^? |% :: - ++ init =< $ :: initial response - %+ pair (list tank) :: - %+ each (unit out) :: - (pair console-prompt ,_.) :: - ++ kick |=(console-input init) :: next response - ++ nice $+(console-input (unit ,?)) :: legal/partial - -- :: + |* out=$+(* *) :: final output + $_ ^? :: + |= (unit console-input) :: ~ is init + =< $ :: + %- unit :: ~ is invalid + %- unit :: ~ is prefix + %+ pair (list tank) :: + %+ each (unit out) :: ~ is abort + (pair console-prompt (console-dialog out)) :: ask and continue +:: ++ console-clock ,[own=@ud his=@ud] :: vector clock ++ console-edit :: shared state change $% [%del p=@ud] :: delete one at From 6f3ba3d9a54144079ab1f5dd6aec6380e6a1879f Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 25 Feb 2015 17:20:45 -0800 Subject: [PATCH 043/219] preliminary auth --- arvo/eyre.hoon | 40 +++++++++++++++++++++++++++------------- arvo/ford.hoon | 2 +- arvo/zuse.hoon | 7 ++++--- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 45026e627f..2651eeaf0b 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -114,6 +114,7 @@ ney=@uvI :: rolling entropy dop=(map host ship) :: host aliasing liz=(jug beam (each duct oryx)) :: clay subscriptions + wup=(map hole cyst) :: secure sessions :: own=(map ship serf) :: domestic servers :: fon=(map ship rote) :: foreign servers :: ask=[p=@ud q=(map ,@ud ,[p=duct q=hiss])] :: outgoing by number @@ -128,6 +129,7 @@ :: == :: ++ cyst :: client session $: ced=cred :: credential + cez=[p=ship q=(set ship)] :: authenticated :: cow=(map ,@ud clue) :: consoles cug=(list ,@t) :: unacked cookies lax=@da :: last used @@ -179,7 +181,6 @@ :: == :: :: ++ serf :: local server :: $: pef=@t :: server prefix -:: wup=(map hole cyst) :: secure sessions :: cah=(map cash vase) :: compilation cache :: == :: :: ++ sink :: page push system @@ -396,6 +397,7 @@ ++ adit .(ney (mix eny ney)) :: + ++ anon (add our ^~((bex 64))) :: pseudo-sub ++ axon |= [tea=wire typ=type sih=sign] ^+ +> @@ -765,7 +767,8 @@ %- mule |. ^+ ..hell =+ hev=(heft oar q.pul) ?^ hev - =: s.u.hev [%web ~(rent co (flux:ya /'' r.pul)) s.u.hev] + =+ ced=ced.q:(huff our q.hyx pul moh) + =: s.u.hev [%web ~(rent co (flux:ya /'' r.pul ced)) s.u.hev] r.u.hev ?+(r.u.hev r.u.hev [%ud %0] da/now) == (honk oar [%cast %mime [%boil ext u.hev ~]]) @@ -783,12 +786,22 @@ {(trip poll:js)} """ :: - | ~|(aute/p.u.hem !!) + | ~| aute/p.u.hem ~| q.moh + =+ hez=(huff our q.hyx pul moh) + =. wup (~(put by wup) hez) + ?^ cug.q.hez + =+ rel=;html:script:"document.location.reload()" + =+ tuv=(tuff 200 text//html (crip (poxo rel))) + =. q.tuv + (weld :_(q.tuv (turn `(list ,@t)`cug.q.hez |=(a=cord set-cookie/a)))) + (muff tuv) + ~| hez !! == :: ++ hemp :: auxillary(/~) request |= [oar=ship pok=pork quy=quay] ^- (unit (each ,@uvH ,[p=ship q=pork])) + ?: ?=([%'~~' *] q.pok) $(q.pok ['~' %as %own t.q.pok]) :: auth shortcut ?. ?=([%'~' @ *] q.pok) ~ :- ~ =* pef i.t.q.pok @@ -805,7 +818,7 @@ ?~ but !! :_ pok(q t.but) ?+ i.but (slav %p i.but) - %anon (add our ^~((bex 64))) + %anon anon %own our == == @@ -912,7 +925,7 @@ 'Disallow: /' == == - :: + :: ++ howa :: ford %wasp request |= [tea=wire dep=@uvH] (miff tea %f [%wasp our dep]) @@ -927,11 +940,11 @@ :: =+ sef=*serf :: sef(pef (cat 3 gub (rsh 3 1 (scot %p our)))) :: XX transitional :: =+ ^= saw ^- [p=hole q=cyst] - =+ pef=(cat 3 gub (rsh 3 1 (scot %p our))) + =+ pef=(rsh 3 1 (scot %p our)) =+ lig=(coss pef q.moh) -:: ?^ lig -:: =+ cyz=(need (~(get by wup.sef) u.lig)) -:: [u.lig cyz(cug ~)] + ?^ lig + =+ cyz=(need (~(get by wup) u.lig)) + [u.lig cyz(cug ~)] =+ ses=(rsh 3 1 (scot %p (end 6 1 ney))) :- ses ^- cyst @@ -946,6 +959,7 @@ cip ~ == + [anon ~] :: :: ~ :: @@ -979,8 +993,8 @@ :: ++ tuff :: mimed response |= [sas=@uG mit=mite rez=@] - ^- gift - [%thou sas ~[content-type/(moon mit)] [~ (taco rez)]] + :: (weld (turn cug |=(a=@t ['set-cookie' a])) + [%thou `httr`[sas ~[content-type/(moon mit)] [~ (taco rez)]]] :: :: ++ myth :: load session :: |= [our=ship ses=hole] @@ -1214,10 +1228,10 @@ =* cyz -> |% ++ flux :: credential caboose - |= [nyp=path quy=quay] ^- coin + |= [nyp=path quy=quay ced=cred] ^- coin :* %many [%$ %ta ~] - [%blob *cred] ::ced] + [%blob ced] |- ^- (list coin) ?~ quy ~ [[%$ %t p.i.quy] [%$ %t q.i.quy] $(quy t.quy)] diff --git a/arvo/ford.hoon b/arvo/ford.hoon index 1018eadf88..0d7f1b71cd 100644 --- a/arvo/ford.hoon +++ b/arvo/ford.hoon @@ -808,7 +808,7 @@ :: ++ lima :: load at depth |= [cof=cafe for=mark bem=beam arg=heel] - %+ (clef %bake) (fine cof for bem arg) + %+ (clef %bake) [p=cof q=[%0 p=[bem `~] q=[for bem arg]]] |= [cof=cafe for=mark bem=beam arg=heel] ^- (bolt (unit vase)) %+ cope (lend cof bem) diff --git a/arvo/zuse.hoon b/arvo/zuse.hoon index 1ee99c3ca7..549b31fe35 100644 --- a/arvo/zuse.hoon +++ b/arvo/zuse.hoon @@ -2064,14 +2064,15 @@ ?~ rax [~ ~] ?^ t.rax - [p.pok [i.rax q.pok]]:[pok=$(rax t.rax) .] + [p.pok [ire q.pok]]:[pok=$(rax t.rax) ire=i.rax] =+ ^- raf=(like tape) %. [1^1 (flop (trip i.rax))] - ;~(sfix (plus ;~(less dot next)) dot) + ;~(sfix (star ;~(less dot next)) dot) ?~ q.raf [~ [i.rax ~]] =+ `[ext=tape [@ @] fyl=tape]`u.q.raf - [[~ (crip (flop ext))] [(crip (flop fyl)) ~]] + :- ?:(=(~ ext) ~ [~ (crip (flop ext))]) + [(crip (flop fyl)) ~] :: ++ fuel :: parse fcgi |= [bem=beam but=path] From e33384f3796ae170c336d9990f3a3d5418a2ccdd Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Thu, 26 Feb 2015 12:06:23 -0800 Subject: [PATCH 044/219] rebase prep --- main/lib/console/core.hook | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/lib/console/core.hook b/main/lib/console/core.hook index e9958fece0..6d10796dd2 100644 --- a/main/lib/console/core.hook +++ b/main/lib/console/core.hook @@ -190,10 +190,11 @@ ++ remit :: conditional accept |= [cal=console-change ask=$+((list ,@c) ?)] ^- [(unit console-change) console-share] + =+ old=buf =^ dat +>+<.$ (receive cal) ?: (ask buf) [~ +>+<.$] - =^ lic +>+<.$ (transmit (inverse dat)) + =^ lic +>+<.$ (transmit (inverse(buf old) dat)) [`lic +>+<.$] -- -- From 002a9b6f4629fc547e3504f951adafc15e090f55 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 26 Feb 2015 13:17:29 -0800 Subject: [PATCH 045/219] preen %e --- arvo/eyre.hoon | 1921 +----------------------------------------------- 1 file changed, 7 insertions(+), 1914 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 2651eeaf0b..2a0c5902ba 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -40,25 +40,10 @@ $: %d :: to %dill $% [%flog p=[%crud p=@tas q=(list tank)]] :: == == :: -:: $: %e :: to %eyre -:: $% [%this p=? q=clip r=httq] :: -:: [%thud ~] :: -:: == == :: $: %f :: to %ford $% [%exec p=@p q=(unit silk)] :: [%wasp p=@p q=@uvH] :: - == == :: -:: $: %g :: to %gall -:: $% [%mess p=hapt q=ship r=cage] :: -:: [%nuke p=hapt q=ship] :: -:: [%show p=hapt q=ship r=path] :: -:: [%took p=hapt q=ship] :: -:: == == :: -:: $: %t :: to %temp -:: $% [%wait p=@da] :: -:: [%rest p=@da] :: -:: == == - == :: + == == == :: ++ rave :: see %clay $% [& p=mood] :: == :: @@ -76,31 +61,13 @@ [%vega p=path] :: == == == :: ++ sign :: in result $<- - $? -:: $: %a :: by %ames -:: $% [%waft p=sock q=*] :: -:: [%went p=ship q=cape] :: -:: == == :: - $: %c :: by %clay + $? $: %c :: by %clay $% [%writ p=riot] :: == == :: -:: $: %e :: by %eyre -:: $% [%thou p=httr] :: -:: == == :: $: %f :: by %ford $% [%made p=@uvH q=(each cage tang)] :: [%news ~] :: == == :: -:: $: %g :: by %gall -:: $% [%dumb ~] :: -:: [%mean p=ares] :: -:: [%nice ~] :: -:: [%rush p=mark q=*] :: -:: [%rust p=mark q=*] :: -:: == == :: -:: $: %t :: by %time -:: $% [%wake ~] :: timer activate -:: == == :: $: @tas :: by any $% [%crud p=@tas q=(list tank)] :: == == == :: @@ -115,91 +82,13 @@ dop=(map host ship) :: host aliasing liz=(jug beam (each duct oryx)) :: clay subscriptions wup=(map hole cyst) :: secure sessions -:: own=(map ship serf) :: domestic servers -:: fon=(map ship rote) :: foreign servers -:: ask=[p=@ud q=(map ,@ud ,[p=duct q=hiss])] :: outgoing by number -:: kes=(map duct ,@ud) :: outgoing by duct -:: lor=(map duct dual) :: incoming by duct == :: -:: ++ clue :: console -:: $: ino=@ud :: input sequence -:: ono=@ud :: (lent out) -:: voy=(map ,@ud (list ,@ud)) :: waiters (q.rey) -:: out=(list json) :: output commands -:: == :: ++ cyst :: client session $: ced=cred :: credential cez=[p=ship q=(set ship)] :: authenticated -:: cow=(map ,@ud clue) :: consoles cug=(list ,@t) :: unacked cookies lax=@da :: last used -:: sok=(map ,@ud (pair ship sink)) :: live apps by reqno -:: rey=[p=@ud q=(map ,@ud pimp)] :: live requests == :: -:: ++ dual ,[p=@ud q=(each ,[p=ship q=hole] ship)] :: request handle -:: ++ dude ,[p=@tas q=@] :: client identity -:: ++ pest :: request in progress -:: $| $? %new :: virgin -:: %way :: waiting -:: == :: -:: $% [%err p=@ud q=(list tank)] :: error report -:: [%fin p=love] :: ready to send -:: [%fud p=(each bead (list tank))] :: function finished -:: [%haz p=riot] :: clay responded -:: [%raw p=hiss] :: wild url -:: [%who p=@tas q=@ta] :: awaiting auth -:: == :: -:: ++ pimp :: traced request -:: $: ful=? :: | === HEAD -:: fur=(unit mark) :: type goal -:: hen=duct :: event trace -:: som=seam :: logical request -:: pez=pest :: request state -:: sip=marl :: injected scripts -:: == :: -:: ++ rote :: remote server -:: $: cnt=@ud :: number served -:: sor=@p :: home sponsor -:: rem=[p=@ud q=(map ,@ud duct)] :: active requests -:: == :: -:: ++ seam :: logical request -:: $% [%ape p=ship q=@ud r=@ud] :: subscribe pull -:: [%aph p=ship q=@ud r=@ud s=json] :: app heartbeat -:: [%apg p=term q=ship r=mark s=path] :: app get/start -:: [%apm p=ship q=@ud r=@ud s=hasp for=mark t=json] :: message send -:: [%app p=ship q=(unit ,@ud)] :: script by port -:: [%aps p=ship q=@ud s=hasp t=path] :: subscribe -:: [%apu p=ship q=@ud s=hasp t=path] :: unsubscribe -:: [%cog p=@ud q=@ud] :: console get -:: [%con p=@ud] :: console face -:: [%cop p=@ud q=@ud r=json] :: console put -:: [%det p=desk q=moat] :: load changes -:: [%fun p=term q=tube r=(list manx)] :: functional -:: [%lon p=seal] :: authentication flow -:: [%red p=purl] :: redirect -:: [%sil p=@ud q=silk] :: status and silk -:: == :: -:: ++ serf :: local server -:: $: pef=@t :: server prefix -:: cah=(map cash vase) :: compilation cache -:: == :: -:: ++ sink :: page push system -:: $: bet=[wig=swig num=@ud tim=@da hen=duct] :: heartbeat -:: meg=[wig=swig num=@ud] :: messages -:: sub=[wig=swig num=@ud can=(map ,@ud stem)] :: subscriptions -:: == :: -:: ++ stem :: subscription -:: $: hap=hasp :: -:: pax=path :: -:: hen=duct :: -:: num=(unit (each ,@ud ,@ud)) :: -:: == :: -:: ++ swig :: update channel -:: $: cnt=@ud :: updates produced -:: toy=@ud :: updates sent -:: wan=(map ,@ud ,@ud) :: upno to reqno -:: red=(map ,@ud (unit (each cage cage))) :: ready for pickup -:: == :: -- :: |% ++ coss :: cookie search @@ -215,81 +104,12 @@ |- ^- (unit hole) ?~ u.mar ^$(cok t.cok) ?:(=(nam p.i.u.mar) [~ q.i.u.mar] $(u.mar t.u.mar)) -:: :: -:: ++ ecca :: [hasp path] -:: |= [orx=oryx moh=moth] -:: ^- (unit ,[hasp path]) -:: =+ jun=(ecci orx moh) -:: :: ~& [%ecca jun] -:: ?~ jun ~ -:: =+ ^- (unit ,[his=ship app=term pax=term]) -:: %. u.jun -:: %- ot:jo -:: ~[[%ship (su:jo fed:ag)] [%appl so:jo] [%path so:jo]] -:: ?~ - ~ -:: =+ ^= pax -:: %+ rush pax.u -:: ;~(pfix fas (more fas ;~(simu next urs:ab))) -:: ?~ pax ~ -:: `[[his.u app.u] u.pax] -:: :: -:: ++ ecce :: JS from moth -:: |= moh=moth -:: ^- (unit json) -:: =+ ten=(~(get by q.moh) 'content-type') -:: ?~ ten ~ -:: ?~ u.ten ~ -:: ?. =('text/json' (end 3 9 i.u.ten)) -:: ~| %ecce-content-type ~ -:: ?~ r.moh ~ -:: `(unit json)`(rush q.u.r.moh apex:poja) -:: :: -:: ++ ecci :: ecce w/oryx -:: |= [orx=oryx moh=moth] -:: ^- (unit json) -:: =+ jun=(ecce moh) -:: ?~ jun ~ -:: ?. ?=(%o -.u.jun) ~ -:: :: ?. =([~ %s orx] (~((get by p.u.jun) %oryx)) -:: :: ~& [%oryx-sent ~(get by p.u.jun) %oryx)] -:: :: ~& [%oryx-good orx] -:: :: ~ -:: ~? !=([~ %s orx] (~(get by p.u.jun) %oryx)) -:: [%oryx [%sent (~(get by p.u.jun) %oryx)] [%good orx]] -:: =+ nuj=(~(get by p.u.jun) %xyro) -:: ?~(nuj [~ ~] [~ u.nuj]) -:: :: ++ ecco :: eat headers |= hed=(list ,[p=@t q=@t]) ^- math %+ roll hed |= [a=[p=cord cord] b=math] =. p.a (cass (trip p.a)) (~(add ja b) a) -:: -:: ++ eccu :: [hasp json] -:: |= [orx=oryx moh=moth] -:: ^- (unit ,[hasp mark json]) -:: =+ jun=(ecci orx moh) -:: ?~ jun ~& %no-ecci ~ -:: =+ ^- (unit ,[his=term app=term for=mark jon=json]) -:: %. u.jun -:: %- ot:jo -:: :~ [%ship so:jo] -:: [%appl so:jo] -:: [%mark so:jo] -:: [%data |=(json (some +<))] -:: == -:: ?~ - ~& %no-json ~ -:: =+ his=(slaw %p (cat 3 '~' his.u)) -:: ?~ his ~& %no-ship ~ -:: `[[u.his app.u] for.u jon.u] -:: :: -:: ++ lopo :: cage to love -:: |= cay=cage -:: ^- love -:: ?> ?=(%mime p.cay) -:: ((hard love) [%mid q.q.cay]) -:: :: ++ loga :: tanks to manx |= tac=(list tank) ^- manx @@ -310,44 +130,6 @@ ?~ dep max max(c.i.c :_(c.i.c.max ;script@"/~/on/{}.js";)) :: -:: ++ lofa :: scripts in head -:: |= [mog=(list manx) luv=love] -:: ^- love -:: ?: =(~ mog) luv -:: ?+ -.luv luv -:: %mid -:: ?. =('')) -:: ;~(plug next (knee *tape ..$)) -:: (easy ~) -:: == -:: =+ hop=(need q:(hed *hair (trip q.q.luv))) -:: ?~ q.q.hop luv -:: =+ rep=:(welp p.hop scr q.q.hop) -:: [%mid p.luv (tact rep)] -:: == -:: :: -:: ++ loft :: love to response -:: |= luv=love -:: ^- httr -:: ?- -.luv -:: %mid [200 ~[content-type/(moon p.luv)] [~ q.luv]] -:: %ham [200 ~[content-type/'text/html'] [~ (tact (poxo p.luv))]] -:: %raw p.luv -:: %wan :+ 200 -:: ~[content-type/'text/plain'] -:: :- ~ -:: %- taco -:: %+ rap 3 -:: |- ^- (list ,@) -:: ?~(p.luv ~ [i.p.luv 10 $(p.luv t.p.luv)]) -:: %zap :+ p.luv -:: ~[content-type/'text/html'] -:: [~ (tact (poxo (loga "server error" ~ q.luv)))] -:: == ++ js :: static javascript |% ++ poll @@ -432,131 +214,6 @@ =+ `[@ caz=case dez=desk]`p.u.p.sih ?> ?=(%ud -.caz) (jive (joba dez (jone p.caz))) -:: %- gout -:: [(slav %p i.t.tea) i.t.t.tea (slav %ud i.t.t.t.tea) p.+.sih] -:: :: -:: ?(%dumb %mean %nice %rush %rust) -:: ?> ?=([%hoop @ @ @ ?([%mess @ @ ~] [%show @ ~])] tea) -:: =+ our=(slav %p i.t.tea) -:: =* ses i.t.t.tea -:: =+ nap=(slav %ud i.t.t.t.tea) -:: =+ ouy=(yolk:(gale our ses) nap) -:: ?~ ouy -:: +>.$ -:: =* mab t.t.t.t.tea -:: =+ woy=(yule:u.ouy ?+(i.mab !! %mess %meg, %show %sub)) -:: ?- -.+.sih -:: %dumb -:: abet:work:abet:dumb:woy -:: :: -:: %nice -:: =< abet =< work =< abet -:: ?. ?=(%mess i.mab) -:: u.ouy -:: (hear:woy ~ %& %json !>((joba %ok %b &))) -:: :: -:: %mean -:: =< abet =< work =< abet -:: =+ jon=(rong p.+.sih) -:: ?: ?=(%mess i.mab) -:: (hear:woy ~ %& %json !>(jon)) -:: =+ can=(slav %ud i.t.mab) -:: =+ sem=(~(get by can.sub.siq:beat:u.ouy) can) -:: ?~ sem :: XX shouldn't occur -:: u.ouy -:: (soon %& u.sem u.ouy can %show ?.(?=(%show i.mab) jon (wrap u.sem jon))) -:: :: -:: ?(%rust %rush) -:: ?> ?=(%show i.mab) -:: =+ can=(slav %ud i.t.mab) -:: =+ sem=(need (~(get by can.sub.siq:beat:u.ouy) can)) -:: =. mow.u.ouy -:: :_(mow.u.ouy [hen %pass tea [%g %took [- + ~]:hap.sem you.u.ouy]]) -:: ?: =(0 can) -:: =< abet =< work =< abet -:: ?~ num.sem -:: (hear:woy ~ %& %json !>((joba %reload %b %&))) -:: ?> -.u.num.sem -:: =+ huq=``[p.+.sih (slot 3 (spec (slot 3 [typ +.sih])))] -:: =+ yoo=abet:(busk:(yule:u.ouy %nil) p.u.num.sem 0 huq) -:: yoo(can.sub.siq (~(put by can.sub.siq.yoo) can sem(num ~))) -:: ?. ?=(%json p.+.sih) -:: %^ hooj our ses :^ nap can ?=(%rust -.+.sih) -:: :+ %cast %json -:: :+ %done ~ -:: [p.+.sih (slot 3 (spec (slot 3 [typ +.sih])))] -:: =< abet =< work =< abet -:: (soon ?=(%rust -.+.sih) sem u.ouy can %show (wrap sem (json q.+.sih))) -:: == -:: :: -:: :: -:: [%honk @ @ @ ~] -:: %- galt -:: [(slav %p i.t.tea) i.t.t.tea (slav %ud i.t.t.t.tea) p.+.sih] -:: :: -:: [%hooj @ @ @ @ @ ~] -:: =+ ^= ouy -:: %- yolk:(gale (slav %p i.t.tea) i.t.t.tea) -:: (slav %ud i.t.t.t.tea) -:: ?~ ouy -:: ~& %hooj-made-no-ouy +>.$ -:: =+ can=(slav %ud i.t.t.t.t.tea) -:: =+ ful=(slav %f i.t.t.t.t.t.tea) -:: =+ sem=(need (~(get by can.sub.siq:beat:u.ouy) can)) -:: =< abet =< work =< abet -:: %^ soon (,? ful) sem :^ u.ouy can %show -:: %+ wrap sem -:: ?: ?=(%& -.p.+.sih) -:: (json q.q.q.p.p.+.sih) -:: (rong ~ %to-json-fail p.p.+.sih) -:: :: -:: [%hoop @ @ @ %mess @ @ ~] -:: =+ ^= ouy -:: %- yolk:(gale (slav %p i.t.tea) i.t.t.tea) -:: (slav %ud i.t.t.t.tea) -:: ?~ ouy -:: ~& %hoop-made-no-ouy +>.$ -:: ?- -.p.+.sih -:: %& -:: =* mab t.t.t.t.tea -:: %= +>.$ -:: mow -:: :_ mow -:: :* hen %pass tea %g -:: %mess [(slav %p i.t.mab) i.t.t.mab ~] -:: you:beat:u.ouy q.p.p.sih -:: == -:: == -:: :: -:: %| -:: =< abet =< work =< abet -:: %^ hear:(yule:u.ouy %meg) ~ %& -:: [%json !>((rong ~ %from-json-fail p.p.+.sih))] -:: == -:: :: -:: %thou :: remote return -:: ?> ?=([@ @ *] tea) -:: (hajj (slav %p i.tea) (slav %p i.t.tea) t.t.tea p.+.sih) -:: :: -:: %waft -:: ?. ?=([%hork @ ~] tea) -:: +>.$ -:: (gosh q.p.+.sih (slav %ud i.t.tea) ((hard httr) q.+.sih)) -:: :: -:: %wake -:: ?> ?=([%leep @ @ @ @ ~] tea) -:: =+ ^= ouy -:: %- yolk:(gale (slav %p i.t.tea) i.t.t.tea) -:: (slav %ud i.t.t.t.tea) -:: ?~ ouy -:: +>.$ -:: ?: (lth ~m2 (sub now tim.bet.siq:beat:u.ouy)) :: XX unnecessary -:: abet:work:amok:u.ouy -:: ~& %bad-timer -:: +>.$ -:: :: -:: %went -:: +>.$ == :: ++ apex @@ -569,40 +226,7 @@ %init :: register ownership %_ +>.$ hov ?~(hov [~ p.kyz] [~ (min u.hov p.kyz)]) -:: :: -:: own -:: %+ ~(put by own) -:: p.kyz -:: ^- serf -:: :* (cat 3 gub (rsh 3 1 (scot %p p.kyz))) -:: ~ -:: ~ -:: == == -:: :: -:: %them :: outbound request -:: ?~ p.kyz -:: =+ sud=(need (~(get by kes) hen)) -:: %= +>.$ -:: mow :_(mow [ged [%give %thus sud ~]]) -:: q.ask (~(del by q.ask) sud) -:: kes (~(del by kes) hen) -:: == -:: :: ~& eyre-them/(earn p.u.p.kyz) -:: %= +>.$ -:: mow :_(mow [ged [%give %thus p.ask p.kyz]]) -:: p.ask +(p.ask) -:: q.ask (~(put by q.ask) p.ask hen u.p.kyz) -:: kes (~(put by kes) hen p.ask) -:: == -:: :: -:: %they :: inbound response -:: =+ kas=(need (~(get by q.ask) p.kyz)) -:: :: ~& > eyre-they/[p.q.kyz (earn p.q.kas)] -:: %= +>.$ -:: mow :_(mow [p.kas [%give %thou q.kyz]]) -:: q.ask (~(del by q.ask) p.kas) -:: == :: %this :: inbound request =* sec p.kyz :: ? :: https bit @@ -622,14 +246,6 @@ %thud :: cancel request ~& e/gone/hen +>.$ -:: =+ dul=(~(get by lor) hen) -:: ?~ dul +>.$ -:: =. lor (~(del by lor) hen) -:: ?- -.q.u.dul -:: & =+ boy=(myth p.p.q.u.dul q.p.q.u.dul) -:: ?~(boy +>.$ abet:(idle:u.boy p.u.dul)) -:: | (hops p.q.u.dul p.u.dul) -:: == :: %wart :: remote request =+ mez=((soft gram) r.kyz) @@ -640,9 +256,6 @@ %lon !! %aut !! %hat !! -:: :: -:: %pr (hare p.p.kyz r.kyz q.p.kyz s.kyz) -:: %pc (here p.p.kyz q.p.kyz s.kyz) == == :: @@ -664,71 +277,6 @@ :: (back ~ dep %tang !>(mez)) :: XX broken tang->mime door in ford (resp sas text//html (poxo (lode dep (loga mez)))) :: -:: ++ gale :: ya from response -:: |= [our=ship ses=hole] -:: =+ sef=(need (~(get by own) our)) -:: =+ cyz=(need (~(get by wup.sef) ses)) -:: ~(. ya [our ses] sef cyz) -:: :: -:: ++ galt :: -:: |= [our=ship ses=hole num=@ud mez=(each bead (list tank))] -:: ^+ +> -:: =+ suf=(~(get by own) our) -:: ?~ suf +>.$ -:: =+ cuz=(~(get by wup.u.suf) ses) -:: ?~ cuz +>.$ -:: abet:work:(~(inch ya [our ses] u.suf u.cuz) num mez) -:: :: -:: ++ gosh :: receive %pr response -:: |= [him=ship num=@ud har=httr] -:: ^+ +> -:: =+ ryt=(~(get by fon) him) -:: ?~ ryt +>.$ -:: =+ zur=(~(get by q.rem.u.ryt) num) -:: ?~ zur +>.$ -:: %_ +>.$ -:: mow :_(mow [u.zur [%give %thou har]]) -:: fon (~(put by fon) him u.ryt(q.rem (~(del by q.rem.u.ryt) num))) -:: == -:: :: -:: ++ gout :: receive %clay -:: |= [our=ship ses=hole num=@ud rot=riot] -:: ^+ +> -:: =+ suf=(~(get by own) our) -:: ?~ suf +>.$ -:: =+ cuz=(~(get by wup.u.suf) ses) -:: ?~ cuz +>.$ -:: abet:work:(~(iota ya [our ses] u.suf u.cuz) num rot) -:: :: -:: ++ haji :: send %pc login -:: |= [our=ship him=ship ses=hole] -:: ^+ +> -:: +>.$(mow :_(mow [hen %pass ~ %a [%want [our him] [%r %pc %e ~] ses]])) -:: :: -:: ++ hajj :: send %pr response -:: |= [our=ship him=ship tus=path har=httr] -:: ^+ +> -:: +>.$(mow :_(mow [hen %pass ~ %a [%want [our him] [%r %pr %e tus] har]])) -:: :: -:: ++ hare :: receive request -:: |= [our=ship tus=path him=ship hor=*] -:: ^+ +> -:: =+ hux=((hard (unit httx)) hor) -:: %_ +>.$ -:: mow -:: :_ mow -:: :- hen -:: :^ %pass [(scot %p our) (scot %p him) tus] -:: %e -:: ?~(hux [%thud ~] [%this u.hux]) -:: == -:: :: -:: ++ here :: receive auth -:: |= [our=ship him=ship hez=*] -:: ^+ +> -:: =+ boy=(myth our (need ((sand %ta) ((hard ,@) hez)))) -:: ?~(boy +>.$ abet:(auth:u.boy him)) -:: :: ++ heck :: extract err beak |= [oar=ship pul=purl] ^- (unit beak) @@ -754,13 +302,6 @@ ^+ +> =+ hon=(horn pul q.hyx moh) ?^ hon (muff u.hon) - :: =^ wiq q.q.pul - :: ?~ q.q.pul [~ ~] - :: =+ nam=(cat 3 '~' i.q.q.pul) - :: =+ gow=(rush i.q.q.pul fed:ag) - :: ^- [(unit ship) (list ,@t)] - :: ?~(gow [~ q.q.pul] [gow t.q.q.pul]) - :: =+ oar=`(unit ship)`?^(wiq wiq (doss r.p.pul)) =+ oar=(fall (doss r.p.pul) (need hov)) =+ ext=(fall p.q.pul %urb) %- |=(a=(each ,_..hell tang) ?~(-.a p.a (fail 404 0v0 >%exit< p.a))) @@ -788,6 +329,10 @@ :: | ~| aute/p.u.hem ~| q.moh =+ hez=(huff our q.hyx pul moh) + =. q.cez.q.hez + ?. =(anon p.p.u.hem) + q.cez.q.hez + (~(put in q.cez.q.hez) p.p.u.hem) =. wup (~(put by wup) hez) ?^ cug.q.hez =+ rel=;html:script:"document.location.reload()" @@ -822,16 +367,6 @@ %own our == == -:: ?. (home oar) -:: (hork oar hyx) -:: (huff oar q.hyx pul moh) -:: :: -:: ++ home :: do we own? -:: |= who=ship -:: ^- ? -:: ?: (~(has by own) who) & -:: ?: (~(has by fon) who) | -:: !=(~ (sky /a/(scot %p who)/buck/(scot %da now))) :: ++ hoot :: clay request |= [our=ship wir=path his=ship rif=riff] @@ -846,64 +381,6 @@ :: ~& [%honk our num ses -.kas] (miff ~ %f [%exec our `kas]) :: -:: ++ hooj :: ford json request -:: |= [our=ship ses=hole nap=@ud can=@ud ful=? kas=silk] -:: %_ +> -:: mow -:: :_ mow -:: :^ hen %pass -:: ~[%hooj (scot %p our) ses (scot %ud nap) (scot %ud can) (scot %f ful)] -:: [%f [%exec our `kas]] -:: == -:: :: -:: ++ hops :: cancel remote -:: |= [him=ship num=@] -:: ^+ +> -:: =+ mun=(scot %ud num) -:: =+ rot=(need (~(get by fon) him)) -:: %_ +>.$ -:: mow -:: :_ mow -:: :- hen -:: :^ %pass [%hork (scot %p sor.rot) mun ~] -:: %a -:: [%want [sor.rot him] [%q %pr %e %hork mun ~] ~] -:: == -:: :: -:: ++ hork :: remote request -:: |= [him=ship hyx=httx] -:: ^+ +> -:: =+ ^= sur ^- (unit ship) -:: ?^ hov hov -:: ?^ own [~ p.n.own] -:: ~ -:: ?~ sur (fail 500 "no vessel available to proxy {}") -:: ?. (gth (met 3 him) (met 3 u.sur)) :: very permissive -:: (fail 500 "{} cannot proxy for {}") -:: =+ ^= rot ^- rote -:: =+ rut=(~(get by fon) him) -:: ?^ rut u.rut -:: [0 u.sur [0 ~]] -:: =+ num=p.rem.rot -:: =+ mun=(scot %ud num) -:: %_ +>.$ -:: lor (~(put by lor) hen num [%| him]) -:: mow -:: :_ mow -:: :- hen -:: :^ %pass [%hork (scot %p sor.rot) mun ~] -:: %a -:: [%want [sor.rot him] [%q %pr %e %hork mun ~] [~ hyx]] -:: :: -:: fon -:: %+ ~(put by fon) him -:: %_ rot -:: cnt +(cnt.rot) -:: p.rem +(p.rem.rot) -:: q.rem (~(put by q.rem.rot) num hen) -:: == -:: == -:: :: ++ horn :: irregular request |= [pul=purl cip=clip moh=moth] ^- (unit gift) @@ -934,12 +411,6 @@ |= [our=ship cip=clip pul=purl moh=moth] ^- [p=hole q=cyst] =* sec p.p.pul -:: =+ ^= sef ^- serf -:: =+ suf=(~(get by own) our) -:: ?^ suf u.suf -:: =+ sef=*serf -:: sef(pef (cat 3 gub (rsh 3 1 (scot %p our)))) :: XX transitional -:: =+ ^= saw ^- [p=hole q=cyst] =+ pef=(rsh 3 1 (scot %p our)) =+ lig=(coss pef q.moh) ?^ lig @@ -973,7 +444,6 @@ :: ~ :: [1 ~] == -:: abet:work:(~(into ya [our p.saw] sef q.saw) pul moh) :: ++ jive :: success json |= jon=json @@ -996,234 +466,8 @@ :: (weld (turn cug |=(a=@t ['set-cookie' a])) [%thou `httr`[sas ~[content-type/(moon mit)] [~ (taco rez)]]] :: -:: ++ myth :: load session -:: |= [our=ship ses=hole] -:: =+ suf=(~(get by own) our) -:: ?~ suf ~ -:: =+ cuz=(~(get by wup.u.suf) ses) -:: ?~ cuz ~ -:: [~ u=~(. ya [our ses] u.suf u.cuz)] -:: :: -:: ++ noon :: login page -:: |= [our=ship ses=hole whu=(unit ship) rul=tape] -:: ^- manx -:: =+ ^= sic ^- manx -:: ;script:''' -:: var seal = { -:: who: goal, -:: url: burl, -:: pas: null, -:: ses: sesh -:: } -:: var hist = [] -:: var hind = 0 -:: $( -:: function() { -:: $input = $('#input .line') -:: $prompt = $('#input .prompt') -:: $prompt.addClass('prefix') -:: $output = $('#output') -:: $input.focus() -:: $('body').click(function() { $input.focus() }) -:: ctrl = false; - -:: start = function(ship) { -:: $prompt.text('vessel: ~') -:: $input.attr('placeholder', 'ship-name') -:: if(ship) { -:: $input.val(ship) -:: } -:: } - -:: ident = function() { -:: seal.who = $input.val() - -:: if( (seal.who.length != 13) && -:: (seal.who.length != 6) && -:: (seal.who.length != 3) ) -:: { -:: $output.text('not a ship name - try again.'); -:: return false; -:: } - -:: if(seal.who !== host) { -:: var all = $.extend({}, seal, {oth:host}); -:: delete all.pas; - -:: console.log('redirect') -:: window.location= -:: "http://"+seal.who+".urbit.org/gul?" -:: + $.param(all); -:: return false; -:: } - -:: $output.text($prompt.text() + " " + seal.who) -:: $input.val('') -:: $input.attr('placeholder', 'ronber-bacnub-hanmev-labnyd') -:: $prompt.text('secret: ~') - -:: return true; -:: } - -:: login = function() { -:: seal.pas = $input.val() -:: var oth = /[&?]oth=[^&]*/.exec(location.search) -:: if(oth && oth.length) -:: seal.oth = oth[0].slice(5) - -:: output = $output.html() -:: console.log($output.html()) -:: $output.html(output.replace( -:: 'sorry. please try again.
','')) - -:: $.post("/pul", seal, function(data,xhr,status) { -:: console.log(data); -:: if(data.ok == true) { -:: document.location = data.next; -:: } else { -:: $output.prepend('sorry. please try again.
') -:: } -:: }) -:: } - -:: steps = [ident,login] -:: step = 0 -:: start(seal.who) -:: if(seal.who) { -:: ident() -:: step++ -:: } - -:: $input.on('keydown', function(e) { -:: if(e.keyCode == 17) { -:: ctrl = true -:: return; -:: } - -:: if(e.keyCode == 68 && -:: ctrl == true && -:: step == 1) { -:: $output.text('') -:: step = 0 -:: start(null) -:: return; -:: } - -:: if(e.keyCode == 13) { -:: if(steps[step]() && step < steps.length-1) -:: step++ -:: return; -:: } -:: }); - -:: $input.on('keyup', function(e) { -:: if(e.keyCode == 17) { -:: ctrl = false -:: } -:: }); -:: }) -:: ''' -:: =+ ^= cof -:: ;= -:: ; var host = '{(trip (rsh 3 1 (scot %p our)))}'; -:: ; var goal = '{?~(whu ~ (trip (rsh 3 1 (scot %p u.whu))))}'; -:: ; var burl = '{rul}'; -:: ; var sesh = '{(trip ses)}'; -:: == -:: => .(+.sic (weld `marl`cof `marl`+.sic)) -:: =+ jqu="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" -:: =+ ^= hed -:: ;head -:: ;title: urbit login -:: ;script(type "text/javascript", src jqu); -:: ;style:''' -:: body { -:: margin: 60px 120px; -:: font: normal 12px "Menlo" monospace; -:: background-color: #000; -:: color: #fff; -:: } - -:: #output { - -:: } - -:: #input .prompt { -:: display: inline-block; -:: margin-right: 12px; -:: } - -:: #input .line { -:: outline: none; -:: width: 80%; -:: border: 0; -:: background-color: transparent; -:: color: #fff; -:: font: normal 12px "Menlo" monospace; -:: } -:: ''' -:: == -:: =+ ^= bod ^- manx -:: ;body -:: ;div#output; -:: ;div#input -:: ;div.prompt; -:: ;input.line(type "text"); -:: == -:: == -:: =. +.bod (weld `marl`+.bod `marl`~[sic]) -:: ;html -:: ;+ hed -:: ;+ bod -:: == -:: :: -:: ++ rong -:: |= are=ares -:: %- jobe -:: :- [%ok %b |] -:: ?~ are ~ -:: :+ [%err %s p.u.are] -:: :+ %res %s -:: %- crip -:: %+ slag 2 -:: ^- tape -:: %+ roll q.u.are -:: |= [p=tank q=tape] -:: :(weld q "\\n" ~(ram re p)) -:: ~ -:: :: -:: ++ soon -:: |= [ful=? sem=stem ouy=_yo:ya can=@ud mab=?(%mess %show) jon=json] -:: ^+ yo:ya -:: =+ huq=``[%json !>(jon)] -:: ?~ num.sem -:: =+ woy=(yule:ouy ?-(mab %mess %meg, %show %sub)) -:: (hear:woy huq) -:: ?- -.u.num.sem -:: %& -:: =+ yoo=abet:(busk:(yule:ouy %nil) p.u.num.sem 0 huq) -:: yoo(can.sub.siq (~(put by can.sub.siq.yoo) can sem(num ~))) -:: %| -:: =+ ^= yoo -:: =< abet -:: %^ busk:(yule:(hear:(yule:ouy %sub) huq) %nil) -:: p.u.num.sem -:: 0 -:: `[%& %json !>((joba %ok %b &))] -:: yoo(can.sub.siq (~(put by can.sub.siq.yoo) can sem(num ~))) -:: == -:: :: -:: ++ wrap -:: |= [sem=stem jon=json] -:: %- jobe -:: :~ [%ship %s (rsh 3 1 (scot %p p.hap.sem))] -:: [%appl %s q.hap.sem] -:: [%path %s (crip )] -:: [%data `json`jon] -:: == -:: :: ++ ya :: session engine - =| [[our=ship ses=hole] cyst] ::serf cyst] +:: =| [[our=ship ses=hole] cyst] ::serf cyst] :: =* sef ->- =* cyz -> |% @@ -1239,1157 +483,6 @@ ++ inte ^- (unit $&([%lon purl] gram)) ~ -:: ++ abet :: resolve engine -:: ^+ ..ya -:: %= ..ya -:: own -:: (~(put by own) our sef(wup (~(put by wup) ses cyz))) -:: == -:: :: -:: ++ auth :: remote authorize -:: |= him=ship -:: %_(+> aut.ced (~(put ju aut.ced) %$ (scot %p him))) -:: :: -:: ++ iota :: fun change response -:: |= [num=@ud rot=riot] -:: ^+ +> -:: =+ pup=(~(get by q.rey) num) -:: ?~ pup -:: ~& [%iota-lost ses num rot] -:: +>.$ -:: ?> ?=(%way pez.u.pup) -:: +>.$(q.rey (~(put by q.rey) num u.pup(pez [%haz rot]))) -:: :: -:: ++ dove :: console waiting -:: |= [jon=json yov=(list ,@ud)] -:: ^+ +> -:: =+ noz=`pest`[%fin %mid /text/json (tact (pojo jon))] -:: |- ^+ +>.^$ -:: ?~ yov +>.^$ -:: =+ pup=(~(get by q.rey) i.yov) -:: ?~ pup $(yov t.yov) -:: ?> ?=(%way pez.u.pup) -:: $(yov t.yov, q.rey (~(put by q.rey) i.yov u.pup(pez noz))) -:: :: -:: ++ duty |= [nap=@ud you=ship] :: interface script -:: ^- cord -:: %^ cat 3 -:: %- crip -:: =- "window.urb = {(pojo (jobe -))}\0a" -:: :~ -:: [%ship (jape |1:)] -:: [%port (jone nap)] -:: [%oryx %s orx.ced] -:: [%auto %b %&] -:: [%user (jape |1:)] -:: == -:: ''' -:: window.urb.seqn_u = 0 -:: window.urb.seqn_h = 0 -:: window.urb.dely = 0 -:: window.urb.puls = 0 -:: window.urb.cabs = {} -:: window.urb.perms = { -:: pol:"gie", -:: sub:"tis", -:: uns:"tiu", -:: mes:"tim", -:: heb:"tih" -:: } - -:: window.urb.req = function(method,url,params,json,cb) { -:: var xhr = new XMLHttpRequest() -:: xhr.open(method.toUpperCase(), url) -:: if(json) -:: xhr.setRequestHeader("content-type", "text/json") - -:: _data = {} -:: if(params.data) { _data.data = params.data; } -:: if(params.ship) { _data.ship = params.ship; } -:: if(params.path) { _data.path = params.path; } -:: if(params.appl) { _data.appl = params.appl; } -:: if(params.mark) { _data.mark = params.mark; } -:: __data = {oryx: window.urb.oryx, xyro: _data} - -:: if(cb) { -:: xhr.onload = function() { -:: try { -:: err = null -:: res = { -:: status:this.status, -:: data: JSON.parse(this.responseText) -:: } -:: if(res.data.reload) -:: res.reload = res.data.reload -:: } catch(e) { -:: err = { -:: message:"Failed to parse JSON", -:: raw:this.responseText -:: } -:: res = null -:: } -:: cb(err,res) -:: } -:: xhr.onerror = function() { -:: cb({ -:: status:this.status, -:: data:this.responseText -:: }) -:: } -:: } -:: xhr.send(JSON.stringify(__data)) -:: } - -:: window.urb.reqq = [] -:: window.urb.qreq = function(method,url,params,json,cb) { -:: walk = function() { -:: qobj = {} -:: qobj.oargs = window.urb.reqq[0] -:: qobj.nargs = [].slice.apply(qobj.oargs,[0,4]) -:: qobj.nargs.push(function(){ -:: if(this.oargs[4]) -:: this.oargs[4].apply(window.urb,arguments) -:: window.urb.reqq.shift() -:: if(window.urb.reqq.length > 0) -:: walk() -:: }.bind(qobj)) -:: window.urb.req.apply(this,qobj.nargs) -:: } -:: l = window.urb.reqq.length -:: window.urb.reqq.push(arguments); -:: if(l == 0) { walk() } -:: } - -:: window.urb.gsig = function(params) { -:: path = params.path -:: if(!path) -:: path = "" -:: return params.appl+","+ -:: path.replace(/[^\x00-\x7F]/g, "")+","+ -:: params.ship -:: } - -:: window.urb.poll = function(params,cb) { -:: if(!params) -:: throw new Error("You must supply params to urb.poll.") - -:: var method, perm, url, $this -:: method = "get" -:: perm = params.type ? this.perms[params.type] : "gie" -:: json = false -:: if(perm[0] == "t") { -:: method = "put" -:: json = true -:: } -:: seqn = this.seqn_u -:: if(params.seqn) -:: seqn = params.seqn() -:: url = [perm,this.user,this.port,seqn] -:: url = "/"+url.join("/") - -:: this.puls = 1 - -:: $this = this -:: this.req(method,url,params,json,function(err,data) { -:: if(data){ -:: if (data.reload) { -:: return document.location.reload() -:: } else { -:: fn = $this.gsig(data.data) -:: if($this.cabs[fn]) { -:: $this.cabs[fn].call(this,err, -:: {status: data.status, data: data.data.data}) -:: } -:: } -:: } - -:: dely = params.dely ? params.dely : $this.dely - -:: if(err) -:: dely = dely+Math.ceil(dely*.02) -:: else { -:: $this.dely = 0 -:: if(params.incs) -:: params.incs() -:: else -:: $this.seqn_u++ -:: } - -:: setTimeout(function() { -:: $this.poll(params,cb) -:: },dely) -:: }) -:: } - -:: if (window.urb.auto) { -:: var tries = 0 -:: var cnt = 0 -:: var param = { -:: type:"pol" -:: } -:: window.urb.poll(param) -:: } - -:: window.urb.heartbeat = function() { -:: this.poll({ -:: type:"heb", -:: ship:this.ship, -:: dely:30000, -:: seqn:function() { -:: return window.urb.seqn_h -:: }, -:: incs:function() { -:: window.urb.seqn_h = window.urb.seqn_h+1 -:: } -:: },function() { -:: console.log('heartbeat.') -:: }) -:: } -:: window.urb.heartbeat() -:: ''' -:: :: -:: ++ fape :: dispatch %ape -:: |= [fur=(unit term) you=@p paw=path] -:: ^- (unit seam) -:: ?> ?=(~ fur) -:: ?> ?=([@ @ ~] paw) -:: :- ~ -:: :* %ape -:: you -:: (slav %ui (cat 3 '0i' i.paw)) -:: (slav %ui (cat 3 '0i' i.t.paw)) -:: == -:: :: -:: ++ fapg :: dispatch %apg -:: |= [fur=(unit term) you=@p paw=path] -:: ^- (unit seam) -:: =+ for=?^(fur u.fur %html) -:: ?> ?=(^ paw) -:: :- ~ -:: :* %apg -:: (need ((sand %tas) i.paw)) -:: you -:: for -:: (turn t.paw |=(a=@ `@ta`(need ((sand %ta) a)))) -:: == -:: :: -:: ++ faph :: dispatch %aph -:: |= [fur=(unit term) you=@p paw=path moh=moth] -:: ^- (unit seam) -:: ?> ?=(~ fur) -:: ?> ?=([@ @ ~] paw) -:: :- ~ -:: :* %aph -:: you -:: (slav %ui (cat 3 '0i' i.paw)) -:: (slav %ui (cat 3 '0i' i.t.paw)) -:: (need (ecci orx.ced moh)) -:: == -:: :: -:: ++ fapm :: dispatch %apm -:: |= [fur=(unit term) you=@p paw=path moh=moth] -:: ^- (unit seam) -:: ?> ?=(~ fur) -:: ?> ?=([@ @ ~] paw) -:: :- ~ -:: :* %apm -:: you -:: (slav %ui (cat 3 '0i' i.paw)) -:: (slav %ui (cat 3 '0i' i.t.paw)) -:: (need (eccu orx.ced moh)) -:: == -:: :: -:: ++ fapp -:: |= [fur=(unit term) you=@p paw=path] -:: ?> ?=([~ %js] fur) -:: ?> ?=(?([%hart ~] [@ %hart ~]) paw) -:: :- ~ -:: :* %app -:: you -:: ?~ t.paw -:: ~ -:: (some (slav %ui (cat 3 '0i' i.paw))) -:: == -:: :: -:: ++ faps :: dispatch %aps -:: |= [fur=(unit term) you=@p paw=path moh=moth] -:: ^- (unit seam) -:: ?> ?=(~ fur) -:: ?> ?=([@ ~] paw) -:: :- ~ -:: :* %aps -:: you -:: (slav %ui (cat 3 '0i' i.paw)) -:: (need (ecca orx.ced moh)) -:: == -:: :: -:: ++ fapu :: dispatch %apu -:: |= [fur=(unit term) you=@p paw=path moh=moth] -:: ^- (unit seam) -:: ?> ?=(~ fur) -:: ?> ?=([@ ~] paw) -:: :- ~ -:: :* %apu -:: you -:: (slav %ui (cat 3 '0i' i.paw)) -:: (need (ecca orx.ced moh)) -:: == -:: :: -:: ++ flea :: permissive decimal -:: |= txt=@t -:: ^- (unit ,@ud) -:: =+ zac=(slay txt) -:: ?: ?=([~ %$ %ud @] zac) -:: [~ q.p.u.zac] -:: =+ soc=(rush txt dim:ag) -:: ?~(soc ~ [~ u.soc]) -:: :: -:: ++ foal :: url from query -:: |= [nam=@t yaq=(map ,@t ,@t)] -:: ^- (unit purl) -:: (biff (~(get by yaq) %url) epur) -:: :: -:: ++ folk :: seal from query -:: |= quy=quay -:: ^- (unit seal) -:: =+ yaq=(~(gas by *(map ,@t ,@t)) quy) -:: =+ pyl=(foal %url yaq) -:: =+ wit==(%yes (fall (~(get by yaq) %wit) %no)) -:: =+ huw=(~(get by yaq) %who) -:: =+ whu=?~(huw ~ (rush u.huw fed:ag)) -:: =+ pus=(~(get by yaq) %pas) -:: =+ tuh=(~(get by yaq) %oth) -:: =+ thu=?~(tuh ~ (rush u.tuh fed:ag)) -:: =+ sus=(~(get by yaq) %ses) -:: =+ foy=?~(sus ~ ?~(thu ~ [~ u.thu u.sus])) -:: ?~ pyl ~ -:: ?: &(wit |(=(~ whu) =(~ ses))) ~ -:: :: ~& [%folk-quay whu u.pyl wit foy pus] -:: [~ whu u.pyl wit foy pus] -:: :: -:: ++ fool :: domestic login get -:: |= quy=quay -:: ^- (unit seam) -:: (bind (folk quy) |=(a=seal [%lon a])) -:: :: -:: ++ foom :: domestic login post -:: |= moh=moth -:: ^- (unit seam) -:: ?. ?& ?=(^ r.moh) -:: :: .= [~ 'application/x-www-form-urlencoded' ~] -:: :: (~(get by q.moh) 'content-type') -:: == ~ -:: =+ yuq=(rush q.u.r.moh yquy:epur) -:: ?~(yuq ~ (fool u.yuq)) -:: :: -:: ++ flub :: console request -:: |= [paw=(list ,@t) muh=(unit moth)] -:: ^- (unit seam) -:: ?: ?=([@ ~] paw) -:: ?^ muh ~ -:: =+ fee=(flea i.paw) -:: ?~ fee ~ -:: [~ %con u.fee] -:: ?. ?=([@ @ ~] paw) ~ -:: =+ [fee=(flea i.paw) fum=(flea i.t.paw)] -:: ?. &(?=(^ fee) ?=(^ fum)) ~ -:: ?: |(?=(~ muh) ?=(~ r.u.muh)) -:: [~ %cog u.fee u.fum] -:: ?. =([~ 'text/json' ~] (~(get by q.u.muh) 'content-type')) -:: ~ -:: =+ jun=`(unit json)`(rush q.u.r.u.muh apex:poja) -:: ?~ jun -:: ~ -:: [~ %cop u.fee u.fum u.jun] -:: :: -:: :: -:: ++ foin :: version request -:: |= [fur=(unit term) you=@p paw=(list ,@t) quy=quay] -:: ^- (unit seam) -:: =. aut.ced (~(put ju aut.ced) %$ (scot %p you)) :: XX backwards -:: ?. ?& ?=(~ fur) -:: ?=(~ quy) -:: ?=([@ @ ~] paw) -:: ((sane %tas) i.t.paw) -:: == ~ -:: %+ bind -:: ^- (unit moat) -:: =+ soy=(slay i.paw) -:: ?~ soy ~ -:: ?+ u.soy -:: ~ -:: :: -:: [%$ ?(%da %ud %tas) @] -:: [~ (case p.u.soy) (case p.u.soy) /] -:: :: -:: [%many [%$ ?(%da %ud %tas) @] [%$ ?(%da %ud %tas) @] ~] -:: [~ (case i.p.u.soy) (case i.t.p.u.soy) /] -:: == -:: |= mot=moat -:: `seam`[%det i.t.paw mot] -:: :: -:: ++ funk :: functional request -:: |= [nep=@tas fur=(unit term) you=@p paw=(list ,@t) quy=quay] -:: ^- (unit seam) -:: =. aut.ced (~(put ju aut.ced) %$ (scot %p you)) :: XX backwards -:: =+ won==(%n (rsh 3 2 nep)) -:: %+ bind -:: ^- (unit ,[mark tube]) -:: =+ ^= zac ^- (unit ,[p=@ta q=path]) -:: ?: won -:: [~ (scot %da now) paw] -:: ?~ paw ~ -:: =+ zac=(slay i.paw) -:: ?. ?=([~ %$ ?(%ud %da %tas) *] zac) ~ -:: [~ i.paw t.paw] -:: ?: ?| ?=(~ zac) -:: ?=(~ q.u.zac) -:: !(levy t.q.u.zac (sane %ta)) -:: == ~ -:: :+ ~ ?~(fur %html u.fur) -:: ^- tube -:: :* (scot %p our) -:: i.q.u.zac -:: p.u.zac -:: t.q.u.zac -:: == -:: |= [for=mark toe=tube] -:: ^- seam -:: =+ nyp=?.(=(%i (cut 3 [1 1] nep)) /[nep] /[nep]/(rsh 3 1 (scot %p you))) -:: :^ %fun for -:: toe(s (weld s.toe `path`[(flux nyp quy) %web ~])) -:: ?. won ~ -:: :_ ~ -:: =+ pey="{(scag 2 (trip nep))}v" -:: =. pey %+ weld pey -:: ?. =(%i (snag 1 pey)) -:: "" -:: "/{(slag 1 (scow %p you))}" -:: =+ ven=+((,@ (need (sky %cw p.toe q.toe r.toe ~)))) -:: ;script@"/~/on/{pey}/{(scow %ud ven)}/{(trip q.toe)}.js"; -:: :: -:: ++ holt :: login redirect -:: |= [whu=(unit ship) pul=purl] -:: ^- (unit seam) -:: :+ ~ -:: %red -:: :: :+ [p.p.pul q.p.pul r.p.pul] -:: :+ [| q.p.pul r.p.pul] :: XX https -:: [p.q.pul /gul] :: XX js discrimination -:: :- [%url (crip (earn pul(p.p |)))] -:: ?~ whu ~ -:: [%who (rsh 3 1 (scot %p u.whu))]~ -:: :: -:: ++ holy :: structured request -:: |= [pul=purl moh=moth] -:: ^- (unit seam) -:: ?~ q.q.pul ~ -:: =* nep i.q.q.pul -:: =+ paw=t.q.q.pul -:: =+ [one=(end 3 1 nep) two=(cut 3 [1 1] nep) tri=(cut 3 [2 1] nep)] -:: ?. ?& ?- p.moh -:: %conn | :: connect -:: %delt | :: delete -:: %get =(%g one) :: get -:: %head =(%g one) :: head -:: %opts | :: options -:: %post =(%p one) :: post -:: %put =(%t one) :: put -:: %trac | :: trace -:: == -:: :: -:: ?+ two | -:: %e & :: stranger -:: %u p.p.pul :: guest -:: %i p.p.pul :: neighbor -:: %o p.p.pul :: identified -:: == -:: :: -:: ?= $? %g :: app get -:: %c :: console -:: %e :: app update -:: %f :: functional -:: %v :: functional version -:: %l :: local login -:: %m :: app message -:: %r :: app response -:: %s :: app subscribe -:: %h :: app heartbeat -:: %p :: app script by port -:: %n :: now -:: %u :: app unsubscribe -:: %z :: app version -:: == -:: tri -:: :: -:: !&(=(%c tri) !=(%o two)) -:: =(3 (met 3 nep)) -:: == -:: ?: &(=(%get p.moh) ?=([~ [@ ~]] q.pul)) :: app shortcut -:: =- $(q.pul [`%html -]) -:: =+ ato=(~(tap in (~(get ju aut.ced) %$))) -:: =+ att=`(list ship)`(murn ato |=(a=span (slaw %p a))) -:: ?~ att [%geg i.q.q.pul ~] -:: ?: (~(has in (sa att)) our) -:: [%gog i.q.q.pul ~] -:: :+ %gig -:: (rsh 3 1 (scot %p (snag 0 (sort att lth)))) -:: /[i.q.q.pul] -:: ~ -:: =^ yun paw -:: ?+ two ~ -:: ?(%e %u) [`@`(shaf %fake ses) paw] -:: %i ?~ paw ~ -:: [(slav %p (cat 3 '~' i.paw)) t.paw] -:: %o [our paw] -:: == -:: ?: &(=(%i two) !(lash yun) !=(yun (shaf %fake ses))) -:: (holt [~ yun] pul) -:: ?: &(=(%o two) !(lash our)) -:: (holt [~ our] pul) -:: ?+ one ~ -:: %g -:: ?+ tri ~ -:: ?(%f %n) (funk nep p.q.pul yun paw r.pul) -:: %v (foin p.q.pul yun paw r.pul) -:: %c (flub paw ~) -:: %l (fool r.pul) -:: %g (fapg p.q.pul yun paw) -:: %e (fape p.q.pul yun paw) -:: %p (fapp p.q.pul yun paw) -:: == -:: :: -:: %p -:: ?+ tri ~ -:: %l (foom moh) -:: %m (fapm p.q.pul yun paw moh) -:: %s (faps p.q.pul yun paw moh) -:: %u (fapu p.q.pul yun paw moh) -:: == -:: :: -:: %t -:: ?+ tri ~ -:: %c (flub paw [~ moh]) -:: %h (faph p.q.pul yun paw moh) -:: %m (fapm p.q.pul yun paw moh) -:: %s (faps p.q.pul yun paw moh) -:: %u (fapu p.q.pul yun paw moh) -:: == -:: == -:: :: -:: ++ idle :: cancel request -:: |= num=@ud -:: ^+ +> -:: =+ pup=(~(get by q.rey) num) -:: ?~ pup +>.$ -:: =. q.rey (~(del by q.rey) num) -:: ?. ?=(%way pez.u.pup) +>.$ -:: ?: ?=(%det -.som.u.pup) -:: +>.$(..ya (hoot our num ses `riff`[p.som.u.pup ~])) -:: ?: ?=(%fun -.som.u.pup) -:: +>.$(..ya (hone our num ses)) -:: +>.$ -:: :: -:: ++ bush :: error response -:: |= [cod=@ud msg=@t num=@ud] -:: ^+ +> -:: =+ pup=(~(get by q.rey) num) -:: ?~ pup +>.$ -:: %= +>.$ -:: q.rey -:: %+ ~(put by q.rey) num -:: %= u.pup -:: pez -:: `pest`[%fin %raw cod ~[content-type/'text/plain'] `(taco msg)] -:: == -:: == -:: :: -:: ++ bust :: no-content response -:: |= [cod=@ud num=@ud] -:: ^+ +> -:: =+ pup=(~(get by q.rey) num) -:: ?~ pup +>.$ -:: :: ?> ?=(%way pez.u.pup) -:: %= +>.$ -:: q.rey -:: %+ ~(put by q.rey) num -:: u.pup(pez [%fin %raw cod *mess `*octs]) -:: == -:: :: -:: ++ erle :: url localize -:: |= [his=ship pul=purl] ^- purl -:: =+ pod=(mo (turn (~(tap by dop)) |=([p=host q=ship] [q p]))) -:: ?: (~(has by pod) his) -:: pul(p [& ~ (~(got by pod) his)]) -:: ?: ?=(hoke r.p.pul) -:: ~| %no-port -:: pul(q.p [~ ?+(his !! %~zod 8.443)]) :: XX -:: pul(p [& ~ [~ /org/urbit/(rsh 3 1 (scot %p his))]]) -:: :: -:: ++ inch :: function built -:: |= [num=@ud mez=(each bead (list tank))] -:: ^+ +> -:: =+ pup=(~(get by q.rey) num) -:: ?~ pup -:: ~& [%inch-lost ses num mez] -:: +>.$ -:: ?> ?=(%way pez.u.pup) -:: +>.$(q.rey (~(put by q.rey) num u.pup(pez [%fud mez]))) -:: :: -:: ++ into :: introduce -:: |= [pul=purl moh=moth] -:: ^+ +> -:: =+ num=p.rey -:: %= +>.$ -:: lor (~(put by lor) hen num [%& our ses]) -:: p.rey +(num) -:: q.rey -:: %+ ~(put by q.rey) num -:: ^- pimp -:: :* !?=(%head p.moh) -:: p.q.pul -:: hen -:: *seam -:: `pest`[%raw pul moh] -:: ~ -:: == -:: == -:: :: -:: ++ iota :: change response -:: |= [num=@ud rot=riot] -:: ^+ +> -:: =+ pup=(~(get by q.rey) num) -:: ?~ pup -:: ~& [%iota-lost ses num rot] -:: +>.$ -:: ?> ?=(%way pez.u.pup) -:: +>.$(q.rey (~(put by q.rey) num u.pup(pez [%haz rot]))) -:: :: -:: ++ lass :: load secret -:: ^- @ta -:: =+ pax=/(scot %p our)/code/(scot %da now)/(scot %p our) -:: %^ rsh 3 1 -:: (scot %p (,@ (need (sky %a pax)))) -:: :: -:: ++ lash :: user is authorized -:: |=(a=ship (~(has ju aut.ced) %$ (scot %p a))) -:: :: -:: ++ redi :: js login redirect -:: |= pul=purl ^- tape -:: "window.location = '{(earn pul)}". -:: "{?~(r.pul "?" "&")}url=' +". -:: "encodeURIComponent(window.location)" -:: :: -:: ++ step :: step in work -:: |- ^+ + -:: =^ zib +.$ -:: =+ yub=q.rey -:: |- ^- [(list ,[p=@ud q=pimp]) _+.^$] -:: ?~ yub [~ +.^$] -:: =^ sid +.^$ $(yub l.yub) -:: =^ dex +.^$ $(yub r.yub) -:: =^ top +.^$ (wink n.yub) -:: =+ pot=`(list ,[p=@ud q=pimp])`?~(top ~ [[p.n.yub u.top] ~]) -:: [:(weld pot dex sid) +.^$] -:: +.$(q.rey (~(gas by `_q.rey`~) zib)) - -:: ++ wink :: advance request -:: |= [num=@ud pip=pimp] -:: ^- [(unit pimp) _+>] -:: :: ~& wink-do/[?@(pez.pip pez.pip -.pez.pip) -.som.pip] -:: ?- pez.pip -:: %way [[~ pip] +>.$] -:: %new -:: ?- -.som.pip -:: %ape :: stream update -:: :: ~& :~ %eyre-ape -:: :: [%owner our] -:: :: [%requester num] -:: :: [%app p.som.pip] -:: :: [%user q.som.pip] -:: :: [%instance r.som.pip] -:: :: [%stream s.som.pip] -:: :: [%request t.som.pip] -:: :: == -:: [`(fall +< -(pez %way)) +>]:[pip (yoke num +.som.pip)] -:: :: -:: %apg :: simple get -:: :: ~& :~ %eyre-apg -:: :: [%owner our] -:: :: [%requester num] -:: :: [%app p.som.pip] -:: :: [%user q.som.pip] -:: :: [%logo r.som.pip] -:: :: [%path s.som.pip] -:: :: == -:: :- [~ pip(pez %way)] -:: (yokg num p.som.pip q.som.pip s.som.pip) -:: :: -:: %aph :: heartbeat -:: :: ~& [%wink-aph +.som.pip] -:: (yokh num +.som.pip) -:: :: -:: %apm :: message -:: :: ~& [%wink-apm +.som.pip] -:: :- [~ pip(pez %way)] -:: (yokm num +.som.pip) -:: :: -:: %app :: script by port -:: :: ~& [%wink-app +.som.pip] -:: (yokp num +.som.pip) -:: :: -:: %aps :: subscribe -:: :: ~& [%wink-aps +.som.pip] -:: :- [~ pip(pez %way)] -:: (yoks num +.som.pip) -:: :: -:: %apu :: unsubscribe -:: :: ~& [%wink-apu +.som.pip] -:: (yoku num +.som.pip) -:: :: -:: %con -:: !! -:: :: -:: %cog -:: !! -:: :: -:: %cop -:: !! -:: :: -:: %det -:: :- [~ pip(pez %way)] -:: +>.$(..ya (hoot our num ses [p.som.pip ~ [%| q.som.pip]])) -:: :: -:: %fun -:: :- [~ pip(pez %way)] -:: =+ bem=`beam`(need (tome q.som.pip)) -:: =+ kas=`silk`[%cast %mime `silk`[%boil p.som.pip bem ~]] -:: +>.$(..ya (honk our num ses kas)) -:: :: -:: %lon -:: ^- [(unit pimp) _+>.$] -:: ?~ pus.p.som.pip -:: :_ +>.$ -:: ?: ?~ whu.p.som.pip | -:: (lash u.whu.p.som.pip) -:: [~ pip(som [%red pul.p.som.pip])] -:: ?: wit.p.som.pip -:: [~ pip(pez [%who %$ (scot %p (need whu.p.som.pip))])] -:: =+ rul=(earn pul.p.som.pip) -:: =+ sus=?~(foy.p.som.pip ses q.u.foy.p.som.pip) -:: ~& auth-request/secret=`cord`lass -:: =+ ham=(noon our sus whu.p.som.pip rul) -:: [~ pip(pez [%fin %ham ham])] -:: ?. =(lass u.pus.p.som.pip) -:: :_ +>.$ -:: :- ~ -:: %= pip -:: pez -:: [%fin %mid /text/json (tact (pojo (jobe [%ok [%b |]]~)))] -:: == -:: =. aut.ced (~(put ju aut.ced) %$ (scot %p (need whu.p.som.pip))) -:: ?~ foy.p.som.pip -:: =+ ^= jon -:: %- jobe -:: :~ [%ok [%b &]] -:: [%next (jape (earn pul.p.som.pip))] -:: == -:: :_(+>.$ [~ pip(pez [%fin %mid /text/json (tact (pojo jon))])]) -:: =. ..ya (haji our u.foy.p.som.pip) -:: =+ ^= lup ^- purl -:: %+ erle p.u.foy.p.som.pip -:: :+ `hart`p.pul.p.som.pip -:: ^- pork -:: [~ /gul] -:: ^- quay -:: :~ [%who (rsh 3 1 (scot %p (need whu.p.som.pip)))] -:: [%url (crip (earn pul.p.som.pip))] -:: [%wit %yes] -:: == -:: =+ jon=(jobe ~[[%ok [%b &]] [%next (jape (earn lup))]]) -:: :_(+>.$ [~ pip(pez [%fin %mid /text/json (tact (pojo jon))])]) -:: :: -:: %red -:: :_ +>.$ -:: :- ~ -:: %= pip -:: pez -:: :- %fin -:: =+ pul=p.som.pip -:: ?: ?=([~ %js] p.q.pul) :: XX js discrimination -:: [%mid /application/javascript (tact (redi pul(p.q ~)))] -:: =. p.q.pul ~ -:: :- %raw -:: :+ 307 -:: [%location (crip (earn pul))]~ -:: ~ -:: == -:: :: -:: %sil -:: :- [~ pip(pez %way)] -:: +>.$(..ya (honk our num ses q.som.pip)) -:: == -:: :: -:: [%err *] -:: [~ +>.$(..ya (muff(hen hen.pip) [%thou (loft `love`[%zap +.pez.pip])]))] -:: :: -:: [%fin *] -:: =+ har=(loft p.pez.pip) -:: =. q.har (weld (turn cug |=(a=@t ['set-cookie' a])) q.har) -:: [~ +>.$(..ya (muff(hen hen.pip) [%thou har]))] -:: :: -:: [%haz *] -:: :_ +>.$ -:: [~ pip(pez [%fin %wan 'Hello, world' ~])] -:: :: -:: [%fud *] -:: =+ ^= mog ^- (list manx) -:: ?: ?=(%fun -.som.pip) -:: (weld r.som.pip sip.pip) -:: sip.pip -:: :_ +>.$ -:: :- ~ -:: %= pip -:: pez -:: ^- pest -:: ?- -.p.pez.pip -:: | =+ mad=(loga "server error" mog p.p.pez.pip) -:: :- %fin -:: :- %raw -:: ^- httr -:: :+ 500 -:: ~[content-type/'text/html'] -:: [~ (tact (poxo mad))] -:: & [%fin (lofa mog (lopo q.p.p.pez.pip))] -:: == -:: == -:: :: -:: [%raw *] -:: :_ +>.$ -:: ^- (unit pimp) -:: :- ~ -:: =+ hoy=(holy p.pez.pip) -:: ?~ hoy -:: pip(pez [%err 404 [[%leaf "invalid request"] ~]]) -:: pip(som u.hoy, pez %new) -:: :: -:: [%who *] -:: :_ +>.$ -:: ?.((~(has ju aut.ced) p.pez.pip q.pez.pip) [~ pip] [~ pip(pez %new)]) -:: == - -:: ++ work -:: |- ^+ + -:: =+ sez=step -:: ?: =(rey.sez rey) sez -:: $(+ sez) -:: :: -:: ++ yoke :: long poll -:: |= [num=@ud you=ship nap=@ud cnt=@ud] -:: ^- [(unit pimp) _+>] -:: =+ yon=(yolk nap) -:: ?~ yon `(bust 204 num) -:: =. +>.$ abet:(hire:(yule %sub):u.yon cnt num) -:: :_ +>.$ -:: =+ pup=(~(get by q.rey) num) -:: ?~ pup ~ -:: ?. ?=(%sil -.som.u.pup) ~ -:: `u.pup -:: :: -:: ++ yokg :: main call -:: |= [num=@ud app=term you=ship pax=path] -:: ^+ +> -:: ?< (~(has by sok) num) -:: abet:(~(self yo num you *sink) app pax) -:: :: -:: ++ yokh :: heartbeat -:: |= [num=@ud you=ship nap=@ud cnt=@ud jon=json] -:: ^- [(unit pimp) _+>] -:: =+ yon=(yolk nap) -:: ?~ yon [~ (bust 204 num)] -:: [- abet:+]:(beat:u.yon cnt num jon) -:: :: -:: ++ yokm :: message -:: |= [num=@ud you=ship nap=@ud cnt=@ud hap=hasp for=mark jon=json] -:: ^+ +> -:: =+ yon=(yolk nap) -:: ?~ yon (bust 204 num) -:: abet:(post:u.yon cnt num hap for jon) -:: :: -:: ++ yokp :: script by port -:: |= [num=@ud you=ship nup=(unit ,@ud)] -:: ^- [(unit pimp) _+>] -:: ?~ nup -:: $(nup [~ num], +> ~(harp yo num you *sink)) -:: =+ yon=(yolk u.nup) -:: ?~ yon -:: =+ err=(bust 204 num) -:: [`(need (~(get by q.rey.err) num)) err] -:: [- abet:+]:(hark:u.yon num) -:: :: -:: ++ yoks :: subscribe -:: |= [num=@ud you=ship nap=@ud hap=hasp pax=path] -:: =+ yon=(yolk nap) -:: ?~ yon (bust 204 num) -:: abet:(scud:u.yon num hap pax) -:: :: -:: ++ yoku :: unsubscribe -:: |= [num=@ud you=ship nap=@ud hap=hasp pax=path] -:: ^- [(unit pimp) _+>] -:: =+ yon=(yolk nap) -:: ?~ yon [~ (bust 204 num)] -:: [- abet:+]:(scad:u.yon num hap pax) -:: :: -:: ++ yolk :: yo by instance -:: |= nap=@ud -:: =+ suy=(~(get by sok) nap) -:: ?~ suy ~ -:: (some ~(. yo nap=nap you=p.u.suy siq=q.u.suy)) -:: :: -:: ++ yo :: app instance -:: |_ $: nap=@ud :: instance number -:: you=ship :: client identity -:: siq=sink :: instance state -:: == -:: ++ abet :: resolve -:: %_ ..yo -:: sok (~(put by sok) nap [you siq]) -:: == -:: :: -:: ++ amok :: demolish -:: ^+ ..yo -:: =+ wuh=(~(tap by can.sub.siq)) -:: |- ^+ ..yo -:: ?~ wuh -:: %= ..yo -:: sok (~(del by sok) nap) -:: == -:: %= $ -:: wuh t.wuh -:: ..amok -:: (pass(hen hen.q.i.wuh) `p.i.wuh [%g %nuke [- + ~]:hap.q.i.wuh you]) -:: == -:: :: -:: ++ beat -:: |= [cnt=@ud num=@ud jon=json] -:: ^- [(unit pimp) _+>] -:: ?. =(cnt num.bet.siq) -:: [~ +>.$(..yo (bust 204 num))] -:: =. +>.$ hast -:: =. bet.siq bet.siq(num +(num.bet.siq), tim now, hen hen) -:: =. +>.$ hawa -:: =. +>.$ (hire:(yule %bet) cnt num) -:: =. +>.$ (hear:(yule %bet) ~ %& %json !>((joba %a-ok %b %&))) -:: [`(need (~(get by q.rey) num)) +>.$] -:: :: -:: ++ hark -:: |= num=@ud -:: ^- [(unit pimp) _+>] -:: =. +>.$ abet:(busk:(yule %nil) num *@ ~ %& %js !>((duty nap you))) -:: [`(need (~(get by q.rey) num)) +>.$] -:: :: -:: ++ harp -:: %* abet hawa -:: tim.bet.siq now -:: num.sub.siq 1 -:: == -:: :: -:: ++ hast -:: %_ . -:: mow -:: :_ mow -:: :- hen.bet.siq -:: :^ %pass -:: [%leep (scot %p our) ses (scot %ud nap) (scot %ud num.bet.siq) ~] -:: %t -:: :- %rest (add ~m2 tim.bet.siq) -:: == -:: :: -:: ++ hawa -:: %_ . -:: mow -:: :_ mow -:: ^- move -:: :- hen.bet.siq -:: :^ %pass -:: [%leep (scot %p our) ses (scot %ud nap) (scot %ud num.bet.siq) ~] -:: %t -:: :- %wait (add ~m2 now) -:: == -:: :: -:: ++ hoop :: request path -:: |= can=(each ,@ud hasp) -:: ^- path -:: :* %hoop -:: (scot %p our) -:: ses -:: (scot %ud nap) -:: ?- -.can -:: %& [%show (scot %ud p.can) ~] -:: %| [%mess (scot %p p.p.can) q.p.can ~] -:: == -:: == -:: :: -:: ++ pass :: pass -:: |= [can=(each ,@ud hasp) noh=note] -:: ^+ +> -:: +>(mow [[hen %pass (hoop can) noh] mow]) -:: :: -:: ++ post :: transmit -:: |= [cnt=@ud num=@ud hap=hasp for=mark jon=json] -:: ^+ +> -:: =. +>.$ -:: ?. =(cnt num.meg.siq) +>.$ -:: %+ pass(num.meg.siq +(num.meg.siq)) [%| hap] -:: `note`[%f %exec our ~ %cast for %done ~ %json !>(jon)] -:: ?. =(+(cnt) num.meg.siq) -:: +>.$(..yo (bust 204 num)) -:: (hire:(yule %meg) cnt num) -:: :: -:: ++ scad -:: |= [num=@ud hap=hasp pax=path] -:: ^- [(unit pimp) _+>] -:: =. +>.$ -:: %- ~(rep by can.sub.siq) -:: =+ [*p=[p=@ud q=stem] q=+>.$] |. -:: ?. =([hap pax] [hap.q.p pax.q.p]) q -:: =. q q(can.sub.siq (~(del by can.sub.siq:q) p.p)) -:: ([-(hen +)]:[pass:q hen.q.p] `p.p %g %nuke [- + ~]:hap you) -:: =+ huq=[~ %& %json !>((joba %ok %b %&))] -:: =. +>.$ abet:(busk:(yule %nil) num 0 huq) -:: [`(need (~(get by q.rey) num)) +>.$] -:: :: -:: ++ scud :: subscribe -:: |= [num=@ud hap=hasp pax=path] -:: =. can.sub.siq -:: (~(put by can.sub.siq) num.sub.siq [hap pax hen `[%| num]]) -:: =. +>.$ (pass `num.sub.siq `note`[%g %show [- + ~]:hap you pax]) -:: =. num.sub.siq +(num.sub.siq) -:: +>.$ -:: :: -:: ++ self :: request main -:: |= [app=term pax=path] -:: ^+ +> -:: =. tim.bet.siq now -:: =. can.sub.siq -:: (~(put by can.sub.siq) 0 [[our app] pax hen `[%& nap]]) -:: =. num.sub.siq +(num.sub.siq) -:: =. hen.bet.siq hen -:: =. +>.$ hawa -:: (pass `0 [%g %show [our app ~] you pax]) -:: :: -:: ++ yule -:: |= pla=?(%bet %meg %sub %nil) -:: %~ . yu :- pla -:: =< wig -:: ?-(pla %bet bet.siq, %meg meg.siq, %sub sub.siq, %nil [wig=*swig ~]) -:: :: -:: ++ yu :: swig state -:: |_ [pla=?(%bet %meg %sub %nil) wig=swig] -:: ++ abet -:: ^+ ..yu -:: ?- pla -:: %bet %_(..yu wig.bet.siq wig) -:: %meg %_(..yu wig.meg.siq wig) -:: %sub %_(..yu wig.sub.siq wig) -:: %nil ..yu -:: == -:: :: -:: ++ busk :: seam result -:: |= $: num=@ud -:: cnt=@ud -:: huq=(unit (each cage cage)) -:: == -:: ^+ +> -:: =+ pup=(~(get by q.rey) num) -:: ?~ pup +>.$ :: XX a hack -:: =. wig ?: ?=(%nil pla) wig -:: ?. =(toy.wig cnt) -:: ?>(=(toy.wig +(cnt)) wig) -:: %= wig -:: toy +(toy.wig) -:: red -:: ?: =(0 toy.wig) red.wig -:: :: ~& [%busk [%sent cnt] [%lost (dec toy.wig)]] -:: (~(del by red.wig) (dec toy.wig)) -:: == -:: =+ pip=u.pup -:: =+ ^= sip -:: ?. ?=(%apg -.som.pip) sip.pip -:: =* his q.som.pip -:: =+ mef=?:(=(our his) "gop" "gip/{|1:}") :: e.g. "gip/zod" -:: =+ hat="/{mef}/{(pojo (jone nap))}/hart.js" -:: [;script(src hat); ;meta(charset "utf-8"); sip.pip] -:: ?~ huq +>.$(..yo (bust 404 num)) -:: %= +>.$ -:: q.rey -:: %+ ~(put by q.rey) num -:: ^- pimp -:: %= pip -:: pez %new -:: sip sip -:: som ^- seam -:: :+ %sil -:: ?:(-.u.huq 200 203) -:: =+ don=`silk`[%done ~ `cage`p.u.huq] -:: ^- silk -:: :+ %cast %mime -:: ?~ fur.pip don -:: `silk`[%cast u.fur.pip don] -:: == -:: == -:: :: -:: ++ dumb :: reset -:: ^+ ..yu -:: =+ dum=(~(tap by wan.wig) ~) -:: |- ^+ ..yu -:: ?~ dum ..yu :: XX drop stream -:: $(dum t.dum, ..yo (bust 404 q.i.dum)) -:: :: -:: ++ hear :: produce -:: |= huq=(unit (each cage cage)) -:: ^+ ..yu -:: =< abet -:: =+ cnt=cnt.wig -:: =+ dul=(~(get by wan.wig) cnt) -:: :: ~& :~ %yu-hear -:: :: [%instance nap] -:: :: [%produced cnt] -:: :: ?~(dul %unrequested [%requester u.dul]) -:: :: == -:: =: cnt.wig +(cnt.wig) -:: wan.wig ?~(dul wan.wig (~(del by wan.wig) cnt.wig)) -:: red.wig (~(put by red.wig) cnt.wig huq) -:: == -:: ?~(dul +>.$ (busk u.dul cnt huq)) -:: :: -:: ++ hire :: consume -:: |= [cnt=@ud num=@ud] -:: ^+ ..yu -:: =< abet -:: :: ~& :~ %yu-hire -:: :: [%instance nap] -:: :: [%produced cnt.wig] -:: :: [%request cnt] -:: :: [%dispatched toy.wig] -:: :: [%requester num] -:: :: == -:: ?: |((lth +(cnt) toy.wig) (gth cnt toy.wig)) -:: ~& [%hire-improper [%request cnt] [%dispatched toy.wig]] -:: +>.$(..yo (bust 204 num)) -:: ?: (gte cnt cnt.wig) -:: :: ~& %hire-wait -:: =+ old=(~(get by wan.wig) cnt) -:: =. wan.wig (~(put by wan.wig) cnt num) -:: +>.$(..yo ?~(old ..yo (bust 204 u.old))) -:: =+ rud=(~(get by red.wig) cnt) -:: ?~ rud -:: :: ~& %hire-bust -:: +>.$(..yo (bust 204 num)) -:: :: ~& %hire-send -:: (busk num cnt u.rud) -:: -- -:: -- -- -- -- From 7638f5897710733008195bac894995e816393f58 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 26 Feb 2015 13:23:46 -0800 Subject: [PATCH 046/219] more ship hacks --- arvo/eyre.hoon | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 2a0c5902ba..e08fe2a96b 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -104,12 +104,14 @@ |- ^- (unit hole) ?~ u.mar ^$(cok t.cok) ?:(=(nam p.i.u.mar) [~ q.i.u.mar] $(u.mar t.u.mar)) +:: ++ ecco :: eat headers |= hed=(list ,[p=@t q=@t]) ^- math %+ roll hed |= [a=[p=cord cord] b=math] =. p.a (cass (trip p.a)) (~(add ja b) a) +:: ++ loga :: tanks to manx |= tac=(list tank) ^- manx @@ -303,6 +305,7 @@ =+ hon=(horn pul q.hyx moh) ?^ hon (muff u.hon) =+ oar=(fall (doss r.p.pul) (need hov)) + =. our oar :: XX =+ ext=(fall p.q.pul %urb) %- |=(a=(each ,_..hell tang) ?~(-.a p.a (fail 404 0v0 >%exit< p.a))) %- mule |. ^+ ..hell @@ -506,7 +509,7 @@ ((hard kiss) q.hic) == ^- [p=(list move) q=_..^$] - =| our=ship :: XX + =+ our=`@p`0x100 :: XX sentinel =+ ska=(slod ski) =+ sky=|=(* `(unit)`=+(a=(ska +<) ?~(a ~ ?~(u.a ~ [~ u.u.a])))) =. ney (shax :(mix (shax now) +(eny) ney)) :: XX!! shd not need @@ -539,7 +542,7 @@ [[hen %give +.q.hin]~ ..^$] ?: ?=(%vega +<.q.hin) :: vomit [[hen %give +.q.hin]~ ..^$] - =| our=ship :: XX + =+ our=`@p`0x100 :: XX sentinel =+ ska=(slod ski) =+ sky=|=(* `(unit)`=+(a=(ska +<) ?~(a ~ ?~(u.a ~ [~ u.u.a])))) =. ney (shax :(mix (shax now) +(eny) ney)) :: XX!! shd not need From 432bf24aed9951be6876ae9cc0721140a1e68e67 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 26 Feb 2015 16:04:12 -0800 Subject: [PATCH 047/219] clarity refactoring --- arvo/eyre.hoon | 107 ++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index e08fe2a96b..7a3a631b80 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -91,7 +91,7 @@ == :: -- :: |% -++ coss :: cookie search +++ sesh :: session from cookies |= [nam=@t mah=math] ^- (unit hole) =+ ^= cok ^- (list ,@t) @@ -105,14 +105,14 @@ ?~ u.mar ^$(cok t.cok) ?:(=(nam p.i.u.mar) [~ q.i.u.mar] $(u.mar t.u.mar)) :: -++ ecco :: eat headers +++ heat :: eat headers |= hed=(list ,[p=@t q=@t]) ^- math %+ roll hed |= [a=[p=cord cord] b=math] =. p.a (cass (trip p.a)) (~(add ja b) a) :: -++ loga :: tanks to manx +++ tanx :: tanks to manx |= tac=(list tank) ^- manx =+ rolt=|=(a=wall `tape`?~(a ~ :(weld i.a "\0a" $(a t.a)))) @@ -125,7 +125,7 @@ ;body:pre:code:"{mec}" == :: -++ lode +++ depo :: inject dependency |= [dep=@uvH max=manx] ^- manx ?> ?=([[%html ~] [[%head ~] *] [[%body ~] ^] ~] max) :: XX static @@ -134,7 +134,7 @@ :: ++ js :: static javascript |% - ++ poll + ++ poll :: dependency long-poll ''' urb.tries = 0 urb.call = function() { @@ -174,15 +174,14 @@ == :: =* bol -> |% - ++ abet + ++ abet :: resolve moves ^- [(list move) bolo] [(flop mow) bol] :: - ++ adit - .(ney (mix eny ney)) + ++ adit .(ney (mix eny ney)) :: flip entropy :: ++ anon (add our ^~((bex 64))) :: pseudo-sub - ++ axon + ++ axon :: accept response |= [tea=wire typ=type sih=sign] ^+ +> ?- -.+.sih @@ -218,7 +217,7 @@ (jive (joba dez (jone p.caz))) == :: - ++ apex + ++ apex :: accept request |= kyz=kiss ^+ +> ?- -.kyz @@ -234,7 +233,7 @@ =* sec p.kyz :: ? :: https bit =* heq r.kyz :: httq :: request content =+ ryp=`quri`(rash q.heq zest:epur) - =+ mah=(ecco r.heq) + =+ mah=(heat r.heq) =+ ^= pul ^- purl ?- -.ryp & ?>(=(sec p.p.p.ryp) p.ryp) @@ -254,7 +253,7 @@ ?~ mez ~& [%strange-wart p.kyz q.kyz] +>.$ - ?- -<.u.mez + ?- -<.u.mez :: XX handle %lon !! %aut !! %hat !! @@ -270,26 +269,17 @@ ^- (unit ship) =+ gow=(~(get by dop) hot) ?^ gow gow - ?. &(?=(& -.hot) ?=(^ p.hot)) ~ - (rush -:(flop p.hot) fed:ag) + ?. ?=(& -.hot) ~ + =+ dom=(flop p.hot) :: domain name + ?~ dom ~ + (rush i.dom fed:ag) :: ++ fail :: request failed |= [sas=@ud dep=@uvH mez=tang] ^+ +> :: (back ~ dep %tang !>(mez)) :: XX broken tang->mime door in ford - (resp sas text//html (poxo (lode dep (loga mez)))) + (resp sas text//html (poxo (depo dep (tanx mez)))) :: - ++ heck :: extract err beak - |= [oar=ship pul=purl] - ^- (unit beak) - %- bind :_ |=(a=$&(beam beak) ?^(-.a -.a a)) - ^- (unit $&(beam beak)) - ?. ?=([%'~' ^] q.q.pul) - (heft oar q.pul) - ?+ i.t.q.q.pul ~ - %as ?~(t.t.q.q.pul ~ $(q.q.pul t.t.t.q.q.pul)) - %on ~ ::(tome (scot %p oar) - == ++ heft :: regular request |= [oar=ship pok=pork] ^- (unit beam) @@ -306,36 +296,37 @@ ?^ hon (muff u.hon) =+ oar=(fall (doss r.p.pul) (need hov)) =. our oar :: XX - =+ ext=(fall p.q.pul %urb) %- |=(a=(each ,_..hell tang) ?~(-.a p.a (fail 404 0v0 >%exit< p.a))) %- mule |. ^+ ..hell + =+ ext=(fall p.q.pul %urb) =+ hev=(heft oar q.pul) ?^ hev - =+ ced=ced.q:(huff our q.hyx pul moh) - =: s.u.hev [%web ~(rent co (flux:ya /'' r.pul ced)) s.u.hev] - r.u.hev ?+(r.u.hev r.u.hev [%ud %0] da/now) - == - (honk oar [%cast %mime [%boil ext u.hev ~]]) + =+ huv=(huff our q.hyx pul moh) + (hons u.hev ext r.pul ced.q.huv) =+ hem=(hemp oar [q r]:pul) - ?~ hem - ~|(strange-path/q.q.pul !!) - ?- -.u.hem + ?^ hem (hemo u.hem pul q.hyx moh) + ~|(strange-path/q.q.pul !!) + :: + ++ hemo :: handle aux request + |= $: hem=(each ,@uvH ,[p=ship q=pork]) + [pul=purl cip=clip moh=moth] + == + ?- -.hem & ?. ?=([~ %js] p.q.pul) :: XX treat non-json cases? - ~! hem - ?~ p.u.hem ..hell - (howa ~ p.u.hem) + ?~ p.hem ..hell + (howa ~ p.hem) %^ resp 200 text//javascript """ window.urb = \{poll: "/{(apex:earn %| q.pul(u.p %json) r.pul)}"} {(trip poll:js)} """ :: - | ~| aute/p.u.hem ~| q.moh - =+ hez=(huff our q.hyx pul moh) + | ~| aute/p.hem ~| q.moh + =+ hez=(huff our cip pul moh) =. q.cez.q.hez - ?. =(anon p.p.u.hem) + ?. =(anon p.p.hem) q.cez.q.hez - (~(put in q.cez.q.hez) p.p.u.hem) + (~(put in q.cez.q.hez) p.p.hem) =. wup (~(put by wup) hez) ?^ cug.q.hez =+ rel=;html:script:"document.location.reload()" @@ -349,7 +340,8 @@ ++ hemp :: auxillary(/~) request |= [oar=ship pok=pork quy=quay] ^- (unit (each ,@uvH ,[p=ship q=pork])) - ?: ?=([%'~~' *] q.pok) $(q.pok ['~' %as %own t.q.pok]) :: auth shortcut + ?: ?=([%'~~' *] q.pok) :: auth shortcut + $(q.pok ['~' %as %own t.q.pok]) ?. ?=([%'~' @ *] q.pok) ~ :- ~ =* pef i.t.q.pok @@ -384,6 +376,13 @@ :: ~& [%honk our num ses -.kas] (miff ~ %f [%exec our `kas]) :: + ++ hons :: regular ford request + |= [bem=beam ext=term quy=quay ced=cred] + =: s.bem [%web ~(rent co (flux:ya quy ced)) s.bem] + r.bem ?+(r.bem r.bem [%ud %0] da/now) + == + (honk our [%cast %mime [%boil ext bem ~]]) + :: ++ horn :: irregular request |= [pul=purl cip=clip moh=moth] ^- (unit gift) @@ -410,12 +409,12 @@ |= [tea=wire dep=@uvH] (miff tea %f [%wasp our dep]) :: - ++ huff :: request by ship + ++ huff :: get request state |= [our=ship cip=clip pul=purl moh=moth] ^- [p=hole q=cyst] =* sec p.p.pul =+ pef=(rsh 3 1 (scot %p our)) - =+ lig=(coss pef q.moh) + =+ lig=(sesh pef q.moh) ?^ lig =+ cyz=(need (~(get by wup) u.lig)) [u.lig cyz(cug ~)] @@ -435,7 +434,7 @@ == [anon ~] :: -:: ~ + :: ~ :: :_ ~ %^ cat 3 @@ -444,8 +443,8 @@ '; Path=/; HttpOnly' :: now -:: ~ -:: [1 ~] + :: ~ + :: [1 ~] == :: ++ jive :: success json @@ -470,12 +469,12 @@ [%thou `httr`[sas ~[content-type/(moon mit)] [~ (taco rez)]]] :: ++ ya :: session engine -:: =| [[our=ship ses=hole] cyst] ::serf cyst] -:: =* sef ->- - =* cyz -> + :: =| [[our=ship ses=hole] cyst] ::serf cyst] + :: =* sef ->- + :: =* cyz -> |% ++ flux :: credential caboose - |= [nyp=path quy=quay ced=cred] ^- coin + |= [quy=quay ced=cred] ^- coin :* %many [%$ %ta ~] [%blob ced] @@ -519,12 +518,12 @@ abet:(apex:~(adit ye [hen [now eny our sky] ~] bol) q.hic) [mos ..^$] :: -++ doze +++ doze :: require no timer |= [now=@da hen=duct] ^- (unit ,@da) ~ :: -++ load +++ load :: clam previous state |= old=_[%0 gub hov ged ney dop **] ^+ ..^$ ..^$(+>- (bolo old)) From 5d5aa0242b3977b4944d59607a154bb529769a3e Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 26 Feb 2015 16:04:50 -0800 Subject: [PATCH 048/219] Fixed regular $ rune parsing --- arvo/hoon.hoon | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index dd254cfcf4..37415f56c0 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -9146,10 +9146,10 @@ ;~ pfix bar %- stew ^. stet ^. limo - :~ ['_' (rune cab %brcb expu)] + :~ ['_' (rune cab %brcb expv)] ['%' (rune cen %brcn expe)] ['.' (rune dot %brdt expa)] - ['/' (rune fas %brfs expu)] + ['/' (rune fas %brfs expv)] ['-' (rune hep %brhp expa)] ['^' (rune ket %brkt expr)] ['+' (rune lus %brls expo)] @@ -9175,7 +9175,15 @@ == :- '$' ;~ pose - (rune com %bccm expv) + ;~ pfix buc + %- stew + ^. stet ^. limo + :~ + [',' (rune com %bccm expt)] + ['*' (rune tar %bctr expt)] + ['@' (rune pat %bcpt expu)] + == + == (stag %bccm (noil tol)) == :- ':' @@ -9404,9 +9412,9 @@ ++ expq |.(;~(gunk rope loaf loaf)) :: wing and two twigs ++ expr |.(;~(gunk loaf wisp)) :: twig and core tail ++ exps |.((butt hank)) :: closed gapped twigs - :: expt - ++ expu |.(;~(gunk lobe wisp)) :: tile, core tail - ++ expv |.(lobe) :: tile + ++ expt |.(lobe) :: tile + ++ expu |.(;~(gunk rope lobe)) :: wing and tile + ++ expv |.(;~(gunk lobe wisp)) :: tile, core tail ++ expw |.(;~(gunk lobe teak)) :: tile and tiki ++ expx |.((butt ;~(gunk teak race))) :: tiki, [tile twig]s ++ expy |.((butt ;~(gunk teak loaf race))) :: tiki twig [tile twig]s From 6cd54faa7a999a8c463c3f9512b1d26d63e92b3c Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 26 Feb 2015 17:29:39 -0800 Subject: [PATCH 049/219] Syntax tightening --- arvo/hoon.hoon | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index 37415f56c0..dd9f54abc5 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -6501,12 +6501,13 @@ ++ hock |- ^- toga ?- gen - [^ *] [%2 $(gen p.gen) $(gen q.gen)] [%cnts [@ ~] ~] i.p.gen [%cnzy @] p.gen [%cnzz [@ ~]] i.p.gen [%zpcb *] $(gen q.gen) - * =+(neg=open ?:(=(gen neg) [%0 ~] $(gen neg))) + [@ *] =+(neg=open ?:(=(gen neg) [%0 ~] $(gen neg))) + [^ *] =+ toe=[$(gen p.gen) $(gen q.gen)] + ?:(=(toe [[%0 ~] [%0 ~]]) [%0 ~] [%2 toe]) == :: ++ open @@ -9003,7 +9004,6 @@ == == (stag %cnzz rope) - (stag %bczp (cold %cell ket)) == :- '`' ;~ pfix tec @@ -9016,8 +9016,6 @@ (cook |=(a=twig [[%dtzz %n ~] a]) wide) == == - :- '#' - ;~(pfix hax rupl) :- '"' %+ cook |= a=(list (list beer)) @@ -9480,11 +9478,12 @@ == ^- (unit twig) ?- -.vil - %tis [~ %ktts ~(hock ap ros) p.vil] %col [~ %tsgl ros p.vil] %pel [~ %cnts ~(rake ap ros) p.vil] %pat [~ %bcpt ~(rake ap ros) p.vil] %ket [~ ros p.vil] + %tis =+ tog=~(hock ap ros) + ?:(=([%0 ~] tog) ~ [~ %ktts tog p.vil]) == :: ++ long From cfa318364061f6e39ba5b09f06c2b340da36ab20 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 26 Feb 2015 18:20:07 -0800 Subject: [PATCH 050/219] improved odor checking --- arvo/hoon.hoon | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index dd9f54abc5..af72f8fb96 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -227,8 +227,8 @@ [%cndt p=twig q=twig] :: %-(q p) [%cnhp p=twig q=tusk] :: slam p w/ sample q [%cntr p=wing q=twig r=tram] :: pull p.q w/ changes - [%cnkt p=twig q=twig r=twig s=twig] :: slam p w/ %*(q r s) - [%cnls p=twig q=twig r=twig] :: slam p w/ %*(q r) + [%cnkt p=twig q=twig r=twig s=twig] :: slam p w/ :*(q r s) + [%cnls p=twig q=twig r=twig] :: slam p w/ :*(q r) [%cnsg p=wing q=twig r=twig] :: pull p from q with r [%cnts p=wing q=tram] :: eval. p w/ q changes [%cnzy p=term] :: pulls limb p @@ -2977,6 +2977,7 @@ ++ teff :: length utf8 |= a=@t ^- @ =+ b=(end 3 1 a) + ~| %bad-utf8 ?: =(0 b) ?>(=(0 a) 0) ?> |((gte b 32) =(10 b)) @@ -7170,7 +7171,8 @@ ~ :+ ~ %leaf - ?+ p.q.ham ~(rend co [~ p.q.ham lum]) + ?+ (rash p.q.ham ;~(sfix (cook crip (star low)) (star hig))) + ~(rend co [~ p.q.ham lum]) %$ ~(rend co [~ %ud lum]) %t (dash (rip 3 lum) '\'') %tas ['%' ?.(=(0 lum) (rip 3 lum) ['$' ~])] From 01becd1f7c677f405d22dc6a1c52990b6ed9a423 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 2 Mar 2015 17:51:00 -0800 Subject: [PATCH 051/219] - regex --- arvo/hoon.hoon | 437 +------------------------------------------------ 1 file changed, 5 insertions(+), 432 deletions(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index af72f8fb96..17010aab1a 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -639,6 +639,7 @@ :: ++ need :: demand |* a=(unit) + ~| %need ?~ a !! u.a :: @@ -3411,11 +3412,13 @@ == :: %u + ?: ?=(%c hay) + %+ welp ['0' 'c' (reap (pad:fa q.p.lot) '1')] + (c-co (enc:fa q.p.lot)) =- (weld p.gam ?:(=(0 q.p.lot) `tape`['0' ~] q.gam)) ^= gam ^- [p=tape q=tape] ?+ hay [~ ((ox-co [10 3] |=(a=@ ~(d ne a))) q.p.lot)] %b [['0' 'b' ~] ((ox-co [2 4] |=(a=@ ~(d ne a))) q.p.lot)] - %c [['0' 'c' (reap (pad:fa q.p.lot) '1')] (c-co (enc:fa q.p.lot))] %i [['0' 'i' ~] ((d-co 1) q.p.lot)] %x [['0' 'x' ~] ((ox-co [16 4] |=(a=@ ~(x ne a))) q.p.lot)] %v [['0' 'v' ~] ((ox-co [32 5] |=(a=@ ~(x ne a))) q.p.lot)] @@ -3696,437 +3699,7 @@ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: section 2eM, regular-expressions :: :: -++ pars - |= [a=tape] :: parse tape to rege - ^- (unit rege) - =+ foo=((full apex:rags) [[1 1] a]) - ?~ q.foo - ~ - [~ p.u.q.foo] -:: -++ rags :: rege parsers - => |% - ++ nor ;~(less (mask "^$()|*?+.[\\") (shim 1 127)) :: non-control char - ++ les ;~(less bas asp) :: not backslash - ++ lep ;~(less (mask "-^[]\\") asp) :: charset non-control - ++ asp (shim 32 126) :: printable ascii - ++ alb ;~(less ser asp) :: charset literal char - ++ mis ;~(less aln asp) :: non alphanumeric - -- - |% - ++ apex :: top level - %+ knee *rege |. ~+ - ;~ pose - ;~((bend |=(a=[rege rege] (some [%eith a]))) mall ;~(pfix bar apex)) - (stag %eith ;~(plug (easy %empt) ;~(pfix bar apex))) - (easy %empt) - == - :: - ++ mall - %+ knee *rege |. ~+ - ;~((bend |=(a=[rege rege] (some [%pair a]))) bets mall) - :: - ++ bets - %+ knee *rege |. ~+ - |= tub=nail - =+ vex=(chun tub) - ?~ q.vex - vex - =+ a=p.u.q.vex - %- ;~ pose - (cold [%eith %empt a] (jest '??')) - (cold [%manl a] (jest '*?')) - (cold [%plll a] (jest '+?')) - (cold [%eith a %empt] wut) - (cold [%mant a] tar) - (cold [%plls a] lus) - (stag %betl ;~(plug (easy a) ;~(sfix rang wut))) - (stag %betw ;~(plug (easy a) rang)) - (stag %binl ;~(plug (easy a) (ifix [kel (jest ',}?')] dim:ag))) - (stag %bant ;~(plug (easy a) (ifix [kel (jest '}?')] dim:ag))) - (stag %bant ;~(plug (easy a) (ifix [kel ker] dim:ag))) - (stag %bint ;~(plug (easy a) (ifix [kel (jest ',}')] dim:ag))) - (easy a) - == - q.u.q.vex - :: - ++ ranc - |= [a=@ b=@] - ^- @ - ?:((gth a b) 0 (con (bex a) $(a +(a)))) - :: - ++ flap |=(a=@ (mix a (dec (bex 256)))) - :: - ++ rang - %+ sear |=([a=@ b=@] ?:((lte a b) (some [a b]) ~)) - (ifix [kel ker] ;~(plug dim:ag ;~(pfix com dim:ag))) - :: - ++ chun - %+ knee *rege |. ~+ - ;~ pose - (cold %ende buc) - (cold %sart ket) - (cold %dote dot) - %+ cook |=(a=(list char) (reel a |=([p=char q=rege] [%pair [%lite p] q]))) - ;~(pfix (jest '\\Q') cape) - |= tub=nail - =+ foo=;~(plug kel dim:ag ;~(pose ker (jest ',}') ;~(plug com dim:ag ker))) - =+ bar=(foo tub) - ?~(q.bar (chad tub) (fail tub)) - (cook |=([a=rege] [%capt a 0]) (ifix [pel per] apex)) - %+ cook |=([a=rege] [%capt a 0]) - (ifix [;~(plug (jest '(?P<') (plus aln) gar) per] apex) - (ifix [(jest '(?:') per] apex) - (stag %brac ;~(pfix sel seac)) - == - :: - ++ seac - |= tub=nail - ?~ q.tub - (fail tub) - ?: =(i.q.tub '^') - (;~(pfix ket (cook flap sead)) tub) - (sead tub) - :: - ++ sead - %+ knee *@ |. ~+ - ;~ pose - |= tub=nail - ?~ q.tub - (fail tub) - ?. =(i.q.tub ']') - (fail tub) - ?~ t.q.tub - (fail tub) - ?: =(i.t.q.tub '-') - ?~ t.t.q.tub - (fail tub) - ?: =(i.t.t.q.tub ']') - (;~(pfix ser (cook |=(a=@ (con (bex ']') a)) sade)) tub) - (fail tub) - (;~(pfix ser (cook |=(a=@ (con (bex ']') a)) sade)) tub) - |= tub=nail - ?~ q.tub - (fail tub) - ?. =(i.q.tub '-') - (fail tub) - ?~ t.q.tub - (fail tub) - ?: =(i.t.q.tub '-') - ?~ t.t.q.tub - (fail tub) - ?: =(i.t.t.q.tub ']') - (;~(pfix hep (cook |=(a=@ (con (bex '-') a)) sade)) tub) - (fail tub) - (;~(pfix hep (cook |=(a=@ (con (bex '-') a)) sade)) tub) - (cook |=(a=[@ @] (con a)) ;~(plug seap sade)) - == - :: - ++ sade - %+ knee *@ |. ~+ - ;~ pose - (cold (bex '-') (jest '-]')) - (cold 0 ser) - (cook |=([p=@ q=@] `@`(con p q)) ;~(plug seap sade)) - == - :: - ++ seap - %+ knee *@ |. ~+ - ;~ pose - unid - %+ ifix (jest '[:')^(jest ':]') - ;~(pose ;~(pfix ket (cook flap chas)) chas) - %+ sear |=([a=@ b=@] ?:((gth a b) ~ (some (ranc a b)))) - ;~(plug asp ;~(pfix hep alb)) - |= tub=nail - ?~ q.tub - (fail tub) - ?~ t.q.tub - ((cook bex les) tub) - ?. =(i.t.q.tub '-') - ((cook bex les) tub) - ?~ t.t.q.tub - ((cook bex les) tub) - ?: =(i.t.t.q.tub ']') - ((cook bex les) tub) - (fail tub) - ;~(pfix bas escd) - == - :: - ++ cape - %+ knee *tape |. ~+ - ;~ pose - (cold ~ (jest '\\E')) - ;~(plug next cape) - (cook |=(a=char (tape [a ~])) next) - (full (easy ~)) - == - ++ chas :: ascii character set - =- (sear ~(get by -) sym) - %- mo ^- (list ,[@tas @I]) - :~ alnum/alnum alpha/alpha ascii/ascii blank/blank cntrl/cntrl - digit/digit graph/graph lower/lower print/print punct/punct - space/space upper/upper word/wordc xdigit/xdigit - == - :: Character sets - ++ alnum :(con lower upper digit) - ++ alpha :(con lower upper) - ++ ascii (ranc 0 127) - ++ blank (con (bex 32) (bex 9)) - ++ cntrl :(con (ranc 0 31) (bex 127)) - ++ digit (ranc '0' '9') - ++ graph (ranc 33 126) - ++ lower (ranc 'a' 'z') - ++ print (ranc 32 126) - ++ punct ;: con - (ranc '!' '/') - (ranc ':' '@') - (ranc '[' '`') - (ranc '{' '~') - == - ++ space :(con (ranc 9 13) (bex ' ')) - ++ upper (ranc 'A' 'Z') - ++ white :(con (bex ' ') (ranc 9 10) (ranc 12 13)) - ++ wordc :(con digit lower upper (bex '_')) - ++ xdigit :(con (ranc 'a' 'f') (ranc 'A' 'F') digit) - :: - ++ chad - %+ knee *rege |. ~+ - ;~(pose (stag %lite nor) (stag %brac unid) ;~(pfix bas escp)) - :: - ++ escd - %+ cook bex - ;~ pose - (cold 0 (just '0')) - (sear ~(get by (mo a/7 t/9 n/10 v/11 f/12 r/13 ~)) low) - (sear |=(a=@ ?:((lth a 256) (some a) ~)) (bass 8 (stun [2 3] cit))) - ;~(pfix (just 'x') (bass 16 (stun [2 2] hit))) - (ifix [(jest 'x{') ker] (bass 16 (stun [2 2] hit))) - mis - == - :: - ++ escp - ;~ pose - (stag %lite escd) - (sear ~(get by (mo b/%boun w/[%brac wordc] z/%ende ~)) low) - =- (sear ~(get by (mo -)) hig) - ~['A'^%sart 'B'^%bout 'C'^%dote 'Q'^%empt 'W'^[%brac (flap wordc)]] - == - :: - ++ unid - =+ cha=~(get by (mo d/digit s/white w/wordc ~)) - ;~ pfix bas - ;~ pose - (sear cha low) - (cook flap (sear |=(a=@ (cha (add a 32))) hig)) - == == - -- -:: -++ ra :: regex engine - |_ a=rege - ++ proc :: capture numbering - |= b=@ - =- -(+ +>.$(a a)) - ^- [p=@ a=rege] - ?- a - [%capt *] =+ foo=$(a p.a, b +(b)) - [p.foo [%capt a.foo b]] - [%eith *] =+ foo=$(a p.a) - =+ bar=$(a q.a, b p.foo) - [p.bar [%eith a.foo a.bar]] - [%pair *] =+ foo=$(a p.a) - =+ bar=$(a q.a, b p.foo) - [p.bar [%pair a.foo a.bar]] - [%manl *] =+ foo=$(a p.a) - [p.foo [%manl a.foo]] - [%plll *] =+ foo=$(a p.a) - [p.foo [%plll a.foo]] - [%binl *] =+ foo=$(a p.a) - [p.foo [%binl a.foo q.a]] - [%betl *] =+ foo=$(a p.a) - [p.foo [%betl a.foo q.a r.a]] - [%mant *] =+ foo=$(a p.a) - [p.foo [%mant a.foo]] - [%plls *] =+ foo=$(a p.a) - [p.foo [%plls a.foo]] - [%bant *] =+ foo=$(a p.a) - [p.foo [%bant a.foo q.a]] - [%bint *] =+ foo=$(a p.a) - [p.foo [%bint a.foo q.a]] - [%betw *] =+ foo=$(a p.a) - [p.foo [%betw a.foo q.a r.a]] - * [b a] - == - :: - ++ cont - |= [a=(map ,@u tape) b=(map ,@u tape)] - (~(gas by *(map ,@u tape)) (weld (~(tap by a)) (~(tap by b)))) - :: - ++ abor - |= [a=char b=(unit ,[tape (map ,@u tape)])] - ^- (unit ,[tape (map ,@u tape)]) - ?~ b - b - [~ [[a -.u.b] +.u.b]] - :: - ++ matc - |= [b=tape c=tape] - ^- (unit (map ,@u tape)) - =+ foo=`(unit ,[tape (map ,@u tape)])`(deep b %empt c) - (bind foo |*(a=^ (~(put by +.a) 0 -.a))) - :: - ++ chet - |= [b=(unit ,[tape (map ,@u tape)]) c=tape d=tape] - ^- (unit ,[tape (map ,@u tape)]) - ?~ b - b - ?~ -.u.b - b - =+ bar=(deep (slag (lent -.u.b) c) %empt d) - ?~ bar - bar - b - ++ blak (some ["" *(map ,@u tape)]) - ++ word |=(a=char =((dis wordc:rags (bex a)) 0)) - ++ deep - |= [b=tape c=rege d=tape] - ^- (unit ,[tape (map ,@u tape)]) - ?- a - %dote ?~(b ~ (some [[i.b ~] *(map ,@u tape)])) - %ende ?~(b blak ~) - %sart ?:(=(b d) blak ~) - %empt blak - %boun =+ ^= luc - ?: =(b d) - & - =+ foo=(slag (dec (sub (lent d) (lent b))) d) - (word -.foo) - =+ cuc=?~(b & (word -.b)) - ?:(!=(luc cuc) blak ~) - %bout =+ ^= luc - ?: =(b d) - & - =+ foo=(slag (dec (sub (lent d) (lent b))) d) - (word -.foo) - =+ cuc=?~(b & (word -.b)) - ?:(=(luc cuc) blak ~) - [%capt *] =+ foo=$(a p.a) - ?~ foo - foo - =+ ft=u.foo - =+ bar=$(a c, b (slag (lent -.ft) b), c %empt) - ?~ bar - bar - [~ [-.ft (~(put by +.ft) q.a -.ft)]] - [%lite *] ?~(b ~ ?:(=(i.b p.a) (some [[i.b ~] *(map ,@u tape)]) ~)) - [%brac *] ?~ b - ~ - ?. =((dis (bex `@`i.b) p.a) 0) - (some [[i.b ~] *(map ,@u tape)]) - ~ - [%eith *] =+ foo=(chet(a c) $(a p.a) b d) - =+ bar=(chet(a c) $(a q.a) b d) - ?~ foo - bar - ?~ bar - foo - =+ ft=u.foo - =+ bt=u.bar - ?: (gte (lent -.ft) (lent -.bt)) - foo - bar - [%pair *] =+ foo=$(a p.a, c [%pair q.a c]) - ?~ foo - foo - =+ ft=u.foo - =+ bar=$(a q.a, b (slag (lent -.ft) b)) - ?~ bar - bar - =+ bt=u.bar - [~ [(weld -.ft -.bt) (cont +.ft +.bt)]] - [%manl *] =+ foo=$(a p.a) - ?~ foo - blak - ?~ -.u.foo - blak - $(a [%eith %empt [%pair p.a [%eith %empt a]]]) - [%mant *] =+ foo=$(a p.a) - ?~ foo - blak - =+ ft=u.foo - ?~ -.ft - blak - $(a [%eith [%pair p.a [%eith a %empt]] %empt]) - [%plls *] $(a [%pair p.a [%mant p.a]]) - [%plll *] $(a [%pair p.a [%manl p.a]]) - [%binl *] =+ min=?:(=(q.a 0) 0 (dec q.a)) - ?: =(q.a 0) - $(a [%manl p.a]) - $(a [%pair p.a [%binl p.a min]]) - [%bant *] ?: =(0 q.a) - blak - $(a [%pair p.a [%bant p.a (dec q.a)]]) - [%bint *] =+ min=?:(=(q.a 0) 0 (dec q.a)) - ?: =(q.a 0) - $(a [%mant p.a]) - $(a [%pair p.a [%bint p.a min]]) - [%betw *] ?: =(0 r.a) - blak - ?: =(q.a 0) - $(a [%eith [%pair p.a [%betw p.a 0 (dec r.a)]] %empt]) - $(a [%pair p.a [%betw p.a (dec q.a) (dec r.a)]]) - [%betl *] ?: =(0 r.a) - blak - ?: =(q.a 0) - $(a [%eith %empt [%pair p.a [%betl p.a 0 (dec r.a)]]]) - $(a [%pair p.a [%betl p.a (dec q.a) (dec r.a)]]) - == - -- -:: -++ rexp :: Regex match - ~/ %rexp - |= [a=tape b=tape] - ^- (unit (unit (map ,@u tape))) - =+ ^= bar - |= [a=@ b=(map ,@u tape)] - ?: =(a 0) - b - =+ c=(~(get by b) a) - ?~ c - $(a (dec a), b (~(put by b) a "")) - $(a (dec a)) - =+ par=(pars a) - ?~ par ~ - =+ poc=(~(proc ra u.par) 1) - =+ c=b - |- - =+ foo=(matc:poc c b) - ?~ foo - ?~ c - [~ ~] - $(c t.c) - [~ [~ (bar (dec p.poc) u.foo)]] -:: -++ repg :: Global regex replace - ~/ %repg - |= [a=tape b=tape c=tape] - ^- (unit tape) - =+ par=(pars a) - ?~ par ~ - =+ poc=(~(proc ra u.par) 1) - =+ d=b - :- ~ - |- - ^- tape - =+ foo=(matc:poc d b) - ?~ foo - ?~ d - ~ - [i.d $(d t.d)] - =+ ft=(need (~(get by u.foo) 0)) - ?~ d - c - (weld c $(d `tape`(slag (lent ft) `tape`d))) + :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: section 2eN, pseudo-cryptography :: :: From de05d4c2b546d9da7f242d950a58489e61b92412 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 2 Mar 2015 17:52:55 -0800 Subject: [PATCH 052/219] restructuring, auth --- arvo/eyre.hoon | 550 ++++++++++++++++++++++++++++++------------------- 1 file changed, 340 insertions(+), 210 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 7a3a631b80..6464253b0f 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -34,9 +34,6 @@ :: $: %a :: to %ames :: $% [%want p=sock q=path r=*] :: :: == == :: - $: %c :: to %clay - $% [%warp p=sock q=riff] :: - == == :: $: %d :: to %dill $% [%flog p=[%crud p=@tas q=(list tank)]] :: == == :: @@ -61,10 +58,7 @@ [%vega p=path] :: == == == :: ++ sign :: in result $<- - $? $: %c :: by %clay - $% [%writ p=riot] :: - == == :: - $: %f :: by %ford + $? $: %f :: by %ford $% [%made p=@uvH q=(each cage tang)] :: [%news ~] :: == == :: @@ -83,19 +77,36 @@ liz=(jug beam (each duct oryx)) :: clay subscriptions wup=(map hole cyst) :: secure sessions == :: +:: ++ cyst :: client session $: ced=cred :: credential - cez=[p=ship q=(set ship)] :: authenticated + [him=ship authed=(set ship)] :: authenticated cug=(list ,@t) :: unacked cookies lax=@da :: last used + vew=(set oryx) :: open views == :: +:: +++ perk :: parsed request + $% [%spur p=spur] + [%beam p=beam] + [%poll p=@uvH] + [%auth perk-auth] + == +:: +++ perk-auth :: parsed auth + $% [%get him=ship rem=pork] + [%js ~] + [%stat ~] :: json with authentication status + [%try him=ship cod=cord] + [%del p=(unit ship)] + == -- :: |% ++ sesh :: session from cookies - |= [nam=@t mah=math] + |= [nam=@t maf=math] ^- (unit hole) =+ ^= cok ^- (list ,@t) - =+ cok=(~(get by mah) 'cookie') + =+ cok=(~(get by maf) 'cookie') ?~(cok ~ u.cok) |- ^- (unit hole) ?~ cok ~ @@ -158,6 +169,36 @@ } urb.call() ''' + :: + ++ auth + ''' + window.urb = {} + window.urb.ship = 'zod' // XX + window.urb.submit = function(){ + xhr = new XMLHttpRequest() + xhr.open('POST', "/~/auth.json?PUT", true) + var dat = {oryx:'hi', ship: ship.value, code: pass.value} + xhr.send(JSON.stringify(dat)) + xhr.addEventListener('load', function(){ + if(this.status !== 200) + return err.innerHTML = ":(\n" + xhr.responseText + else return document.location.reload() + }) + } + ''' + -- +++ xml + |% + ++ login-page + ;html + ;head:title:'Hello World' + ;body + ;p: Identify yourself, ~;{input#ship(value "zod")}? + ;input#pass(onchange "urb.submit()"); + ;pre:code#err; + ;script@"/~/auth.js"; + == + == -- -- |% :: functions @@ -180,7 +221,7 @@ :: ++ adit .(ney (mix eny ney)) :: flip entropy :: - ++ anon (add our ^~((bex 64))) :: pseudo-sub + ++ anon `@p`(add our ^~((bex 64))) :: pseudo-sub ++ axon :: accept response |= [tea=wire typ=type sih=sign] ^+ +> @@ -203,18 +244,12 @@ %mime ~| q.q.cag =+ ((hard ,[mit=mite rez=octs]) q.q.cag) :: XX - (muff %thou 200 [content-type/(moon mit)]~ ~ rez) + (give-gift %thou 200 [content-type/(moon mit)]~ ~ rez) == == == :: - %news (jive %b &) :: dependency updated - %writ - :: ?^ tea ~&(e/missed/writ/tea=tea +>.$) - ?~ p.sih +>.$ - =+ `[@ caz=case dez=desk]`p.u.p.sih - ?> ?=(%ud -.caz) - (jive (joba dez (jone p.caz))) + %news (give-json 205 ~ %b &) :: dependency updated == :: ++ apex :: accept request @@ -233,16 +268,16 @@ =* sec p.kyz :: ? :: https bit =* heq r.kyz :: httq :: request content =+ ryp=`quri`(rash q.heq zest:epur) - =+ mah=(heat r.heq) + =+ maf=(heat r.heq) =+ ^= pul ^- purl ?- -.ryp & ?>(=(sec p.p.p.ryp) p.ryp) - | =+ hot=(~(get ja mah) %host) + | =+ hot=(~(get ja maf) %host) ?> ?=([@ ~] hot) [[sec (rash i.hot thor:epur)] p.ryp q.ryp] == =. p.p.pul |(p.p.pul ?=(hoke r.p.pul)) - (hell pul +.kyz [p.heq mah s.heq]) + abet:~(handle rq pul q.+.kyz [p.heq maf s.heq]) :: %thud :: cancel request ~& e/gone/hen @@ -260,11 +295,47 @@ == == :: + ++ fail :: request failed + |= [sas=@ud dep=@uvH mez=tang] + ^+ +> + :: (back ~ dep %tang !>(mez)) :: XX broken tang->mime door in ford + (give-html sas (depo dep (tanx mez))) + :: + ++ give-html :: request failed + |=([sas=@ud max=manx] (resp sas text//html (poxo max))) + :: + ++ give-json :: success json + |= [sas=@uG cug=(list ,@t) jon=json] + %- give-gift + =+ git=(tuff sas application//json (crip (pojo jon))) + ?~ cug git + =+ cuh=(turn `(list ,@t)`cug |=(a=@t set-cookie/a)) + git(q (weld cuh q.git)) + :: + ++ give-gift :: done card + |= gef=gift + +>(mow :_(mow [hen %give gef])) + :: + ++ resp :: mime response + |= [sas=@uG mit=mite bod=tape] + (give-gift (tuff sas mit (crip bod))) + :: + ++ pass-note |=(noe=[wire note] +>(mow :_(mow [hen %pass noe]))) + ++ ford-req + |= [tea=wire our=ship kas=silk] + :: ~& [%ford-req our num ses -.kas] + (pass-note tea %f [%exec our `kas]) + :: ++ back :: %ford bounce |= [tea=wire dep=@uvH cag=cage] - (miff tea %f %exec our `[%cast %mime %done ~ cag]) :: XX deps + (ford-req tea our [%cast %mime %done ~ cag]) :: XX deps :: - ++ doss :: host to ship + ++ tuff :: mimed response + |= [sas=@uG mit=mite rez=@] + :: (weld (turn cug |=(a=@t ['set-cookie' a])) + [%thou `httr`[sas ~[content-type/(moon mit)] [~ (taco rez)]]] + :: + ++ host-to-ship :: host to ship |= hot=host ^- (unit ship) =+ gow=(~(get by dop) hot) @@ -274,200 +345,259 @@ ?~ dom ~ (rush i.dom fed:ag) :: - ++ fail :: request failed - |= [sas=@ud dep=@uvH mez=tang] - ^+ +> - :: (back ~ dep %tang !>(mez)) :: XX broken tang->mime door in ford - (resp sas text//html (poxo (depo dep (tanx mez)))) - :: - ++ heft :: regular request - |= [oar=ship pok=pork] - ^- (unit beam) - ?~ q.pok - $(q.pok /index) - ?. ((sane %tas) i.q.pok) - (tome q.pok) - `[[oar i.q.pok da/now] (flop t.q.pok)] - :: - ++ hell :: request, no ship - |= [pul=purl hyx=httx moh=moth] - ^+ +> - =+ hon=(horn pul q.hyx moh) - ?^ hon (muff u.hon) - =+ oar=(fall (doss r.p.pul) (need hov)) - =. our oar :: XX - %- |=(a=(each ,_..hell tang) ?~(-.a p.a (fail 404 0v0 >%exit< p.a))) - %- mule |. ^+ ..hell - =+ ext=(fall p.q.pul %urb) - =+ hev=(heft oar q.pul) - ?^ hev - =+ huv=(huff our q.hyx pul moh) - (hons u.hev ext r.pul ced.q.huv) - =+ hem=(hemp oar [q r]:pul) - ?^ hem (hemo u.hem pul q.hyx moh) - ~|(strange-path/q.q.pul !!) - :: - ++ hemo :: handle aux request - |= $: hem=(each ,@uvH ,[p=ship q=pork]) - [pul=purl cip=clip moh=moth] + ++ rq + =| (unit ,@t) :: cookie given? + |_ $: [hat=hart pok=pork quy=quay] :: purl, parsed url + cip=clip :: client ip + [mef=meth maf=math bod=(unit octs)] :: method/headers/body == - ?- -.hem - & ?. ?=([~ %js] p.q.pul) :: XX treat non-json cases? - ?~ p.hem ..hell - (howa ~ p.hem) - %^ resp 200 text//javascript - """ - window.urb = \{poll: "/{(apex:earn %| q.pul(u.p %json) r.pul)}"} - {(trip poll:js)} - """ + ++ done . + ++ abet ..rq + ++ teba |*(a=$+(* ..rq) |*(b=* %_(done ..rq (a b)))) + ++ fail (teba ^fail) + ++ resp (teba ^resp) + ++ give-html (teba ^give-html) + ++ give-gift (teba ^give-gift) + ++ give-json (teba ^give-json) + ++ pass-note (teba ^pass-note) + ++ ford-req (teba ^ford-req) + ++ back (teba ^back) :: - | ~| aute/p.hem ~| q.moh - =+ hez=(huff our cip pul moh) - =. q.cez.q.hez - ?. =(anon p.p.hem) - q.cez.q.hez - (~(put in q.cez.q.hez) p.p.hem) - =. wup (~(put by wup) hez) - ?^ cug.q.hez - =+ rel=;html:script:"document.location.reload()" - =+ tuv=(tuff 200 text//html (crip (poxo rel))) - =. q.tuv - (weld :_(q.tuv (turn `(list ,@t)`cug.q.hez |=(a=cord set-cookie/a)))) - (muff tuv) - ~| hez !! - == - :: - ++ hemp :: auxillary(/~) request - |= [oar=ship pok=pork quy=quay] - ^- (unit (each ,@uvH ,[p=ship q=pork])) - ?: ?=([%'~~' *] q.pok) :: auth shortcut - $(q.pok ['~' %as %own t.q.pok]) - ?. ?=([%'~' @ *] q.pok) ~ - :- ~ - =* pef i.t.q.pok - =+ but=t.t.q.pok :: XX =* - ?+ pef ~|(pfix-lost/`path`/~/[pef] !!) - %on - :- %& - ~| on/bad-path/but - ?> ?=([@ ~] but) - (slav %uv i.but) - %as - :- %| - ~| bad-ship/?~(but ~ i.but) - ?~ but !! - :_ pok(q t.but) - ?+ i.but (slav %p i.but) - %anon anon - %own our - == - == - :: - ++ hoot :: clay request - |= [our=ship wir=path his=ship rif=riff] - (miff wir %c [%warp [our his] rif]) - :: - ++ hone :: kill ford - |= [our=ship ses=hole] - (miff ~ %f [%exec our ~]) - :: - ++ honk :: ford request - |= [our=ship kas=silk] - :: ~& [%honk our num ses -.kas] - (miff ~ %f [%exec our `kas]) - :: - ++ hons :: regular ford request - |= [bem=beam ext=term quy=quay ced=cred] - =: s.bem [%web ~(rent co (flux:ya quy ced)) s.bem] - r.bem ?+(r.bem r.bem [%ud %0] da/now) - == - (honk our [%cast %mime [%boil ext bem ~]]) - :: - ++ horn :: irregular request - |= [pul=purl cip=clip moh=moth] - ^- (unit gift) - ?+ [(fall p.q.pul %$) q.q.pul] ~ - [?(%ico %png) %favicon ~] - :- ~ - %^ tuff 200 image//png - 0w89wg.GV4jA.l9000.00dPb.YzBT6.giO00.o100d.wZcqc.a9tg-.VTG0b. - AUIvE.HBM3g.cK4SE.0aagi.l090p.I1P5g.Y-80r.y1YS9.1xE~Y.qgpFY. - vKN1V.905y0.2UwvL.43TUw.uL406.0-31h.xwoJF.Ul454.ilk00.00Yps. - BNumh.xpl9B.pS5Ji.i1BoC.ZAgg1.BsC5T.t6pLk.Thohn.gp000.0ov~P. - 7M000.0o840.00010.0001i.h4x93.g0000.Eq2wR.7jB29 + ++ ford-kill (pass-note ~ %f [%exec our ~]) :: XX unused + ++ ford-wasp + |= [tea=wire dep=@uvH] + (pass-note tea %f [%wasp our dep]) :: - [%txt %robots ~] - :- ~ - %^ tuff 200 text//plain - %- role - :~ 'User-agent: *' - 'Disallow: /' + ++ beam-into-ford + |= [bem=beam ext=term ced=cred] + =: s.bem [%web ~(rent co (flux:ya quy ced)) s.bem] + r.bem ?+(r.bem r.bem [%ud %0] da/now) == - == - :: - ++ howa :: ford %wasp request - |= [tea=wire dep=@uvH] - (miff tea %f [%wasp our dep]) - :: - ++ huff :: get request state - |= [our=ship cip=clip pul=purl moh=moth] - ^- [p=hole q=cyst] - =* sec p.p.pul - =+ pef=(rsh 3 1 (scot %p our)) - =+ lig=(sesh pef q.moh) - ?^ lig - =+ cyz=(need (~(get by wup) u.lig)) - [u.lig cyz(cug ~)] - =+ ses=(rsh 3 1 (scot %p (end 6 1 ney))) - :- ses - ^- cyst - :* ^- cred - :* [sec q.p.pul r.p.pul] - ~ - (rsh 3 1 (scot %p (end 6 1 (shaf %oryx ses)))) - :: - =+ lag=(~(get by q.moh) %accept-language) - ?~(lag ~ ?~(u.lag ~ [~ i.u.lag])) - :: - cip - ~ + (ford-req ~ our [%cast %mime [%boil ext bem ~]]) + :: + :: + ++ as-beam + ^- (unit beam) + |- + ?~ q.pok + $(q.pok /index) + ?. ((sane %tas) i.q.pok) + (tome q.pok) + `[[our i.q.pok da/now] (flop t.q.pok)] + :: + ++ as-magic-filename + ^- (unit gift) + ?+ [(fall p.pok %$) q.pok] ~ + [?(%ico %png) %favicon ~] + :- ~ + %^ tuff 200 image//png + 0w89wg.GV4jA.l9000.00dPb.YzBT6.giO00.o100d.wZcqc.a9tg-.VTG0b. + AUIvE.HBM3g.cK4SE.0aagi.l090p.I1P5g.Y-80r.y1YS9.1xE~Y.qgpFY. + vKN1V.905y0.2UwvL.43TUw.uL406.0-31h.xwoJF.Ul454.ilk00.00Yps. + BNumh.xpl9B.pS5Ji.i1BoC.ZAgg1.BsC5T.t6pLk.Thohn.gp000.0ov~P. + 7M000.0o840.00010.0001i.h4x93.g0000.Eq2wR.7jB29 + :: + [%txt %robots ~] + :- ~ + %^ tuff 200 text//plain + %- role + :~ 'User-agent: *' + 'Disallow: /' == - [anon ~] + == :: - :: ~ + ++ as-aux-request :: /~/... req parser + ^- (unit perk) + |- + ?: ?=([%'~~' *] q.pok) :: auth shortcut + $(q.pok ['~' %as %own t.q.pok]) + ?. ?=([%'~' @ *] q.pok) ~ + :- ~ + =* pef i.t.q.pok + =+ but=t.t.q.pok :: XX =* + ?+ pef ~|(pfix-lost/`path`/~/[pef] !!) + %on + :- %poll + ~| on/bad-path/but + ?> ?=([@ ~] but) + (slav %uv i.but) + %as + :+ %auth %get + ~| bad-ship/?~(but ~ i.but) + ?~ but !! + :_ pok(q t.but) + ?+ i.but (slav %p i.but) + %anon anon + %own our + == + %auth + :- %auth + |- + ?+ p.pok !! + ~ $(p.pok [~ %json]) + [~ %js] [%js ~] + [~ %json] + ?+ mef ~|(%bad-meth !!) + %get [%stat ~] + %post + ?+ quy ~|(bad-quy/'"PUT" or "DELETE"' !!) + [[%'PUT' ~] ~] + =+ paz=(ot ship/(su fed:ag) code/so ~):jo + ~| parsing/bod + [%try (need (paz (need (poja q:(need bod)))))] + :: + [[%'DELETE' ~] ~] + !! + == == + == == :: - :_ ~ - %^ cat 3 - (cat 3 (cat 3 pef '=') ses) - :: (cat 3 '; HttpOnly' ?.(sec '' '; Secure')) - '; Path=/; HttpOnly' + ++ handle + ^+ done + =+ git=as-magic-filename + ?^ git (give-gift u.git) + =+ oar=(fall (host-to-ship r.hat) (need hov)) + =. our oar :: XX + %- |=(a=(each ,_done tang) ?~(-.a p.a (fail 404 0v0 >%exit< p.a))) + %- mule |. ^+ done ~| [mef maf bod] + =+ ext=(fall p.pok %urb) + =+ bem=as-beam + ?^ bem + :: abet:(~(into-ford ya (get-sess..)) ..$) + =+ [ses cyz]=get-session + (beam-into-ford u.bem ext ced.cyz) + ?> check-oryx + =+ hem=as-aux-request + ?^ hem (handle-parsed u.hem) + ~|(strange-path/q.pok !!) :: - now - :: ~ - :: [1 ~] - == - :: - ++ jive :: success json - |= jon=json - (resp 205 application//json (pojo jon)) - :: - ++ muff :: return card - |= gef=gift - +>(mow :_(mow [hen %give gef])) - :: - ++ miff :: pass card - |= noe=[wire note] - +>(mow :_(mow [hen %pass noe])) - :: - ++ resp :: mime response - |= [sas=@uG mit=mite bod=tape] - (muff (tuff sas mit (crip bod))) - :: - ++ tuff :: mimed response - |= [sas=@uG mit=mite rez=@] - :: (weld (turn cug |=(a=@t ['set-cookie' a])) - [%thou `httr`[sas ~[content-type/(moon mit)] [~ (taco rez)]]] - :: + ++ check-oryx :: | if json with bad oryx + ^- ? + ?. &(?=([~ %json] p.pok) ?=(%post mef) ?=(^ bod)) & + =| cyz=cyst :: XX + =+ oxe=(parse-to-oryx q.u.bod) + ?~ oxe | + & :: XX + :: (~(has in vew.cyz) u.oxe) + :: + ++ parse-to-oryx ;~(biff poja (ot oryx/so ~):jo) + ++ continue-with-request |=(rem=pork handle(pok rem)) + ++ foreign-auth ,_!! + ++ handle-parsed + |= hem=perk + ^+ +> + ?- -.hem + ?(%spur %beam) !! + %poll + ?. ?=([~ %js] p.pok) :: XX treat non-json cases? + ?~ p.hem done + (ford-wasp ~ p.hem) + %^ resp 200 text//javascript + """ + window.urb = \{poll: "/{(apex:earn %| pok(u.p %json) quy)}"} + {(trip poll:js)} + """ + %auth + =+ `[ses=hole cyz=cyst]`get-session + ?- &2.hem + %js (resp 200 text//javascript (trip auth:js)) + %stat (give-json 200 ~ (get-auth-status ses)) + %try + ?. =(our him.hem) + ~|(stub-foreign/him.hem !!) + ?. =(load-secret cod.hem) + ~|(try/`@t`load-secret !!) + =. authed.cyz (~(put in authed.cyz) our) + =. wup (~(put by wup) ses cyz) + (give-json 200 cug.cyz (get-auth-status ses)) + :: + %del + =< (nice-json) + ?~ p.hem + .(wup (~(del by wup) ses)) + =< .(wup (~(put by wup) ses cyz)) + =. authed.cyz (~(del in authed.cyz) u.p.hem) + ?. =(u.p.hem him.cyz) . + .(him.cyz anon) + :: + %get + ~| aute/+.hem + ?: =(anon him.hem) + (continue-with-request rem.hem) + ?: (~(has in authed.cyz) him.hem) + (continue-with-request rem.hem) + ?. =(our him.hem) + (foreign-auth) + (show-login-page) + == + :: =. q.cez + :: ?. =(anon p.p.hem) + :: q.cez + :: (~(put in q.cez) p.p.hem) + :: =+ hez=(get-session our cip pul moh) + :: =. wup (~(put by wup) hez) + :: ?^ cug.q.hez + :: =+ rel=;html:script:"document.location.reload()" + :: =+ tuv=(tuff 200 text//html (crip (poxo rel))) + :: =. q.tuv + :: =- (weld :_(q.tuv -)) + :: (turn `(list ,@t)`cug.q.hez |=(a=cord set-cookie/a)))) + :: (give-gift tuv) + :: ~| hez !! + == + ++ show-login-page ,_(give-html 200 login-page:xml) + ++ get-auth-status + |= ses=hole + =+ [cyz=(~(get by wup) ses) orx=(rsh 3 1 (scot %p eny))] + %- jobe :~ + oryx/s/orx + user/(jape +:) + auth/a/?~(cyz ~ (turn (~(tap in authed.u.cyz)) |=(a=@p (jape +:)))) + == + ++ nice-json ,_(give-json 200 ~ (joba %ok %b &)) + :: + ++ load-secret + ^- @ta + =+ pax=/(scot %p our)/code/(scot %da now)/(scot %p our) + %^ rsh 3 1 + (scot %p (,@ (need (sky %a pax)))) + :: + ++ get-session :: get request state + ^- [hole cyst] + =* sec p.hat + =+ pef=(rsh 3 1 (scot %p our)) + =+ lig=(sesh pef maf) + ?^ lig + =+ cyz=(need (~(get by wup) u.lig)) + [u.lig cyz(cug ~)] + =+ ses=(rsh 3 1 (scot %p (end 6 1 ney))) + :- ses + ^- cyst + :* ^- cred + :* hat(p sec) + ~ + (rsh 3 1 (scot %p (end 6 1 (shaf %oryx ses)))) + :: + =+ lag=(~(get by maf) %accept-language) + ?~(lag ~ ?~(u.lag ~ [~ i.u.lag])) + :: + cip + ~ + == + [anon ~] + :: + :: ~ + :: + :_ ~ + %^ cat 3 + (cat 3 (cat 3 pef '=') ses) + :: (cat 3 '; HttpOnly' ?.(sec '' '; Secure')) + '; Path=/; HttpOnly' + :: + now + ~ + :: [1 ~] + == + -- ++ ya :: session engine :: =| [[our=ship ses=hole] cyst] ::serf cyst] :: =* sef ->- From f92d84c7a19068413783d62eba5d42f25b5d71f8 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 3 Mar 2015 18:22:02 -0800 Subject: [PATCH 053/219] passing ced to ford --- arvo/eyre.hoon | 230 ++++++++++++++++++++++++++++++------------------- 1 file changed, 139 insertions(+), 91 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 6464253b0f..2577b4a895 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -65,6 +65,7 @@ $: @tas :: by any $% [%crud p=@tas q=(list tank)] :: == == == :: +++ whir $|(~ $%([%at p=hole q=whir])) :: wire subset -- :: |% :: models ++ bolo :: eyre state @@ -80,10 +81,10 @@ :: ++ cyst :: client session $: ced=cred :: credential - [him=ship authed=(set ship)] :: authenticated + [him=ship aut=(set ship)] :: authenticated cug=(list ,@t) :: unacked cookies lax=@da :: last used - vew=(set oryx) :: open views + vew=(set oryx) :: open views XX expire == :: :: ++ perk :: parsed request @@ -95,11 +96,26 @@ :: ++ perk-auth :: parsed auth $% [%get him=ship rem=pork] + [%at p=pork] :: inject auth [%js ~] - [%stat ~] :: json with authentication status + [%json ~] [%try him=ship cod=cord] [%del p=(unit ship)] == +:: +++ pest :: result + $% [%for p=whir q=beam r=term s=cred] :: %f block + [%fow p=@uvH] :: %f deps + [%fin $|(~ pest-fin)] :: done + [%zap p=@ud q=(list tank)] :: err + == +:: +++ pest-fin :: response + $% [%json p=json] + [%html p=manx] + [%js p=@t] + [%$ p=httr] + == -- :: |% ++ sesh :: session from cookies @@ -143,6 +159,12 @@ ?~ dep max max(c.i.c :_(c.i.c.max ;script@"/~/on/{}.js";)) :: +++ jass :: inject window.urb + |= [urb=json jaz=cord] ^- cord + %^ cat 3 + (crip "window.urb = {(pojo urb)}\0a") + jaz +:: ++ js :: static javascript |% ++ poll :: dependency long-poll @@ -172,12 +194,11 @@ :: ++ auth ''' - window.urb = {} - window.urb.ship = 'zod' // XX + ship.innerText = urb.ship window.urb.submit = function(){ xhr = new XMLHttpRequest() xhr.open('POST', "/~/auth.json?PUT", true) - var dat = {oryx:'hi', ship: ship.value, code: pass.value} + var dat = {oryx:'hi', ship: ship.innerText, code: pass.value} xhr.send(JSON.stringify(dat)) xhr.addEventListener('load', function(){ if(this.status !== 200) @@ -193,10 +214,11 @@ ;html ;head:title:'Hello World' ;body - ;p: Identify yourself, ~;{input#ship(value "zod")}? + ;p: Identify yourself, ~;{span#ship(contenteditable "")}? + ;style:'#ship {background: lightgray} #ship br {display: none}' ;input#pass(onchange "urb.submit()"); ;pre:code#err; - ;script@"/~/auth.js"; + ;script@"/~/at/~/auth.js"; == == -- @@ -230,7 +252,7 @@ +>.$(mow [[hen %slip %d %flog +.sih] mow]) :: %made - ?+ tea +>.$ + ?+ tea ~& e/ford/lost/hen +>.$ ~ :: ~& e/ford/hen ?- -.q.sih @@ -302,7 +324,7 @@ (give-html sas (depo dep (tanx mez))) :: ++ give-html :: request failed - |=([sas=@ud max=manx] (resp sas text//html (poxo max))) + |=([sas=@ud max=manx] (resp sas text//html (crip (poxo max)))) :: ++ give-json :: success json |= [sas=@uG cug=(list ,@t) jon=json] @@ -317,17 +339,17 @@ +>(mow :_(mow [hen %give gef])) :: ++ resp :: mime response - |= [sas=@uG mit=mite bod=tape] - (give-gift (tuff sas mit (crip bod))) + |= [sas=@uG mit=mite bod=cord] + (give-gift (tuff sas mit bod)) :: ++ pass-note |=(noe=[wire note] +>(mow :_(mow [hen %pass noe]))) ++ ford-req - |= [tea=wire our=ship kas=silk] + |= [tea=whir our=ship kas=silk] :: ~& [%ford-req our num ses -.kas] (pass-note tea %f [%exec our `kas]) :: ++ back :: %ford bounce - |= [tea=wire dep=@uvH cag=cage] + |= [tea=whir dep=@uvH cag=cage] (ford-req tea our [%cast %mime %done ~ cag]) :: XX deps :: ++ tuff :: mimed response @@ -346,7 +368,6 @@ (rush i.dom fed:ag) :: ++ rq - =| (unit ,@t) :: cookie given? |_ $: [hat=hart pok=pork quy=quay] :: purl, parsed url cip=clip :: client ip [mef=meth maf=math bod=(unit octs)] :: method/headers/body @@ -365,15 +386,15 @@ :: ++ ford-kill (pass-note ~ %f [%exec our ~]) :: XX unused ++ ford-wasp - |= [tea=wire dep=@uvH] + |= [tea=whir dep=@uvH] (pass-note tea %f [%wasp our dep]) :: ++ beam-into-ford - |= [bem=beam ext=term ced=cred] + |= [tea=whir bem=beam ext=term ced=cred] =: s.bem [%web ~(rent co (flux:ya quy ced)) s.bem] r.bem ?+(r.bem r.bem [%ud %0] da/now) == - (ford-req ~ our [%cast %mime [%boil ext bem ~]]) + (ford-req tea our [%cast %mime [%boil ext bem ~]]) :: :: ++ as-beam @@ -430,6 +451,7 @@ %anon anon %own our == + %at [%auth %at pok(q but)] %auth :- %auth |- @@ -438,7 +460,7 @@ [~ %js] [%js ~] [~ %json] ?+ mef ~|(%bad-meth !!) - %get [%stat ~] + %get [%json ~] %post ?+ quy ~|(bad-quy/'"PUT" or "DELETE"' !!) [[%'PUT' ~] ~] @@ -453,106 +475,110 @@ :: ++ handle ^+ done - =+ git=as-magic-filename - ?^ git (give-gift u.git) =+ oar=(fall (host-to-ship r.hat) (need hov)) =. our oar :: XX - %- |=(a=(each ,_done tang) ?~(-.a p.a (fail 404 0v0 >%exit< p.a))) - %- mule |. ^+ done ~| [mef maf bod] - =+ ext=(fall p.pok %urb) + =+ pez=process + ?: ?=(%| -.pez) p.pez :: XX transitional + |- ^+ done + ?- -.p.pez + %for (beam-into-ford +.p.pez) + %fow (ford-wasp ~ p.p.pez) + %zap (fail p.p.pez 0v0 q.p.pez) + %fin ?~ +.p.pez done + ?- &2.p.pez + ~ (give-gift %thou p.p.pez) + %js (resp 200 text//javascript p.p.pez) + %html (give-html 200 p.p.pez) + %json (give-json 200 ~ p.p.pez) + == == + :: + ++ process + ^- (each pest ,_done) + =+ git=as-magic-filename + ?^ git [%| (give-gift u.git)] + %- |= a=(each (each pest ,_done) tang) + ?~(-.a p.a [%& %zap 404 >%exit< p.a]) + %- mule |. ^- (each pest ,_done) + ~| [mef maf bod] =+ bem=as-beam - ?^ bem - :: abet:(~(into-ford ya (get-sess..)) ..$) - =+ [ses cyz]=get-session - (beam-into-ford u.bem ext ced.cyz) + ?^ bem (process-parsed %beam u.bem) ?> check-oryx =+ hem=as-aux-request - ?^ hem (handle-parsed u.hem) + ?^ hem (process-parsed u.hem) ~|(strange-path/q.pok !!) :: ++ check-oryx :: | if json with bad oryx ^- ? ?. &(?=([~ %json] p.pok) ?=(%post mef) ?=(^ bod)) & - =| cyz=cyst :: XX =+ oxe=(parse-to-oryx q.u.bod) ?~ oxe | - & :: XX - :: (~(has in vew.cyz) u.oxe) + & ::(~(has in vew.cyz:for-client) u.oxe) ::XX :: ++ parse-to-oryx ;~(biff poja (ot oryx/so ~):jo) ++ continue-with-request |=(rem=pork handle(pok rem)) ++ foreign-auth ,_!! - ++ handle-parsed + ++ root-beak `beak`[our %main ud/0] :: XX + ++ process-parsed |= hem=perk - ^+ +> + ^- (each pest ,_done) ?- -.hem - ?(%spur %beam) !! + ?(%spur %beam) + =+ ext=(fall p.pok %urb) + =+ bem=?-(-.hem %beam p.hem, %spur [root-beak p.hem]) + [%& %for ~ bem ext ced.cyz:for-client] %poll - ?. ?=([~ %js] p.pok) :: XX treat non-json cases? - ?~ p.hem done - (ford-wasp ~ p.hem) - %^ resp 200 text//javascript - """ - window.urb = \{poll: "/{(apex:earn %| pok(u.p %json) quy)}"} - {(trip poll:js)} - """ - %auth - =+ `[ses=hole cyz=cyst]`get-session + ?: ?=([~ %js] p.pok) :: XX treat non-json cases? + =+ pol=(apex:earn %| pok(u.p %json) quy) :: polling url + :^ %& %fin %js + (jass (joba %poll (jape pol)) poll:js) + ?~ p.hem [%| done] + [%& %fow p.hem] + %auth + =+ yac=for-client ?- &2.hem - %js (resp 200 text//javascript (trip auth:js)) - %stat (give-json 200 ~ (get-auth-status ses)) + %json + :- %| + =^ jon ..ya stat-json.yac + (give-json 200 ~ jon) + %js [%& %fin %js auth:js] + %at + =. ..ya abet.yac + =+ pez=process(pok p.hem) + ?. ?=(%& -.pez) ~|(no-inject/p.hem !!) + ?- -.p.pez + ?(%fow %zap) pez + %for pez(p.p [%at ses.yac p.p.pez]) + %fin + ~| %not-script + ?> ?=(%js &2.p.pez) + =^ jon ..ya stat-json:for-client :: XX state lost + pez(p.p (jass jon p.p.pez)) + == + :: %try + :- %| ?. =(our him.hem) ~|(stub-foreign/him.hem !!) ?. =(load-secret cod.hem) ~|(try/`@t`load-secret !!) - =. authed.cyz (~(put in authed.cyz) our) - =. wup (~(put by wup) ses cyz) - (give-json 200 cug.cyz (get-auth-status ses)) + =^ jon ..ya stat-json:(logon:yac him.hem) + (give-json 200 cug.yac jon) :: - %del - =< (nice-json) - ?~ p.hem - .(wup (~(del by wup) ses)) - =< .(wup (~(put by wup) ses cyz)) - =. authed.cyz (~(del in authed.cyz) u.p.hem) - ?. =(u.p.hem him.cyz) . - .(him.cyz anon) + %del [%| (nice-json(..ya (logoff:yac p.hem)))] :: %get ~| aute/+.hem - ?: =(anon him.hem) - (continue-with-request rem.hem) - ?: (~(has in authed.cyz) him.hem) - (continue-with-request rem.hem) + ?: |(=(anon him.hem) (~(has in aut.yac) him.hem)) + =+ pez=process(pok rem.hem) + ?. ?=([%& %for ^] pez) + pez + pez(aut.s.p (~(put ju aut.s.p.pez) %$ (scot %p him.hem))) ?. =(our him.hem) (foreign-auth) - (show-login-page) + [%& (show-login-page)] == - :: =. q.cez - :: ?. =(anon p.p.hem) - :: q.cez - :: (~(put in q.cez) p.p.hem) - :: =+ hez=(get-session our cip pul moh) - :: =. wup (~(put by wup) hez) - :: ?^ cug.q.hez - :: =+ rel=;html:script:"document.location.reload()" - :: =+ tuv=(tuff 200 text//html (crip (poxo rel))) - :: =. q.tuv - :: =- (weld :_(q.tuv -)) - :: (turn `(list ,@t)`cug.q.hez |=(a=cord set-cookie/a)))) - :: (give-gift tuv) - :: ~| hez !! - == - ++ show-login-page ,_(give-html 200 login-page:xml) - ++ get-auth-status - |= ses=hole - =+ [cyz=(~(get by wup) ses) orx=(rsh 3 1 (scot %p eny))] - %- jobe :~ - oryx/s/orx - user/(jape +:) - auth/a/?~(cyz ~ (turn (~(tap in authed.u.cyz)) |=(a=@p (jape +:)))) == + ++ show-login-page ,_[%fin %html login-page:xml] ++ nice-json ,_(give-json 200 ~ (joba %ok %b &)) :: ++ load-secret @@ -561,8 +587,9 @@ %^ rsh 3 1 (scot %p (,@ (need (sky %a pax)))) :: - ++ get-session :: get request state - ^- [hole cyst] + ++ for-client :: stateful per-session engine + ^+ ya + %~ . ya =* sec p.hat =+ pef=(rsh 3 1 (scot %p our)) =+ lig=(sesh pef maf) @@ -599,10 +626,31 @@ == -- ++ ya :: session engine - :: =| [[our=ship ses=hole] cyst] ::serf cyst] - :: =* sef ->- - :: =* cyz -> + =| [ses=hole cyst] + =* cyz -> |% + ++ abet ..ya(wup (~(put by wup) ses cyz)) + ++ abut ..ya(wup (~(del by wup) ses)) + ++ logon |=(her=ship +>(him her, aut (~(put in aut) her))) + ++ logoff + |= her=(unit ship) ^+ ..ya + ?~ her abut + =. aut (~(del in aut) u.her) + ?~ aut abut + abet(him ?.(=(her him) him n.aut)) + :: + ++ stat-json + ^+ [*json ..ya] + =+ orx=(rsh 3 1 (scot %p (shaf %orx eny))) + =. vew (~(put in vew) orx) + :_ abet + %- jobe :~ + oryx/s/orx + ship/(jape +:) + user/(jape +:) + auth/a/(turn (~(tap in aut)) |=(a=@p (jape +:))) + == + :: ++ flux :: credential caboose |= [quy=quay ced=cred] ^- coin :* %many From bda50103112a8bd22625e4fc4c8f9b97bb57d0c1 Mon Sep 17 00:00:00 2001 From: Galen Wolfe-Pauly Date: Wed, 4 Mar 2015 17:51:03 -0800 Subject: [PATCH 054/219] talking --- docs/pub/tree/src/readme.md | 12 ++ main/pub/talk/src/css/fonts.styl | 12 ++ main/pub/talk/src/css/main.styl | 5 +- .../js/components/MessagesComponent.coffee | 19 ++- .../src/js/components/StationComponent.coffee | 6 +- .../js/components/StationsComponent.coffee | 2 +- .../src/js/components/WritingComponent.coffee | 12 +- main/pub/talk/src/js/main.coffee | 32 ++-- main/pub/talk/src/js/main.js | 156 +++++++----------- 9 files changed, 119 insertions(+), 137 deletions(-) create mode 100644 docs/pub/tree/src/readme.md diff --git a/docs/pub/tree/src/readme.md b/docs/pub/tree/src/readme.md new file mode 100644 index 0000000000..b6776e98dc --- /dev/null +++ b/docs/pub/tree/src/readme.md @@ -0,0 +1,12 @@ +# installing + +`npm install` + +# building + +in `src/js/`: +`watchify -v -t coffeeify -o main.js main.coffee` + +in `src/css/`: +`stylus -w main.styl` + diff --git a/main/pub/talk/src/css/fonts.styl b/main/pub/talk/src/css/fonts.styl index 8048040a31..1e64aa3860 100644 --- a/main/pub/talk/src/css/fonts.styl +++ b/main/pub/talk/src/css/fonts.styl @@ -69,4 +69,16 @@ src: url("http://storage.googleapis.com/urbit-extra/scp-medium.woff"); font-weight: 500; font-style: normal; +} +@font-face { + font-family: "scp"; + src: url("http://storage.googleapis.com/urbit-extra/scp-bold.woff"); + font-weight: 600; + font-style: normal; +} +@font-face { + font-family: "scp"; + src: url("http://storage.googleapis.com/urbit-extra/scp-black.woff"); + font-weight: 700; + font-style: normal; } \ No newline at end of file diff --git a/main/pub/talk/src/css/main.styl b/main/pub/talk/src/css/main.styl index c478b20316..a669dda956 100644 --- a/main/pub/talk/src/css/main.styl +++ b/main/pub/talk/src/css/main.styl @@ -202,7 +202,9 @@ body vertical-align top .attr - color #D7D7D7 + text-align right + display inline-block + margin-right .3rem .attr .iden color #000 @@ -212,7 +214,6 @@ body .mess font-size .9rem - line-height 1.6rem letter-spacing .03rem word-wrap break-word max-width 31rem diff --git a/main/pub/talk/src/js/components/MessagesComponent.coffee b/main/pub/talk/src/js/components/MessagesComponent.coffee index f721e7659c..b15b33b282 100644 --- a/main/pub/talk/src/js/components/MessagesComponent.coffee +++ b/main/pub/talk/src/js/components/MessagesComponent.coffee @@ -1,7 +1,7 @@ moment = require 'moment-timezone' recl = React.createClass -[div,input,textarea] = [React.DOM.div,React.DOM.input,React.DOM.textarea] +[div,br,input,textarea] = [React.DOM.div,React.DOM.br,React.DOM.input,React.DOM.textarea] MessageStore = require '../stores/MessageStore.coffee' StationStore = require '../stores/StationStore.coffee' @@ -29,14 +29,16 @@ Message = recl console.log delivery name = if @props.name then @props.name else "" - audi = _.remove _.keys(@props.thought.audience), (stat) => - stat isnt "~"+window.urb.ship+"/"+@props.station + audi = _.keys(@props.thought.audience) + # audi = _.remove _.keys(@props.thought.audience), (stat) => + # stat isnt "~"+window.urb.ship+"/"+@props.station audi = audi.join " " div {className:"message "+pendingClass}, [ (div {className:"attr"}, [ - (Member {ship:@props.ship}, "") div {className:"audi"}, "#{audi}" + (Member {ship:@props.ship}, "") + (br {},"") div {className:"time"}, @convTime @props.thought.statement.date ]) div {className:"mess"}, @props.thought.statement.speech.lin.txt @@ -51,7 +53,7 @@ module.exports = recl last:MessageStore.getLast() fetching:MessageStore.getFetching() listening:MessageStore.getListening() - station:StationStore.getStation() + station:"court" stations:StationStore.getStations() configs:StationStore.getConfigs() typing:MessageStore.getTyping() @@ -106,9 +108,10 @@ module.exports = recl _station = "~"+window.urb.ship+"/"+station sources = _.clone @state.configs[@state.station]?.sources ? [] sources.push _station - _messages = _.filter @state.messages, (_message) -> - audience = _.keys(_message.thought.audience) - _.intersection(sources,audience).length > 0 + _messages = @state.messages + # _messages = _.filter @state.messages, (_message) -> + # audience = _.keys(_message.thought.audience) + # _.intersection(sources,audience).length > 0 _messages = _.sortBy _messages, (_message) -> _message.pending = _message.thought.audience[station] _message.thought.statement.time diff --git a/main/pub/talk/src/js/components/StationComponent.coffee b/main/pub/talk/src/js/components/StationComponent.coffee index 0d6546bf43..a033d450c9 100644 --- a/main/pub/talk/src/js/components/StationComponent.coffee +++ b/main/pub/talk/src/js/components/StationComponent.coffee @@ -15,7 +15,7 @@ module.exports = recl stateFromStore: -> { audi:StationStore.getAudience() members:StationStore.getMembers() - station:StationStore.getStation() + station:"court" stations:StationStore.getStations() configs:StationStore.getConfigs() typing:StationStore.getTyping() @@ -91,8 +91,8 @@ module.exports = recl sources = "" station = [] - station.push (a {className:"up",href:"\#/"}, [(div {className:"arow-up"}, "")]) - station.push (h1 {},@state.station) + # station.push (a {className:"up",href:"\#/"}, [(div {className:"arow-up"}, "")]) + # station.push (h1 {},@state.station) station.push (div {id:"members"},members) parts.push (div {id:"station-container"}, (div {id:"station-meta"},station)) diff --git a/main/pub/talk/src/js/components/StationsComponent.coffee b/main/pub/talk/src/js/components/StationsComponent.coffee index df5a5411db..1d1aea5866 100644 --- a/main/pub/talk/src/js/components/StationsComponent.coffee +++ b/main/pub/talk/src/js/components/StationsComponent.coffee @@ -7,7 +7,7 @@ StationActions = require '../actions/StationActions.coffee' module.exports = recl stateFromStore: -> { stations: StationStore.getStations() - station: StationStore.getStation() + station: "~zod/court" } getInitialState: -> @stateFromStore() diff --git a/main/pub/talk/src/js/components/WritingComponent.coffee b/main/pub/talk/src/js/components/WritingComponent.coffee index f6888e543c..d77e482b94 100644 --- a/main/pub/talk/src/js/components/WritingComponent.coffee +++ b/main/pub/talk/src/js/components/WritingComponent.coffee @@ -14,10 +14,9 @@ module.exports = recl if window.localStorage then window.localStorage.getItem 'writing' stateFromStore: -> { - audi:StationStore.getAudience() + audi:["~zod/court"] members:StationStore.getMembers() typing:StationStore.getTyping() - station:StationStore.getStation() } getInitialState: -> @stateFromStore() @@ -35,7 +34,7 @@ module.exports = recl @typing true sendMessage: -> - MessageActions.sendMessage @state.station,@$writing.text(),@state.audi + MessageActions.sendMessage @state.audi,@$writing.text(),@state.audi @$length.text "0/69" @$writing.text('') @set() @@ -109,13 +108,16 @@ module.exports = recl name = if iden then iden.name else "" k = "writing" - k+= " hidden" if not @state?.station - div {className:k,onClick:@_setFocus}, [ + div {className:k}, [ (div {className:"attr"}, [ (Member iden, "") (div {className:"time"}, @getTime()) ]) + (div { + id:"audi" + contentEditable:true + }, "~zod/court") (div { id:"writing" contentEditable:true diff --git a/main/pub/talk/src/js/main.coffee b/main/pub/talk/src/js/main.coffee index 1610d6025b..253517b96c 100644 --- a/main/pub/talk/src/js/main.coffee +++ b/main/pub/talk/src/js/main.coffee @@ -86,26 +86,14 @@ $(() -> React.unmountComponentAtNode $('#writing-container')[0] React.unmountComponentAtNode $('#messages-container')[0] - routes = - '': -> - clean() - $c.html "
" - rend (StationsComponent {}, ""),$('#stations-container')[0] - '/:station': (station) -> - clean() - StationActions.switchStation station - $c.html "" - $c.append("
") - $d = $('#messaging-container') - $d.append("
") - $d.append("
") - $d.append("
") - $c.append("
BOTTOM
") - rend (StationComponent {}, ""),$('#station-parts-container')[0] - rend (MessagesComponent {}, ""),$('#messages-container')[0] - rend (WritingComponent {}, ""),$('#writing-container')[0] - - router = Router routes - if not window.location.hash then window.location.hash = "/" - router.init() + $c.html "" + $c.append("
") + $d = $('#messaging-container') + $d.append("
") + $d.append("
") + $d.append("
") + $c.append("
BOTTOM
") + rend (StationComponent {}, ""),$('#station-parts-container')[0] + rend (MessagesComponent {}, ""),$('#messages-container')[0] + rend (WritingComponent {}, ""),$('#writing-container')[0] ) \ No newline at end of file diff --git a/main/pub/talk/src/js/main.js b/main/pub/talk/src/js/main.js index e59436ea56..dbb6407d3e 100644 --- a/main/pub/talk/src/js/main.js +++ b/main/pub/talk/src/js/main.js @@ -37,7 +37,7 @@ module.exports = { return window.chat.MessagePersistence.get(station, start, end); }, sendMessage: function(station, message, audience) { - var k, serial, v, _audi, _message; + var _audi, _message, k, serial, v; serial = window.util.uuid32(); if (station[0] !== "~") { station = "~" + window.urb.ship + "/" + station; @@ -167,11 +167,11 @@ module.exports = { },{"../dispatcher/Dispatcher.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/dispatcher/Dispatcher.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/MemberComponent.coffee":[function(require,module,exports){ -var div, input, recl, textarea, _ref; +var div, input, recl, ref, textarea; recl = React.createClass; -_ref = [React.DOM.div, React.DOM.input, React.DOM.textarea], div = _ref[0], input = _ref[1], textarea = _ref[2]; +ref = [React.DOM.div, React.DOM.input, React.DOM.textarea], div = ref[0], input = ref[1], textarea = ref[2]; module.exports = recl({ render: function() { @@ -196,13 +196,13 @@ module.exports = recl({ },{}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/MessagesComponent.coffee":[function(require,module,exports){ -var Member, Message, MessageActions, MessageStore, StationActions, StationStore, div, input, moment, recl, textarea, _ref; +var Member, Message, MessageActions, MessageStore, StationActions, StationStore, br, div, input, moment, recl, ref, textarea; moment = require('moment-timezone'); recl = React.createClass; -_ref = [React.DOM.div, React.DOM.input, React.DOM.textarea], div = _ref[0], input = _ref[1], textarea = _ref[2]; +ref = [React.DOM.div, React.DOM.br, React.DOM.input, React.DOM.textarea], div = ref[0], br = ref[1], input = ref[2], textarea = ref[3]; MessageStore = require('../stores/MessageStore.coffee'); @@ -239,11 +239,7 @@ Message = recl({ console.log(delivery); } name = this.props.name ? this.props.name : ""; - audi = _.remove(_.keys(this.props.thought.audience), (function(_this) { - return function(stat) { - return stat !== "~" + window.urb.ship + "/" + _this.props.station; - }; - })(this)); + audi = _.keys(this.props.thought.audience); audi = audi.join(" "); return div({ className: "message " + pendingClass @@ -251,11 +247,11 @@ Message = recl({ div({ className: "attr" }, [ - Member({ - ship: this.props.ship - }, ""), div({ + div({ className: "audi" - }, "" + audi), div({ + }, "" + audi), Member({ + ship: this.props.ship + }, ""), br({}, ""), div({ className: "time" }, this.convTime(this.props.thought.statement.date)) ]), div({ @@ -274,7 +270,7 @@ module.exports = recl({ last: MessageStore.getLast(), fetching: MessageStore.getFetching(), listening: MessageStore.getListening(), - station: StationStore.getStation(), + station: "court", stations: StationStore.getStations(), configs: StationStore.getConfigs(), typing: MessageStore.getTyping() @@ -335,16 +331,12 @@ module.exports = recl({ return this.setState(this.stateFromStore()); }, render: function() { - var messages, sources, station, _messages, _ref1, _ref2, _station; + var _messages, _station, messages, ref1, ref2, sources, station; station = this.state.station; _station = "~" + window.urb.ship + "/" + station; - sources = _.clone((_ref1 = (_ref2 = this.state.configs[this.state.station]) != null ? _ref2.sources : void 0) != null ? _ref1 : []); + sources = _.clone((ref1 = (ref2 = this.state.configs[this.state.station]) != null ? ref2.sources : void 0) != null ? ref1 : []); sources.push(_station); - _messages = _.filter(this.state.messages, function(_message) { - var audience; - audience = _.keys(_message.thought.audience); - return _.intersection(sources, audience).length > 0; - }); + _messages = this.state.messages; _messages = _.sortBy(_messages, function(_message) { _message.pending = _message.thought.audience[station]; return _message.thought.statement.time; @@ -373,11 +365,11 @@ module.exports = recl({ },{"../actions/MessageActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/actions/MessageActions.coffee","../actions/StationActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/actions/StationActions.coffee","../stores/MessageStore.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/stores/MessageStore.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/stores/StationStore.coffee","./MemberComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/MemberComponent.coffee","moment-timezone":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/node_modules/moment-timezone/index.js"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/StationComponent.coffee":[function(require,module,exports){ -var Member, StationActions, StationStore, a, div, h1, input, recl, textarea, _ref; +var Member, StationActions, StationStore, a, div, h1, input, recl, ref, textarea; recl = React.createClass; -_ref = [React.DOM.div, React.DOM.input, React.DOM.textarea, React.DOM.h1, React.DOM.a], div = _ref[0], input = _ref[1], textarea = _ref[2], h1 = _ref[3], a = _ref[4]; +ref = [React.DOM.div, React.DOM.input, React.DOM.textarea, React.DOM.h1, React.DOM.a], div = ref[0], input = ref[1], textarea = ref[2], h1 = ref[3], a = ref[4]; StationStore = require('../stores/StationStore.coffee'); @@ -390,7 +382,7 @@ module.exports = recl({ return { audi: StationStore.getAudience(), members: StationStore.getMembers(), - station: StationStore.getStation(), + station: "court", stations: StationStore.getStations(), configs: StationStore.getConfigs(), typing: StationStore.getTyping(), @@ -421,7 +413,7 @@ module.exports = recl({ return this.setState(this.stateFromStore()); }, _keyUp: function(e) { - var v, _sources; + var _sources, v; if (e.keyCode === 13) { v = this.$input.val(); if (this.state.configs[this.state.station].sources.indexOf(v) === -1) { @@ -442,7 +434,7 @@ module.exports = recl({ return StationActions.setSources(this.state.station, _sources); }, render: function() { - var members, parts, sourceCtrl, sourceInput, sources, station, _remove, _sources; + var _remove, _sources, members, parts, sourceCtrl, sourceInput, sources, station; parts = []; members = []; if (this.state.station && this.state.members[this.state.station]) { @@ -497,15 +489,6 @@ module.exports = recl({ sources = ""; } station = []; - station.push(a({ - className: "up", - href: "\#/" - }, [ - div({ - className: "arow-up" - }, "") - ])); - station.push(h1({}, this.state.station)); station.push(div({ id: "members" }, members)); @@ -530,11 +513,11 @@ module.exports = recl({ },{"../actions/StationActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/actions/StationActions.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/stores/StationStore.coffee","./MemberComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/MemberComponent.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/StationsComponent.coffee":[function(require,module,exports){ -var StationActions, StationStore, div, input, recl, _ref; +var StationActions, StationStore, div, input, recl, ref; recl = React.createClass; -_ref = [React.DOM.div, React.DOM.input], div = _ref[0], input = _ref[1]; +ref = [React.DOM.div, React.DOM.input], div = ref[0], input = ref[1]; StationStore = require('../stores/StationStore.coffee'); @@ -544,7 +527,7 @@ module.exports = recl({ stateFromStore: function() { return { stations: StationStore.getStations(), - station: StationStore.getStation() + station: "~zod/court" }; }, getInitialState: function() { @@ -587,7 +570,7 @@ module.exports = recl({ return e.preventDefault(); }, render: function() { - var station, stations, _click, _remove; + var _click, _remove, station, stations; station = this.state.station; _click = this._click; _remove = this._remove; @@ -632,11 +615,11 @@ module.exports = recl({ },{"../actions/StationActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/actions/StationActions.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/stores/StationStore.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/WritingComponent.coffee":[function(require,module,exports){ -var Member, MessageActions, StationActions, StationStore, div, input, recl, textarea, _ref; +var Member, MessageActions, StationActions, StationStore, div, input, recl, ref, textarea; recl = React.createClass; -_ref = [React.DOM.div, React.DOM.input, React.DOM.textarea], div = _ref[0], input = _ref[1], textarea = _ref[2]; +ref = [React.DOM.div, React.DOM.input, React.DOM.textarea], div = ref[0], input = ref[1], textarea = ref[2]; MessageActions = require('../actions/MessageActions.coffee'); @@ -659,10 +642,9 @@ module.exports = recl({ }, stateFromStore: function() { return { - audi: StationStore.getAudience(), + audi: ["~zod/court"], members: StationStore.getMembers(), - typing: StationStore.getTyping(), - station: StationStore.getStation() + typing: StationStore.getTyping() }; }, getInitialState: function() { @@ -682,7 +664,7 @@ module.exports = recl({ return this.typing(true); }, sendMessage: function() { - MessageActions.sendMessage(this.state.station, this.$writing.text(), this.state.audi); + MessageActions.sendMessage(this.state.audi, this.$writing.text(), this.state.audi); this.$length.text("0/69"); this.$writing.text(''); this.set(); @@ -698,14 +680,14 @@ module.exports = recl({ return this.set(); }, _input: function(e) { - var geturl, length, text, url, urls, _i, _len; + var geturl, i, len, length, text, url, urls; text = this.$writing.text(); length = text.length; geturl = new RegExp("(^|[ \t\r\n])((ftp|http|https|gopher|mailto|news|nntp|telnet|wais|file|prospero|aim|webcal):(([A-Za-z0-9$_.+!*(),;/?:@&~=-])|%[A-Fa-f0-9]{2}){2,}(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*(),;/?:@&~=%-]*))?([A-Za-z0-9$_+!*();/?:~-]))", "g"); urls = text.match(geturl); if (urls !== null && urls.length > 0) { - for (_i = 0, _len = urls.length; _i < _len; _i++) { - url = urls[_i]; + for (i = 0, len = urls.length; i < len; i++) { + url = urls[i]; length -= url.length; length += 10; } @@ -766,18 +748,14 @@ module.exports = recl({ return this.setState(this.stateFromStore()); }, render: function() { - var iden, k, name, ship, user, _ref1; + var iden, k, name, ship, user; user = "~" + window.urb.user; iden = StationStore.getMember(user); ship = iden ? iden.ship : user; name = iden ? iden.name : ""; k = "writing"; - if (!((_ref1 = this.state) != null ? _ref1.station : void 0)) { - k += " hidden"; - } return div({ - className: k, - onClick: this._setFocus + className: k }, [ div({ className: "attr" @@ -786,6 +764,9 @@ module.exports = recl({ className: "time" }, this.getTime()) ]), div({ + id: "audi", + contentEditable: true + }, "~zod/court"), div({ id: "writing", contentEditable: true, onFocus: this._focus, @@ -827,7 +808,7 @@ module.exports = _.merge(new Dispatcher(), { },{"flux":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/node_modules/flux/index.js"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/main.coffee":[function(require,module,exports){ $(function() { - var $c, MessagesComponent, StationActions, StationComponent, StationsComponent, WritingComponent, clean, rend, router, routes; + var $c, $d, MessagesComponent, StationActions, StationComponent, StationsComponent, WritingComponent, clean, rend; StationActions = require('./actions/StationActions.coffee'); rend = React.render; window.chat = {}; @@ -851,10 +832,10 @@ $(function() { return window.chat.StationPersistence.addSource("main", window.urb.ship, ["~zod/" + name]); }, uuid32: function() { - var i, str, _i, _str; + var _str, i, j, str; str = "0v"; str += Math.ceil(Math.random() * 8) + "."; - for (i = _i = 0; _i <= 5; i = ++_i) { + for (i = j = 0; j <= 5; i = ++j) { _str = Math.ceil(Math.random() * 10000000).toString(32); _str = ("00000" + _str).substr(-5, 5); str += _str + "."; @@ -920,33 +901,16 @@ $(function() { React.unmountComponentAtNode($('#writing-container')[0]); return React.unmountComponentAtNode($('#messages-container')[0]); }; - routes = { - '': function() { - clean(); - $c.html("
"); - return rend(StationsComponent({}, ""), $('#stations-container')[0]); - }, - '/:station': function(station) { - var $d; - clean(); - StationActions.switchStation(station); - $c.html(""); - $c.append("
"); - $d = $('#messaging-container'); - $d.append("
"); - $d.append("
"); - $d.append("
"); - $c.append("
BOTTOM
"); - rend(StationComponent({}, ""), $('#station-parts-container')[0]); - rend(MessagesComponent({}, ""), $('#messages-container')[0]); - return rend(WritingComponent({}, ""), $('#writing-container')[0]); - } - }; - router = Router(routes); - if (!window.location.hash) { - window.location.hash = "/"; - } - return router.init(); + $c.html(""); + $c.append("
"); + $d = $('#messaging-container'); + $d.append("
"); + $d.append("
"); + $d.append("
"); + $c.append("
BOTTOM
"); + rend(StationComponent({}, ""), $('#station-parts-container')[0]); + rend(MessagesComponent({}, ""), $('#messages-container')[0]); + return rend(WritingComponent({}, ""), $('#writing-container')[0]); }); @@ -5325,13 +5289,13 @@ module.exports = { appl: "rodeo", path: "/f/" + station + "/" + since }, function(err, res) { - var _ref, _ref1; + var ref, ref1; console.log('m subscription updates'); console.log(res.data); if (res.data.ok === true) { MessageActions.listeningStation(station); } - if ((_ref = res.data) != null ? (_ref1 = _ref.grams) != null ? _ref1.tele : void 0 : void 0) { + if ((ref = res.data) != null ? (ref1 = ref.grams) != null ? ref1.tele : void 0 : void 0) { return MessageActions.loadMessages(res.data.grams); } }); @@ -5341,10 +5305,10 @@ module.exports = { appl: "rodeo", path: "/f/" + station + "/" + end + "/" + start }, function(err, res) { - var _ref, _ref1; + var ref, ref1; console.log('get'); console.log(res); - if ((_ref = res.data) != null ? (_ref1 = _ref.grams) != null ? _ref1.tele : void 0 : void 0) { + if ((ref = res.data) != null ? (ref1 = ref.grams) != null ? ref1.tele : void 0 : void 0) { MessageActions.loadMessages(res.data.grams, true); return window.urb.unsubscribe({ appl: "rodeo", @@ -5441,10 +5405,10 @@ module.exports = { appl: "rodeo", path: "/a/court" }, function(err, res) { - var _ref, _ref1; + var ref, ref1; console.log('membership updates'); console.log(res.data); - if ((_ref = res.data) != null ? (_ref1 = _ref.group) != null ? _ref1.global : void 0 : void 0) { + if ((ref = res.data) != null ? (ref1 = ref.group) != null ? ref1.global : void 0 : void 0) { return StationActions.loadMembers(res.data.group.global); } }); @@ -5466,13 +5430,13 @@ module.exports = { appl: "rodeo", path: "/ax/" + station }, function(err, res) { - var _ref; + var ref; console.log('station subscription updates'); console.log(res.data); if (res.data.ok === true) { StationActions.listeningStation(station); } - if ((_ref = res.data.group) != null ? _ref.local : void 0) { + if ((ref = res.data.group) != null ? ref.local : void 0) { StationActions.loadMembers(station, res.data.group.local); } if (res.data.config) { @@ -5485,7 +5449,7 @@ module.exports = { },{"../actions/StationActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/actions/StationActions.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/stores/MessageStore.coffee":[function(require,module,exports){ -var EventEmitter, MessageDispatcher, MessageStore, moment, _fetching, _last, _listening, _messages, _station, _typing; +var EventEmitter, MessageDispatcher, MessageStore, _fetching, _last, _listening, _messages, _station, _typing, moment; moment = require('moment-timezone'); @@ -5730,8 +5694,8 @@ StationStore = _.merge(new EventEmitter, { return _station; }, joinStation: function(station) { - var _ref; - if (((_ref = _config.court) != null ? _ref.sources.indexOf(station) : void 0) === -1) { + var ref; + if (((ref = _config.court) != null ? ref.sources.indexOf(station) : void 0) === -1) { return _config.court.sources.push(station); } }, From f4d4cd6ba7d168f93ee6f75cd101cdf037d7cba9 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Thu, 5 Mar 2015 13:22:39 -0800 Subject: [PATCH 055/219] Various fixes and improvements. --- main/app/dojo/core.hook | 152 +++++++++++++++++++++++++++++++++------- 1 file changed, 127 insertions(+), 25 deletions(-) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 9df12ce867..97d2d126b8 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -13,7 +13,6 @@ == :: ++ session :: per conversation $: say=console-share :: command-line state - duy=(unit tape) :: waiting poy=(unit dojo-project) :: working var=(map term cage) :: variable state old=(set term) :: used TLVs @@ -24,12 +23,11 @@ == :: ++ dojo-source :: $: inx=@ud :: index, assigned - mar=mark :: content type mod=dojo-model :: == :: ++ dojo-model :: data source - $% [%& twig] :: - [%| (pair path dojo-config)] :: + $% [%& twig] :: direct expression + [%| (trel term term dojo-config)] :: command engine == :: ++ dojo-config :: configuration $: ord=(list dojo-source) :: by order @@ -39,7 +37,9 @@ $: mad=dojo-command :: operation num=@ud :: number of tasks cur=@ud :: currently solving - pro=(unit vase) :: prompting form + pro=(unit vase) :: prompting loop + idl=? :: not calling ford + per=(unit console-edit) :: pending reverse job=(map ,@ud dojo-source) :: problems rez=(map ,@ud cage) :: results == :: @@ -130,6 +130,26 @@ |_ dojo-project :: ++ dy-abet +>(poy `+<) :: resolve ++ dy-amok +>(poy ~) :: terminate + ++ dy-ford :: send to ford + |= [pax=path kas=silk] + ^+ +>+> + (he-pass(poy `+>+<(idl %|)) pax %f %exec our.hid `kas) + :: + ++ dy-slam :: call to ford + |= [pax=path gat=vase sam=vase] + ^+ +>+> + (dy-ford pax %call [%done ~ %noun gat] [%done ~ %noun sam]) + :: + ++ dy-rush :: send effects, abet + |= fec=console-effect + ^+ +>+> + (he-rush(poy `+>+<) fec) + :: + ++ dy-rash :: send effects, amok + |= fec=console-effect + ^+ +>+> + (he-rush(poy ~) fec) + :: ++ dy-init-ordered :: prepare source list |= ord=(list dojo-source) ^+ [ord +>] @@ -152,8 +172,8 @@ ^+ [mod +>] ?- -.mod %& [mod +>] - %| =^ cig +> (dy-init-config q.mod) - [mod(q cig) +>.$] + %| =^ cig +> (dy-init-config r.mod) + [mod(r cig) +>.$] == :: ++ dy-init-source :: prepare source @@ -181,12 +201,61 @@ +>(mad dam(r src)) == :: - ++ dy-made-hand + ++ dy-work :: console action + |= act=console-action + ?- -.act + %det (he-stir +.act) + %ret (he-done (tufa buf.say)) + == + :: + ++ dy-hand :: complete step |= cag=cage ^+ +>+> dy-step(cur +(cur), rez (~(put by rez) cur cag)) :: - ++ dy-over + ++ dy-made-edit :: console edit + |= cag=cage + ^+ +>+> + ?> ?=(^ per) + ?^ q.q.cag + ~& %dy-made-edit-good + dy-abet(per ~) + ~& %dy-made-edit-bad + =^ lic say (~(transmit cs say) u.per) + (dy-rush(per ~) %mor [%bel ~] [%det lic] ~) + :: + ++ dy-made-make :: created prompt + |= cag=cage + ^+ +>+> + ~& %dy-made-make + (dy-slam /dial q.cag [[%atom %n] ~]) + :: + ++ dy-made-dial :: dialog result + |= cag=cage + ?. ?=([~ ~ a=* b=*] q.q.cag) + ~& %dy-made-init-fail + (dy-rash %bel ~) + =. +>+> + ?: =(a.q.q.cag ~) + +>+> + (he-rush %tan ((list tank) a.q.q.cag)) + ?+ -.b.q.q.cag (dy-rash %bel ~) + %& + ?~ +.b.q.q.cag + (dy-rash %bel ~) + (dy-hand %noun (slot 63 q.cag)) + :: + %| + (dy-rush(pro `(slot 63 q.cag)) %pro (console-prompt +<.b.q.q.cag)) + == + :: + ++ dy-done + |= txt=tape + ~& %dy-done + ?> ?=(^ pro) + (dy-slam /dial u.pro (slop [[%atom %n] ~] !>(txt))) + :: + ++ dy-over :: finish construction ^+ +> ?- -.mad %poke @@ -199,6 +268,26 @@ (he-rush(poy ~) [%tan (sell q.cag) ~]) == :: + ++ dy-edit :: handle edit + |= cal=console-change + ^+ +>+> + =+ old=buf.say + =^ dat say (~(receive cs say) cal) + =. dat (~(inverse cs say(buf old)) dat) + ?: |(?=(^ per) !idl ?=(~ pro)) + ~& %dy-edit-busy + =^ lic say (~(transmit cs say) dat) + (dy-rush %mor [%det lic] [%bel ~] ~) + (dy-slam(per `dat) /edit u.pro !>(buf.say)) + :: + ++ dy-work :: handle input + |= act=console-action + ^+ +>+> + ?- -.act + %det (dy-edit +.act) + %ret (dy-done (tufa buf.say)) + == + :: ++ dy-step :: advance project ^+ +> ?: =(cur num) @@ -206,16 +295,27 @@ =+ src=(~(got by job) cur) ?- -.mod.src %& - %- he-pass(poy `+>-) - [/hand %f %exec our.hid `[%ride +.mod.src [%reef ~]]] + %- he-pass(poy `+>-) + [/hand %f %exec our.hid `[%ride +.mod.src [%reef ~]]] :: - %| !! + %| + %- he-pass(poy `+>-) + :* /make + %f + %exec + our.hid + ~ + %boil + %noun + [[our.hid %main %da lat.hid] [p.mod.src %mad q.mod.src ~]] + ~ + == == -- :: ++ he-abet :: resolve - [(flop moz) %_(+> hoc (~(put by hoc) ost +<+))] :: - :: :: + [(flop moz) %_(+> hoc (~(put by hoc) ost +<+))] + :: ++ he-give :: emit gift |= git=gift ^+ +> @@ -236,8 +336,6 @@ ++ he-prom :: send prompt %- he-rush :- %pro - ?^ duy - [& %$ (tuba u.duy)] [& %$ (tuba (weld (scow %p our.hid) ":dojo> "))] :: ++ he-ford :: sign from ford @@ -245,9 +343,13 @@ ^+ +> ?> ?=(^ poy) ?- -.rey - %& ?+ pax ~&(%he-ford-path !!) - [%hand ~] - (~(dy-made-hand dy u.poy) q.p.rey) + %& =+ dye=~(. dy u.poy) + =. idl.dye & + ?+ pax ~&(%he-ford-path !!) + [%hand ~] (dy-hand:dye q.p.rey) + [%dial ~] (dy-made-dial:dye q.p.rey) + [%make ~] (dy-made-make:dye q.p.rey) + [%edit ~] (dy-made-edit:dye q.p.rey) == %| (he-rush(poy ~) %tan p.rey) == @@ -261,9 +363,7 @@ ++ he-stir :: apply change |= cal=console-change ^+ +> - =^ dut say - %+ ~(remit cs say) cal - ?~(duy he-like |=((list ,@c) %|)) + =^ dut say (~(remit cs say) cal he-like) ?~ dut +>.$ (he-rush %mor [%det u.dut] [%bel ~] ~) @@ -273,12 +373,11 @@ ^+ +> ?> ?=(~ poy) =< dy-step - ~(dy-init dy mad [0 0 ~ ~ ~]) + ~(dy-init dy mad [0 0 ~ %& ~ ~ ~]) :: ++ he-done :: parse command |= txt=tape ^+ +> - ?^ duy (he-rush %bel ~) =+ foy=(rust txt wide:(vang & ~)) ?~ foy (he-rush %bel ~) @@ -291,11 +390,13 @@ [%nex ~] [%det cal] == - `dojo-command`[%save & %foo 0 %noun %& u.foy] + `dojo-command`[%save & %foo 0 %& u.foy] :: ++ he-work :: apply input |= act=console-action ^+ +> + ?^ poy + (~(dy-work dy u.poy) act) ?- -.act %det (he-stir +.act) %ret (he-done (tufa buf.say)) @@ -312,6 +413,7 @@ :: ++ poke-console-action |= [ost=bone her=ship act=console-action] + ~& %poke-console-action ^- [(list move) _+>] he-abet:(~(he-work he [ost [ost %give %nice ~]~] (~(got by hoc) ost)) act) :: From 46f4f89183e6d50851f50142a15f4e40c2411deb Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Thu, 5 Mar 2015 14:58:04 -0800 Subject: [PATCH 056/219] Re-converged ford with dojo. --- arvo/hoon.hoon | 12 +++++++++++- main/app/dojo/core.hook | 5 +++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index 5184d1a4e5..1140f12c02 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -6176,7 +6176,9 @@ |= [sut=type ref=type] ^- [? worm] ?: (~(has in nes) [sut ref]) [& +>+<] - ?. (~(nest ut sut) | ref) [| +>+<] + ?. (~(nest ut sut) | ref) + :: ~& %nest-failed + [| +>+<] [& +>+<(nes (~(put in nes) [sut ref]))] :: ++ nets :: typeless nest @@ -6185,6 +6187,14 @@ ?: (~(has in nes) [sut ref]) [& +>+<] =+ gat=|=([a=type b=type] (~(nest ut a) | b)) ?. (,? .*(gat(+< [sut ref]) -.gat)) + :: ~& %nets-failed + :: =+ tag=`*`skol + :: =+ foo=(tank .*(tag(+< ref) -.tag)) + :: =+ bar=(skol sut) + :: ~& %nets-need + :: ~> %slog.[0 bar] + :: ~& %nets-have + :: ~> %slog.[0 foo] [| +>+<.$] [& +>+<.$(nes (~(put in nes) [sut ref]))] :: diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 97d2d126b8..84abcd2a3b 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -71,7 +71,7 @@ [%dub p=term q=horn] :: /= apply face [%fan p=(list horn)] :: /. list [%for p=path q=horn] :: /, descend - [%hel p=horn] :: /% propagate heel + [%hel p=@ud q=horn] :: /% propagate heel [%hub p=horn] :: /@ list by @ud [%man p=(map span horn)] :: /* hetero map [%nap p=horn] :: /_ homo map @@ -81,7 +81,7 @@ [%sic p=tile q=horn] :: /^ cast [%toy p=mark] :: /mark/ static == :: - ++ silk :: from %ford + ++ silk :: construction layer $& [p=silk q=silk] :: cons $% [%bake p=mark q=beam r=path] :: local synthesis [%boil p=mark q=beam r=path] :: general synthesis @@ -323,6 +323,7 @@ :: ++ he-pass |= [pax=path noy=note] + ~& [%he-pass pax noy] %_(+> moz [[ost %pass pax noy] moz]) :: ++ he-rush :: emit update From 91ebe88f6de77afbe034fe76da9677c80ca6eb96 Mon Sep 17 00:00:00 2001 From: Galen Wolfe-Pauly Date: Thu, 5 Mar 2015 19:58:23 -0800 Subject: [PATCH 057/219] talk reorg --- docs/pub/doc/arvo/clay/commentary.md | 2 +- main/pub/talk/src/css/main.css | 78 +++++++++--------- main/pub/talk/src/css/main.styl | 61 +++++++------- .../js/components/MessagesComponent.coffee | 6 +- .../src/js/components/StationComponent.coffee | 10 +-- .../src/js/components/WritingComponent.coffee | 38 +++++++-- main/pub/talk/src/js/main.js | 79 ++++++++++++------- .../talk/src/js/stores/MessageStore.coffee | 5 ++ 8 files changed, 158 insertions(+), 121 deletions(-) diff --git a/docs/pub/doc/arvo/clay/commentary.md b/docs/pub/doc/arvo/clay/commentary.md index d0edfea2dd..daf8bc7dfb 100644 --- a/docs/pub/doc/arvo/clay/commentary.md +++ b/docs/pub/doc/arvo/clay/commentary.md @@ -1989,7 +1989,7 @@ try to get the aeon referred to by the starting case. If it doesn't exist yet, then we can't do anything interesting with this subscription, so we move on to the next one. -Otherwise, we try to get the aeon referrred to by the ending case. If it +Otherwise, we try to get the aeon referred to by the ending case. If it doesn't exist yet, then we produce all the information we can. We call `++lobes-at-path` at the given aeon and path to see if the requested path has actually changed. If it hasn't, then we don't produce anything; diff --git a/main/pub/talk/src/css/main.css b/main/pub/talk/src/css/main.css index ba91bd6a23..2e38121c8c 100644 --- a/main/pub/talk/src/css/main.css +++ b/main/pub/talk/src/css/main.css @@ -70,6 +70,18 @@ font-weight: 500; font-style: normal; } +@font-face { + font-family: "scp"; + src: url("http://storage.googleapis.com/urbit-extra/scp-bold.woff"); + font-weight: 600; + font-style: normal; +} +@font-face { + font-family: "scp"; + src: url("http://storage.googleapis.com/urbit-extra/scp-black.woff"); + font-weight: 700; + font-style: normal; +} .iden, .audi, .time, @@ -124,22 +136,9 @@ body { margin-left: -12rem; font-size: 4rem; } -#station-container { - position: fixed; - top: 0; - left: 50%; - width: 28rem; - max-height: 2.6rem; - overflow: hidden; - margin-left: -14rem; +#station #station-container { + display: block; padding-top: 1rem; - background-color: #f5f5f5; - border-bottom: 3px solid #ededed; - transition: max-height 0.15s ease-out; -} -#station-container:hover { - max-height: 12rem; - transition: max-height 0.25s ease-in; } #stations-container, #messages-container { @@ -149,8 +148,8 @@ body { position: absolute; top: 4rem; left: 50%; - width: 24rem; - margin-left: -12rem; + width: 66rem; + margin-left: -46rem; margin-bottom: 4rem; } #station > div { @@ -161,9 +160,14 @@ body { margin-bottom: 1rem; } #sources-container { - width: 6rem; - float: right; - margin: 1rem -6rem 0 0; + position: fixed; + top: 0; + left: 50%; + margin-left: -35rem; + text-align: right; + background-color: #000; + color: #fff; + padding: 1rem; } #members { margin-left: 2rem; @@ -172,8 +176,6 @@ body { display: block; } .station { - display: inline-block; - width: 9rem; margin-bottom: 0.3rem; cursor: pointer; font-weight: 200; @@ -245,9 +247,6 @@ body { #messages .message:hover .time { opacity: 1; } -.time { - margin-right: 0.6rem; -} .member { width: 12rem; margin: 0.3rem 0.6rem 0.3rem 0; @@ -271,20 +270,21 @@ body { vertical-align: top; } .attr { - color: #d7d7d7; + text-align: right; + display: inline-block; + margin-right: 0.3rem; + min-width: 30rem; } .attr .iden { color: #000; -} -.attr > div { - margin-right: 0.3rem; + width: 6rem; } .mess { font-size: 0.9rem; - line-height: 1.6rem; letter-spacing: 0.03rem; word-wrap: break-word; - max-width: 31rem; + max-width: 30rem; + margin-left: 0.3rem; } .ship { font-weight: 600; @@ -303,7 +303,6 @@ body { #writing-container { bottom: 4rem; margin-bottom: 1rem; - float: left; } .writing { padding-top: 0.3rem; @@ -313,14 +312,20 @@ body { margin-left: 1rem; margin-top: 1.2rem; } +#audi { + background-color: #eee; + padding: 0.3rem; + margin-top: -0.3rem; + outline: none; +} #writing { font-size: 0.9rem; min-height: 1.6rem; - line-height: 1.6rem; min-width: 1.3rem; padding: 0; outline: none; background-color: #eee; + margin-left: 0.3rem; } #writing:focus { background-color: #fff; @@ -333,8 +338,9 @@ body { text-transform: lowercase; } input.join { + text-align: right; font-size: 4rem; - background-color: #fff; + background-color: transparent; outline: none; width: 24rem; } @@ -345,10 +351,10 @@ input.join { width: 12rem; } input.join::-webkit-input-placeholder { - color: #0003ff; + color: #fff; } input.join:focus::-webkit-input-placeholder { - color: #fff; + color: #000; } .pending { color: #ccc; diff --git a/main/pub/talk/src/css/main.styl b/main/pub/talk/src/css/main.styl index a669dda956..f3fa996435 100644 --- a/main/pub/talk/src/css/main.styl +++ b/main/pub/talk/src/css/main.styl @@ -54,22 +54,9 @@ body margin-left -12rem font-size 4rem -#station-container - position fixed - top 0 - left 50% - width 28rem - max-height 2.6rem - overflow hidden - margin-left -14rem +#station #station-container + display block padding-top 1rem - background-color #f5f5f5 - border-bottom 3px solid #ededed - transition max-height 0.15s ease-out - -#station-container:hover - max-height 12rem - transition max-height 0.25s ease-in #stations-container #messages-container @@ -79,8 +66,8 @@ body position absolute top 4rem left 50% - width 24rem - margin-left -12rem + width 66rem + margin-left -46rem margin-bottom 4rem #station > div @@ -91,9 +78,14 @@ body margin-bottom 1rem #sources-container - width 6rem - float right - margin 1rem -6rem 0 0 + position fixed + top 0 + left 50% + margin-left -35rem + text-align right + background-color #000 + color #fff + padding 1rem #members margin-left 2rem @@ -102,8 +94,6 @@ body display block .station - display inline-block - width 9rem margin-bottom .3rem cursor pointer font-weight 200 @@ -176,9 +166,6 @@ body #messages .message:hover .time opacity 1 -.time - margin-right .6rem - .member width 12rem margin .3rem .6rem .3rem 0 @@ -205,18 +192,18 @@ body text-align right display inline-block margin-right .3rem + min-width 30rem .attr .iden color #000 - -.attr > div - margin-right .3rem + width 6rem .mess font-size .9rem letter-spacing .03rem word-wrap break-word - max-width 31rem + max-width 30rem + margin-left .3rem .ship font-weight 600 @@ -235,7 +222,6 @@ body #writing-container bottom 4rem margin-bottom 1rem - float left .writing padding-top .3rem @@ -245,14 +231,20 @@ body margin-left 1rem margin-top 1.2rem +#audi + background-color #eee + padding .3rem + margin-top -.3rem + outline none + #writing font-size .9rem min-height 1.6rem - line-height 1.6rem min-width 1.3rem padding 0 outline none background-color #eee + margin-left .3rem #writing:focus background-color #fff @@ -265,8 +257,9 @@ body text-transform lowercase input.join + text-align right font-size 4rem - background-color #fff + background-color transparent outline none width 24rem @@ -277,10 +270,10 @@ input.join width 12rem input.join::-webkit-input-placeholder - color #0003FF + color #fff input.join:focus::-webkit-input-placeholder - color #fff + color #000 .pending color #ccc diff --git a/main/pub/talk/src/js/components/MessagesComponent.coffee b/main/pub/talk/src/js/components/MessagesComponent.coffee index b15b33b282..5e8c713d48 100644 --- a/main/pub/talk/src/js/components/MessagesComponent.coffee +++ b/main/pub/talk/src/js/components/MessagesComponent.coffee @@ -3,11 +3,11 @@ moment = require 'moment-timezone' recl = React.createClass [div,br,input,textarea] = [React.DOM.div,React.DOM.br,React.DOM.input,React.DOM.textarea] -MessageStore = require '../stores/MessageStore.coffee' -StationStore = require '../stores/StationStore.coffee' MessageActions = require '../actions/MessageActions.coffee' +MessageStore = require '../stores/MessageStore.coffee' StationActions = require '../actions/StationActions.coffee' -Member = require './MemberComponent.coffee' +StationStore = require '../stores/StationStore.coffee' +Member = require './MemberComponent.coffee' Message = recl lz: (n) -> if n<10 then "0#{n}" else "#{n}" diff --git a/main/pub/talk/src/js/components/StationComponent.coffee b/main/pub/talk/src/js/components/StationComponent.coffee index a033d450c9..90e4b9c9f3 100644 --- a/main/pub/talk/src/js/components/StationComponent.coffee +++ b/main/pub/talk/src/js/components/StationComponent.coffee @@ -35,10 +35,6 @@ module.exports = recl componentWillUnmount: -> StationStore.removeChangeListener @_onChangeStore - _toggleAudi: (e) -> - $e = $(e.target).closest('.station') - station = $e.find('.path').text() - StationActions.toggleAudience station _onChangeStore: -> @setState @stateFromStore() @@ -77,12 +73,8 @@ module.exports = recl if @state.station and @state.configs[@state.station] _remove = @_remove _sources = _.clone @state.configs[@state.station].sources - _sources.push "twitter/hoontap" sources = _.map _sources,(source) => - toggleClass = "toggle " - if @state.audi.indexOf(source) isnt -1 then toggleClass += "active" - (div {className:"station",onClick:@_toggleAudi}, [ - (div {className:toggleClass}) + (div {className:"station"}, [ (div {className:"path"}, source), (div {className:"remove",onClick:_remove,"data-station":source},"×") ]) diff --git a/main/pub/talk/src/js/components/WritingComponent.coffee b/main/pub/talk/src/js/components/WritingComponent.coffee index d77e482b94..219a6c9940 100644 --- a/main/pub/talk/src/js/components/WritingComponent.coffee +++ b/main/pub/talk/src/js/components/WritingComponent.coffee @@ -1,10 +1,11 @@ recl = React.createClass -[div,input,textarea] = [React.DOM.div,React.DOM.input,React.DOM.textarea] +[div,br,input,textarea] = [React.DOM.div,React.DOM.br,React.DOM.input,React.DOM.textarea] MessageActions = require '../actions/MessageActions.coffee' +MessageStore = require '../stores/MessageStore.coffee' StationActions = require '../actions/StationActions.coffee' -StationStore = require '../stores/StationStore.coffee' -Member = require './MemberComponent.coffee' +StationStore = require '../stores/StationStore.coffee' +Member = require './MemberComponent.coffee' module.exports = recl set: -> @@ -14,9 +15,10 @@ module.exports = recl if window.localStorage then window.localStorage.getItem 'writing' stateFromStore: -> { - audi:["~zod/court"] + audi:StationStore.getAudience() members:StationStore.getMembers() typing:StationStore.getTyping() + ludi:MessageStore.getLastAudience() } getInitialState: -> @stateFromStore() @@ -66,6 +68,17 @@ module.exports = recl _setFocus: -> @$writing.focus() + _commitAudi: -> + _checkAudi() + $('#writing').focus() + + _checkAudi: -> + v = $('#audi').text() + v = v.split "," + for a in v + a = a.trim() + StationActions.setAudience v + getTime: -> d = new Date() seconds = d.getSeconds() @@ -84,6 +97,7 @@ module.exports = recl componentDidMount: -> window.util.sendMessage = @sendMessage StationStore.addChangeListener @_onChangeStore + MessageStore.addChangeListener @_onChangeStore @$el = $ @getDOMNode() @$length = $('#length') @$writing = $('#writing') @@ -107,17 +121,25 @@ module.exports = recl ship = if iden then iden.ship else user name = if iden then iden.name else "" + audi = @state.audi + if audi.length is 0 + audi = @state.ludi + k = "writing" div {className:k}, [ (div {className:"attr"}, [ + (div { + id:"audi" + className:"audi" + contentEditable:true + onBlur:@_checkAudi + onKeyDown:@_commitAudi + }, audi.join(",")) (Member iden, "") + (br {},"") (div {className:"time"}, @getTime()) ]) - (div { - id:"audi" - contentEditable:true - }, "~zod/court") (div { id:"writing" contentEditable:true diff --git a/main/pub/talk/src/js/main.js b/main/pub/talk/src/js/main.js index dbb6407d3e..63fea5013f 100644 --- a/main/pub/talk/src/js/main.js +++ b/main/pub/talk/src/js/main.js @@ -204,14 +204,14 @@ recl = React.createClass; ref = [React.DOM.div, React.DOM.br, React.DOM.input, React.DOM.textarea], div = ref[0], br = ref[1], input = ref[2], textarea = ref[3]; -MessageStore = require('../stores/MessageStore.coffee'); - -StationStore = require('../stores/StationStore.coffee'); - MessageActions = require('../actions/MessageActions.coffee'); +MessageStore = require('../stores/MessageStore.coffee'); + StationActions = require('../actions/StationActions.coffee'); +StationStore = require('../stores/StationStore.coffee'); + Member = require('./MemberComponent.coffee'); Message = recl({ @@ -403,12 +403,6 @@ module.exports = recl({ componentWillUnmount: function() { return StationStore.removeChangeListener(this._onChangeStore); }, - _toggleAudi: function(e) { - var $e, station; - $e = $(e.target).closest('.station'); - station = $e.find('.path').text(); - return StationActions.toggleAudience(station); - }, _onChangeStore: function() { return this.setState(this.stateFromStore()); }, @@ -461,21 +455,12 @@ module.exports = recl({ if (this.state.station && this.state.configs[this.state.station]) { _remove = this._remove; _sources = _.clone(this.state.configs[this.state.station].sources); - _sources.push("twitter/hoontap"); sources = _.map(_sources, (function(_this) { return function(source) { - var toggleClass; - toggleClass = "toggle "; - if (_this.state.audi.indexOf(source) !== -1) { - toggleClass += "active"; - } return div({ - className: "station", - onClick: _this._toggleAudi + className: "station" }, [ div({ - className: toggleClass - }), div({ className: "path" }, source), div({ className: "remove", @@ -615,14 +600,16 @@ module.exports = recl({ },{"../actions/StationActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/actions/StationActions.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/stores/StationStore.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/WritingComponent.coffee":[function(require,module,exports){ -var Member, MessageActions, StationActions, StationStore, div, input, recl, ref, textarea; +var Member, MessageActions, MessageStore, StationActions, StationStore, br, div, input, recl, ref, textarea; recl = React.createClass; -ref = [React.DOM.div, React.DOM.input, React.DOM.textarea], div = ref[0], input = ref[1], textarea = ref[2]; +ref = [React.DOM.div, React.DOM.br, React.DOM.input, React.DOM.textarea], div = ref[0], br = ref[1], input = ref[2], textarea = ref[3]; MessageActions = require('../actions/MessageActions.coffee'); +MessageStore = require('../stores/MessageStore.coffee'); + StationActions = require('../actions/StationActions.coffee'); StationStore = require('../stores/StationStore.coffee'); @@ -642,9 +629,10 @@ module.exports = recl({ }, stateFromStore: function() { return { - audi: ["~zod/court"], + audi: StationStore.getAudience(), members: StationStore.getMembers(), - typing: StationStore.getTyping() + typing: StationStore.getTyping(), + ludi: MessageStore.getLastAudience() }; }, getInitialState: function() { @@ -705,6 +693,20 @@ module.exports = recl({ _setFocus: function() { return this.$writing.focus(); }, + _commitAudi: function() { + _checkAudi(); + return $('#writing').focus(); + }, + _checkAudi: function() { + var a, i, len, v; + v = $('#audi').text(); + v = v.split(","); + for (i = 0, len = v.length; i < len; i++) { + a = v[i]; + a = a.trim(); + } + return StationActions.setAudience(v); + }, getTime: function() { var d, seconds; d = new Date(); @@ -726,6 +728,7 @@ module.exports = recl({ componentDidMount: function() { window.util.sendMessage = this.sendMessage; StationStore.addChangeListener(this._onChangeStore); + MessageStore.addChangeListener(this._onChangeStore); this.$el = $(this.getDOMNode()); this.$length = $('#length'); this.$writing = $('#writing'); @@ -748,11 +751,15 @@ module.exports = recl({ return this.setState(this.stateFromStore()); }, render: function() { - var iden, k, name, ship, user; + var audi, iden, k, name, ship, user; user = "~" + window.urb.user; iden = StationStore.getMember(user); ship = iden ? iden.ship : user; name = iden ? iden.name : ""; + audi = this.state.audi; + if (audi.length === 0) { + audi = this.state.ludi; + } k = "writing"; return div({ className: k @@ -760,13 +767,16 @@ module.exports = recl({ div({ className: "attr" }, [ - Member(iden, ""), div({ + div({ + id: "audi", + className: "audi", + contentEditable: true, + onBlur: this._checkAudi, + onKeyDown: this._commitAudi + }, audi.join(",")), Member(iden, ""), br({}, ""), div({ className: "time" }, this.getTime()) ]), div({ - id: "audi", - contentEditable: true - }, "~zod/court"), div({ id: "writing", contentEditable: true, onFocus: this._focus, @@ -784,7 +794,7 @@ module.exports = recl({ -},{"../actions/MessageActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/actions/MessageActions.coffee","../actions/StationActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/actions/StationActions.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/stores/StationStore.coffee","./MemberComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/MemberComponent.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/dispatcher/Dispatcher.coffee":[function(require,module,exports){ +},{"../actions/MessageActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/actions/MessageActions.coffee","../actions/StationActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/actions/StationActions.coffee","../stores/MessageStore.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/stores/MessageStore.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/stores/StationStore.coffee","./MemberComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/MemberComponent.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/dispatcher/Dispatcher.coffee":[function(require,module,exports){ var Dispatcher; Dispatcher = require('flux').Dispatcher; @@ -5501,6 +5511,15 @@ MessageStore = _.merge(new EventEmitter, { getTyping: function() { return _typing; }, + getLastAudience: function() { + if (_.keys(_messages).length === 0) { + return []; + } + _messages = _.sortBy(_messages, function(_message) { + return _message.thought.statement.time; + }); + return _.keys(_messages[_messages.length - 1].thought.audience); + }, setTyping: function(state) { return _typing = state; }, diff --git a/main/pub/talk/src/js/stores/MessageStore.coffee b/main/pub/talk/src/js/stores/MessageStore.coffee index ef533599f1..4745e15eaa 100644 --- a/main/pub/talk/src/js/stores/MessageStore.coffee +++ b/main/pub/talk/src/js/stores/MessageStore.coffee @@ -33,6 +33,11 @@ MessageStore = _.merge new EventEmitter,{ getTyping: -> _typing + getLastAudience: -> + if _.keys(_messages).length is 0 then return [] + _messages = _.sortBy _messages, (_message) -> _message.thought.statement.time + _.keys _messages[_messages.length-1].thought.audience + setTyping: (state) -> _typing = state setListening: (station) -> From ff0f2d2c2283b66b5218a7aef1e57e00b5602bc2 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Fri, 6 Mar 2015 01:11:01 -0800 Subject: [PATCH 058/219] Dojo with command parser, etc. --- arvo/hoon.hoon | 5 + main/app/dojo/core.hook | 352 +++++++++++++++++++++++++++++----------- 2 files changed, 264 insertions(+), 93 deletions(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index 1140f12c02..0c4d8a3374 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -101,6 +101,11 @@ ++ nail ,[p=hair q=tape] :: parsing input ++ numb ,@ :: just a number ++ pair |*([a=$+(* *) b=$+(* *)] ,[p=a q=b]) :: just a pair +++ wand |* a=(list $+(* *)) :: hetero list + |= b=* :: + ?~ a ~ :: + ?@ b ~ :: + [i=(i.a -.b) t=$(a t.a, b +.b)] :: ++ pass ,@ :: public key ++ path (list span) :: filesys location ++ pint ,[p=[p=@ q=@] q=[p=@ q=@]] :: line/column range diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 84abcd2a3b..32a6be7267 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -18,21 +18,44 @@ old=(set term) :: used TLVs == :: ++ dojo-command :: - $% [%poke p=hapt q=dojo-source] :: make and poke - [%save p=? q=term r=dojo-source] :: save/print + $% [%poke p=goal q=dojo-source] :: make and poke + [%save p=term q=dojo-source] :: save/print + [%show p=dojo-source] :: print == :: - ++ dojo-source :: - $: inx=@ud :: index, assigned - mod=dojo-model :: + ++ dojo-source :: construction node + $: p=@ud :: assembly index + q=dojo-build :: general build == :: - ++ dojo-model :: data source - $% [%& twig] :: direct expression - [%| (trel term term dojo-config)] :: command engine + ++ dojo-build :: one ford step + $& [p=dojo-build q=dojo-build] :: build cell + $% [%ex p=twig] :: hoon expression + [%fi p=(list dojo-filter) q=dojo-build] :: filter pipeline + [%fo p=dojo-model] :: form + [%sc p=dojo-model] :: script + [%va p=term] :: dojo variable + == :: + ++ dojo-filter :: pipeline filter + $% [%a p=twig] :: direct gate + [%b p=mark] :: simple transmute + [%c p=dojo-model] :: full filter + == :: + ++ dojo-model :: data construction + $: p=dojo-server :: core source + q=dojo-config :: configuration + == :: + ++ dojo-server :: numbered device + $: p=@ud :: assembly index + q=dojo-device :: loadable + == :: + ++ dojo-device :: core devices + $% [%& p=term] :: general device + [%| p=term q=path] :: special device == :: ++ dojo-config :: configuration - $: ord=(list dojo-source) :: by order - key=(map term dojo-source) :: by keyword + $: p=(list dojo-source) :: by order + q=(map term dojo-source) :: by keyword == :: + ++ dojo-problem (each dojo-source dojo-server) :: construction problem ++ dojo-project :: construction state $: mad=dojo-command :: operation num=@ud :: number of tasks @@ -40,10 +63,11 @@ pro=(unit vase) :: prompting loop idl=? :: not calling ford per=(unit console-edit) :: pending reverse - job=(map ,@ud dojo-source) :: problems + job=(map ,@ud dojo-problem) :: problems rez=(map ,@ud cage) :: results == :: ++ bead ,[p=(set beam) q=cage] :: computed result + ++ goal ,[p=ship q=term] :: flat application ++ gift :: out result <-$ $% [%mean p=ares] :: error [%nice ~] :: acknowledge @@ -126,16 +150,99 @@ == :: ++ he :: per session |_ [[ost=bone moz=(list move)] session] :: + ++ dp :: dojo parser + |% + ++ dp-command :: ++dojo-command + %+ knee *dojo-command |. ~+ + ;~ pose + %+ stag %poke + ;~ pfix zap + ;~(plug dp-goal ;~(pfix ace dp-source)) + == + :: + %+ stag %save + ;~ pfix tis + ;~(plug sym ;~(pfix ace dp-source)) + == + :: + (stag %show dp-source) + == + ++ dp-source (stag 0 dp-build) :: ++dojo-source + ++ dp-build :: ++dojo-build + %+ knee *dojo-build |. ~+ + ;~ pose + (ifix [sel ser] dp-many) + ;~(pfix col (stag %fo dp-model)) + ;~(pfix bar (stag %sc dp-model)) + ;~(pfix buc (stag %va sym)) + (stag %ex dp-twig) + == + ++ dp-many :: ++dojo-build + %+ cook + |= a=(list dojo-build) + ^- dojo-build + ?~(a !! ?~(t.a i.a [i.a $(a t.a)])) + (most ace dp-build) + :: + ++ dp-goal :: ++goal + %+ cook |=(a=goal a) + ;~ pose + ;~ plug + ;~(pfix sig fed:ag) + ;~(pfix fas sym) + == + (cook |=(a=term `goal`[our.hid a]) sym) + == + ++ dp-model ;~(plug dp-server dp-config) :: ++dojo-model + ++ dp-server (stag 0 dp-device) :: ++dojo-server + ++ dp-twig wide:(vang & ~) :: ++twig + ++ dp-device :: ++dojo-device + %+ cook + |= [a=term b=path] + ^- dojo-device + ?~(b [%& a] [%| a b]) + ;~(plug sym (more fas sym)) + :: + ++ dp-value :: ++dojo-source + %+ cook |=(a=dojo-source a) + %+ stag 0 + ;~ pose + (ifix [kel ker] dp-many) + (stag %va ;~(pfix buc sym)) + (stag %ex dp-twig) + == + :: + ++ dp-config :: ++dojo-config + %+ cook |=(a=dojo-config a) + ;~ plug + (more ;~(plug com ace) dp-value) + %+ cook + |= a=(list (pair term (unit dojo-source))) + %- ~(gas by *(map term dojo-source)) + %+ turn a + |= b=(pair term (unit dojo-source)) + [p.b ?~(q.b [0 %ex [%dtzy %f &]] u.q.b)] + %+ more ;~(plug com ace) + ;~ plug + ;~(pfix tis sym) + ;~ pose + ;~(pfix ace (stag ~ dp-value)) + (easy ~) + == + == + == + -- + :: ++ dy :: project work |_ dojo-project :: ++ dy-abet +>(poy `+<) :: resolve ++ dy-amok +>(poy ~) :: terminate - ++ dy-ford :: send to ford + ++ dy-ford :: silk to ford |= [pax=path kas=silk] ^+ +>+> (he-pass(poy `+>+<(idl %|)) pax %f %exec our.hid `kas) :: - ++ dy-slam :: call to ford + ++ dy-slam :: call by ford |= [pax=path gat=vase sam=vase] ^+ +>+> (dy-ford pax %call [%done ~ %noun gat] [%done ~ %noun sam]) @@ -150,7 +257,59 @@ ^+ +>+> (he-rush(poy ~) fec) :: - ++ dy-init-ordered :: prepare source list + ++ dy-init-command :: ++dojo-command + |= mad=dojo-command + ^+ [mad +>] + ?- -.mad + %poke =^(src +>.$ (dy-init-source q.mad) [[%poke p.mad src] +>.$]) + %save =^(src +>.$ (dy-init-source q.mad) [[%save p.mad src] +>.$]) + %show =^(src +>.$ (dy-init-source p.mad) [[%show p.mad] +>.$]) + == + :: + ++ dy-init-source :: ++dojo-source + |= src=dojo-source + ^+ [src +>] + =^ bul +> (dy-init-build q.src) + =: p.src num + q.src bul + == + [src +>.$(num +(num), job (~(put by job) num [%& src]))] + :: + ++ dy-init-build :: ++dojo-build + |= bul=dojo-build + ^+ [bul +>] + ?^ -.bul + =^ one +>.$ $(bul -.bul) + =^ two +>.$ $(bul +.bul) + [[one two] +>.$] + ?- -.bul + %ex [bul +>.$] + %fi !! + %fo =^(mod +>.$ (dy-init-model p.bul) [[%fo mod] +>.$]) + %sc !! + %va [bul +>.$] + == + :: + ++ dy-init-model :: ++dojo-model + |= mol=dojo-model + ^+ [mol +>] + =^ one +>.$ (dy-init-server p.mol) + =^ two +>.$ (dy-init-config q.mol) + [[one two] +>.$] + :: + ++ dy-init-server :: ++dojo-server + |= srv=dojo-server + =. p.srv num + [srv +>.$(num +(num), job (~(put by job) num [%| srv]))] + :: + ++ dy-init-config :: prepare config + |= cig=dojo-config + ^+ [cig +>] + =^ ord +>.$ (dy-init-ordered p.cig) + =^ key +>.$ (dy-init-named q.cig) + [[ord key] +>.$] + :: + ++ dy-init-ordered :: (list dojo-source) |= ord=(list dojo-source) ^+ [ord +>] ?~ ord [~ +>.$] @@ -158,7 +317,7 @@ =^ mor +>.$ $(ord t.ord) [[fir mor] +>.$] :: - ++ dy-init-named :: prepare source map + ++ dy-init-named :: (map @tas dojo-src) |= key=(map term dojo-source) ^+ [key +>.$] ?~ key [~ +>.$] @@ -167,46 +326,16 @@ =^ rit +>.$ $(key r.key) [[[p.n.key top] lef rit] +>.$] :: - ++ dy-init-model :: prepare dojo-model - |= mod=dojo-model - ^+ [mod +>] - ?- -.mod - %& [mod +>] - %| =^ cig +> (dy-init-config r.mod) - [mod(r cig) +>.$] - == - :: - ++ dy-init-source :: prepare source - |= src=dojo-source - ^+ [src +>] - =^ mod +> (dy-init-model mod.src) - =: inx.src num - mod.src mod - == - [src +>.$(num +(num), job (~(put by job) num src))] - :: - ++ dy-init-config :: prepare config - |= cig=dojo-config - ^+ [cig +>] - =^ ord +>.$ (dy-init-ordered ord.cig) - =^ key +>.$ (dy-init-named key.cig) - [[ord key] +>.$] - :: - ++ dy-init - =+ dam=mad - ?- -.dam - %poke =^ src + (dy-init-source q.dam) - +>(mad dam(q src)) - %save =^ src + (dy-init-source r.dam) - +>(mad dam(r src)) - == + ++ dy-init :: full initialize + ^+ . + =^(dam . (dy-init-command mad) +(mad dam)) :: ++ dy-work :: console action |= act=console-action - ?- -.act - %det (he-stir +.act) - %ret (he-done (tufa buf.say)) - == + ?- -.act + %det (he-stir +.act) + %ret (he-done (tufa buf.say)) + == :: ++ dy-hand :: complete step |= cag=cage @@ -259,13 +388,20 @@ ^+ +> ?- -.mad %poke - (he-pass(poy ~) /poke %g %mess p.mad our.hid (~(got by rez) inx.q.mad)) + %- he-pass(poy ~) + :* /poke + %g + %mess + [p.p.mad [q.p.mad ~]] + our.hid + (~(got by rez) p.q.mad) + == :: %save - =+ cag=(~(got by rez) inx.r.mad) - =. var (~(put by var) q.mad cag) - ?. p.mad +>+ - (he-rush(poy ~) [%tan (sell q.cag) ~]) + dy-amok(var (~(put by var) p.mad (~(got by rez) p.q.mad))) + :: + %show + (dy-rash %tan (sell q:(~(got by rez) p.p.mad)) ~) == :: ++ dy-edit :: handle edit @@ -288,31 +424,55 @@ %ret (dy-done (tufa buf.say)) == :: + ++ dy-silk-build :: build to silk + |= bul=dojo-build + ^- silk + ?^ -.bul [$(bul -.bul) $(bul +.bul)] + ?+ -.bul !! + %ex [%ride p.bul [%reef ~]] + == + :: + ++ dy-silk-device :: device to silk + |= dov=dojo-device + ^- silk + :* %boil + %noun + :- [our.hid %main %da lat.hid] + ?- -.dov + %& [%mad p.dov ~] + %| [%app p.dov %mad q.dov] + == + ~ + == + :: ++ dy-step :: advance project ^+ +> ?: =(cur num) dy-over - =+ src=(~(got by job) cur) - ?- -.mod.src - %& - %- he-pass(poy `+>-) - [/hand %f %exec our.hid `[%ride +.mod.src [%reef ~]]] - :: - %| - %- he-pass(poy `+>-) - :* /make - %f - %exec - our.hid - ~ - %boil - %noun - [[our.hid %main %da lat.hid] [p.mod.src %mad q.mod.src ~]] - ~ - == + =+ pob=(~(got by job) cur) + ?- -.pob + %& (dy-ford /hand (dy-silk-build q.p.pob)) + %| (dy-ford /make (dy-silk-device q.p.pob)) == -- :: + ++ he-dope :: sole user of ++dp + |= txt=tape :: + ^- (each (unit dojo-command) hair) :: prefix/result + =+ vex=(dp-command:dp [1 1] txt) + ?. =(+((lent txt)) q.p.vex) :: fully parsed + [%| p.vex] :: syntax error + [%& ?~(q.vex ~ `p.u.q.vex)] :: prefix/complete + :: + ++ he-duke :: ++he-dope variant + |= txt=tape + ^- (each dojo-command ,@ud) + =+ foy=(he-dope txt) + ?- -.foy + %| [%| q.p.foy] + %& ?~(p.foy [%| (lent txt)] [%& u.p.foy]) + == + :: ++ he-abet :: resolve [(flop moz) %_(+> hoc (~(put by hoc) ost +<+))] :: @@ -339,7 +499,7 @@ :- %pro [& %$ (tuba (weld (scow %p our.hid) ":dojo> "))] :: - ++ he-ford :: sign from ford + ++ he-ford :: result from ford |= [pax=path rey=(each bead (list tank))] ^+ +> ?> ?=(^ poy) @@ -355,11 +515,9 @@ %| (he-rush(poy ~) %tan p.rey) == :: - ++ he-like :: filter line + ++ he-like :: accept line |= buf=(list ,@c) - ^- ? - =+ txt=(tufa buf) - =(+((lent txt)) q.p:(wide:(vang & ~) [1 1] txt)) + =(%& -:(he-dope (tufa buf))) :: ++ he-stir :: apply change |= cal=console-change @@ -379,19 +537,27 @@ ++ he-done :: parse command |= txt=tape ^+ +> - =+ foy=(rust txt wide:(vang & ~)) - ?~ foy - (he-rush %bel ~) - =+ old=(weld "> " (tufa buf.say)) - =^ cal say (~(transmit cs say) [%set ~]) - %- =< he-plan - %- he-rush - :~ %mor - [%txt old] - [%nex ~] - [%det cal] - == - `dojo-command`[%save & %foo 0 %& u.foy] + =+ doy=(he-duke txt) + ?- -.doy + %| + %- he-rush + :~ %mor + [%tan [%leaf "syntax error at {}"]~] + [%bel ~] + == + :: + %& + =+ old=(weld "> " (tufa buf.say)) + =^ cal say (~(transmit cs say) [%set ~]) + %. p.doy + =< he-plan + %- he-rush + :~ %mor + [%txt old] + [%nex ~] + [%det cal] + == + == :: ++ he-work :: apply input |= act=console-action From 404b8cedf7fa1fa01edb3f791ad0a21a46593901 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 6 Mar 2015 17:15:51 -0800 Subject: [PATCH 059/219] %- stack trace annotation --- arvo/hoon.hoon | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index 17010aab1a..2e90c73869 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -2083,8 +2083,8 @@ :: +- get :: grab value by key ~/ %get - |* b=* - |- ^- ?(~ [~ u=_?>(?=(^ a) q.n.a)]) + |= b=* + ^- $|(~ [~ u=_?>(?=(^ a) q.n.a)]) ?~ a ~ ?: =(b p.n.a) @@ -6131,7 +6131,12 @@ [i.p.gen $(p.gen t.p.gen)] :: [%cncb *] [%ktls [%cnzz p.gen] %cnts p.gen q.gen] - [%cncl *] [%cnsg [%$ ~] p.gen q.gen] + [%cncl *] + =+ rem=[%cnsg [%$ ~] p.gen q.gen] + ?. ?=([%zpcb ^ %cnzz @ ~] p.gen) rem + => .(p.gen `[@ ^ @ p=@tas ~]`p.gen) + :+ %sgzp [[%dtzz %tas 'slam'] [%dtzz %tas p.p.gen]] + rem [%cndt *] [%cnhp q.gen [p.gen ~]] [%cnkt *] [%cnhp p.gen q.gen r.gen s.gen ~] [%cnls *] [%cnhp p.gen q.gen r.gen ~] From 7373c47237c0d61dac99b64dd6df64c1754115d2 Mon Sep 17 00:00:00 2001 From: Galen Wolfe-Pauly Date: Sat, 7 Mar 2015 11:09:30 -0800 Subject: [PATCH 060/219] talking --- main/pub/talk/src/css/main.css | 4 + main/pub/talk/src/css/main.styl | 4 + .../talk/src/js/actions/StationActions.coffee | 5 + .../js/components/MessagesComponent.coffee | 11 +- .../src/js/components/StationComponent.coffee | 2 +- .../src/js/components/WritingComponent.coffee | 49 ++++++-- main/pub/talk/src/js/main.coffee | 7 +- main/pub/talk/src/js/main.js | 109 ++++++++++++++---- .../talk/src/js/stores/MessageStore.coffee | 4 +- .../talk/src/js/stores/StationStore.coffee | 10 ++ 10 files changed, 160 insertions(+), 45 deletions(-) diff --git a/main/pub/talk/src/css/main.css b/main/pub/talk/src/css/main.css index 2e38121c8c..40a71d1dc4 100644 --- a/main/pub/talk/src/css/main.css +++ b/main/pub/talk/src/css/main.css @@ -318,6 +318,9 @@ body { margin-top: -0.3rem; outline: none; } +#audi.valid-false { + color: #ff2f2f; +} #writing { font-size: 0.9rem; min-height: 1.6rem; @@ -343,6 +346,7 @@ input.join { background-color: transparent; outline: none; width: 24rem; + color: #fff; } #station input.join { font-family: "scp"; diff --git a/main/pub/talk/src/css/main.styl b/main/pub/talk/src/css/main.styl index f3fa996435..4afc89aca5 100644 --- a/main/pub/talk/src/css/main.styl +++ b/main/pub/talk/src/css/main.styl @@ -237,6 +237,9 @@ body margin-top -.3rem outline none +#audi.valid-false + color #ff2f2f + #writing font-size .9rem min-height 1.6rem @@ -262,6 +265,7 @@ input.join background-color transparent outline none width 24rem + color #fff #station input.join font-family "scp" diff --git a/main/pub/talk/src/js/actions/StationActions.coffee b/main/pub/talk/src/js/actions/StationActions.coffee index 55ac7c54a1..6e8bc11d60 100644 --- a/main/pub/talk/src/js/actions/StationActions.coffee +++ b/main/pub/talk/src/js/actions/StationActions.coffee @@ -17,6 +17,11 @@ module.exports = type:"station-set-audience" audience:audience + setValidAudience: (valid) -> + StationDispatcher.handleViewAction + type:"station-set-valid-audience" + valid:valid + toggleAudience: (station) -> StationDispatcher.handleViewAction type:"station-audience-toggle" diff --git a/main/pub/talk/src/js/components/MessagesComponent.coffee b/main/pub/talk/src/js/components/MessagesComponent.coffee index 5e8c713d48..8b09f7046d 100644 --- a/main/pub/talk/src/js/components/MessagesComponent.coffee +++ b/main/pub/talk/src/js/components/MessagesComponent.coffee @@ -19,6 +19,11 @@ Message = recl s = @lz d.getSeconds() "~#{h}.#{m}.#{s}" + _handlePm: (e) -> + $t = $(e.target).closest('.iden') + console.log 'pm' + console.log window.util.mainStation $t.text().slice(1) + render: -> # pendingClass = if @props.pending isnt "received" then "pending" else "" delivery = _.uniq _.pluck @props.thought.audience, "delivery" @@ -30,14 +35,12 @@ Message = recl name = if @props.name then @props.name else "" audi = _.keys(@props.thought.audience) - # audi = _.remove _.keys(@props.thought.audience), (stat) => - # stat isnt "~"+window.urb.ship+"/"+@props.station audi = audi.join " " div {className:"message "+pendingClass}, [ (div {className:"attr"}, [ div {className:"audi"}, "#{audi}" - (Member {ship:@props.ship}, "") + (Member {onClick:@_handlePm,ship:@props.ship}, "") (br {},"") div {className:"time"}, @convTime @props.thought.statement.date ]) @@ -53,7 +56,7 @@ module.exports = recl last:MessageStore.getLast() fetching:MessageStore.getFetching() listening:MessageStore.getListening() - station:"court" + station:window.util.mainStation() stations:StationStore.getStations() configs:StationStore.getConfigs() typing:MessageStore.getTyping() diff --git a/main/pub/talk/src/js/components/StationComponent.coffee b/main/pub/talk/src/js/components/StationComponent.coffee index 90e4b9c9f3..ed48574de0 100644 --- a/main/pub/talk/src/js/components/StationComponent.coffee +++ b/main/pub/talk/src/js/components/StationComponent.coffee @@ -15,7 +15,7 @@ module.exports = recl stateFromStore: -> { audi:StationStore.getAudience() members:StationStore.getMembers() - station:"court" + station:window.util.mainStation() stations:StationStore.getStations() configs:StationStore.getConfigs() typing:StationStore.getTyping() diff --git a/main/pub/talk/src/js/components/WritingComponent.coffee b/main/pub/talk/src/js/components/WritingComponent.coffee index 219a6c9940..d63937a257 100644 --- a/main/pub/talk/src/js/components/WritingComponent.coffee +++ b/main/pub/talk/src/js/components/WritingComponent.coffee @@ -19,6 +19,7 @@ module.exports = recl members:StationStore.getMembers() typing:StationStore.getTyping() ludi:MessageStore.getLastAudience() + valid:StationStore.getValidAudience() } getInitialState: -> @stateFromStore() @@ -36,7 +37,15 @@ module.exports = recl @typing true sendMessage: -> - MessageActions.sendMessage @state.audi,@$writing.text(),@state.audi + if @_validateAudi() is false + $('#audi').focus() + return + if @state.audi.length is 0 and $('#audi').text().trim().length > 0 + audi = @state.ludi + @_setAudi() + else + audi = @state.audi + MessageActions.sendMessage audi,@$writing.text(),audi @$length.text "0/69" @$writing.text('') @set() @@ -68,16 +77,35 @@ module.exports = recl _setFocus: -> @$writing.focus() - _commitAudi: -> - _checkAudi() - $('#writing').focus() + _validateAudiPart: (a) -> + if a[0] isnt "~" + return false + if a.indexOf("/") is -1 + return false + _a = a.split("/") + if _a[0].length < 3 + return false + if _a[1].length is 0 + return false + return true - _checkAudi: -> + _validateAudi: -> v = $('#audi').text() v = v.split "," for a in v a = a.trim() - StationActions.setAudience v + valid = @_validateAudiPart(a) + valid + + _setAudi: -> + valid = _validateAudi() + StationActions.setValidAudience valid + if valid is true + v = $('#audi').text() + v = v.split "," + for a in v + a = a.trim() + StationActions.setAudience v getTime: -> d = new Date() @@ -121,9 +149,7 @@ module.exports = recl ship = if iden then iden.ship else user name = if iden then iden.name else "" - audi = @state.audi - if audi.length is 0 - audi = @state.ludi + audi = if @state.audi.length is 0 then @state.ludi else @state.audi k = "writing" @@ -131,10 +157,9 @@ module.exports = recl (div {className:"attr"}, [ (div { id:"audi" - className:"audi" + className:"audi valid-#{@state.valid}" contentEditable:true - onBlur:@_checkAudi - onKeyDown:@_commitAudi + onBlur:@_setAudi }, audi.join(",")) (Member iden, "") (br {},"") diff --git a/main/pub/talk/src/js/main.coffee b/main/pub/talk/src/js/main.coffee index 253517b96c..9cdf9f7e94 100644 --- a/main/pub/talk/src/js/main.coffee +++ b/main/pub/talk/src/js/main.coffee @@ -8,11 +8,12 @@ $(() -> window.chat.StationPersistence = require './persistence/StationPersistence.coffee' window.util = - mainStation: -> - switch window.urb.user.length + mainStation (user): -> + if not user then user = window.urb.user + switch user.length when 3 return "court" - when 5 + when 6 return "floor" when 13 return "porch" diff --git a/main/pub/talk/src/js/main.js b/main/pub/talk/src/js/main.js index 63fea5013f..454e783c46 100644 --- a/main/pub/talk/src/js/main.js +++ b/main/pub/talk/src/js/main.js @@ -108,6 +108,12 @@ module.exports = { audience: audience }); }, + setValidAudience: function(valid) { + return StationDispatcher.handleViewAction({ + type: "station-set-valid-audience", + valid: valid + }); + }, toggleAudience: function(station) { return StationDispatcher.handleViewAction({ type: "station-audience-toggle", @@ -230,6 +236,12 @@ Message = recl({ s = this.lz(d.getSeconds()); return "~" + h + "." + m + "." + s; }, + _handlePm: function(e) { + var $t; + $t = $(e.target).closest('.iden'); + console.log('pm'); + return console.log(window.util.mainStation($t.text().slice(1))); + }, render: function() { var audi, delivery, name, pendingClass; delivery = _.uniq(_.pluck(this.props.thought.audience, "delivery")); @@ -249,9 +261,11 @@ Message = recl({ }, [ div({ className: "audi" - }, "" + audi), Member({ + }, "" + audi), div({ + onClick: this._handlePm + }, Member({ ship: this.props.ship - }, ""), br({}, ""), div({ + }, "")), br({}, ""), div({ className: "time" }, this.convTime(this.props.thought.statement.date)) ]), div({ @@ -270,7 +284,7 @@ module.exports = recl({ last: MessageStore.getLast(), fetching: MessageStore.getFetching(), listening: MessageStore.getListening(), - station: "court", + station: window.util.mainStation(), stations: StationStore.getStations(), configs: StationStore.getConfigs(), typing: MessageStore.getTyping() @@ -382,7 +396,7 @@ module.exports = recl({ return { audi: StationStore.getAudience(), members: StationStore.getMembers(), - station: "court", + station: window.util.mainStation(), stations: StationStore.getStations(), configs: StationStore.getConfigs(), typing: StationStore.getTyping(), @@ -632,7 +646,8 @@ module.exports = recl({ audi: StationStore.getAudience(), members: StationStore.getMembers(), typing: StationStore.getTyping(), - ludi: MessageStore.getLastAudience() + ludi: MessageStore.getLastAudience(), + valid: StationStore.getValidAudience() }; }, getInitialState: function() { @@ -652,7 +667,18 @@ module.exports = recl({ return this.typing(true); }, sendMessage: function() { - MessageActions.sendMessage(this.state.audi, this.$writing.text(), this.state.audi); + var audi; + if (this._validateAudi() === false) { + $('#audi').focus(); + return; + } + if (this.state.audi.length === 0 && $('#audi').text().trim().length > 0) { + audi = this.state.ludi; + this._setAudi(); + } else { + audi = this.state.audi; + } + MessageActions.sendMessage(audi, this.$writing.text(), audi); this.$length.text("0/69"); this.$writing.text(''); this.set(); @@ -693,19 +719,47 @@ module.exports = recl({ _setFocus: function() { return this.$writing.focus(); }, - _commitAudi: function() { - _checkAudi(); - return $('#writing').focus(); + _validateAudiPart: function(a) { + var _a; + if (a[0] !== "~") { + return false; + } + if (a.indexOf("/") === -1) { + return false; + } + _a = a.split("/"); + if (_a[0].length < 3) { + return false; + } + if (_a[1].length === 0) { + return false; + } + return true; }, - _checkAudi: function() { - var a, i, len, v; + _validateAudi: function() { + var a, i, len, v, valid; v = $('#audi').text(); v = v.split(","); for (i = 0, len = v.length; i < len; i++) { a = v[i]; a = a.trim(); + valid = this._validateAudiPart(a); + } + return valid; + }, + _setAudi: function() { + var a, i, len, v, valid; + valid = _validateAudi(); + StationActions.setValidAudience(valid); + if (valid === true) { + v = $('#audi').text(); + v = v.split(","); + for (i = 0, len = v.length; i < len; i++) { + a = v[i]; + a = a.trim(); + } + return StationActions.setAudience(v); } - return StationActions.setAudience(v); }, getTime: function() { var d, seconds; @@ -756,10 +810,7 @@ module.exports = recl({ iden = StationStore.getMember(user); ship = iden ? iden.ship : user; name = iden ? iden.name : ""; - audi = this.state.audi; - if (audi.length === 0) { - audi = this.state.ludi; - } + audi = this.state.audi.length === 0 ? this.state.ludi : this.state.audi; k = "writing"; return div({ className: k @@ -769,10 +820,9 @@ module.exports = recl({ }, [ div({ id: "audi", - className: "audi", + className: "audi valid-" + this.state.valid, contentEditable: true, - onBlur: this._checkAudi, - onKeyDown: this._commitAudi + onBlur: this._setAudi }, audi.join(",")), Member(iden, ""), br({}, ""), div({ className: "time" }, this.getTime()) @@ -829,7 +879,7 @@ $(function() { switch (window.urb.user.length) { case 3: return "court"; - case 5: + case 6: return "floor"; case 13: return "porch"; @@ -5512,13 +5562,14 @@ MessageStore = _.merge(new EventEmitter, { return _typing; }, getLastAudience: function() { + var messages; if (_.keys(_messages).length === 0) { return []; } - _messages = _.sortBy(_messages, function(_message) { + messages = _.sortBy(_messages, function(_message) { return _message.thought.statement.time; }); - return _.keys(_messages[_messages.length - 1].thought.audience); + return _.keys(messages[messages.length - 1].thought.audience); }, setTyping: function(state) { return _typing = state; @@ -5604,7 +5655,7 @@ module.exports = MessageStore; },{"../dispatcher/Dispatcher.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/dispatcher/Dispatcher.coffee","events":"/usr/local/lib/node_modules/watchify/node_modules/browserify/node_modules/events/events.js","moment-timezone":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/node_modules/moment-timezone/index.js"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/stores/StationStore.coffee":[function(require,module,exports){ -var EventEmitter, StationDispatcher, StationStore, _audience, _config, _listening, _members, _station, _stations, _typing; +var EventEmitter, StationDispatcher, StationStore, _audience, _config, _listening, _members, _station, _stations, _typing, _validAudience; EventEmitter = require('events').EventEmitter; @@ -5624,6 +5675,8 @@ _config = {}; _typing = {}; +_validAudience = true; + StationStore = _.merge(new EventEmitter, { removeChangeListener: function(cb) { return this.removeListener("change", cb); @@ -5640,6 +5693,12 @@ StationStore = _.merge(new EventEmitter, { setAudience: function(audience) { return _audience = audience; }, + getValidAudience: function() { + return _validAudience; + }, + setValidAudience: function(valid) { + return _validAudience = valid; + }, toggleAudience: function(station) { if (_audience.indexOf(station) !== -1) { return _audience.splice(_audience.indexOf(station), 1); @@ -5745,6 +5804,10 @@ StationStore.dispatchToken = StationDispatcher.register(function(payload) { StationStore.setAudience(action.audience); StationStore.emitChange(); break; + case 'station-set-valid-audience': + StationStore.setValidAudience(action.valid); + StationStore.emitChange(); + break; case 'station-switch': StationStore.setAudience([]); StationStore.setStation(action.station); diff --git a/main/pub/talk/src/js/stores/MessageStore.coffee b/main/pub/talk/src/js/stores/MessageStore.coffee index 4745e15eaa..1bd902a29b 100644 --- a/main/pub/talk/src/js/stores/MessageStore.coffee +++ b/main/pub/talk/src/js/stores/MessageStore.coffee @@ -35,8 +35,8 @@ MessageStore = _.merge new EventEmitter,{ getLastAudience: -> if _.keys(_messages).length is 0 then return [] - _messages = _.sortBy _messages, (_message) -> _message.thought.statement.time - _.keys _messages[_messages.length-1].thought.audience + messages = _.sortBy _messages, (_message) -> _message.thought.statement.time + _.keys messages[messages.length-1].thought.audience setTyping: (state) -> _typing = state diff --git a/main/pub/talk/src/js/stores/StationStore.coffee b/main/pub/talk/src/js/stores/StationStore.coffee index 77c3f60858..bc5e6f1e96 100644 --- a/main/pub/talk/src/js/stores/StationStore.coffee +++ b/main/pub/talk/src/js/stores/StationStore.coffee @@ -10,6 +10,8 @@ _station = null _config = {} _typing = {} +_validAudience = true + StationStore = _.merge new EventEmitter,{ removeChangeListener: (cb) -> @removeListener "change", cb @@ -21,6 +23,10 @@ StationStore = _.merge new EventEmitter,{ setAudience: (audience) -> _audience = audience + getValidAudience: -> _validAudience + + setValidAudience: (valid) -> _validAudience = valid + toggleAudience: (station) -> if _audience.indexOf(station) isnt -1 _audience.splice _audience.indexOf(station), 1 @@ -94,6 +100,10 @@ StationStore.dispatchToken = StationDispatcher.register (payload) -> StationStore.setAudience action.audience StationStore.emitChange() break + when 'station-set-valid-audience' + StationStore.setValidAudience action.valid + StationStore.emitChange() + break when 'station-switch' StationStore.setAudience [] StationStore.setStation action.station From d816297615ba0a99d61fe20e2841ac28b7b6e40d Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Sat, 7 Mar 2015 12:39:54 -0800 Subject: [PATCH 061/219] Proper prompt configuration. --- arvo/dull.hoon | 13 +++++-- arvo/gall.hoon | 4 +-- main/app/dojo/core.hook | 79 ++++++++++++++++++++++++++++------------- main/app/seat/core.hook | 3 +- 4 files changed, 69 insertions(+), 30 deletions(-) diff --git a/arvo/dull.hoon b/arvo/dull.hoon index 7b0a9e85b8..20eece3d12 100644 --- a/arvo/dull.hoon +++ b/arvo/dull.hoon @@ -147,6 +147,9 @@ ++ sign-ames :: $% [%nice ~] :: == :: +++ sign-clay :: + $% [%note p=@tD q=tank] :: + == :: ++ sign-gall :: $% [%crud p=@tas q=(list tank)] :: [%mean p=ares] :: @@ -158,6 +161,7 @@ == :: ++ sign :: in result $<- $% [%a sign-ames] :: + [%c sign-clay] :: [%g sign-gall] :: [%t sign-time] :: == :: @@ -180,6 +184,7 @@ ?+ -.kyz ~& [%strange-kiss -.kyz] +> %flow +> %belt (send `dill-belt`p.kyz) + %crud (send `dill-belt`[%cru p.kyz q.kyz]) %blew (send %rez p.p.kyz q.p.kyz) == :: @@ -226,10 +231,12 @@ [%a %nice *] :: ~& [%take-nice-ames sih] +> + :: + [%c %note *] + (from %out (tuba ~(ram re q.+.sih))) :: [%g %crud *] - ~& [%take-crud sih] - +> + (send %cru p.+.sih q.+.sih) :: [%g %mean *] +>(moz [[hen %give %logo ~] moz]) @@ -248,7 +255,7 @@ == -- :: - ++ ax :: make as + ++ ax :: make ++as |= [hen=duct kyz=kiss] :: ?~ ore.all ~ =+ nux=(~(get by dug.all) hen) diff --git a/arvo/gall.hoon b/arvo/gall.hoon index 12f70d229e..ec1d86f765 100644 --- a/arvo/gall.hoon +++ b/arvo/gall.hoon @@ -259,8 +259,8 @@ |= [pax=path hen=duct hin=(hypo sign)] :: ^- [p=(list move) q=_..^$] ?: ?=(%crud +<.q.hin) - ~& [%gall-crud-error pax hen] - ~& [%gall-crud-data (,[@tas (list tank)] +>.q.hin)] + :: ~& [%gall-crud-error pax hen] + :: ~& [%gall-crud-data (,[@tas (list tank)] +>.q.hin)] ?> ?=(%g -.q.hin) ?~ pax ~& %strange-path [~ ..^$] =+ lum=(lump t.pax) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 32a6be7267..ef8cfcbb2b 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -1,18 +1,19 @@ :: :: :: -:::: /hook/core/dojo/app :: :: - :: :: :: -/? 314 :: zuse version +:::: /hook/core/dojo/app :: :::: + :: :: :: +/? 314 :: arvo kelvin /- *console :: console structures /+ console :: console library :: :: :: -:::: :: :: - !: :: :: +:::: :: :::: + !: :: :: => |% :: external structures ++ house :: all state $: hoc=(map bone session) :: conversations == :: ++ session :: per conversation $: say=console-share :: command-line state + bem=beam :: location poy=(unit dojo-project) :: working var=(map term cage) :: variable state old=(set term) :: used TLVs @@ -53,7 +54,7 @@ == :: ++ dojo-config :: configuration $: p=(list dojo-source) :: by order - q=(map term dojo-source) :: by keyword + q=(map term (unit dojo-source)) :: by keyword == :: ++ dojo-problem (each dojo-source dojo-server) :: construction problem ++ dojo-project :: construction state @@ -215,14 +216,11 @@ ++ dp-config :: ++dojo-config %+ cook |=(a=dojo-config a) ;~ plug - (more ;~(plug com ace) dp-value) + (more ace dp-value) %+ cook - |= a=(list (pair term (unit dojo-source))) - %- ~(gas by *(map term dojo-source)) - %+ turn a - |= b=(pair term (unit dojo-source)) - [p.b ?~(q.b [0 %ex [%dtzy %f &]] u.q.b)] - %+ more ;~(plug com ace) + ~(gas by *(map term (unit dojo-source))) + %+ more + ;~(plug com ace) ;~ plug ;~(pfix tis sym) ;~ pose @@ -266,6 +264,13 @@ %show =^(src +>.$ (dy-init-source p.mad) [[%show p.mad] +>.$]) == :: + ++ dy-init-source-unit :: (unit dojo-source) + |= urc=(unit dojo-source) + ^+ [urc +>] + ?~ urc [~ +>] + =^ src +> (dy-init-source u.urc) + [`src +>.$] + :: ++ dy-init-source :: ++dojo-source |= src=dojo-source ^+ [src +>] @@ -318,10 +323,10 @@ [[fir mor] +>.$] :: ++ dy-init-named :: (map @tas dojo-src) - |= key=(map term dojo-source) + |= key=(map term (unit dojo-source)) ^+ [key +>.$] ?~ key [~ +>.$] - =^ top +>.$ (dy-init-source q.n.key) + =^ top +>.$ (dy-init-source-unit q.n.key) =^ lef +>.$ $(key l.key) =^ rit +>.$ $(key r.key) [[[p.n.key top] lef rit] +>.$] @@ -357,7 +362,7 @@ |= cag=cage ^+ +>+> ~& %dy-made-make - (dy-slam /dial q.cag [[%atom %n] ~]) + (dy-slam /dial q.cag !>(~)) :: ++ dy-made-dial :: dialog result |= cag=cage @@ -424,11 +429,38 @@ %ret (dy-done (tufa buf.say)) == :: + ++ dy-cage |=(num=@ud (~(got by rez) num)) :: known cage + ++ dy-vase |=(num=@ud q:(dy-cage num)) :: known vase + ++ dy-silk-vase |=(vax=vase [%done ~ %noun vax]) :: vase to silk + ++ dy-silk-form :: configure + |= [cag=cage cig=dojo-config] + ^- silk + :+ %ride [%cnzy %$] + :+ %mute [%done ~ cag] + ^- (list (pair wing silk)) + :* :- [[~ 12] ~] + (dy-silk-vase !>([p.bem lat.hid])) + :: + :- [[~ 46] ~] + %- dy-silk-vase + |- ^- vase + ?~ p.cig !>(~) + (slop (dy-vase p.i.p.cig) $(p.cig t.p.cig)) + :: + %+ turn (~(tap by q.cig)) + |= [a=term b=(unit dojo-source)] + ^- (pair wing silk) + :- [a [~ 47] ~] + %- dy-silk-vase + ?~(b !>([~ ~]) (dy-vase p.u.b)) + == + :: ++ dy-silk-build :: build to silk |= bul=dojo-build ^- silk ?^ -.bul [$(bul -.bul) $(bul +.bul)] ?+ -.bul !! + %fo (dy-silk-form (dy-cage p.p.p.bul) q.p.bul) %ex [%ride p.bul [%reef ~]] == :: @@ -436,11 +468,11 @@ |= dov=dojo-device ^- silk :* %boil - %noun + %gate :- [our.hid %main %da lat.hid] ?- -.dov - %& [%mad p.dov ~] - %| [%app p.dov %mad q.dov] + %& [p.dov %gun ~] + %| (weld (flop q.dov) `path`[%gun p.dov %app ~]) == ~ == @@ -483,7 +515,6 @@ :: ++ he-pass |= [pax=path noy=note] - ~& [%he-pass pax noy] %_(+> moz [[ost %pass pax noy] moz]) :: ++ he-rush :: emit update @@ -512,7 +543,8 @@ [%make ~] (dy-made-make:dye q.p.rey) [%edit ~] (dy-made-edit:dye q.p.rey) == - %| (he-rush(poy ~) %tan p.rey) + %| ~& [%he-ford-fail pax] + (he-rush(poy ~) %tan p.rey) == :: ++ he-like :: accept line @@ -580,14 +612,13 @@ :: ++ poke-console-action |= [ost=bone her=ship act=console-action] - ~& %poke-console-action ^- [(list move) _+>] he-abet:(~(he-work he [ost [ost %give %nice ~]~] (~(got by hoc) ost)) act) :: ++ pour - |= [ost=bone pax=path sih=*] + |= [ost=bone pax=path sih=sign] ^- [(list move) _+>] - =+ sih=((hard sign) sih) + :: ~& [%dojo-pour pax] ?- -.sih %f he-abet:(~(he-ford he [[ost ~] (~(got by hoc) ost)]) pax +>.sih) diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index be097f6511..cf1553bfc4 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -204,7 +204,8 @@ ^+ +> ?- -.sil %mean - ~& [%seat-mean sil] + :: ~& [%seat-mean sil] + ~& %seat-mean +>.$ :: %nice From af40c910534827e42b87c9cc0800062f8d17994d Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Sun, 8 Mar 2015 13:19:39 -0700 Subject: [PATCH 062/219] Various fixes and improvements. --- main/app/dojo/core.hook | 92 ++++++++++++++++++++------------------ main/sur/console/core.hook | 11 ++--- 2 files changed, 55 insertions(+), 48 deletions(-) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index ef8cfcbb2b..3323e2d2b7 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -13,7 +13,8 @@ == :: ++ session :: per conversation $: say=console-share :: command-line state - bem=beam :: location + syd=desk :: active desk + luc=(unit case) :: special case poy=(unit dojo-project) :: working var=(map term cage) :: variable state old=(set term) :: used TLVs @@ -46,11 +47,7 @@ == :: ++ dojo-server :: numbered device $: p=@ud :: assembly index - q=dojo-device :: loadable - == :: - ++ dojo-device :: core devices - $% [%& p=term] :: general device - [%| p=term q=path] :: special device + q=path :: gate path == :: ++ dojo-config :: configuration $: p=(list dojo-source) :: by order @@ -173,8 +170,8 @@ %+ knee *dojo-build |. ~+ ;~ pose (ifix [sel ser] dp-many) - ;~(pfix col (stag %fo dp-model)) - ;~(pfix bar (stag %sc dp-model)) + ;~(pfix col (stag %fo dp-model-gun)) + ;~(pfix bar (stag %sc dp-model-sic)) ;~(pfix buc (stag %va sym)) (stag %ex dp-twig) == @@ -194,16 +191,12 @@ == (cook |=(a=term `goal`[our.hid a]) sym) == - ++ dp-model ;~(plug dp-server dp-config) :: ++dojo-model - ++ dp-server (stag 0 dp-device) :: ++dojo-server - ++ dp-twig wide:(vang & ~) :: ++twig - ++ dp-device :: ++dojo-device - %+ cook - |= [a=term b=path] - ^- dojo-device - ?~(b [%& a] [%| a b]) - ;~(plug sym (more fas sym)) - :: + ++ dp-model-gun ;~(plug dp-server-gun dp-config) :: ++dojo-model + ++ dp-model-sic ;~(plug dp-server-sic dp-config) :: ++dojo-model + ++ dp-server-gun (stag 0 (stag %gun dp-device)) :: ++dojo-server + ++ dp-server-sic (stag 0 (stag %sic dp-device)) :: ++dojo-server + ++ dp-twig wide:(vang & ~) :: ++twig + ++ dp-device (most fas sym) :: ++dojo-device ++ dp-value :: ++dojo-source %+ cook |=(a=dojo-source a) %+ stag 0 @@ -347,6 +340,13 @@ ^+ +>+> dy-step(cur +(cur), rez (~(put by rez) cur cag)) :: + ++ dy-meal :: vase to cage + |= vax=vase + ?. &(?=(@ -.q.vax) !((sane %tas) -.q.vax)) + ~& %dy-meal-cage + (dy-rash %bel ~) + (dy-hand -.q.vax (slot 3 vax)) + :: ++ dy-made-edit :: console edit |= cag=cage ^+ +>+> @@ -364,26 +364,26 @@ ~& %dy-made-make (dy-slam /dial q.cag !>(~)) :: - ++ dy-made-dial :: dialog result + ++ dy-made-dial :: dialog product |= cag=cage - ?. ?=([~ ~ a=* b=*] q.q.cag) - ~& %dy-made-init-fail + ^+ +>+> + ?. ?=([~ ~ *] q.q.cag) + ~& %dy-made-dial-fail (dy-rash %bel ~) - =. +>+> - ?: =(a.q.q.cag ~) - +>+> - (he-rush %tan ((list tank) a.q.q.cag)) - ?+ -.b.q.q.cag (dy-rash %bel ~) - %& - ?~ +.b.q.q.cag + =+ tan=((list tank) +14.q.cag) + =+ vax=(spec (slot 15 q.cag)) + ?+ -.q.vax !! + %& + ?~ +<.q.vax + ~& %dy-made-dial-abort (dy-rash %bel ~) - (dy-hand %noun (slot 63 q.cag)) + (dy-meal (slot 7 vax)) :: %| - (dy-rush(pro `(slot 63 q.cag)) %pro (console-prompt +<.b.q.q.cag)) + (dy-rush(pro `(slot 2 vax)) %pro (console-prompt +.q.vax)) == :: - ++ dy-done + ++ dy-done :: submit |= txt=tape ~& %dy-done ?> ?=(^ pro) @@ -439,7 +439,7 @@ :+ %mute [%done ~ cag] ^- (list (pair wing silk)) :* :- [[~ 12] ~] - (dy-silk-vase !>([p.bem lat.hid])) + (dy-silk-vase !>([he-beak lat.hid])) :: :- [[~ 46] ~] %- dy-silk-vase @@ -465,17 +465,9 @@ == :: ++ dy-silk-device :: device to silk - |= dov=dojo-device + |= pax=path ^- silk - :* %boil - %gate - :- [our.hid %main %da lat.hid] - ?- -.dov - %& [p.dov %gun ~] - %| (weld (flop q.dov) `path`[%gun p.dov %app ~]) - == - ~ - == + [%boil %gate [he-beak pax] ~] :: ++ dy-step :: advance project ^+ +> @@ -508,6 +500,10 @@ ++ he-abet :: resolve [(flop moz) %_(+> hoc (~(put by hoc) ost +<+))] :: + ++ he-beak :: logical beam + ^- beak + [our.hid syd ?^(luc u.luc [%da lat.hid])] + :: ++ he-give :: emit gift |= git=gift ^+ +> @@ -608,7 +604,17 @@ ?< (~(has by hoc) ost) ?> =(/console pax) ?> =(her our.hid) - he-abet:~(he-peer he [ost ~] *session) + =< he-abet + %~ he-peer he + :- [ost ~] + ^- session + :* *console-share :: say=console-share + %main :: syd=desk + ~ :: luc=(unit case) + ~ :: poy=(unit dojo-project) + ~ :: var=(map term cage) + ~ :: old=(set term) + == :: ++ poke-console-action |= [ost=bone her=ship act=console-action] diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook index a10793f18c..ff9a2b15bd 100644 --- a/main/sur/console/core.hook +++ b/main/sur/console/core.hook @@ -14,16 +14,17 @@ ted=console-edit :: state change == :: ++ console-dialog :: standard dialog - |* out=$+(* *) :: final output - $_ ^? :: - |= (unit console-input) :: ~ is init - =< $ :: + |* out=$+(* *) :: output structure + $+((unit console-input) (console-result out)) :: +:: :: +++ console-result :: standard output + |* out=$+(* *) :: output structure %- unit :: ~ is invalid %- unit :: ~ is prefix %+ pair (list tank) :: %+ each (unit out) :: ~ is abort (pair console-prompt (console-dialog out)) :: ask and continue -:: +:: :: ++ console-clock ,[own=@ud his=@ud] :: vector clock ++ console-edit :: shared state change $% [%del p=@ud] :: delete one at From ff257eda97deef5906034ceaa9aeb9dc35ad1d18 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 9 Mar 2015 13:06:00 -0700 Subject: [PATCH 063/219] Foreign auth --- arvo/ames.hoon | 2 + arvo/eyre.hoon | 195 +++++++++++++++++++++++++++++++++++++------------ arvo/zuse.hoon | 14 +++- 3 files changed, 162 insertions(+), 49 deletions(-) diff --git a/arvo/ames.hoon b/arvo/ames.hoon index 04ba95c5c1..04646dc63d 100644 --- a/arvo/ames.hoon +++ b/arvo/ames.hoon @@ -1688,6 +1688,8 @@ %milk :: ~& [%rx p.bon q.bon] ?> ?=([@ *] q.q.bon) + ?: ?=(%e i.q.q.bon) + :_(fox [hen [%slip %e %wart p.bon %$ t.q.q.bon r.bon]]~) ?: ?=(%r i.q.q.bon) ?: ?=([%ta *] t.q.q.bon) =+ wil=((hard (unit will)) r.bon) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 2577b4a895..db030e7b47 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -26,14 +26,13 @@ :: [%they p=@ud q=httr] :: inbound response [%this p=? q=clip r=httq] :: inbound request [%thud ~] :: inbound cancel - [%wart p=sock q=@tas r=_`[path *]`*gram] :: urbit message + [%wart p=sack q=@tas r=_`[path *]`*gram] :: urbit message == :: ++ move ,[p=duct q=(mold note gift)] :: local move ++ note :: out request $-> - $% -:: $: %a :: to %ames -:: $% [%want p=sock q=path r=*] :: -:: == == :: + $% $: %a :: to %ames + $% [%want p=sock q=[path *]] :: + == == :: $: %d :: to %dill $% [%flog p=[%crud p=@tas q=(list tank)]] :: == == :: @@ -77,6 +76,7 @@ dop=(map host ship) :: host aliasing liz=(jug beam (each duct oryx)) :: clay subscriptions wup=(map hole cyst) :: secure sessions + sop=(map hole ,[ship ?]) :: foreign session names == :: :: ++ cyst :: client session @@ -84,6 +84,7 @@ [him=ship aut=(set ship)] :: authenticated cug=(list ,@t) :: unacked cookies lax=@da :: last used + way=(map ship ,[purl duct]) :: waiting auth vew=(set oryx) :: open views XX expire == :: :: @@ -96,6 +97,7 @@ :: ++ perk-auth :: parsed auth $% [%get him=ship rem=pork] + [%xen ses=hole rem=pork] [%at p=pork] :: inject auth [%js ~] [%json ~] @@ -107,11 +109,13 @@ $% [%for p=whir q=beam r=term s=cred] :: %f block [%fow p=@uvH] :: %f deps [%fin $|(~ pest-fin)] :: done + [%red p=purl q=@t] :: redirect [%zap p=@ud q=(list tank)] :: err == :: ++ pest-fin :: response - $% [%json p=json] + $% [%code p=@ud q=pest-fin] + [%json p=json] [%html p=manx] [%js p=@t] [%$ p=httr] @@ -195,7 +199,8 @@ ++ auth ''' ship.innerText = urb.ship - window.urb.submit = function(){ + urb.foreign = /^\/~\/am/.test(window.location.pathname) + urb.submit = function(){ xhr = new XMLHttpRequest() xhr.open('POST', "/~/auth.json?PUT", true) var dat = {oryx:'hi', ship: ship.innerText, code: pass.value} @@ -203,7 +208,13 @@ xhr.addEventListener('load', function(){ if(this.status !== 200) return err.innerHTML = ":(\n" + xhr.responseText - else return document.location.reload() + else if(urb.foreign) document.location = + document.location.hash.match(/#[^?]+/)[0].slice(1) + + document.location.pathname.replace( + /^\/~\/am\/[^/]+/, + '/~/as/~' + urb.ship) + + document.location.search + else document.location.reload() }) } ''' @@ -247,13 +258,27 @@ ++ axon :: accept response |= [tea=wire typ=type sih=sign] ^+ +> + =. our ?~(hov our u.hov) :: XX ?- -.+.sih %crud +>.$(mow [[hen %slip %d %flog +.sih] mow]) :: %made - ?+ tea ~& e/ford/lost/hen +>.$ - ~ + =+ tee=((soft whir) tea) + ?~ tee ~& e/ford/lost/hen +>.$ + =. our (need hov) :: XX + |- ^+ ..axon + ?- u.tee + [%at ^] + ?. ?=([%& %js ^] q.sih) + ~& e/at-lost/p.u.tee + $(u.tee q.u.tee) + =* cag p.q.sih + ?> ?=(@ q.q.cag) + =+ cyz=(~(got by wup) p.u.tee) + =^ jon ..ya ~(stat-json ya p.u.tee cyz) + $(u.tee q.u.tee, q.q.p.q.sih (jass jon q.q.cag)) + ~ :: ~& e/ford/hen ?- -.q.sih | (fail 404 p.sih p.q.sih) @@ -277,6 +302,7 @@ ++ apex :: accept request |= kyz=kiss ^+ +> + =. our ?~(hov our u.hov) :: XX ?- -.kyz %born +>.$(ged hen) :: register external %crud @@ -310,26 +336,48 @@ ?~ mez ~& [%strange-wart p.kyz q.kyz] +>.$ - ?- -<.u.mez :: XX handle - %lon !! - %aut !! - %hat !! + ?- -<.u.mez + %aut abet:(logon:(ses-ya p.u.mez) q.p.kyz) + %hat (foreign-hat:(ses-ya p.u.mez) q.p.kyz q.u.mez) + %lon + ~& ses-ask/[p.u.mez sop (~(run by wup) ,~)] + ?: (ses-authed p.u.mez) + (ames-gram q.p.kyz aut/~ p.u.mez) + =. sop (~(put by sop) p.u.mez q.p.kyz |) + (ames-gram q.p.kyz hat/~ p.u.mez our-host) == == :: + ++ ses-authed + |= ses=hole + =+ sap=(~(get by sop) ses) + ?: ?=([~ @ %&] sap) & + =+ cyz=(~(get by wup) ses) + ?~ cyz | + (~(has in aut.u.cyz) our) + :: + ++ ses-ya |=(ses=hole ~(. ya ses (~(got by wup) ses))) + ++ our-host `hart`[| [~ 8.445] `/localhost] :: XX testing ++ fail :: request failed |= [sas=@ud dep=@uvH mez=tang] ^+ +> :: (back ~ dep %tang !>(mez)) :: XX broken tang->mime door in ford - (give-html sas (depo dep (tanx mez))) + (give-html sas ~ (depo dep (tanx mez))) :: ++ give-html :: request failed - |=([sas=@ud max=manx] (resp sas text//html (crip (poxo max)))) + |= [sas=@ud cug=(list ,@t) max=manx] + %- give-gift + %+ add-cookies cug + (make-resp-gift sas text//html (crip (poxo max))) :: ++ give-json :: success json |= [sas=@uG cug=(list ,@t) jon=json] %- give-gift - =+ git=(tuff sas application//json (crip (pojo jon))) + %+ add-cookies cug + (make-resp-gift sas application//json (crip (pojo jon))) + :: + ++ add-cookies + |= [cug=(list ,@t) git=[%thou httr]] ?~ cug git =+ cuh=(turn `(list ,@t)`cug |=(a=@t set-cookie/a)) git(q (weld cuh q.git)) @@ -340,9 +388,12 @@ :: ++ resp :: mime response |= [sas=@uG mit=mite bod=cord] - (give-gift (tuff sas mit bod)) + (give-gift (make-resp-gift sas mit bod)) + :: + ++ pass-note |=(noe=[whir note] +>(mow :_(mow [hen %pass noe]))) + ++ ames-gram + |=([him=ship gam=gram] (pass-note ~ %a %want [our him] [%e -.gam] +.gam)) :: - ++ pass-note |=(noe=[wire note] +>(mow :_(mow [hen %pass noe]))) ++ ford-req |= [tea=whir our=ship kas=silk] :: ~& [%ford-req our num ses -.kas] @@ -352,7 +403,7 @@ |= [tea=whir dep=@uvH cag=cage] (ford-req tea our [%cast %mime %done ~ cag]) :: XX deps :: - ++ tuff :: mimed response + ++ make-resp-gift :: mimed response |= [sas=@uG mit=mite rez=@] :: (weld (turn cug |=(a=@t ['set-cookie' a])) [%thou `httr`[sas ~[content-type/(moon mit)] [~ (taco rez)]]] @@ -394,7 +445,7 @@ =: s.bem [%web ~(rent co (flux:ya quy ced)) s.bem] r.bem ?+(r.bem r.bem [%ud %0] da/now) == - (ford-req tea our [%cast %mime [%boil ext bem ~]]) + (ford-req tea our [%boil ext bem ~]) :: :: ++ as-beam @@ -411,7 +462,7 @@ ?+ [(fall p.pok %$) q.pok] ~ [?(%ico %png) %favicon ~] :- ~ - %^ tuff 200 image//png + %^ make-resp-gift 200 image//png 0w89wg.GV4jA.l9000.00dPb.YzBT6.giO00.o100d.wZcqc.a9tg-.VTG0b. AUIvE.HBM3g.cK4SE.0aagi.l090p.I1P5g.Y-80r.y1YS9.1xE~Y.qgpFY. vKN1V.905y0.2UwvL.43TUw.uL406.0-31h.xwoJF.Ul454.ilk00.00Yps. @@ -420,7 +471,7 @@ :: [%txt %robots ~] :- ~ - %^ tuff 200 text//plain + %^ make-resp-gift 200 text//plain %- role :~ 'User-agent: *' 'Disallow: /' @@ -451,6 +502,7 @@ %anon anon %own our == + %am ?~(but !! [%auth %xen i.but pok(q t.but)]) %at [%auth %at pok(q but)] %auth :- %auth @@ -475,21 +527,26 @@ :: ++ handle ^+ done - =+ oar=(fall (host-to-ship r.hat) (need hov)) - =. our oar :: XX + =+ oar=(host-to-ship r.hat) + =. our ?~(oar our u.oar) :: XX =+ pez=process ?: ?=(%| -.pez) p.pez :: XX transitional + =+ status=200 |- ^+ done ?- -.p.pez %for (beam-into-ford +.p.pez) %fow (ford-wasp ~ p.p.pez) %zap (fail p.p.pez 0v0 q.p.pez) + %red =+ fra=?~(q.p.pez "" ['#' (trip q.p.pez)]) + =+ url=(weld (earn p.p.pez) `tape`fra) + $(p.pez [%fin ~ 307 [location/(crip url)]~ ~]) %fin ?~ +.p.pez done ?- &2.p.pez ~ (give-gift %thou p.p.pez) - %js (resp 200 text//javascript p.p.pez) - %html (give-html 200 p.p.pez) - %json (give-json 200 ~ p.p.pez) + %js (resp status text//javascript p.p.pez) + %html (give-html status ~ p.p.pez) + %json (give-json status ~ p.p.pez) + %code $(+.p.pez q.p.pez, status p.p.pez) == == :: ++ process @@ -515,8 +572,6 @@ & ::(~(has in vew.cyz:for-client) u.oxe) ::XX :: ++ parse-to-oryx ;~(biff poja (ot oryx/so ~):jo) - ++ continue-with-request |=(rem=pork handle(pok rem)) - ++ foreign-auth ,_!! ++ root-beak `beak`[our %main ud/0] :: XX ++ process-parsed |= hem=perk @@ -528,9 +583,9 @@ [%& %for ~ bem ext ced.cyz:for-client] %poll ?: ?=([~ %js] p.pok) :: XX treat non-json cases? - =+ pol=(apex:earn %| pok(u.p %json) quy) :: polling url + =+ polling-url=(apex:earn %| pok(u.p %json) quy) :^ %& %fin %js - (jass (joba %poll (jape pol)) poll:js) + (jass (joba %poll (jape polling-url)) poll:js) ?~ p.hem [%| done] [%& %fow p.hem] %auth @@ -546,7 +601,7 @@ =+ pez=process(pok p.hem) ?. ?=(%& -.pez) ~|(no-inject/p.hem !!) ?- -.p.pez - ?(%fow %zap) pez + ?(%fow %zap %red) pez %for pez(p.p [%at ses.yac p.p.pez]) %fin ~| %not-script @@ -556,6 +611,7 @@ == :: %try + ~& ses-try/ses.yac :- %| ?. =(our him.hem) ~|(stub-foreign/him.hem !!) @@ -565,7 +621,6 @@ (give-json 200 cug.yac jon) :: %del [%| (nice-json(..ya (logoff:yac p.hem)))] - :: %get ~| aute/+.hem ?: |(=(anon him.hem) (~(has in aut.yac) him.hem)) @@ -574,11 +629,20 @@ pez pez(aut.s.p (~(put ju aut.s.p.pez) %$ (scot %p him.hem))) ?. =(our him.hem) - (foreign-auth) - [%& (show-login-page)] + [%| ((teba foreign-auth:for-client) him.hem hat rem.hem quy)] + (show-login-page ~) + %xen + (show-login-page ~ ses.hem) == == - ++ show-login-page ,_[%fin %html login-page:xml] + ++ show-login-page + |= ses=(unit hole) ^- (each pest ,_done) + ?~ ses + [%& %fin %code 401 %html login-page:xml] + =+ yac=~(. ya u.ses (ses-cyst u.ses)) + =. ..ya abet.yac + [%| (give-html 401 cug.yac login-page:xml)] + :: ++ nice-json ,_(give-json 200 ~ (joba %ok %b &)) :: ++ load-secret @@ -587,22 +651,26 @@ %^ rsh 3 1 (scot %p (,@ (need (sky %a pax)))) :: + ++ cookie-prefix (rsh 3 1 (scot %p our)) ++ for-client :: stateful per-session engine ^+ ya - %~ . ya - =* sec p.hat - =+ pef=(rsh 3 1 (scot %p our)) + =+ pef=cookie-prefix =+ lig=(sesh pef maf) ?^ lig - =+ cyz=(need (~(get by wup) u.lig)) - [u.lig cyz(cug ~)] + =+ cyz=(~(got by wup) u.lig) + ~(. ya u.lig cyz(cug ~)) =+ ses=(rsh 3 1 (scot %p (end 6 1 ney))) - :- ses + ~(. ya ses (ses-cyst ses)) + :: + ++ ses-cyst + |= ses=hole + =* sec p.hat + =+ pef=cookie-prefix ^- cyst :* ^- cred :* hat(p sec) ~ - (rsh 3 1 (scot %p (end 6 1 (shaf %oryx ses)))) + 'not-yet-implemented' ::(rsh 3 1 (scot %p (end 6 1 (shaf %oryx ses)))) :: =+ lag=(~(get by maf) %accept-language) ?~(lag ~ ?~(u.lag ~ [~ i.u.lag])) @@ -611,8 +679,6 @@ ~ == [anon ~] - :: - :: ~ :: :_ ~ %^ cat 3 @@ -622,6 +688,7 @@ :: now ~ + ~ :: [1 ~] == -- @@ -631,7 +698,21 @@ |% ++ abet ..ya(wup (~(put by wup) ses cyz)) ++ abut ..ya(wup (~(del by wup) ses)) - ++ logon |=(her=ship +>(him her, aut (~(put in aut) her))) + ++ logon + |= her=ship + %_ +> + him her + aut (~(put in aut) her) + ..ya + ~& logon/[our her ses] + ?. =(our her) + ..ya + =+ sap=(~(get by sop) ses) + ~& sap + ?. ?=([~ @ %|] sap) + ..ya + (ames-gram -.u.sap aut/~ ses) + == ++ logoff |= her=(unit ship) ^+ ..ya ?~ her abut @@ -639,6 +720,24 @@ ?~ aut abut abet(him ?.(=(her him) him n.aut)) :: + ++ foreign-auth + |= [him=ship pul=purl] ^+ ..ya + =. way (~(put by way) him pul hen) + (ames-gram:abet him [lon/~ ses]) + :: + ++ foreign-hat + |= [him=ship hat=hart] ^+ ..ya + ~| way + =^ pul hen (~(got by way) him) + =. way (~(del by way) him) + =. q.q.pul ['~' %am ses q.q.pul] + =+ url=(welp (earn pul(p hat)) '#' (head:earn p.pul)) + %- give-gift + %+ add-cookies cug + :+ %thou 307 + [[location/(crip url)]~ ~] + :: + ++ foreign-good !! ++ stat-json ^+ [*json ..ya] =+ orx=(rsh 3 1 (scot %p (shaf %orx eny))) @@ -702,7 +801,7 @@ ~ :: ++ load :: clam previous state - |= old=_[%0 gub hov ged ney dop **] + |= old=_[%0 gub hov ged ney dop liz wup=wup sop=sop] ^+ ..^$ ..^$(+>- (bolo old)) :: diff --git a/arvo/zuse.hoon b/arvo/zuse.hoon index 549b31fe35..79797cd513 100644 --- a/arvo/zuse.hoon +++ b/arvo/zuse.hoon @@ -2115,7 +2115,19 @@ ~ =+ d=(end 0 6 pad) [(cut 3 [d 1] cha) $(pad (rsh 0 6 pad))] - (weld (flop (slag poc sif)) (trip (fil 3 poc '='))) + (weld (flop (slag poc sif)) (reap poc '=')) +:: +++ ofis + =- |=(a=cord (rash a fel)) + =- fel=;~(sfix (boss 64 (plus siw)) (stun 0^3 tis)) + ^= siw + ;~ pose + dit + (cook |=(a=@ (sub a (sub 'A' 10))) (shim 'A' 'Z')) + (cook |=(a=@ (sub a (sub 'a' 36))) (shim 'a' 'z')) + (cold 62 (just '-')) + (cold 63 (just '~')) + == :: ++ urle :: URL encode |= tep=tape From b154a69b2ecdb883d1296f17195ebbdef9b1358d Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 9 Mar 2015 13:55:54 -0700 Subject: [PATCH 064/219] Log out --- arvo/eyre.hoon | 69 ++++++++++++++++++++++++++++++----------- main/app/into/core.hook | 1 + 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index db030e7b47..6b1ff431e7 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -93,6 +93,7 @@ [%beam p=beam] [%poll p=@uvH] [%auth perk-auth] + [%away ~] == :: ++ perk-auth :: parsed auth @@ -122,7 +123,7 @@ == -- :: |% -++ sesh :: session from cookies +++ session-from-cookies |= [nam=@t maf=math] ^- (unit hole) =+ ^= cok ^- (list ,@t) @@ -134,7 +135,9 @@ ?~ mar $(cok t.cok) |- ^- (unit hole) ?~ u.mar ^$(cok t.cok) - ?:(=(nam p.i.u.mar) [~ q.i.u.mar] $(u.mar t.u.mar)) + ?: &(=(nam p.i.u.mar) !=('~' q.i.u.mar)) + [~ q.i.u.mar] + $(u.mar t.u.mar) :: ++ heat :: eat headers |= hed=(list ,[p=@t q=@t]) ^- math @@ -198,32 +201,43 @@ :: ++ auth ''' + var req = function(url,dat,cb){ + var xhr = new XMLHttpRequest() + xhr.open('POST', url, true) + dat.oryx = urb.oryx + xhr.send(JSON.stringify(dat)) + xhr.addEventListener('load', function(ev){ + if(this.status !== 200) + return err.innerHTML = ":(\n" + xhr.responseText + else if(cb) return cb(xhr.responseText,ev) + }) + } + ship.innerText = urb.ship urb.foreign = /^\/~\/am/.test(window.location.pathname) urb.submit = function(){ - xhr = new XMLHttpRequest() - xhr.open('POST', "/~/auth.json?PUT", true) - var dat = {oryx:'hi', ship: ship.innerText, code: pass.value} - xhr.send(JSON.stringify(dat)) - xhr.addEventListener('load', function(){ - if(this.status !== 200) - return err.innerHTML = ":(\n" + xhr.responseText - else if(urb.foreign) document.location = + req( + "/~/auth.json?PUT", + {ship: ship.innerText, code: pass.value}, + function(){ + if(urb.foreign) document.location = document.location.hash.match(/#[^?]+/)[0].slice(1) + document.location.pathname.replace( /^\/~\/am\/[^/]+/, '/~/as/~' + urb.ship) + document.location.search else document.location.reload() - }) + }) } + urb.away = function(){req("/~/auth.json?DELETE", {}, + function(){document.write("success!")})} ''' -- ++ xml |% ++ login-page ;html - ;head:title:'Hello World' + ;head:title:'Log in' ;body ;p: Identify yourself, ~;{span#ship(contenteditable "")}? ;style:'#ship {background: lightgray} #ship br {display: none}' @@ -232,6 +246,17 @@ ;script@"/~/at/~/auth.js"; == == + :: + ++ logout-page + ;html + ;head:title:'Log out' + ;body + ;p: Goodbye ~;{span#ship}. + ;button#act(onclick "urb.away()"): Log out + ;pre:code#err; + ;script@"/~/at/~/auth.js"; + == + == -- -- |% :: functions @@ -504,9 +529,10 @@ == %am ?~(but !! [%auth %xen i.but pok(q t.but)]) %at [%auth %at pok(q but)] + %away [%away ~] %auth :- %auth - |- + |- ^- perk-auth ?+ p.pok !! ~ $(p.pok [~ %json]) [~ %js] [%js ~] @@ -521,7 +547,11 @@ [%try (need (paz (need (poja q:(need bod)))))] :: [[%'DELETE' ~] ~] - !! + ~| parsing/bod + =+ jon=(need (poja q:(need bod))) + ?> ?=(%o -.jon) + =+ sip=(~(get by p.jon) %ship) + [%del ?~(sip ~ [~ (need ((su:jo fed:ag) u.sip))])] == == == == :: @@ -583,11 +613,12 @@ [%& %for ~ bem ext ced.cyz:for-client] %poll ?: ?=([~ %js] p.pok) :: XX treat non-json cases? - =+ polling-url=(apex:earn %| pok(u.p %json) quy) + =+ polling-url=['/' (apex:earn %| pok(u.p %json) quy)] :^ %& %fin %js (jass (joba %poll (jape polling-url)) poll:js) ?~ p.hem [%| done] [%& %fow p.hem] + %away [%& %fin %html logout-page:xml] %auth =+ yac=for-client ?- &2.hem @@ -620,7 +651,10 @@ =^ jon ..ya stat-json:(logon:yac him.hem) (give-json 200 cug.yac jon) :: - %del [%| (nice-json(..ya (logoff:yac p.hem)))] + %del + =. ..ya (logoff:yac p.hem) + =+ cug=[(cat 3 cookie-prefix '=~; Path=/')]~ + [%| (give-json 200 cug (joba %ok %b &))] %get ~| aute/+.hem ?: |(=(anon him.hem) (~(has in aut.yac) him.hem)) @@ -655,7 +689,7 @@ ++ for-client :: stateful per-session engine ^+ ya =+ pef=cookie-prefix - =+ lig=(sesh pef maf) + =+ lig=(session-from-cookies pef maf) ?^ lig =+ cyz=(~(got by wup) u.lig) ~(. ya u.lig cyz(cug ~)) @@ -737,7 +771,6 @@ :+ %thou 307 [[location/(crip url)]~ ~] :: - ++ foreign-good !! ++ stat-json ^+ [*json ..ya] =+ orx=(rsh 3 1 (scot %p (shaf %orx eny))) diff --git a/main/app/into/core.hook b/main/app/into/core.hook index 25f92812d6..f7f93a6f2d 100644 --- a/main/app/into/core.hook +++ b/main/app/into/core.hook @@ -1,3 +1,4 @@ +:: Over/write to location, usage :into %/foo/txt 'Contents' !: :::: :: From 7c846667e02a4a39ff4a2aaea0c318b893f1271a Mon Sep 17 00:00:00 2001 From: Galen Wolfe-Pauly Date: Mon, 9 Mar 2015 15:45:34 -0700 Subject: [PATCH 065/219] membership --- main/pub/talk/src/css/main.css | 21 +++-- main/pub/talk/src/css/main.styl | 21 +++-- .../talk/src/js/actions/StationActions.coffee | 3 +- .../js/components/MessagesComponent.coffee | 20 ++-- .../src/js/components/StationComponent.coffee | 7 +- .../src/js/components/WritingComponent.coffee | 2 +- main/pub/talk/src/js/main.coffee | 3 +- main/pub/talk/src/js/main.js | 93 ++++++++++++------- .../js/persistence/StationPersistence.coffee | 4 +- .../talk/src/js/stores/StationStore.coffee | 32 +++---- 10 files changed, 122 insertions(+), 84 deletions(-) diff --git a/main/pub/talk/src/css/main.css b/main/pub/talk/src/css/main.css index 40a71d1dc4..68bc9539d1 100644 --- a/main/pub/talk/src/css/main.css +++ b/main/pub/talk/src/css/main.css @@ -137,8 +137,9 @@ body { font-size: 4rem; } #station #station-container { - display: block; padding-top: 1rem; + min-width: 30rem; + text-align: right; } #stations-container, #messages-container { @@ -155,9 +156,13 @@ body { #station > div { display: inline-block; } -#station-meta { - margin-right: 1rem; - margin-bottom: 1rem; +#station-meta .audi, +#station-meta .iden { + display: inline-block; +} +#station-meta .iden { + width: 6rem; + margin-left: 0.3rem; } #sources-container { position: fixed; @@ -172,9 +177,6 @@ body { #members { margin-left: 2rem; } -#station .iden { - display: block; -} .station { margin-bottom: 0.3rem; cursor: pointer; @@ -247,6 +249,9 @@ body { #messages .message:hover .time { opacity: 1; } +#messages .message .ship { + cursor: pointer; +} .member { width: 12rem; margin: 0.3rem 0.6rem 0.3rem 0; @@ -278,6 +283,7 @@ body { .attr .iden { color: #000; width: 6rem; + margin-left: 0.3rem; } .mess { font-size: 0.9rem; @@ -317,6 +323,7 @@ body { padding: 0.3rem; margin-top: -0.3rem; outline: none; + margin-right: -0.3rem; } #audi.valid-false { color: #ff2f2f; diff --git a/main/pub/talk/src/css/main.styl b/main/pub/talk/src/css/main.styl index 4afc89aca5..a90c32a191 100644 --- a/main/pub/talk/src/css/main.styl +++ b/main/pub/talk/src/css/main.styl @@ -55,8 +55,9 @@ body font-size 4rem #station #station-container - display block padding-top 1rem + min-width 30rem + text-align right #stations-container #messages-container @@ -73,9 +74,13 @@ body #station > div display inline-block -#station-meta - margin-right 1rem - margin-bottom 1rem +#station-meta .audi +#station-meta .iden + display inline-block + +#station-meta .iden + width 6rem + margin-left .3rem #sources-container position fixed @@ -90,9 +95,6 @@ body #members margin-left 2rem -#station .iden - display block - .station margin-bottom .3rem cursor pointer @@ -166,6 +168,9 @@ body #messages .message:hover .time opacity 1 +#messages .message .ship + cursor pointer + .member width 12rem margin .3rem .6rem .3rem 0 @@ -197,6 +202,7 @@ body .attr .iden color #000 width 6rem + margin-left .3rem .mess font-size .9rem @@ -236,6 +242,7 @@ body padding .3rem margin-top -.3rem outline none + margin-right -.3rem #audi.valid-false color #ff2f2f diff --git a/main/pub/talk/src/js/actions/StationActions.coffee b/main/pub/talk/src/js/actions/StationActions.coffee index 6e8bc11d60..f7bac708da 100644 --- a/main/pub/talk/src/js/actions/StationActions.coffee +++ b/main/pub/talk/src/js/actions/StationActions.coffee @@ -58,11 +58,10 @@ module.exports = type:"stations-load" stations:stations - loadMembers: (station,members) -> + loadMembers: (members) -> StationDispatcher.handleServerAction type:"members-load" members:members - station:station createStation: (station) -> StationDispatcher.handleViewAction diff --git a/main/pub/talk/src/js/components/MessagesComponent.coffee b/main/pub/talk/src/js/components/MessagesComponent.coffee index 8b09f7046d..399ecc829d 100644 --- a/main/pub/talk/src/js/components/MessagesComponent.coffee +++ b/main/pub/talk/src/js/components/MessagesComponent.coffee @@ -20,19 +20,15 @@ Message = recl "~#{h}.#{m}.#{s}" _handlePm: (e) -> - $t = $(e.target).closest('.iden') - console.log 'pm' - console.log window.util.mainStation $t.text().slice(1) + return if not @props._handlePm + user = $(e.target).closest('.iden').text().slice(1) + @props._handlePm user render: -> # pendingClass = if @props.pending isnt "received" then "pending" else "" delivery = _.uniq _.pluck @props.thought.audience, "delivery" pendingClass = if delivery.indexOf("received") isnt -1 then "received" else "pending" - if pendingClass is "pending" - console.log @props.thought - console.log delivery - name = if @props.name then @props.name else "" audi = _.keys(@props.thought.audience) audi = audi.join " " @@ -40,7 +36,7 @@ Message = recl div {className:"message "+pendingClass}, [ (div {className:"attr"}, [ div {className:"audi"}, "#{audi}" - (Member {onClick:@_handlePm,ship:@props.ship}, "") + (div {onClick:@_handlePm}, (Member {ship:@props.ship}, "")) (br {},"") div {className:"time"}, @convTime @props.thought.statement.date ]) @@ -106,6 +102,13 @@ module.exports = recl _onChangeStore: -> @setState @stateFromStore() + _handlePm: (user) -> + audi = [ + window.util.mainStationPath(user) + window.util.mainStationPath(window.urb.user) + ] + StationActions.setAudience audi + render: -> station = @state.station _station = "~"+window.urb.ship+"/"+station @@ -128,5 +131,6 @@ module.exports = recl messages = _messages.map (_message) => _message.station = @state.station + _message._handlePm = @_handlePm Message _message, "" div {id: "messages"}, messages \ No newline at end of file diff --git a/main/pub/talk/src/js/components/StationComponent.coffee b/main/pub/talk/src/js/components/StationComponent.coffee index ed48574de0..b3a7f294e4 100644 --- a/main/pub/talk/src/js/components/StationComponent.coffee +++ b/main/pub/talk/src/js/components/StationComponent.coffee @@ -60,9 +60,10 @@ module.exports = recl parts = [] members = [] - if @state.station and @state.members[@state.station] - members = _.map @state.members[@state.station], (state,member) -> - Member {ship:member,presence:state.presence} + if @state.station and @state.members + members = _.map @state.members, (stations,member) -> + audi = _.map stations,(presence,station) -> (div {className:"audi"}, station) + (div {}, [audi,Member {ship:member}]) else members = "" diff --git a/main/pub/talk/src/js/components/WritingComponent.coffee b/main/pub/talk/src/js/components/WritingComponent.coffee index d63937a257..720a836894 100644 --- a/main/pub/talk/src/js/components/WritingComponent.coffee +++ b/main/pub/talk/src/js/components/WritingComponent.coffee @@ -98,7 +98,7 @@ module.exports = recl valid _setAudi: -> - valid = _validateAudi() + valid = @_validateAudi() StationActions.setValidAudience valid if valid is true v = $('#audi').text() diff --git a/main/pub/talk/src/js/main.coffee b/main/pub/talk/src/js/main.coffee index 9cdf9f7e94..37b1238230 100644 --- a/main/pub/talk/src/js/main.coffee +++ b/main/pub/talk/src/js/main.coffee @@ -8,7 +8,8 @@ $(() -> window.chat.StationPersistence = require './persistence/StationPersistence.coffee' window.util = - mainStation (user): -> + mainStationPath: (user) -> "~#{user}/#{window.util.mainStation(user)}" + mainStation: (user) -> if not user then user = window.urb.user switch user.length when 3 diff --git a/main/pub/talk/src/js/main.js b/main/pub/talk/src/js/main.js index 454e783c46..f646b9176e 100644 --- a/main/pub/talk/src/js/main.js +++ b/main/pub/talk/src/js/main.js @@ -154,11 +154,10 @@ module.exports = { stations: stations }); }, - loadMembers: function(station, members) { + loadMembers: function(members) { return StationDispatcher.handleServerAction({ type: "members-load", - members: members, - station: station + members: members }); }, createStation: function(station) { @@ -237,19 +236,17 @@ Message = recl({ return "~" + h + "." + m + "." + s; }, _handlePm: function(e) { - var $t; - $t = $(e.target).closest('.iden'); - console.log('pm'); - return console.log(window.util.mainStation($t.text().slice(1))); + var user; + if (!this.props._handlePm) { + return; + } + user = $(e.target).closest('.iden').text().slice(1); + return this.props._handlePm(user); }, render: function() { var audi, delivery, name, pendingClass; delivery = _.uniq(_.pluck(this.props.thought.audience, "delivery")); pendingClass = delivery.indexOf("received") !== -1 ? "received" : "pending"; - if (pendingClass === "pending") { - console.log(this.props.thought); - console.log(delivery); - } name = this.props.name ? this.props.name : ""; audi = _.keys(this.props.thought.audience); audi = audi.join(" "); @@ -344,6 +341,11 @@ module.exports = recl({ _onChangeStore: function() { return this.setState(this.stateFromStore()); }, + _handlePm: function(user) { + var audi; + audi = [window.util.mainStationPath(user), window.util.mainStationPath(window.urb.user)]; + return StationActions.setAudience(audi); + }, render: function() { var _messages, _station, messages, ref1, ref2, sources, station; station = this.state.station; @@ -367,6 +369,7 @@ module.exports = recl({ messages = _messages.map((function(_this) { return function(_message) { _message.station = _this.state.station; + _message._handlePm = _this._handlePm; return Message(_message, ""); }; })(this)); @@ -445,12 +448,19 @@ module.exports = recl({ var _remove, _sources, members, parts, sourceCtrl, sourceInput, sources, station; parts = []; members = []; - if (this.state.station && this.state.members[this.state.station]) { - members = _.map(this.state.members[this.state.station], function(state, member) { - return Member({ - ship: member, - presence: state.presence + if (this.state.station && this.state.members) { + members = _.map(this.state.members, function(stations, member) { + var audi; + audi = _.map(stations, function(presence, station) { + return div({ + className: "audi" + }, station); }); + return div({}, [ + audi, Member({ + ship: member + }) + ]); }); } else { members = ""; @@ -749,7 +759,7 @@ module.exports = recl({ }, _setAudi: function() { var a, i, len, v, valid; - valid = _validateAudi(); + valid = this._validateAudi(); StationActions.setValidAudience(valid); if (valid === true) { v = $('#audi').text(); @@ -875,8 +885,14 @@ $(function() { window.chat.MessagePersistence = require('./persistence/MessagePersistence.coffee'); window.chat.StationPersistence = require('./persistence/StationPersistence.coffee'); window.util = { - mainStation: function() { - switch (window.urb.user.length) { + mainStationPath: function(user) { + return "~" + user + "/" + (window.util.mainStation(user)); + }, + mainStation: function(user) { + if (!user) { + user = window.urb.user; + } + switch (user.length) { case 3: return "court"; case 6: @@ -5496,8 +5512,8 @@ module.exports = { if (res.data.ok === true) { StationActions.listeningStation(station); } - if ((ref = res.data.group) != null ? ref.local : void 0) { - StationActions.loadMembers(station, res.data.group.local); + if ((ref = res.data.group) != null ? ref.global : void 0) { + StationActions.loadMembers(res.data.group.global); } if (res.data.config) { return StationActions.loadConfig(station, res.data.config); @@ -5720,21 +5736,26 @@ StationStore = _.merge(new EventEmitter, { ship: ship }; }, - changeMember: function(dir, name, ship) { - if (dir === "out") { - _members = _.filter(_members, function(_member) { - return _member.ship !== ship; - }); + loadMembers: function(members) { + var list, member, presence, results, station; + _members = {}; + results = []; + for (station in members) { + list = members[station]; + results.push((function() { + var results1; + results1 = []; + for (member in list) { + presence = list[member]; + if (!_members[member]) { + _members[member] = {}; + } + results1.push(_members[member][station] = presence); + } + return results1; + })()); } - if (dir === "in") { - return _members.push({ - name: name, - ship: ship - }); - } - }, - loadMembers: function(station, members) { - return _members[station] = members; + return results; }, getMembers: function() { return _members; @@ -5835,7 +5856,7 @@ StationStore.dispatchToken = StationDispatcher.register(function(payload) { StationStore.emitChange(); break; case "members-load": - StationStore.loadMembers(action.station, action.members); + StationStore.loadMembers(action.members); StationStore.emitChange(); break; case "typing-set": diff --git a/main/pub/talk/src/js/persistence/StationPersistence.coffee b/main/pub/talk/src/js/persistence/StationPersistence.coffee index d774bf63bd..83b63ed07c 100644 --- a/main/pub/talk/src/js/persistence/StationPersistence.coffee +++ b/main/pub/talk/src/js/persistence/StationPersistence.coffee @@ -68,7 +68,7 @@ module.exports = console.log(res.data) if res.data.ok is true StationActions.listeningStation station - if res.data.group?.local - StationActions.loadMembers station,res.data.group.local + if res.data.group?.global + StationActions.loadMembers res.data.group.global if res.data.config StationActions.loadConfig station,res.data.config \ No newline at end of file diff --git a/main/pub/talk/src/js/stores/StationStore.coffee b/main/pub/talk/src/js/stores/StationStore.coffee index bc5e6f1e96..c7b8940ca4 100644 --- a/main/pub/talk/src/js/stores/StationStore.coffee +++ b/main/pub/talk/src/js/stores/StationStore.coffee @@ -1,14 +1,14 @@ -EventEmitter = require('events').EventEmitter +EventEmitter = require('events').EventEmitter StationDispatcher = require '../dispatcher/Dispatcher.coffee' -_audience = [] -_members = {} -_stations = [] -_listening = [] -_station = null -_config = {} -_typing = {} +_audience = [] +_members = {} +_stations = [] +_listening = [] +_station = null +_config = {} +_typing = {} _validAudience = true @@ -41,14 +41,12 @@ StationStore = _.merge new EventEmitter,{ getMember: (ship) -> {ship:ship} - changeMember: (dir,name,ship) -> - if dir is "out" - _members = _.filter _members, (_member) -> - return (_member.ship isnt ship) - if dir is "in" - _members.push {name:name, ship:ship} - - loadMembers: (station,members) -> _members[station] = members + loadMembers: (members) -> + _members = {} + for station,list of members + for member,presence of list + _members[member] = {} if not _members[member] + _members[member][station] = presence getMembers: -> _members @@ -131,7 +129,7 @@ StationStore.dispatchToken = StationDispatcher.register (payload) -> StationStore.emitChange() break when "members-load" - StationStore.loadMembers action.station,action.members + StationStore.loadMembers action.members StationStore.emitChange() break when "typing-set" From 90fe0fef0e9c79e42ffb4f60def87fc4d79d5fa5 Mon Sep 17 00:00:00 2001 From: Galen Wolfe-Pauly Date: Tue, 10 Mar 2015 11:49:01 -0700 Subject: [PATCH 066/219] better pms --- .../js/components/MessagesComponent.coffee | 11 ++- .../src/js/components/WritingComponent.coffee | 25 ++++--- main/pub/talk/src/js/main.coffee | 16 +++++ main/pub/talk/src/js/main.js | 67 ++++++++++++++----- 4 files changed, 89 insertions(+), 30 deletions(-) diff --git a/main/pub/talk/src/js/components/MessagesComponent.coffee b/main/pub/talk/src/js/components/MessagesComponent.coffee index 399ecc829d..ad29d3233f 100644 --- a/main/pub/talk/src/js/components/MessagesComponent.coffee +++ b/main/pub/talk/src/js/components/MessagesComponent.coffee @@ -19,6 +19,10 @@ Message = recl s = @lz d.getSeconds() "~#{h}.#{m}.#{s}" + _handleAudi: (e) -> + audi = $(e.target).closest('.audi').text().split(" ") + @props._handleAudi audi + _handlePm: (e) -> return if not @props._handlePm user = $(e.target).closest('.iden').text().slice(1) @@ -30,12 +34,12 @@ Message = recl pendingClass = if delivery.indexOf("received") isnt -1 then "received" else "pending" name = if @props.name then @props.name else "" - audi = _.keys(@props.thought.audience) + audi = window.util.clipAudi _.keys @props.thought.audience audi = audi.join " " div {className:"message "+pendingClass}, [ (div {className:"attr"}, [ - div {className:"audi"}, "#{audi}" + div {onClick:@_handleAudi,className:"audi"}, "#{audi}" (div {onClick:@_handlePm}, (Member {ship:@props.ship}, "")) (br {},"") div {className:"time"}, @convTime @props.thought.statement.date @@ -109,6 +113,8 @@ module.exports = recl ] StationActions.setAudience audi + _handleAudi: (audi) -> StationActions.setAudience audi + render: -> station = @state.station _station = "~"+window.urb.ship+"/"+station @@ -132,5 +138,6 @@ module.exports = recl messages = _messages.map (_message) => _message.station = @state.station _message._handlePm = @_handlePm + _message._handleAudi = @_handleAudi Message _message, "" div {id: "messages"}, messages \ No newline at end of file diff --git a/main/pub/talk/src/js/components/WritingComponent.coffee b/main/pub/talk/src/js/components/WritingComponent.coffee index 720a836894..dd11844fda 100644 --- a/main/pub/talk/src/js/components/WritingComponent.coffee +++ b/main/pub/talk/src/js/components/WritingComponent.coffee @@ -45,6 +45,7 @@ module.exports = recl @_setAudi() else audi = @state.audi + audi = window.util.expandAudi audi MessageActions.sendMessage audi,@$writing.text(),audi @$length.text "0/69" @$writing.text('') @@ -80,18 +81,20 @@ module.exports = recl _validateAudiPart: (a) -> if a[0] isnt "~" return false - if a.indexOf("/") is -1 - return false - _a = a.split("/") - if _a[0].length < 3 - return false - if _a[1].length is 0 + if a.indexOf("/") isnt -1 + _a = a.split("/") + if _a[1].length is 0 + return false + ship = _a[0] + else + ship = a + if ship.length < 3 return false return true _validateAudi: -> v = $('#audi').text() - v = v.split "," + v = v.split " " for a in v a = a.trim() valid = @_validateAudiPart(a) @@ -102,9 +105,8 @@ module.exports = recl StationActions.setValidAudience valid if valid is true v = $('#audi').text() - v = v.split "," - for a in v - a = a.trim() + v = v.split " " + v = window.util.expandAudi v StationActions.setAudience v getTime: -> @@ -150,6 +152,7 @@ module.exports = recl name = if iden then iden.name else "" audi = if @state.audi.length is 0 then @state.ludi else @state.audi + audi = window.util.clipAudi audi k = "writing" @@ -160,7 +163,7 @@ module.exports = recl className:"audi valid-#{@state.valid}" contentEditable:true onBlur:@_setAudi - }, audi.join(",")) + }, audi.join(" ")) (Member iden, "") (br {},"") (div {className:"time"}, @getTime()) diff --git a/main/pub/talk/src/js/main.coffee b/main/pub/talk/src/js/main.coffee index 37b1238230..360fa1b77d 100644 --- a/main/pub/talk/src/js/main.coffee +++ b/main/pub/talk/src/js/main.coffee @@ -8,7 +8,10 @@ $(() -> window.chat.StationPersistence = require './persistence/StationPersistence.coffee' window.util = + mainStations: ["court","floor","porch"] + mainStationPath: (user) -> "~#{user}/#{window.util.mainStation(user)}" + mainStation: (user) -> if not user then user = window.urb.user switch user.length @@ -19,6 +22,19 @@ $(() -> when 13 return "porch" + clipAudi: (audi) -> + audi = audi.join " " + for v in window.util.mainStations + regx = new RegExp "/#{v}","g" + audi = audi.replace regx,"" + audi.split " " + + expandAudi: (audi) -> + for k,v of audi + if v.indexOf("/") is -1 + audi[k] = "#{v}/#{window.util.mainStation(v.slice(1))}" + audi + create: (name) -> window.chat.StationPersistence.createStation name, (err,res) -> diff --git a/main/pub/talk/src/js/main.js b/main/pub/talk/src/js/main.js index f646b9176e..81f1b1894f 100644 --- a/main/pub/talk/src/js/main.js +++ b/main/pub/talk/src/js/main.js @@ -235,6 +235,11 @@ Message = recl({ s = this.lz(d.getSeconds()); return "~" + h + "." + m + "." + s; }, + _handleAudi: function(e) { + var audi; + audi = $(e.target).closest('.audi').text().split(" "); + return this.props._handleAudi(audi); + }, _handlePm: function(e) { var user; if (!this.props._handlePm) { @@ -248,7 +253,7 @@ Message = recl({ delivery = _.uniq(_.pluck(this.props.thought.audience, "delivery")); pendingClass = delivery.indexOf("received") !== -1 ? "received" : "pending"; name = this.props.name ? this.props.name : ""; - audi = _.keys(this.props.thought.audience); + audi = window.util.clipAudi(_.keys(this.props.thought.audience)); audi = audi.join(" "); return div({ className: "message " + pendingClass @@ -257,6 +262,7 @@ Message = recl({ className: "attr" }, [ div({ + onClick: this._handleAudi, className: "audi" }, "" + audi), div({ onClick: this._handlePm @@ -346,6 +352,9 @@ module.exports = recl({ audi = [window.util.mainStationPath(user), window.util.mainStationPath(window.urb.user)]; return StationActions.setAudience(audi); }, + _handleAudi: function(audi) { + return StationActions.setAudience(audi); + }, render: function() { var _messages, _station, messages, ref1, ref2, sources, station; station = this.state.station; @@ -370,6 +379,7 @@ module.exports = recl({ return function(_message) { _message.station = _this.state.station; _message._handlePm = _this._handlePm; + _message._handleAudi = _this._handleAudi; return Message(_message, ""); }; })(this)); @@ -688,6 +698,7 @@ module.exports = recl({ } else { audi = this.state.audi; } + audi = window.util.expandAudi(audi); MessageActions.sendMessage(audi, this.$writing.text(), audi); this.$length.text("0/69"); this.$writing.text(''); @@ -730,18 +741,20 @@ module.exports = recl({ return this.$writing.focus(); }, _validateAudiPart: function(a) { - var _a; + var _a, ship; if (a[0] !== "~") { return false; } - if (a.indexOf("/") === -1) { - return false; + if (a.indexOf("/") !== -1) { + _a = a.split("/"); + if (_a[1].length === 0) { + return false; + } + ship = _a[0]; + } else { + ship = a; } - _a = a.split("/"); - if (_a[0].length < 3) { - return false; - } - if (_a[1].length === 0) { + if (ship.length < 3) { return false; } return true; @@ -749,7 +762,7 @@ module.exports = recl({ _validateAudi: function() { var a, i, len, v, valid; v = $('#audi').text(); - v = v.split(","); + v = v.split(" "); for (i = 0, len = v.length; i < len; i++) { a = v[i]; a = a.trim(); @@ -758,16 +771,13 @@ module.exports = recl({ return valid; }, _setAudi: function() { - var a, i, len, v, valid; + var v, valid; valid = this._validateAudi(); StationActions.setValidAudience(valid); if (valid === true) { v = $('#audi').text(); - v = v.split(","); - for (i = 0, len = v.length; i < len; i++) { - a = v[i]; - a = a.trim(); - } + v = v.split(" "); + v = window.util.expandAudi(v); return StationActions.setAudience(v); } }, @@ -821,6 +831,7 @@ module.exports = recl({ ship = iden ? iden.ship : user; name = iden ? iden.name : ""; audi = this.state.audi.length === 0 ? this.state.ludi : this.state.audi; + audi = window.util.clipAudi(audi); k = "writing"; return div({ className: k @@ -833,7 +844,7 @@ module.exports = recl({ className: "audi valid-" + this.state.valid, contentEditable: true, onBlur: this._setAudi - }, audi.join(",")), Member(iden, ""), br({}, ""), div({ + }, audi.join(" ")), Member(iden, ""), br({}, ""), div({ className: "time" }, this.getTime()) ]), div({ @@ -885,6 +896,7 @@ $(function() { window.chat.MessagePersistence = require('./persistence/MessagePersistence.coffee'); window.chat.StationPersistence = require('./persistence/StationPersistence.coffee'); window.util = { + mainStations: ["court", "floor", "porch"], mainStationPath: function(user) { return "~" + user + "/" + (window.util.mainStation(user)); }, @@ -901,6 +913,27 @@ $(function() { return "porch"; } }, + clipAudi: function(audi) { + var j, len, ref, regx, v; + audi = audi.join(" "); + ref = window.util.mainStations; + for (j = 0, len = ref.length; j < len; j++) { + v = ref[j]; + regx = new RegExp("/" + v, "g"); + audi = audi.replace(regx, ""); + } + return audi.split(" "); + }, + expandAudi: function(audi) { + var k, v; + for (k in audi) { + v = audi[k]; + if (v.indexOf("/") === -1) { + audi[k] = v + "/" + (window.util.mainStation(v.slice(1))); + } + } + return audi; + }, create: function(name) { return window.chat.StationPersistence.createStation(name, function(err, res) {}); }, From 1a3b562d22360149f511a52a44f08caf2cfff2dc Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 11 Mar 2015 11:13:56 -0700 Subject: [PATCH 067/219] ++dear path->tuple parser --- arvo/zuse.hoon | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/arvo/zuse.hoon b/arvo/zuse.hoon index 79797cd513..3cd033faac 100644 --- a/arvo/zuse.hoon +++ b/arvo/zuse.hoon @@ -2058,6 +2058,30 @@ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: section 3bG, URL handling :: :: +:: .= [p=%ack q=~sarnel r=&] +:: (dear /ack/~sarnel/.y p=%tas q=%p r=%f ~) +++ dear :: parse odored path + =+ ^= odo + |* a=@tas + |= b=* + =< a(. (. b)) :: preserve face + ?+ a ,@ + %c ,@c %da ,@da %dr ,@dr %f ,@f %if ,@if %is ,@is %p ,@p + %u ,@u %uc ,@uc %ub ,@ub %ui ,@ui %ux ,@ux %uv ,@uv %uw ,@uw + %s ,@s %t ,@t %ta ,@ta %tas ,@tas + == + |* [a=path b=[@tas (pole ,@tas)]] + %. a %. b + |* b=[@tas (pole ,@tas)] + |= a=path + ?~ a ~ + =+ hed=(slaw -.b i.a) + ?~ +.b + ^- (unit (odo -.b)) + ?^(+.a ~ hed) + ^- (unit ,[(odo -.b) _(need *(..^$ +.b))]) + (both hed ((..^$ +.b) +.a)) +:: ++ deft :: parse url extension |= rax=(list ,@t) |- ^- pork @@ -2117,16 +2141,16 @@ [(cut 3 [d 1] cha) $(pad (rsh 0 6 pad))] (weld (flop (slag poc sif)) (reap poc '=')) :: -++ ofis +++ ofis :: XX broken =- |=(a=cord (rash a fel)) - =- fel=;~(sfix (boss 64 (plus siw)) (stun 0^3 tis)) + =- fel=;~(sfix (boss 64 (plus siw)) (stun 0^2 tis)) ^= siw ;~ pose dit (cook |=(a=@ (sub a (sub 'A' 10))) (shim 'A' 'Z')) (cook |=(a=@ (sub a (sub 'a' 36))) (shim 'a' 'z')) - (cold 62 (just '-')) - (cold 63 (just '~')) + (cold 62 (just '+')) + (cold 63 (just '/')) == :: ++ urle :: URL encode From 2382c8c863e219c93e5d73528955f780395ec966 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 11 Mar 2015 16:25:07 -0700 Subject: [PATCH 068/219] renamed dear to raid --- arvo/zuse.hoon | 52 +++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/arvo/zuse.hoon b/arvo/zuse.hoon index 3cd033faac..8b34f81693 100644 --- a/arvo/zuse.hoon +++ b/arvo/zuse.hoon @@ -2058,30 +2058,6 @@ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: section 3bG, URL handling :: :: -:: .= [p=%ack q=~sarnel r=&] -:: (dear /ack/~sarnel/.y p=%tas q=%p r=%f ~) -++ dear :: parse odored path - =+ ^= odo - |* a=@tas - |= b=* - =< a(. (. b)) :: preserve face - ?+ a ,@ - %c ,@c %da ,@da %dr ,@dr %f ,@f %if ,@if %is ,@is %p ,@p - %u ,@u %uc ,@uc %ub ,@ub %ui ,@ui %ux ,@ux %uv ,@uv %uw ,@uw - %s ,@s %t ,@t %ta ,@ta %tas ,@tas - == - |* [a=path b=[@tas (pole ,@tas)]] - %. a %. b - |* b=[@tas (pole ,@tas)] - |= a=path - ?~ a ~ - =+ hed=(slaw -.b i.a) - ?~ +.b - ^- (unit (odo -.b)) - ?^(+.a ~ hed) - ^- (unit ,[(odo -.b) _(need *(..^$ +.b))]) - (both hed ((..^$ +.b) +.a)) -:: ++ deft :: parse url extension |= rax=(list ,@t) |- ^- pork @@ -2153,6 +2129,34 @@ (cold 63 (just '/')) == :: +:: .= [p=%ack q=~sarnel r=&] +:: (raid /ack/~sarnel/.y p=%tas q=%p r=%f ~) +++ raid :: demand path odors + =- |* [a=path b=[@tas (pole ,@tas)]] + ?~ +.b `(odo -.b)`(slav -.b -.a) + [`(odo -.b)`(slav -.b -.a) (..$ +.a +.b)] + ^= odo + |* a=@tas + |= b=* + =< a(. (. b)) :: preserve face + ?+ a ,@ + %c ,@c %da ,@da %dr ,@dr %f ,@f %if ,@if %is ,@is %p ,@p + %u ,@u %uc ,@uc %ub ,@ub %ui ,@ui %ux ,@ux %uv ,@uv %uw ,@uw + %s ,@s %t ,@t %ta ,@ta %tas ,@tas + == +:: +++ read :: parse odored path + =< |*([a=path b=[@tas (pole ,@tas)]] ((+> b) a)) + |* b=[@tas (pole ,@tas)] + |= a=path + ?~ a ~ + =+ hed=(slaw -.b i.a) + ?~ +.b + ^- (unit (odo:raid -.b)) + ?^(+.a ~ hed) + ^- (unit ,[(odo:raid -.b) _(need *(..^$ +.b))]) + (both hed ((..^$ +.b) +.a)) +:: ++ urle :: URL encode |= tep=tape ^- tape From 8c067b4c8bdca8173e3de28d9cdd115a03fbcb00 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 11 Mar 2015 16:51:04 -0700 Subject: [PATCH 069/219] eyre /to/app poke json --- arvo/eyre.hoon | 109 ++++++++++++++++++++++++++++++++++++++----------- arvo/gall.hoon | 7 ++-- 2 files changed, 89 insertions(+), 27 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 6b1ff431e7..a0713b49a0 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -39,6 +39,12 @@ $: %f :: to %ford $% [%exec p=@p q=(unit silk)] :: [%wasp p=@p q=@uvH] :: + == == :: + $: %g :: to %gall + $% [%mess p=hapt q=ship r=cage] :: + [%nuke p=hapt q=ship] :: + [%show p=hapt q=ship r=path] :: + [%took p=hapt q=ship] :: == == == :: ++ rave :: see %clay $% [& p=mood] :: @@ -60,11 +66,21 @@ $? $: %f :: by %ford $% [%made p=@uvH q=(each cage tang)] :: [%news ~] :: + == == :: + $: %g :: by %gall + $% [%dumb ~] :: + [%mean p=ares] :: + [%nice ~] :: + [%rush p=mark q=*] :: + [%rust p=mark q=*] :: == == :: $: @tas :: by any $% [%crud p=@tas q=(list tank)] :: == == == :: -++ whir $|(~ $%([%at p=hole q=whir])) :: wire subset +++ whir $| ~ :: wire subset + $% [%at p=hole q=whir] :: + [%to p=span:ship q=term r=span:ship ~] :: + == :: -- :: |% :: models ++ bolo :: eyre state @@ -94,6 +110,8 @@ [%poll p=@uvH] [%auth perk-auth] [%away ~] + [%bugs %as ~] + [%mess p=hasp q=mark r=json] == :: ++ perk-auth :: parsed auth @@ -108,8 +126,10 @@ :: ++ pest :: result $% [%for p=whir q=beam r=term s=cred] :: %f block + [%fot p=whir q=mark r=cage] :: %f translate [%fow p=@uvH] :: %f deps [%fin $|(~ pest-fin)] :: done + [%mez p=hapt q=ship r=cage] :: %g message [%red p=purl q=@t] :: redirect [%zap p=@ud q=(list tank)] :: err == @@ -146,17 +166,21 @@ =. p.a (cass (trip p.a)) (~(add ja b) a) :: -++ tanx :: tanks to manx - |= tac=(list tank) - ^- manx +++ wush + |= [wid=@u tan=tang] + ^- tape =+ rolt=|=(a=wall `tape`?~(a ~ :(weld i.a "\0a" $(a t.a)))) - =+ mec=(rolt (turn tac |=(a=tank (rolt (wash 0^160 a))))) + (rolt (turn tan |=(a=tank (rolt (wash 0^wid a))))) +:: +++ tanx :: tanks to manx + |= tan=tang + ^- manx ;html ;head ;meta(charset "utf-8"); ;title: server error == - ;body:pre:code:"{mec}" + ;body:pre:code:"{(wush 160 tan)}" == :: ++ depo :: inject dependency @@ -208,7 +232,7 @@ xhr.send(JSON.stringify(dat)) xhr.addEventListener('load', function(ev){ if(this.status !== 200) - return err.innerHTML = ":(\n" + xhr.responseText + return err.innerHTML = ":( " + Date.now() + "\n" + xhr.responseText else if(cb) return cb(xhr.responseText,ev) }) } @@ -288,12 +312,21 @@ %crud +>.$(mow [[hen %slip %d %flog +.sih] mow]) :: + ?(%dumb %rush %rust) ~|(%gall-stub !!) + %nice ?>(?=(~ tea) nice-json) :: XX subscriptions + %mean ?>(?=(~ tea) (mean-json 500 p.sih)) %made =+ tee=((soft whir) tea) ?~ tee ~& e/ford/lost/hen +>.$ =. our (need hov) :: XX |- ^+ ..axon ?- u.tee + [%to ^] + ?: ?=(%| -.q.sih) + (mean-json 500 ~ %cast-fail p.q.sih) + ~| u.tee + =+ [her app him]=(raid +.u.tee %p %tas %p ~) + (pass-note ~ %g [%mess [her app ~] him p.q.sih]) [%at ^] ?. ?=([%& %js ^] q.sih) ~& e/at-lost/p.u.tee @@ -350,7 +383,7 @@ [[sec (rash i.hot thor:epur)] p.ryp q.ryp] == =. p.p.pul |(p.p.pul ?=(hoke r.p.pul)) - abet:~(handle rq pul q.+.kyz [p.heq maf s.heq]) + abet:~(handle rq pul [anon q.+.kyz] [p.heq maf s.heq]) :: %thud :: cancel request ~& e/gone/hen @@ -401,6 +434,14 @@ %+ add-cookies cug (make-resp-gift sas application//json (crip (pojo jon))) :: + ++ nice-json (give-json 200 ~ (joba %ok %b &)) + ++ mean-json + |= [sas=@uG are=ares] + =- (give-json sas ~ (jobe fail/s/typ mess/(jape err) ~)) + ^- [typ=term err=tape] + ?~ are [%fail "Unknown Error"] + [p.u.are (wush 160 q.u.are)] + :: ++ add-cookies |= [cug=(list ,@t) git=[%thou httr]] ?~ cug git @@ -445,7 +486,7 @@ :: ++ rq |_ $: [hat=hart pok=pork quy=quay] :: purl, parsed url - cip=clip :: client ip + [him=ship cip=clip] :: client ip [mef=meth maf=math bod=(unit octs)] :: method/headers/body == ++ done . @@ -456,15 +497,12 @@ ++ give-html (teba ^give-html) ++ give-gift (teba ^give-gift) ++ give-json (teba ^give-json) + ++ nice-json (teba ^nice-json) ++ pass-note (teba ^pass-note) ++ ford-req (teba ^ford-req) ++ back (teba ^back) :: ++ ford-kill (pass-note ~ %f [%exec our ~]) :: XX unused - ++ ford-wasp - |= [tea=whir dep=@uvH] - (pass-note tea %f [%wasp our dep]) - :: ++ beam-into-ford |= [tea=whir bem=beam ext=term ced=cred] =: s.bem [%web ~(rent co (flux:ya quy ced)) s.bem] @@ -509,15 +547,14 @@ ?: ?=([%'~~' *] q.pok) :: auth shortcut $(q.pok ['~' %as %own t.q.pok]) ?. ?=([%'~' @ *] q.pok) ~ - :- ~ + :- ~ ^- perk =* pef i.t.q.pok =+ but=t.t.q.pok :: XX =* ?+ pef ~|(pfix-lost/`path`/~/[pef] !!) %on - :- %poll ~| on/bad-path/but - ?> ?=([@ ~] but) - (slav %uv i.but) + [%poll (raid but %uv ~)] + :: %as :+ %auth %get ~| bad-ship/?~(but ~ i.but) @@ -527,9 +564,11 @@ %anon anon %own our == + :: %am ?~(but !! [%auth %xen i.but pok(q t.but)]) %at [%auth %at pok(q but)] %away [%away ~] + %debug ;;(perk [%bugs but]) %auth :- %auth |- ^- perk-auth @@ -544,7 +583,7 @@ [[%'PUT' ~] ~] =+ paz=(ot ship/(su fed:ag) code/so ~):jo ~| parsing/bod - [%try (need (paz (need (poja q:(need bod)))))] + [%try (grab-body paz)] :: [[%'DELETE' ~] ~] ~| parsing/bod @@ -552,8 +591,23 @@ ?> ?=(%o -.jon) =+ sip=(~(get by p.jon) %ship) [%del ?~(sip ~ [~ (need ((su:jo fed:ag) u.sip))])] + == == == - == == + :: + %to + =- [%mess [- +<]:dir +>.dir (grab-body (ot:jo xyro/some ~))] + ^= dir + =+ ful=(read but %p %tas %tas ~) + ?^ ful u.ful + ~| bad-mess/but + [our (raid but %tas %tas ~)] + == + :: + ++ grab-body + |* a=fist:jo ^+ (need *a) + ~| parse-fail/bod + ?> &(?=(%post mef) ?=(^ bod)) + (need %.(q.u.bod ;~(biff poja a))) :: ++ handle ^+ done @@ -565,7 +619,9 @@ |- ^+ done ?- -.p.pez %for (beam-into-ford +.p.pez) - %fow (ford-wasp ~ p.p.pez) + %fot (ford-req p.p.pez our [%cast q.p.pez %done ~ r.p.pez]) + %fow (pass-note ~ %f [%wasp our p.p.pez]) + %mez (pass-note ~ %g [%mess +.p.pez]) %zap (fail p.p.pez 0v0 q.p.pez) %red =+ fra=?~(q.p.pez "" ['#' (trip q.p.pez)]) =+ url=(weld (earn p.p.pez) `tape`fra) @@ -619,6 +675,12 @@ ?~ p.hem [%| done] [%& %fow p.hem] %away [%& %fin %html logout-page:xml] + %bugs (show-login-page) + %mess =+ cay=[%json !>(`json`r.hem)] + ?: ?=(%json q.hem) + [%& %mez [- + ~]:p.hem him cay] + =+ wir=to//(scot %p p.p.hem)/[q.p.hem]/(scot %p him) + [%& %fot wir q.hem cay] %auth =+ yac=for-client ?- &2.hem @@ -631,8 +693,8 @@ =. ..ya abet.yac =+ pez=process(pok p.hem) ?. ?=(%& -.pez) ~|(no-inject/p.hem !!) - ?- -.p.pez - ?(%fow %zap %red) pez + ?+ -.p.pez ~&(bad-inject/p.pez !!) + ?(%zap %red) pez %for pez(p.p [%at ses.yac p.p.pez]) %fin ~| %not-script @@ -658,6 +720,7 @@ %get ~| aute/+.hem ?: |(=(anon him.hem) (~(has in aut.yac) him.hem)) + =. him him.hem =+ pez=process(pok rem.hem) ?. ?=([%& %for ^] pez) pez @@ -677,8 +740,6 @@ =. ..ya abet.yac [%| (give-html 401 cug.yac login-page:xml)] :: - ++ nice-json ,_(give-json 200 ~ (joba %ok %b &)) - :: ++ load-secret ^- @ta =+ pax=/(scot %p our)/code/(scot %da now)/(scot %p our) diff --git a/arvo/gall.hoon b/arvo/gall.hoon index 3875c0ab9d..fe7fc78555 100644 --- a/arvo/gall.hoon +++ b/arvo/gall.hoon @@ -1210,8 +1210,10 @@ (goc p.q.kon /pock) :(goc p.q.kon (rsh 3 ofs p.q.kon) /pock) =+ hyp=?=(%pock (end 3 4 cog)) + =+ ^- err=tape + ?.(?=(?(%poke %pock) cog) "{} with mark {}") ?. (warm cog) - (give(qic.sat ~) %mean ~ %poke-find-fail ~) + (give(qic.sat ~) %mean ~ %poke-find-fail leaf/err ~) ?> ?=(^ huv.sat) =+ ^= sam ;: slop @@ -1219,10 +1221,9 @@ [[%atom %p] p.kon] ?.(hyp q.q.kon (slop !>(p.q.q.kon) q.q.kon)) == - =+ err=?.(?=(?(%poke %pock) cog) "{} with mark ") :: ~& [%mess-poke cog] %+ ford /s/poke - :+ %dude leaf/"poking {err}" + :+ %dude leaf/err [%call (harm cog (conf (core u.huv.sat))) (cove %$ sam)] :: %show From 5436ac187073e8d64aa8ec4f0f50c925dc5703fa Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 11 Mar 2015 16:51:23 -0700 Subject: [PATCH 070/219] Various fix --- main/app/reload/core.hook | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/app/reload/core.hook b/main/app/reload/core.hook index 4f595d3303..c12947d80a 100644 --- a/main/app/reload/core.hook +++ b/main/app/reload/core.hook @@ -25,6 +25,6 @@ ?> ?=([[@ ~] ~] zaz) `term`p.i.zaz =+ tip=(end 3 1 nam) - =+ pax=[(scot %p our.hid) %arvo (scot %da lat.hid) nam %hoon ~] - [%veer ?:(=('z' tip) %$ tip) pax (,@ .^(%cx pax))] + =+ pax=[(scot %p our.hid) %arvo (scot %da lat.hid) nam ~] + [%veer ?:(=('z' tip) %$ tip) pax (,@ .^(%cx (welp pax /hoon)))] -- From 262ecf5e7b01c96605b75ce6f80cd3a6196bd5c3 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Thu, 12 Mar 2015 09:35:06 -0700 Subject: [PATCH 071/219] Dojo with reset and reload. --- arvo/dull.hoon | 19 ++- main/app/dojo/core.hook | 280 +++++++++++++++++++-------------- main/app/helm/core.hook | 171 ++++++-------------- main/gun/helm/reload/gate.hook | 12 ++ main/gun/helm/reset/gate.hook | 12 ++ main/gun/solid/gate.hook | 40 +++++ main/sur/console/core.hook | 23 ++- 7 files changed, 322 insertions(+), 235 deletions(-) create mode 100644 main/gun/helm/reload/gate.hook create mode 100644 main/gun/helm/reset/gate.hook create mode 100644 main/gun/solid/gate.hook diff --git a/arvo/dull.hoon b/arvo/dull.hoon index 20eece3d12..b0a815b5b1 100644 --- a/arvo/dull.hoon +++ b/arvo/dull.hoon @@ -93,6 +93,9 @@ ++ flog :: sent to %dill $% [%crud p=@tas q=(list tank)] :: [%text p=tape] :: + [%veer p=@ta q=path r=@t] :: install vane + [%vega p=path] :: reboot by path + [%verb ~] :: verbose mode == :: ++ gift :: out result <-$ $% [%bbye ~] :: reset prompt @@ -101,7 +104,7 @@ [%logo ~] :: logout [%veer p=@ta q=path r=@t] :: install vane [%vega p=path] :: reboot by path - [%verb ~] :: + [%verb ~] :: verbose mode == :: ++ kiss :: in request ->$ $% [%belt p=belt] :: terminal input @@ -117,6 +120,9 @@ [%noop ~] :: no operation [%talk p=tank] :: [%text p=tape] :: + [%veer p=@ta q=path r=@t] :: install vane + [%vega p=path] :: reboot by path + [%verb ~] :: verbose mode == :: -- => :: |% :: protocol outward @@ -131,6 +137,9 @@ ++ note-dill :: note to self, odd $% [%crud p=@tas q=(list tank)] :: [%text p=tape] :: + [%veer p=@ta q=path r=@t] :: install vane + [%vega p=path] :: reboot by path + [%verb ~] :: verbose mode == :: ++ note-gall :: outbound message $% [%mess p=[ship q=path] q=ship r=mess] :: @@ -186,8 +195,16 @@ %belt (send `dill-belt`p.kyz) %crud (send `dill-belt`[%cru p.kyz q.kyz]) %blew (send %rez p.p.kyz q.p.kyz) + %veer (dump kyz) + %vega (dump kyz) + %verb (dump kyz) == :: + ++ dump :: pass down to hey + |= git=gift + ?> ?=(^ hey.all) + +>(moz [[u.hey.all %give git] moz]) + :: ++ done :: return gift |= git=gift +>(moz :_(moz [hen %give git])) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 3323e2d2b7..efbba9c805 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -20,26 +20,29 @@ old=(set term) :: used TLVs == :: ++ dojo-command :: - $% [%poke p=goal q=dojo-source] :: make and poke - [%save p=term q=dojo-source] :: save/print + $% [%flat p=path q=dojo-source] :: noun to unix atom + [%pill p=path q=dojo-source] :: noun to unix pill + [%poke p=goal q=dojo-source] :: make and poke [%show p=dojo-source] :: print + [%verb p=term q=dojo-source] :: store variable == :: ++ dojo-source :: construction node $: p=@ud :: assembly index q=dojo-build :: general build == :: ++ dojo-build :: one ford step - $& [p=dojo-build q=dojo-build] :: build cell $% [%ex p=twig] :: hoon expression - [%fi p=(list dojo-filter) q=dojo-build] :: filter pipeline - [%fo p=dojo-model] :: form + [%di p=dojo-model] :: dialog + [%dv p=path] :: gate from source + [%fi p=(list dojo-filter) q=dojo-source] :: filter pipeline [%sc p=dojo-model] :: script + [%tu p=(list dojo-source)] :: tuple [%va p=term] :: dojo variable == :: ++ dojo-filter :: pipeline filter $% [%a p=twig] :: direct gate [%b p=mark] :: simple transmute - [%c p=dojo-model] :: full filter + [%c p=dojo-source] :: full filter == :: ++ dojo-model :: data construction $: p=dojo-server :: core source @@ -53,15 +56,14 @@ $: p=(list dojo-source) :: by order q=(map term (unit dojo-source)) :: by keyword == :: - ++ dojo-problem (each dojo-source dojo-server) :: construction problem ++ dojo-project :: construction state $: mad=dojo-command :: operation num=@ud :: number of tasks - cur=@ud :: currently solving + cud=(unit dojo-source) :: now solving + pux=(unit path) :: ford working pro=(unit vase) :: prompting loop - idl=? :: not calling ford per=(unit console-edit) :: pending reverse - job=(map ,@ud dojo-problem) :: problems + job=(map ,@ud dojo-build) :: problems rez=(map ,@ud cage) :: results == :: ++ bead ,[p=(set beam) q=cage] :: computed result @@ -154,14 +156,37 @@ %+ knee *dojo-command |. ~+ ;~ pose %+ stag %poke - ;~ pfix zap - ;~(plug dp-goal ;~(pfix ace dp-source)) + ;~ pfix bar + %+ cook + |= [a=goal b=(each dojo-source (pair path dojo-config))] + ^- (pair goal dojo-source) + ?- -.b + %& [a p.b] + %| [a [0 %di [0 [%gun q.a p.p.b]] q.p.b]] + == + ;~ plug + dp-goal + ;~ pose + (stag %& ;~(pfix ace dp-source)) + (stag %| ;~(plug (plus ;~(pfix fas sym)) dp-config)) + == + == == :: - %+ stag %save + %+ stag %verb ;~ pfix tis ;~(plug sym ;~(pfix ace dp-source)) == + :: + %+ stag %flat + ;~ pfix pat + ;~(plug (most fas sym) ;~(pfix ace dp-source)) + == + :: + %+ stag %pill + ;~ pfix lus + ;~(plug (most fas sym) ;~(pfix ace dp-source)) + == :: (stag %show dp-source) == @@ -169,18 +194,12 @@ ++ dp-build :: ++dojo-build %+ knee *dojo-build |. ~+ ;~ pose - (ifix [sel ser] dp-many) - ;~(pfix col (stag %fo dp-model-gun)) - ;~(pfix bar (stag %sc dp-model-sic)) + (ifix [sel ser] (stag %tu (most ace dp-source))) + ;~(pfix col (stag %di dp-model-gun)) + ;~(pfix pam (stag %sc dp-model-sic)) ;~(pfix buc (stag %va sym)) (stag %ex dp-twig) == - ++ dp-many :: ++dojo-build - %+ cook - |= a=(list dojo-build) - ^- dojo-build - ?~(a !! ?~(t.a i.a [i.a $(a t.a)])) - (most ace dp-build) :: ++ dp-goal :: ++goal %+ cook |=(a=goal a) @@ -201,7 +220,7 @@ %+ cook |=(a=dojo-source a) %+ stag 0 ;~ pose - (ifix [kel ker] dp-many) + (ifix [kel ker] (stag %tu (most ace dp-source))) (stag %va ;~(pfix buc sym)) (stag %ex dp-twig) == @@ -209,7 +228,7 @@ ++ dp-config :: ++dojo-config %+ cook |=(a=dojo-config a) ;~ plug - (more ace dp-value) + (star ;~(pfix ace dp-value)) %+ cook ~(gas by *(map term (unit dojo-source))) %+ more @@ -228,10 +247,16 @@ |_ dojo-project :: ++ dy-abet +>(poy `+<) :: resolve ++ dy-amok +>(poy ~) :: terminate - ++ dy-ford :: silk to ford + ++ dy-ford :: send work to ford |= [pax=path kas=silk] ^+ +>+> - (he-pass(poy `+>+<(idl %|)) pax %f %exec our.hid `kas) + ?> ?=(~ pux) + (he-pass(poy `+>+<(pux `pax)) pax %f %exec our.hid `kas) + :: + ++ dy-stop :: stop work + ^+ +> + ?~ pux +> + (he-pass(poy ~) u.pux %f %exec our.hid ~) :: ++ dy-slam :: call by ford |= [pax=path gat=vase sam=vase] @@ -252,9 +277,11 @@ |= mad=dojo-command ^+ [mad +>] ?- -.mad + %flat =^(src +>.$ (dy-init-source q.mad) [[%flat p.mad src] +>.$]) + %pill =^(src +>.$ (dy-init-source q.mad) [[%pill p.mad src] +>.$]) %poke =^(src +>.$ (dy-init-source q.mad) [[%poke p.mad src] +>.$]) - %save =^(src +>.$ (dy-init-source q.mad) [[%save p.mad src] +>.$]) - %show =^(src +>.$ (dy-init-source p.mad) [[%show p.mad] +>.$]) + %show =^(src +>.$ (dy-init-source p.mad) [[%show src] +>.$]) + %verb =^(src +>.$ (dy-init-source q.mad) [[%verb p.mad src] +>.$]) == :: ++ dy-init-source-unit :: (unit dojo-source) @@ -271,20 +298,24 @@ =: p.src num q.src bul == - [src +>.$(num +(num), job (~(put by job) num [%& src]))] + [src +>.$(num +(num), job (~(put by job) num q.src))] :: ++ dy-init-build :: ++dojo-build |= bul=dojo-build ^+ [bul +>] - ?^ -.bul - =^ one +>.$ $(bul -.bul) - =^ two +>.$ $(bul +.bul) - [[one two] +>.$] ?- -.bul %ex [bul +>.$] + %di =^(mod +>.$ (dy-init-model p.bul) [[%di mod] +>.$]) + %dv [bul +>.$] %fi !! - %fo =^(mod +>.$ (dy-init-model p.bul) [[%fo mod] +>.$]) %sc !! + %tu =^ dof +>.$ + |- ^+ [p.bul +>.^$] + ?~ p.bul [~ +>.^$] + =^ dis +>.^$ (dy-init-source i.p.bul) + =^ mor +>.^$ $(p.bul t.p.bul) + [[dis mor] +>.^$] + [[%tu dof] +>.$] %va [bul +>.$] == :: @@ -298,7 +329,7 @@ ++ dy-init-server :: ++dojo-server |= srv=dojo-server =. p.srv num - [srv +>.$(num +(num), job (~(put by job) num [%| srv]))] + [srv +>.$(num +(num), job (~(put by job) num [%dv q.srv]))] :: ++ dy-init-config :: prepare config |= cig=dojo-config @@ -328,21 +359,15 @@ ^+ . =^(dam . (dy-init-command mad) +(mad dam)) :: - ++ dy-work :: console action - |= act=console-action - ?- -.act - %det (he-stir +.act) - %ret (he-done (tufa buf.say)) - == - :: ++ dy-hand :: complete step |= cag=cage ^+ +>+> - dy-step(cur +(cur), rez (~(put by rez) cur cag)) + ?> ?=(^ cud) + (dy-step(cud ~, rez (~(put by rez) p.u.cud cag)) +(p.u.cud)) :: ++ dy-meal :: vase to cage |= vax=vase - ?. &(?=(@ -.q.vax) !((sane %tas) -.q.vax)) + ?. &(?=(@ -.q.vax) ((sane %tas) -.q.vax)) ~& %dy-meal-cage (dy-rash %bel ~) (dy-hand -.q.vax (slot 3 vax)) @@ -352,47 +377,20 @@ ^+ +>+> ?> ?=(^ per) ?^ q.q.cag - ~& %dy-made-edit-good dy-abet(per ~) - ~& %dy-made-edit-bad =^ lic say (~(transmit cs say) u.per) (dy-rush(per ~) %mor [%bel ~] [%det lic] ~) :: - ++ dy-made-make :: created prompt - |= cag=cage - ^+ +>+> - ~& %dy-made-make - (dy-slam /dial q.cag !>(~)) - :: - ++ dy-made-dial :: dialog product - |= cag=cage - ^+ +>+> - ?. ?=([~ ~ *] q.q.cag) - ~& %dy-made-dial-fail - (dy-rash %bel ~) - =+ tan=((list tank) +14.q.cag) - =+ vax=(spec (slot 15 q.cag)) - ?+ -.q.vax !! - %& - ?~ +<.q.vax - ~& %dy-made-dial-abort - (dy-rash %bel ~) - (dy-meal (slot 7 vax)) - :: - %| - (dy-rush(pro `(slot 2 vax)) %pro (console-prompt +.q.vax)) - == - :: - ++ dy-done :: submit + ++ dy-done :: dialog submit |= txt=tape - ~& %dy-done ?> ?=(^ pro) - (dy-slam /dial u.pro (slop [[%atom %n] ~] !>(txt))) + (dy-slam /dial u.pro !>(txt)) :: ++ dy-over :: finish construction ^+ +> ?- -.mad %poke + ~& [%dy-over-poke p.mad] %- he-pass(poy ~) :* /poke %g @@ -402,7 +400,16 @@ (~(got by rez) p.q.mad) == :: - %save + %flat + =+ out=q.q:(~(got by rez) p.q.mad) + ?^ out + (dy-rash %tan [%leaf "not an atom"]~) + (dy-rash %sav p.mad out) + :: + %pill + (dy-rash %sag p.mad q.q:(~(got by rez) p.q.mad)) + :: + %verb dy-amok(var (~(put by var) p.mad (~(got by rez) p.q.mad))) :: %show @@ -415,15 +422,14 @@ =+ old=buf.say =^ dat say (~(receive cs say) cal) =. dat (~(inverse cs say(buf old)) dat) - ?: |(?=(^ per) !idl ?=(~ pro)) + ?: |(?=(^ per) ?=(^ pux) ?=(~ pro)) ~& %dy-edit-busy =^ lic say (~(transmit cs say) dat) (dy-rush %mor [%det lic] [%bel ~] ~) - (dy-slam(per `dat) /edit u.pro !>(buf.say)) + (dy-slam(per `dat) /edit u.pro !>((tufa buf.say))) :: - ++ dy-work :: handle input + ++ dy-type :: console action |= act=console-action - ^+ +>+> ?- -.act %det (dy-edit +.act) %ret (dy-done (tufa buf.say)) @@ -432,16 +438,16 @@ ++ dy-cage |=(num=@ud (~(got by rez) num)) :: known cage ++ dy-vase |=(num=@ud q:(dy-cage num)) :: known vase ++ dy-silk-vase |=(vax=vase [%done ~ %noun vax]) :: vase to silk - ++ dy-silk-form :: configure + ++ dy-silk-config :: configure |= [cag=cage cig=dojo-config] ^- silk :+ %ride [%cnzy %$] :+ %mute [%done ~ cag] ^- (list (pair wing silk)) :* :- [[~ 12] ~] - (dy-silk-vase !>([he-beak lat.hid])) + (dy-silk-vase !>([now=lat.hid bec=he-beak])) :: - :- [[~ 46] ~] + :- [[~ 26] ~] %- dy-silk-vase |- ^- vase ?~ p.cig !>(~) @@ -450,34 +456,69 @@ %+ turn (~(tap by q.cig)) |= [a=term b=(unit dojo-source)] ^- (pair wing silk) - :- [a [~ 47] ~] + :- [a [~ 27] ~] %- dy-silk-vase ?~(b !>([~ ~]) (dy-vase p.u.b)) == :: - ++ dy-silk-build :: build to silk - |= bul=dojo-build + ++ dy-silk-init-dial :: init and config + |= [cag=cage cig=dojo-config] ^- silk - ?^ -.bul [$(bul -.bul) $(bul +.bul)] - ?+ -.bul !! - %fo (dy-silk-form (dy-cage p.p.p.bul) q.p.bul) - %ex [%ride p.bul [%reef ~]] - == + (dy-silk-config cag cig) :: ++ dy-silk-device :: device to silk |= pax=path ^- silk - [%boil %gate [he-beak pax] ~] + [%boil %gate [he-beak (flop pax)] ~] + :: + ++ dy-made-dial :: dialog product + |= cag=cage + ^+ +>+> + ?. ?=([~ ~ *] q.q.cag) + ~& %dy-made-dial-fail + (dy-rash %bel ~) + =+ tan=((list tank) +14.q.q.cag) + =. +>+>.$ (he-rush %tan tan) + =+ vax=(spec (slot 15 q.cag)) + ?+ -.q.vax !! + %& + ?~ +.q.vax + ~& %dy-made-dial-abort + (dy-rash %bel ~) + (dy-meal (slot 7 vax)) + :: + %| + =< he-pone + %- dy-rush(pro `(slap (slot 7 vax) [%cnzy %q])) + [%pro (console-prompt +<.q.vax)] + == + :: + ++ dy-make :: build step + ^+ +> + ?> ?=(^ cud) + %- dy-ford + ^- (pair path silk) + ?+ -.q.u.cud !! + %di [/dial (dy-silk-init-dial (dy-cage p.p.p.q.u.cud) q.p.q.u.cud)] + %dv [/hand (dy-silk-device p.q.u.cud)] + %ex [/hand [%ride p.q.u.cud [%reef ~]]] + %tu :- /hand + :+ %done ~ + :- %noun + |- ^- vase + ?~ p.q.u.cud !! + =+ hed=(dy-vase p.i.p.q.u.cud) + ?~ t.p.q.u.cud hed + (slop hed $(p.q.u.cud t.p.q.u.cud)) + == :: ++ dy-step :: advance project - ^+ +> - ?: =(cur num) + |= nex=@ud + ^+ +>+> + ?> ?=(~ cud) + ?: =(nex num) dy-over - =+ pob=(~(got by job) cur) - ?- -.pob - %& (dy-ford /hand (dy-silk-build q.p.pob)) - %| (dy-ford /make (dy-silk-device q.p.pob)) - == + dy-make(cud `[nex (~(got by job) nex)]) -- :: ++ he-dope :: sole user of ++dp @@ -521,25 +562,35 @@ ++ he-peer :: subscribe to he-prom :: + ++ he-pine :: restore prompt + ^+ . + ?^ poy . + he-prom:he-pone + :: + ++ he-pone :: clear prompt + ^+ . + =^ cal say (~(transmit cs say) [%set ~]) + (he-rush %mor [%det cal] ~) + :: ++ he-prom :: send prompt %- he-rush :- %pro [& %$ (tuba (weld (scow %p our.hid) ":dojo> "))] :: - ++ he-ford :: result from ford + ++ he-made :: result from ford |= [pax=path rey=(each bead (list tank))] ^+ +> ?> ?=(^ poy) + =< he-pine ?- -.rey - %& =+ dye=~(. dy u.poy) - =. idl.dye & - ?+ pax ~&(%he-ford-path !!) - [%hand ~] (dy-hand:dye q.p.rey) - [%dial ~] (dy-made-dial:dye q.p.rey) - [%make ~] (dy-made-make:dye q.p.rey) - [%edit ~] (dy-made-edit:dye q.p.rey) + %& %. q.p.rey + =+ dye=~(. dy u.poy(pux ~)) + ?+ pax !! + [%hand ~] dy-hand:dye + [%dial ~] dy-made-dial:dye + [%edit ~] dy-made-edit:dye == - %| ~& [%he-ford-fail pax] + %| ~& [%he-made-fail pax] (he-rush(poy ~) %tan p.rey) == :: @@ -559,8 +610,7 @@ |= mad=dojo-command ^+ +> ?> ?=(~ poy) - =< dy-step - ~(dy-init dy mad [0 0 ~ %& ~ ~ ~]) + he-pine:(dy-step:~(dy-init dy mad [0 ~ ~ ~ ~ ~ ~]) 0) :: ++ he-done :: parse command |= txt=tape @@ -587,11 +637,11 @@ == == :: - ++ he-work :: apply input + ++ he-type :: apply input |= act=console-action ^+ +> ?^ poy - (~(dy-work dy u.poy) act) + he-pine:(~(dy-type dy u.poy) act) ?- -.act %det (he-stir +.act) %ret (he-done (tufa buf.say)) @@ -619,7 +669,7 @@ ++ poke-console-action |= [ost=bone her=ship act=console-action] ^- [(list move) _+>] - he-abet:(~(he-work he [ost [ost %give %nice ~]~] (~(got by hoc) ost)) act) + he-abet:(~(he-type he [ost [ost %give %nice ~]~] (~(got by hoc) ost)) act) :: ++ pour |= [ost=bone pax=path sih=sign] @@ -627,8 +677,10 @@ :: ~& [%dojo-pour pax] ?- -.sih %f - he-abet:(~(he-ford he [[ost ~] (~(got by hoc) ost)]) pax +>.sih) + he-abet:(~(he-made he [[ost ~] (~(got by hoc) ost)]) pax +>.sih) :: - %g !! + %g + ~& [%dojo-pour sih] + [~ +>.$] == -- diff --git a/main/app/helm/core.hook b/main/app/helm/core.hook index 18c002cac7..596e9709ec 100644 --- a/main/app/helm/core.hook +++ b/main/app/helm/core.hook @@ -10,21 +10,26 @@ => |% :: principal structures ++ helm-house :: all state $: %0 :: state version + hoc=(map bone helm-session) :: consoles == :: ++ helm-session :: $: say=console-share :: mud=(unit (console-dialog ,@ud)) :: == :: + ++ funk (pair ,@ ,@) :: ++ helm-wish :: - $| $? %solid :: save kernel pill - %reset :: reset kernel - %test :: fun test + $| $? %reset :: reset kernel %verb :: verbose mode == :: $% [%reload p=(list term)] :: reload vanes [%begin p=(qual ,@p ,@p ,@t gens)] :: start new ship == :: + ++ dill-flog :: sent to %dill + $% [%veer p=@ta q=path r=@t] :: install vane + [%vega p=path] :: reboot by path + [%verb ~] :: verbose mode + == :: :: :: ++ gift :: out result <-$ $% [%mean p=ares] :: error @@ -39,24 +44,13 @@ [%took p=[p=ship q=path] q=ship] :: == :: ++ note-dill :: system command - $% [%veer p=@ta q=path r=@t] :: - [%vega p=path] :: - [%verb ~] :: + $% [%flog p=dill-flog] :: == :: ++ note :: out request $-> $% [%d note-dill] :: [%g note-gall] :: == :: -- :: -=> |% :: parser - ++ parse-helm-wish - %+ cook |=(a=helm-wish a) - ;~ pose - (cold %test (jest %test)) - (cold %solid (jest %solid)) - (cold %reset (jest %reset)) - == - -- :: :: :::: :: :: :: @@ -72,73 +66,12 @@ |= git=gift %_(+> moz [[ost %give git] moz]) :: - ++ he-test - ^- (console-dialog ,@) - |= fin=(unit console-input) - ?^ fin !! - :- ~ :- ~ - :- [%leaf "a number..."]~ - :- %| - :- `console-prompt`[& %$ (tuba "number one> ")] - he-test-two - :: - ++ he-test-two - |= fin=(unit console-input) - =+ uno=?~(fin ~ (ruse u.fin dem:ag)) - ?~ uno ~ - ?~ u.uno [~ ~] - [~ ~ ~ %& ~ u.u.uno] - :: - ++ he-peer :: subscribe to - (he-rush [%pro %& %$ (tuba ":helm! ")]~) - :: - ++ he-rush :: emit changes - |= fes=(list console-effect) - ?~ fes +> - (he-give %rush %console-effect ?~(t.fes i.fes [%mor fes])) - :: - ++ he-wish-solid - ^+ . - =- %_ + - moz :_ moz - [ost %give %rush %console-effect %sag /urbit/pill pil] - == - ^= pil - =+ top=`path`/(scot %p our.hid)/arvo/(scot %da lat.hid) - =+ pax=`path`(weld top `path`[%hoon ~]) - ~& %solid-start - =+ gen=(reck pax) - ~& %solid-parsed - =+ ken=q:(~(mint ut %noun) %noun gen) - ~& %solid-compiled - :- ken - =+ all=.*(0 ken) - =+ ^= vay ^- (list ,[p=@tas q=@tas]) - :~ [%$ %zuse] - [%g %gall] - [%f %ford] - [%a %ames] - [%c %clay] - [%d %dill] - [%e %eyre] - [%t %time] - == - |- ^+ all - ?~ vay all - =+ pax=(weld top `path`[q.i.vay ~]) - =+ txt=((hard ,@) .^(%cx (weld pax `path`[%hoon ~]))) - =+ sam=[lat.hid `ovum`[[%gold ~] [%veer p.i.vay pax txt]]] - ~& [%solid-veer i.vay] - =+ gat=.*(all .*(all [0 42])) - =+ nex=+:.*([-.gat [sam +>.gat]] -.gat) - $(vay t.vay, all nex) - :: ++ he-wish-reset ^+ . =- %_(+ moz (weld zum moz)) ^= zum ^- (list move) =+ top=`path`/(scot %p our.hid)/arvo/(scot %da lat.hid) - :- [ost %pass /reset %d %vega (weld top `path`/hoon)] + :- [ost %pass /reset %d %flog %vega (weld top `path`/hoon)] %+ turn ^- (list ,[p=@tas q=@tas]) :~ [%$ %zuse] @@ -153,7 +86,35 @@ |= [p=@tas q=@tas] =+ pax=`path`(welp top /[q]) =+ txt=((hard ,@) .^(%cx (welp pax /hoon))) - [ost %pass /reset %d %veer p pax txt] + [ost %pass /reset %d %flog %veer p pax txt] + :: + ++ he-wish-reload + |= all=(list term) + %_ +>.$ + moz + %- weld + :_ moz + %+ turn all + =+ ark=(arch .^(%cy /(scot %p our.hid)/arvo/(scot %da lat.hid))) + =+ van=(~(tap by r.ark)) + |= nam=@tas + =. nam + ?. =(1 (met 3 nam)) + nam + =+ ^- zaz=(list ,[p=span ~]) + (skim van |=([a=term ~] =(nam (end 3 1 a)))) + ?> ?=([[@ ~] ~] zaz) + `term`p.i.zaz + =+ tip=(end 3 1 nam) + =+ pax=[(scot %p our.hid) %arvo (scot %da lat.hid) nam %hoon ~] + :* ost + %pass + /reload + %d + %flog + [%veer ?:(=('z' tip) %$ tip) pax (,@ .^(%cx pax))] + == + == :: ++ he-wish-begin |= mes=(qual ,@p ,@p ,@t gens) @@ -167,61 +128,33 @@ %_ . moz :_ moz - [ost %pass /verb %d %verb ~] + [ost %pass /verb %d %flog %verb ~] == :: - ++ he-proceed - |= res=(unit (unit ,@)) - ^+ +> - ?~ res - ~& %abort - +>.$(mud ~) - ?~ u.res - +>.$ - ~& [%result u.u.res] - +>.$(mud ~) - :: - ++ he-wish-test - |- ^+ + - =+ cow=he-test - =^ nib say ((~(apse cs say) cow) ~) - =^ don cow nib - (he-proceed:(he-rush(mud `cow) p.don) q.don) - :: ++ he-wish |= wus=(unit helm-wish) ^+ +> ?~ wus +> ?- u.wus %verb he-wish-verb - %test he-wish-test - %solid he-wish-solid %reset he-wish-reset [%reload *] !! :: (he-wish-reload +.u.wus) [%begin *] (he-wish-begin +.u.wus) == - :: - ++ he-work :: apply input - |= act=console-action - ^+ +> - ?~ mud - =^ wig say ((~(apex cs say) parse-helm-wish) act) - (he-wish:(he-rush p.wig) q.wig) - =^ nib say ((~(apse cs say) u.mud) `act) - =^ don u.mud nib - (he-proceed:(he-rush p.don) q.don) -- :: -++ peer - |= [ost=bone her=ship pax=path] - ^- [(list move) _+>] - ?< (~(has by hoc) ost) - ?> =(/console pax) +++ hake :: poke core + |= [ost=bone her=ship] ?> =(her our.hid) - he-abet:~(he-peer he [ost ~] *helm-session) + ~(. he [ost [ost %give %nice ~]~] (fall (~(get by hoc) ost) *helm-session)) :: -++ poke-console-action - |= [ost=bone her=ship act=console-action] - ^- [(list move) _+>] - he-abet:(~(he-work he [ost [ost %give %nice ~]~] (~(got by hoc) ost)) act) +++ poke-helm-reset + |= [ost=bone her=ship ~] + ~& %poke-helm-reset + he-abet:he-wish-reset:(hake ost her) +:: +++ poke-helm-reload + |= [ost=bone her=ship all=(list term)] + ~& %poke-helm-reload + he-abet:(he-wish-reload:(hake ost her) all) -- diff --git a/main/gun/helm/reload/gate.hook b/main/gun/helm/reload/gate.hook new file mode 100644 index 0000000000..49e1ab612f --- /dev/null +++ b/main/gun/helm/reload/gate.hook @@ -0,0 +1,12 @@ +:: +:::: /hook/gate/reload/helm/gun + :: +/? 314 +/- *console +:: +:::: + !: +|= $: [now=@da bec=beak] + [arg=(list term) ~] + == +(console-so %helm-reload arg) diff --git a/main/gun/helm/reset/gate.hook b/main/gun/helm/reset/gate.hook new file mode 100644 index 0000000000..f0180d5b71 --- /dev/null +++ b/main/gun/helm/reset/gate.hook @@ -0,0 +1,12 @@ +:: +:::: /hook/gate/reset/helm/gun + :: +/? 314 +/- *console +:: +:::: + !: +|= $: [now=@da bec=beak] + [~ ~] + == +(console-so %helm-reset ~) diff --git a/main/gun/solid/gate.hook b/main/gun/solid/gate.hook new file mode 100644 index 0000000000..e3a0488b1a --- /dev/null +++ b/main/gun/solid/gate.hook @@ -0,0 +1,40 @@ +:: +:::: /hook/gate/solid/gun + :: +/? 314 +/- *console +:: +:::: + !: +|= $: [now=@da bec=beak] + [~ ~] + == +%+ console-so %noun +=+ top=`path`/(scot %p p.bec)/arvo/(scot %da now) +=+ pax=`path`(weld top `path`[%hoon ~]) +~& %solid-start +=+ gen=(reck pax) +~& %solid-parsed +=+ ken=q:(~(mint ut %noun) %noun gen) +~& %solid-compiled +:- ken +=+ all=.*(0 ken) +=+ ^= vay ^- (list ,[p=@tas q=@tas]) + :~ [%$ %zuse] + [%g %gall] + [%f %ford] + [%a %ames] + [%c %clay] + [%d %dill] + [%e %eyre] + [%t %time] + == +|- ^+ all +?~ vay all +=+ pax=(weld top `path`[q.i.vay ~]) +=+ txt=((hard ,@) .^(%cx (weld pax `path`[%hoon ~]))) +=+ sam=[now `ovum`[[%gold ~] [%veer p.i.vay pax txt]]] +~& [%solid-veer i.vay] +=+ gat=.*(all .*(all [0 42])) +=+ nex=+:.*([-.gat [sam +>.gat]] -.gat) +$(vay t.vay, all nex) diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook index ff9a2b15bd..67d5d3eccc 100644 --- a/main/sur/console/core.hook +++ b/main/sur/console/core.hook @@ -15,7 +15,7 @@ == :: ++ console-dialog :: standard dialog |* out=$+(* *) :: output structure - $+((unit console-input) (console-result out)) :: + $+(console-input (console-result out)) :: output function :: :: ++ console-result :: standard output |* out=$+(* *) :: output structure @@ -25,6 +25,27 @@ %+ each (unit out) :: ~ is abort (pair console-prompt (console-dialog out)) :: ask and continue :: :: +++ console-so :: construct result + |* pro=* :: + [~ u=[~ u=[p=*(list tank) q=[%& p=[~ u=pro]]]]] :: +:: :: +++ console-yo :: add output tank + |* [tan=tank res=(console-result)] :: + ?~ res ~ :: + ?~ u.res [~ u=~] :: + [~ u=[~ u=[p=[i=tan t=p.u.u.res] q=q.u.u.res]]] :: +:: :: +++ console-no :: empty result + [~ u=[~ u=[p=*(list tank) q=~]]] :: +:: :: +++ console-go :: parse by rule + |* [sef=_rule fun=$+(* *)] :: + |= txt=console-input :: + =+ yid=(ruse txt sef) :: + ?~ yid ~ :: + ?~ u.yid [~ u=~] :: + (fun u.u.yid) :: +:: :: ++ console-clock ,[own=@ud his=@ud] :: vector clock ++ console-edit :: shared state change $% [%del p=@ud] :: delete one at From 82fcb09b0815bdabddb74e009713c41ac5106e83 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 12 Mar 2015 11:39:22 -0700 Subject: [PATCH 072/219] Self-closing br tags --- arvo/zuse.hoon | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/arvo/zuse.hoon b/arvo/zuse.hoon index 8b34f81693..68c0f1822a 100644 --- a/arvo/zuse.hoon +++ b/arvo/zuse.hoon @@ -630,7 +630,7 @@ :: ++ poxo :: node to tape =< |=(a=manx `tape`(apex a ~)) - |_ unq=_`?`| + |_ _[unq=`?`| cot=`?`|] :: self-close all tags ++ apex :: top level |= [mex=manx rez=tape] ^- tape @@ -644,8 +644,8 @@ %+ welp tam =- ?~(att rez [' ' (attr att rez)]) ^- rez=tape - ::?~ c.mex - :: [' ' '/' '>' rez] + ?: &(?=(~ c.mex) |(cot (clot man))) + [' ' '/' '>' rez] :- '>' (many c.mex :(weld "" rez)) :: :: @@ -679,16 +679,23 @@ == == :: - ++ name :: name to tape - |= man=mane ^- tape - ?@ man (trip man) - (weld (trip -.man) `tape`[':' (trip +.man)]) - :: ++ many :: nodelist to tape |= [lix=(list manx) rez=tape] |- ^- tape ?~ lix rez (apex i.lix $(lix t.lix)) + :: + ++ name :: name to tape + |= man=mane ^- tape + ?@ man (trip man) + (weld (trip -.man) `tape`[':' (trip +.man)]) + :: + ++ clot ~+ :: self-closing tags + %~ has in + %- sa ^- (list term) :~ + %area %base %br %col %command %embed %hr %img %input %keygen + %link %meta %param %source %track %wbr + == -- :: ++ poxa :: xml parser From c68e6232fb8dab784f5606f9b94a209e30668d53 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 12 Mar 2015 16:48:24 -0700 Subject: [PATCH 073/219] Fixed 36-byte subs --- arvo/hoon.hoon | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index 2e90c73869..471521d55a 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -3289,7 +3289,10 @@ ++ dim (ape (bass 10 ;~(plug sed:ab (star sid:ab)))) ++ dum (bass 10 (plus sid:ab)) ++ fed ;~ pose - (bass 0x1.0000.0000.0000.0000 (most doh hyf:ab)) + %+ bass 0x1.0000.0000.0000.0000 + ;~((glue doh) ;~(pose hyf:ab huf:ab) (more doh hyf:ab)) + :: + hyf:ab huf:ab hif:ab tiq:ab @@ -3377,12 +3380,13 @@ (trip (tod:po (rsh 3 1 q.p.lot))) rex == - =+ [dyz=(met 5 q.p.lot) fin=|] + =+ [dyz=(met 5 q.p.lot) fin=| dub=&] |- ^- tape ?: =(0 dyz) rex %= $ fin & + dub !dub dyz (dec dyz) q.p.lot (rsh 5 1 q.p.lot) rex @@ -3394,7 +3398,7 @@ `tape`['-' ~] (trip (tos:po (end 3 1 q.cog))) (trip (tod:po (rsh 3 1 q.cog))) - `tape`?:(fin ['-' ?:(=(1 (end 0 1 dyz)) ~ ['-' ~])] ~) + `tape`?.(fin ~ ['-' ?.(dub ~ ['-' ~])]) rex == == From bf99b79dc711693fd0633c0ffd4d7f255ec8ec28 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 12 Mar 2015 17:17:00 -0700 Subject: [PATCH 074/219] Better redirects --- arvo/eyre.hoon | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index a0713b49a0..829d18a78c 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -130,7 +130,7 @@ [%fow p=@uvH] :: %f deps [%fin $|(~ pest-fin)] :: done [%mez p=hapt q=ship r=cage] :: %g message - [%red p=purl q=@t] :: redirect + [%red %html] :: redirect [%zap p=@ud q=(list tank)] :: err == :: @@ -618,22 +618,30 @@ =+ status=200 |- ^+ done ?- -.p.pez - %for (beam-into-ford +.p.pez) - %fot (ford-req p.p.pez our [%cast q.p.pez %done ~ r.p.pez]) - %fow (pass-note ~ %f [%wasp our p.p.pez]) - %mez (pass-note ~ %g [%mess +.p.pez]) - %zap (fail p.p.pez 0v0 q.p.pez) - %red =+ fra=?~(q.p.pez "" ['#' (trip q.p.pez)]) - =+ url=(weld (earn p.p.pez) `tape`fra) - $(p.pez [%fin ~ 307 [location/(crip url)]~ ~]) - %fin ?~ +.p.pez done - ?- &2.p.pez - ~ (give-gift %thou p.p.pez) - %js (resp status text//javascript p.p.pez) - %html (give-html status ~ p.p.pez) - %json (give-json status ~ p.p.pez) - %code $(+.p.pez q.p.pez, status p.p.pez) - == == + %for (beam-into-ford +.p.pez) + %fot (ford-req p.p.pez our [%cast q.p.pez %done ~ r.p.pez]) + %fow (pass-note ~ %f [%wasp our p.p.pez]) + %mez (pass-note ~ %g [%mess +.p.pez]) + %zap (fail p.p.pez 0v0 q.p.pez) + %red + =+ url=(earn hat pok(p [~ %html]) quy) + ?+ p.pok (fail 404 0v0 leaf/"bad redirect" leaf/ leaf/url ~) + [~ %js] + $(p.pez [%fin %js (crip "document.location = '{url}'")]) + [~ %json] + $(p.pez [%fin %json (jobe ok/b/| red/(jape url) ~)]) + == + :: + %fin + ?~ +.p.pez done + ?- &2.p.pez + ~ (give-gift %thou p.p.pez) + %js (resp status text//javascript p.p.pez) + %html (give-html status ~ p.p.pez) + %json (give-json status ~ p.p.pez) + %code $(+.p.pez q.p.pez, status p.p.pez) + == + == :: ++ process ^- (each pest ,_done) @@ -734,6 +742,8 @@ == ++ show-login-page |= ses=(unit hole) ^- (each pest ,_done) + ?. ?=($|(~ [~ %html]) p.pok) + [%& %red %html] ?~ ses [%& %fin %code 401 %html login-page:xml] =+ yac=~(. ya u.ses (ses-cyst u.ses)) From edaeb1959a97290c2b96623e75adb6d0288785d4 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 12 Mar 2015 17:37:52 -0700 Subject: [PATCH 075/219] Added /~/debug/to.html page --- arvo/eyre.hoon | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 829d18a78c..b202089f4c 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -110,7 +110,7 @@ [%poll p=@uvH] [%auth perk-auth] [%away ~] - [%bugs %as ~] + [%bugs p=?(%as %to) ~] [%mess p=hasp q=mark r=json] == :: @@ -237,7 +237,7 @@ }) } - ship.innerText = urb.ship + if(window.ship) ship.innerText = urb.ship urb.foreign = /^\/~\/am/.test(window.location.pathname) urb.submit = function(){ req( @@ -254,33 +254,42 @@ }) } urb.away = function(){req("/~/auth.json?DELETE", {}, - function(){document.write("success!")})} + function(){document.write("success!")} + )} ''' -- ++ xml |% ++ login-page - ;html - ;head:title:'Log in' - ;body - ;p: Identify yourself, ~;{span#ship(contenteditable "")}? + %+ titl 'Log in' + ;= ;p: Identify yourself, ~;{span#ship(contenteditable "")}? ;style:'#ship {background: lightgray} #ship br {display: none}' ;input#pass(onchange "urb.submit()"); ;pre:code#err; ;script@"/~/at/~/auth.js"; - == == :: ++ logout-page - ;html - ;head:title:'Log out' - ;body - ;p: Goodbye ~;{span#ship}. + %+ titl 'Log out' + ;= ;p: Goodbye ~;{span#ship}. ;button#act(onclick "urb.away()"): Log out ;pre:code#err; ;script@"/~/at/~/auth.js"; - == == + :: + ++ poke-test + %+ titl 'Poke' + ;= ;button(onclick "urb.testPoke('/~/to/hi/txt.json')"): Hi anonymous + ;button(onclick "urb.testPoke('/~/as/own/~/to/hi/txt.json')"): Hi + ;pre:code#err; + ;script@"/~/at/~/auth.js"; + ;script:''' + urb.testPoke = function(url){ + req(url,{xyro:{test:true}}, function(t){err.innerText = t}) + } + ''' + == + ++ titl |=([a=cord b=marl] ;html:(head:title:"{(trip a)}" body:"*{b}")) -- -- |% :: functions @@ -675,6 +684,7 @@ =+ ext=(fall p.pok %urb) =+ bem=?-(-.hem %beam p.hem, %spur [root-beak p.hem]) [%& %for ~ bem ext ced.cyz:for-client] + :: %poll ?: ?=([~ %js] p.pok) :: XX treat non-json cases? =+ polling-url=['/' (apex:earn %| pok(u.p %json) quy)] @@ -682,13 +692,19 @@ (jass (joba %poll (jape polling-url)) poll:js) ?~ p.hem [%| done] [%& %fow p.hem] + :: %away [%& %fin %html logout-page:xml] - %bugs (show-login-page) + %bugs ?- p.hem + %as (show-login-page) + %to [%& %fin %html poke-test:xml] + == + :: %mess =+ cay=[%json !>(`json`r.hem)] ?: ?=(%json q.hem) [%& %mez [- + ~]:p.hem him cay] =+ wir=to//(scot %p p.p.hem)/[q.p.hem]/(scot %p him) [%& %fot wir q.hem cay] + :: %auth =+ yac=for-client ?- &2.hem From bf84060fde060bf3b035fcc51a74385a79994457 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 13 Mar 2015 16:44:46 -0700 Subject: [PATCH 076/219] debug/to support files --- main/app/test/core.hook | 6 +++--- main/mar/json/door.hook | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/main/app/test/core.hook b/main/app/test/core.hook index 3469b292c3..ce86491ea2 100644 --- a/main/app/test/core.hook +++ b/main/app/test/core.hook @@ -6,7 +6,7 @@ :::: /hook/core/test/app :: /? 314 :: need urbit 314 -/= front /:/%%/front:/hymn/ :: load front page +:: /= front /:/%%/front:/hymn/ :: load front page :: :::: structures :: @@ -297,7 +297,7 @@ |= [ost=bone you=ship pax=path] ^- [(list move) _+>] ~& [%test-peer hid] - ?~ pax [[ost %give %rust %hymn front]~ +>.$] + ?~ pax !! ::[[ost %give %rust %hymn front]~ +>.$] ?: ?=(%tests -.pax) [[ost %give %rust %json tests-json:et]~ +>.$] :_ +>.$ :_ ~ @@ -308,7 +308,7 @@ ++ poke-json :: browser message |= [ost=bone you=ship jon=json] ^- [(list move) _+>] - ~& [%test-poke hid] + ~& [%test-poke hid you] =+ tes=((of [%test so] ~):jo jon) ?~ tes [[ost %give %mean ~ %strange-json ~]~ +>.$] =+ tst=(~(get by tests) +.u.tes) diff --git a/main/mar/json/door.hook b/main/mar/json/door.hook index e345cd08c7..ce7ae80143 100644 --- a/main/mar/json/door.hook +++ b/main/mar/json/door.hook @@ -9,8 +9,8 @@ :: ++ grow :: convert to |% - ++ mime :: convert to %mime - [/text/json (tact (pojo jon))] + ++ mime [/text/json (taco txt)] :: convert to %mime + ++ txt (crip (pojo jon)) -- ++ grab |% :: convert from ++ noun json :: clam from %noun From 3100abc59c649e7451aa7efd15e3487cab4d24eb Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 13 Mar 2015 16:45:03 -0700 Subject: [PATCH 077/219] oryx fiddling --- arvo/eyre.hoon | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index b202089f4c..485a2917e9 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -128,13 +128,14 @@ $% [%for p=whir q=beam r=term s=cred] :: %f block [%fot p=whir q=mark r=cage] :: %f translate [%fow p=@uvH] :: %f deps - [%fin $|(~ pest-fin)] :: done + [%fin pest-fin] :: done [%mez p=hapt q=ship r=cage] :: %g message [%red %html] :: redirect [%zap p=@ud q=(list tank)] :: err == :: ++ pest-fin :: response + $| ~ $% [%code p=@ud q=pest-fin] [%json p=json] [%html p=manx] @@ -624,7 +625,6 @@ =. our ?~(oar our u.oar) :: XX =+ pez=process ?: ?=(%| -.pez) p.pez :: XX transitional - =+ status=200 |- ^+ done ?- -.p.pez %for (beam-into-ford +.p.pez) @@ -632,6 +632,7 @@ %fow (pass-note ~ %f [%wasp our p.p.pez]) %mez (pass-note ~ %g [%mess +.p.pez]) %zap (fail p.p.pez 0v0 q.p.pez) + %fin (finish +.p.pez) %red =+ url=(earn hat pok(p [~ %html]) quy) ?+ p.pok (fail 404 0v0 leaf/"bad redirect" leaf/ leaf/url ~) @@ -640,16 +641,18 @@ [~ %json] $(p.pez [%fin %json (jobe ok/b/| red/(jape url) ~)]) == - :: - %fin - ?~ +.p.pez done - ?- &2.p.pez - ~ (give-gift %thou p.p.pez) - %js (resp status text//javascript p.p.pez) - %html (give-html status ~ p.p.pez) - %json (give-json status ~ p.p.pez) - %code $(+.p.pez q.p.pez, status p.p.pez) - == + == + :: + ++ finish + =+ status=200 + |= pef=pest-fin ^+ done + ?~ pef done + ?- -.pef + ~ (give-gift %thou p.pef) + %js (resp status text//javascript p.pef) + %html (give-html status ~ p.pef) + %json (give-json status ~ p.pef) + %code $(pef q.pef, status p.pef) == :: ++ process @@ -662,7 +665,8 @@ ~| [mef maf bod] =+ bem=as-beam ?^ bem (process-parsed %beam u.bem) - ?> check-oryx + ?. check-oryx + ~|(%bad-oryx ~|([(parse-to-oryx q:(need bod)) vew.cyz:for-client] !!)) =+ hem=as-aux-request ?^ hem (process-parsed u.hem) ~|(strange-path/q.pok !!) @@ -672,7 +676,7 @@ ?. &(?=([~ %json] p.pok) ?=(%post mef) ?=(^ bod)) & =+ oxe=(parse-to-oryx q.u.bod) ?~ oxe | - & ::(~(has in vew.cyz:for-client) u.oxe) ::XX + (~(has in vew.cyz:for-client) u.oxe) :: ++ parse-to-oryx ;~(biff poja (ot oryx/so ~):jo) ++ root-beak `beak`[our %main ud/0] :: XX @@ -723,8 +727,8 @@ %fin ~| %not-script ?> ?=(%js &2.p.pez) - =^ jon ..ya stat-json:for-client :: XX state lost - pez(p.p (jass jon p.p.pez)) + =^ jon ..ya stat-json:for-client + [%| (finish +.p.pez(p (jass jon p.p.pez)))] :: XX better storage? == :: %try @@ -855,7 +859,7 @@ =+ url=(welp (earn pul(p hat)) '#' (head:earn p.pul)) %- give-gift %+ add-cookies cug - :+ %thou 307 + :+ %thou 307 [[location/(crip url)]~ ~] :: ++ stat-json From 9fc5f812c0f9cfef3a301327b33ade246fa57ac5 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 16 Mar 2015 17:32:44 -0700 Subject: [PATCH 078/219] polling stage one --- arvo/eyre.hoon | 151 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 127 insertions(+), 24 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 485a2917e9..614e9d4cf5 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -44,7 +44,11 @@ $% [%mess p=hapt q=ship r=cage] :: [%nuke p=hapt q=ship] :: [%show p=hapt q=ship r=path] :: - [%took p=hapt q=ship] :: + [%took p=hapt q=ship] :: + == == :: + $: %t :: to %temp + $% [%wait p=@da] :: + [%rest p=@da] :: == == == :: ++ rave :: see %clay $% [& p=mood] :: @@ -73,13 +77,19 @@ [%nice ~] :: [%rush p=mark q=*] :: [%rust p=mark q=*] :: + == == :: + $: %t :: by %time + $% [%wake ~] :: timer activate == == :: $: @tas :: by any $% [%crud p=@tas q=(list tank)] :: == == == :: +++ ixor ,@t :: oryx hash ++ whir $| ~ :: wire subset - $% [%at p=hole q=whir] :: - [%to p=span:ship q=term r=span:ship ~] :: + $% [%at p=hole q=whir] :: authenticated + [%of p=ixor ~] :: associated view + [%to p=span:hasp q=span:ship ~] :: associated poke + [%is p=ixor q=span:hasp r=path] :: subscription == :: -- :: |% :: models @@ -93,6 +103,7 @@ liz=(jug beam (each duct oryx)) :: clay subscriptions wup=(map hole cyst) :: secure sessions sop=(map hole ,[ship ?]) :: foreign session names + wix=(map ixor stem) :: open views == :: :: ++ cyst :: client session @@ -104,6 +115,19 @@ vew=(set oryx) :: open views XX expire == :: :: +++ stem :: client view + $: ore=oryx + ude=(unit ,[p=duct q=?]) :: stream, long-poll? + era=@da :: next wake + eve=[p=@u q=(map ,@u even)] + == +:: +++ even :: client event + $% [%mod p=@uv] + [%rush p=[hasp path] q=wain] + [%mean p=[hasp path] q=ares] + == +:: ++ perk :: parsed request $% [%spur p=spur] [%beam p=beam] @@ -111,8 +135,11 @@ [%auth perk-auth] [%away ~] [%bugs p=?(%as %to) ~] - [%mess p=hasp q=mark r=json] + [%mess p=hasp q=mark r=json] + [%subs p=ixor q=[hasp path]] + [%view p=ixor q=[~ u=@ud]] == + :: ++ perk-auth :: parsed auth $% [%get him=ship rem=pork] @@ -128,8 +155,9 @@ $% [%for p=whir q=beam r=term s=cred] :: %f block [%fot p=whir q=mark r=cage] :: %f translate [%fow p=@uvH] :: %f deps - [%fin pest-fin] :: done - [%mez p=hapt q=ship r=cage] :: %g message + [%gap p=hapt q=ship r=cage] :: %g message + [%gas p=whir q=hapt r=ship s=path] :: %g subscription + [%fin pest-fin] :: done [%red %html] :: redirect [%zap p=@ud q=(list tank)] :: err == @@ -325,18 +353,34 @@ ?(%dumb %rush %rust) ~|(%gall-stub !!) %nice ?>(?=(~ tea) nice-json) :: XX subscriptions %mean ?>(?=(~ tea) (mean-json 500 p.sih)) + %wake + =+ tee=((soft whir) tea) + ?~ tee ~& e/temp/lost/hen +>.$ + ?> ?=([%of ^] u.tee) + => ~(wake ix p.u.tee (~(got by wix) p.u.tee)) + (give-json 200 ~ %b &) + :: %made =+ tee=((soft whir) tea) ?~ tee ~& e/ford/lost/hen +>.$ =. our (need hov) :: XX |- ^+ ..axon ?- u.tee + [?(%of) *] ~|(e/ford/lost/-.u.tee !!) + [%is ^] + %+ ~(get-rush ix p.u.tee (~(got by wix) p.u.tee)) + [(pick-hasp q.u.tee) r.u.tee] + ?> ?=([%& %mime ^] q.sih) + ?> ?=([@ @] |3.q.sih) + |3.q.sih + :: [%to ^] ?: ?=(%| -.q.sih) (mean-json 500 ~ %cast-fail p.q.sih) ~| u.tee - =+ [her app him]=(raid +.u.tee %p %tas %p ~) + =+ [[her app]=(pick-hasp p.u.tee) him=(slav %p q.u.tee)] (pass-note ~ %g [%mess [her app ~] him p.q.sih]) + :: [%at ^] ?. ?=([%& %js ^] q.sih) ~& e/at-lost/p.u.tee @@ -360,8 +404,7 @@ ~| q.q.cag =+ ((hard ,[mit=mite rez=octs]) q.q.cag) :: XX (give-gift %thou 200 [content-type/(moon mit)]~ ~ rez) - == - == + == == == :: %news (give-json 205 ~ %b &) :: dependency updated @@ -416,6 +459,8 @@ == == :: + ++ pack-hasp |=(a=hasp `span`(pack /(scot %p p.a)/[q.a])) + ++ pick-hasp |=(a=span (raid (need (pick a)) [%p %tas ~])) ++ ses-authed |= ses=hole =+ sap=(~(get by sop) ses) @@ -564,6 +609,12 @@ %on ~| on/bad-path/but [%poll (raid but %uv ~)] + :: + %of + ~| of/bad-path/[but quy] + :+ %view ?>(?=([@ ~] but) i.but) + ?> ?=([[%poll @] ~] quy) :: XX eventsource + [~ (rash q.i.quy dem)] :: %as :+ %auth %get @@ -604,13 +655,13 @@ == == == :: - %to - =- [%mess [- +<]:dir +>.dir (grab-body (ot:jo xyro/some ~))] - ^= dir - =+ ful=(read but %p %tas %tas ~) - ?^ ful u.ful - ~| bad-mess/but - [our (raid but %tas %tas ~)] + %to + =- [%mess [- +<]:dir +>.dir (grab-body (ot:jo xyro/some ~))] + ^= dir + =+ ful=(read but %p %tas %tas ~) + ?^ ful u.ful + ~| bad-mess/but + [our (raid but %tas %tas ~)] == :: ++ grab-body @@ -630,7 +681,8 @@ %for (beam-into-ford +.p.pez) %fot (ford-req p.p.pez our [%cast q.p.pez %done ~ r.p.pez]) %fow (pass-note ~ %f [%wasp our p.p.pez]) - %mez (pass-note ~ %g [%mess +.p.pez]) + %gap (pass-note ~ %g [%mess +.p.pez]) + %gas (pass-note p.p.pez %g [%show +>.p.pez]) %zap (fail p.p.pez 0v0 q.p.pez) %fin (finish +.p.pez) %red @@ -665,8 +717,8 @@ ~| [mef maf bod] =+ bem=as-beam ?^ bem (process-parsed %beam u.bem) - ?. check-oryx - ~|(%bad-oryx ~|([(parse-to-oryx q:(need bod)) vew.cyz:for-client] !!)) +:: ?. check-oryx +:: ~|(%bad-oryx ~|([(parse-to-oryx q:(need bod)) vew.cyz:for-client] !!)) =+ hem=as-aux-request ?^ hem (process-parsed u.hem) ~|(strange-path/q.pok !!) @@ -705,9 +757,19 @@ :: %mess =+ cay=[%json !>(`json`r.hem)] ?: ?=(%json q.hem) - [%& %mez [- + ~]:p.hem him cay] - =+ wir=to//(scot %p p.p.hem)/[q.p.hem]/(scot %p him) + [%& %gap [- + ~]:p.hem him cay] + =+ wir=to//(pack-hasp p.hem)/(scot %p him) [%& %fot wir q.hem cay] + :: + %subs + :^ %& %gas + [%is p.hem (pack-hasp -.q.hem) +.q.hem] + [[- + ~]:-.q.hem him +.q.hem] + :: + %view + ~| lost-ixor/p.hem + =+ sem=(~(got by wix) p.hem) + [%| ((teba ~(poll ix p.hem sem)) u.q.hem)] :: %auth =+ yac=for-client @@ -817,6 +879,7 @@ :: [1 ~] == -- + :: ++ ya :: session engine =| [ses=hole cyst] =* cyz -> @@ -866,9 +929,12 @@ ^+ [*json ..ya] =+ orx=(rsh 3 1 (scot %p (shaf %orx eny))) =. vew (~(put in vew) orx) + =+ ire=(rsh 3 1 (scot %p (end 6 1 (shas %ire orx)))) + =. wix (~(put by wix) ire [orx ~ now [1 ~]]) :_ abet %- jobe :~ oryx/s/orx + ixor/s/ire ship/(jape +:) user/(jape +:) auth/a/(turn (~(tap in aut)) |=(a=@p (jape +:
))) @@ -887,9 +953,46 @@ ^- (unit $&([%lon purl] gram)) ~ -- + :: + ++ ix + =| [ire=ixor stem] + =* sem -> + |% + ++ done . + ++ abet ..ix(wix (~(put by wix) ire sem)) + ++ teba |*(a=$+(* ..ix) |*(b=* %_(done ..ix (a b)))) + ++ pass-note (teba ^pass-note) + :: + ++ poll + |= a=@u ^+ ..ix + ?: =(a p.eve) + =. +> + ?^ ude ~&(e/ix/wait/%replaced done) + wait-era(era (add ~s3 now)) :: XX ~s30 + abet(ude [~ hen &]) + ?: (gth a p.eve) ~|(seq-high/cur=p.eve !!) + =+ ven=~|(seq-low/cur=p.eve (~(got by q.eve) a)) + =. q.eve (~(del by q.eve) (dec a)) :: TODO ponder a-2 + abet:(give-even & ven) + :: + ++ get-rush + |= [a=[hasp path] b=octs] + =+ ven=`even`[%rush a [q.b]~] :: XX multiline + =. eve (get-even ven) + =< abet + ?~ ude done + (give-even(hen p.u.ude, ude ~) q.u.ude ven) + :: + ++ get-even + |= a=even ^+ eve + [+(p.eve) (~(put by q.eve) p.eve a)] + :: + ++ give-even ,_`_.`!! + ++ wait-era (pass-note of//[ire] [%t %wait era]) + ++ wake ^+(..ix abet(ude ~)) :: XX other effects? +-- -- -- --- -. == +. == =| bolo =* bol - |= [now=@da eny=@ ski=sled] :: activate @@ -925,7 +1028,7 @@ ~ :: ++ load :: clam previous state - |= old=_[%0 gub hov ged ney dop liz wup=wup sop=sop] + |= old=_[%0 gub hov ged ney dop liz wup sop **] ^+ ..^$ ..^$(+>- (bolo old)) :: From 6587a05a7e81ea343f19fb875346e81e51eae266 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 17 Mar 2015 10:56:54 -0700 Subject: [PATCH 079/219] Right before pill switch from dull to dill. --- arvo/doll.hoon | 754 +++++++++++++++++++++++++++++++++++++ arvo/dull.hoon | 2 + arvo/gall.hoon | 6 +- main/app/began/core.hook | 11 + main/app/helm/core.hook | 50 +-- main/sur/console/core.hook | 4 + 6 files changed, 805 insertions(+), 22 deletions(-) create mode 100644 arvo/doll.hoon diff --git a/arvo/doll.hoon b/arvo/doll.hoon new file mode 100644 index 0000000000..a5afa719de --- /dev/null +++ b/arvo/doll.hoon @@ -0,0 +1,754 @@ +!: +:: dill (4d), terminal handling +:: +|= pit=vase +=> |% :: interface tiles +++ gift :: out result <-$ + $% [%bbye ~] :: reset prompt + [%blit p=(list blit)] :: terminal output + [%init p=@p] :: report install + [%logo @] :: logout + [%veer p=@ta q=path r=@t] :: install vane + [%vega p=path] :: reboot by path + [%verb ~] :: + == :: +++ kiss :: in request ->$ + $% [%belt p=belt] :: terminal input + [%blew p=blew] :: terminal config + [%boot p=*] :: weird %dill boot + [%crud p=@tas q=(list tank)] :: error with trace + [%flog p=flog] :: wrapped error + [%hail ~] :: terminal refresh + [%hook ~] :: this term hung up + [%harm ~] :: all terms hung up + [%init p=ship] :: after gall ready + [%noop ~] :: no operation + [%talk p=tank] :: + [%text p=tape] :: + == :: +++ flog :: sent to %dill + $% [%crud p=@tas q=(list tank)] :: + [%text p=tape] :: + == :: +++ mess :: message to terminal + $% [%term-ctrl p=(hypo ,%hail)] :: + [%term-in p=(hypo term-in)] :: + == :: +++ move ,[p=duct q=(mold note gift)] :: local move +++ note :: out request $-> + $% $: %a :: + $% [%make p=(unit ,@t) q=@ud r=@ s=?] :: + [%sith p=@p q=@uw r=?] :: + == == :: + $: %c :: + $% [%warp p=sock q=riff] :: + == == :: + $: %d :: + $% [%crud p=@tas q=(list tank)] :: + [%text p=tape] :: + [%logo ~] :: + == == :: + $: %g :: + $% [%mess p=[p=ship q=path] q=ship r=mess] :: + [%nuke p=[p=ship q=path] q=ship] :: + [%show p=[p=ship q=path] q=ship r=path] :: + [%took p=[p=ship q=path] q=ship] :: + == == :: + $: %t :: + $% [%wait p=@da] :: + == == == :: +++ riff ,[p=desk q=(unit rave)] :: see %clay +++ sign :: in result $<- + $? + $: %c :: + $% [%writ p=riot] :: + == == :: + $: %g :: + $% [%logo p=@] :: + [%mean p=ares] :: + [%nice ~] :: + $: %rush :: + $% [%term-line q=term-line] :: + [%hymn q=manx] :: + == == :: + [%verb ~] :: + [%sage p=path q=*] :: + [%veer p=@ta q=path r=@t] :: + [%vega p=path] :: + == == :: + $: %t :: + $% [%wake ~] :: + == == + $: @tas :: by any + $% [%crud p=@tas q=(list tank)] :: + [%init p=@p] :: + [%note p=@tD q=tank] :: + == == == :: +++ term-in :: + $: pax=path :: + $= jof :: + $% [%line p=cord] :: + [%res p=span] :: + [%cmd p=char] :: + [%type p=?] :: + == == :: +++ term-line ,[p=[p=cord q=prom r=cord] q=(list cord) r=(list tark)] +++ tark ?(tank [%stem p=@da q=tank r=tank]) :: +:::::::: :: dill tiles +++ bein :: terminal control + $: $: bul=@ud :: buffer length + bus=@ud :: cursor in buffer + but=(list ,@c) :: buffer text + buy=prom :: input style + == :: + $: hiz=@ud :: history depth + hux=path :: history path + hym=(map ,@ud (list ,@c)) :: history overlay + hyt=hist :: history object + hyr=(unit (list ,@c)) :: history search + == :: + $: pol=@ud :: length of prompt + pot=tape :: prompt text + == :: + == :: +++ blew ,[p=@ud q=@ud] :: columns rows +++ belt :: raw console input + $% [%aro p=?(%d %l %r %u)] :: arrow key + [%bac ~] :: true backspace + [%ctl p=@ud] :: control-key + [%del ~] :: true delete + [%met p=@ud] :: meta-key + [%ret ~] :: return + [%txt p=(list ,@c)] :: utf32 text + == :: +++ blit :: raw console output + $% [%bel ~] :: make a noise + [%clr ~] :: clear the screen + [%hop p=@ud] :: set cursor position + [%lin p=(list ,@c)] :: set current line + [%mor ~] :: newline + [%sag p=path q=*] :: save to jamfile + [%sav p=path q=@] :: save to file + == :: +++ blot :: kill ring + $: p=@ud :: length + q=@ud :: depth + r=(list (list ,@c)) :: kills + == :: +++ blur ,[p=@ud q=(unit bein) r=blot] :: columns, prompt +++ kyev :: + $: p=(set ?(%ctrl %shift %alt %meta)) :: + q=$|(cord [%act speck]) :: + == :: +++ speck :: + $? %ctrl %shift %alt %meta %entr %esc :: + %caps %uncap %pgup %pgdn %home %end :: + %baxp %del %ins %up %down %left :: + %right :: + == :: +++ yard :: terminal state + $: p=? :: verbose + q=blur :: display state + r=(map path hist) :: history + s=[p=? q=@da] :: typing?/last typed + == :: + :: XX LEGACY 12-16-2014 +++ yord :: old terminal state + $: p=? :: verbose + q=blur :: display state + r=(map path hist) :: history + == :: +-- => +|% +++ dy + |= [hen=duct our=ship now=@da def=(unit duct) dug=(map duct yard)] + =+ ^= yar ^- yard + =+ yur=(~(get by dug) hen) + ?^ yur u.yur + ?^ def (~(got by dug) u.def) + [& [80 ~ *blot] ~ | *@da] + =| mos=(list move) + |% + ++ beep (curb [[%bel ~] ~]) :: send beep + ++ curb :: send blits + |= wab=(list blit) + ^+ +> + ?~ wab +> + +>(mos [[hen [%give %blit (flop wab)]] mos]) + :: + ++ wod :: word forward + |= bed=bein + ^- @ud + ?: =(bul.bed bus.bed) + bus.bed + ?: =(' ' (snag bus.bed but.bed)) + $(bus.bed +(bus.bed)) + |- + ^- @ud + ?: =(bul.bed bus.bed) + bus.bed + ?: =(' ' (snag bus.bed but.bed)) + bus.bed + $(bus.bed +(bus.bed)) + :: + ++ wob :: word backward + |= bed=bein + ^- @ud + ?: =(0 bus.bed) + bus.bed + ?: =(' ' (snag (dec bus.bed) but.bed)) + $(bus.bed (dec bus.bed)) + |- + ^- @ud + ?: =(0 bus.bed) + bus.bed + ?: =(' ' (snag (dec bus.bed) but.bed)) + bus.bed + $(bus.bed (dec bus.bed)) + :: + ++ edit :: change the bed + |= bed=bein + ^+ +> + =. q.q.yar [~ bed] + ?> ?=(^ q.q.yar) + %- curb + |- ^- (list blit) + ?^ hyr.u.q.q.yar + =+ ris=:(weld "(reverse-i-search)'" (tufa u.hyr.u.q.q.yar) "': ") + %= $ + pot.bed ris + pol.bed (lent ris) + hyr.u.q.q.yar ~ + == + :~ [%hop (add pol.bed bus.bed)] + :- %lin + %+ weld pot.bed + ?- buy.bed + %none but.bed + %text but.bed + %pass `(list ,@)`(runt [(lent but.bed) '*'] ~) + == + == + :: + ++ fume :: print tank, prefix + |= [pef=@tD tac=tank] + ^+ +> + =+ wol=(~(win re tac) 2 p.q.yar) + %- furl + %+ turn wol + |= a=tape ^- tape + ?> ?=([@ @ *] a) + [pef ' ' t.t.a] + :: + ++ furl :: print wall + |= wol=(list tape) + ^+ +> + =. +> + %- curb + %- flop + |- ^- (list blit) + ?~ wol ~ + [[%lin (tuba i.wol)] [%mor ~] $(wol t.wol)] + ?~ q.q.yar +> + (edit(q.q.yar ~) u.q.q.yar) + :: + ++ gore :: move in history + |= hup=@ud + ^+ +> + =+ but=(goth hup) + =+ bul=(lent but) + %- edit + ?> ?=(^ q.q.yar) + %= u.q.q.yar + hiz hup + hym %+ ~(put by hym.u.q.q.yar) + hiz.u.q.q.yar + but.u.q.q.yar + bus bul + bul bul + but but + == + :: + ++ goth :: extract history + |= hup=@ud + ?> ?=(^ q.q.yar) + =+ byt=(~(get by hym.u.q.q.yar) hup) + ?^ byt u.byt + (tuba (rip 3 (snag hup q.hyt.u.q.q.yar))) + :: + ++ kill :: add to kill ring + |= txt=(list ,@c) + ^+ +> + => ?. =(16 p.r.q.yar) . + .(p.r.q.yar 15, r.r.q.yar (scag 15 r.r.q.yar)) + %= +> + p.r.q.yar +(p.r.q.yar) + q.r.q.yar 0 + r.r.q.yar [txt r.r.q.yar] + == + :: + ++ look :: search in history + |= [hup=@ud txt=(list ,@c)] + ^+ +> + =+ ^= beg + |= [a=(list ,@c) b=(list ,@c)] ^- ? + ?~(a & ?~(b | &(=(i.a i.b) $(a t.a, b t.b)))) + =+ ^= mid + |= [a=(list ,@c) b=(list ,@c)] ^- ? + ?~(a & ?~(b | |((beg a b) $(b t.b)))) + ?> ?=(^ q.q.yar) + ?: =(hup p.hyt.u.q.q.yar) + beep + =+ but=(goth hup) + ?: (mid txt but) + (gore(hyr.u.q.q.yar [~ txt]) hup) + $(hup +(hup)) + :: + ++ leap :: accept response + |= [tea=wire sih=sign] + ^+ +> + ?- -.+.sih + %crud :: error trace + =. q.+.sih [[%leaf (trip p.+.sih)] q.+.sih] + |- ^+ +>.^$ + ?~ q.+.sih +>.^$ + (fume:$(q.+.sih t.q.+.sih) '!' `tank`i.q.+.sih) + :: + %mean ~& %dill-mean +>.$ + %nice +>.$ + %note ?.(p.yar +>.$ (fume p.+.sih q.+.sih)) :: debug message + ?(%rush %rust) :: XX reset prompt + =. mos :_(mos [hen %pass tea %g %took [our /terminal] our]) + ?> ?=(%term-line +>-.sih) + =. +>.$ + =+ lis=(scag 1.000 r.q.sih) + =- (furl (zing (turn (flop lis) -))) + |= a=tark + ^- wall + ?+ -.a (~(win re a) 0 p.q.yar) + %stem + ?: =(q.s.yar p.a) ~ + ~[(welp ~(ram re q.a) ~(ram re r.a))] + == + ?. (levy r.q.sih |=(a=tark ?=(%stem -.a))) + +>.$ :: XX separate prompt/history messages + %- edit + =| bed=bein + =+ ^= hyt ^- hist + =+ hyt=(~(get by r.yar) /) + ?~(hyt *hist u.hyt) + ?: &(?=(^ q.q.yar) =(/ hux.u.q.q.yar)) + =+ bun=(rip 5 (turf r.p.q.sih)) + %= u.q.q.yar + bul ?~ r.p.q.sih bul.u.q.q.yar (lent bun) + bus ?~ r.p.q.sih bus.u.q.q.yar (lent bun) + but ?~ r.p.q.sih but.u.q.q.yar bun + hyt [+(p.hyt) [%$ q.hyt]] + pot (trip p.p.q.sih) + pol (met 3 p.p.q.sih) + buy q.p.q.sih + == + %_ bed + bul (met 3 r.p.q.sih) + bus (met 3 r.p.q.sih) + but (rip 3 r.p.q.sih) + buy q.p.q.sih + hux / + hiz 0 + hyt [+(p.hyt) [%$ q.hyt]] + pot (trip p.p.q.sih) + pol (met 3 p.p.q.sih) + == + :: + %sage :: write a jamfile + %= +>.$ + mos :_(mos [hen [%give %blit [%sag p.+.sih q.+.sih] ~]]) + == + ?(%init %logo %veer %vega %verb) :: drop-throughs + +>(mos :_(mos [hen %give +.sih])) + %writ :: file exists + %_ +>.$ + mos + :_ mos + [hen %pass /term-show %g %show [our /terminal] our /lines] + == + :: + %wake + ?: (lte (sub now ~s15) q.s.yar) + %_ +>.$ + mos + :_ mos + [hen %pass /activity %t %wait (add q.s.yar ~s15)] + == + %_ +>.$ + p.s.yar | + mos :_(mos (poke %term-in -:!>(*term-in) / %type %|)) + == + == + :: + ++ lear :: handle request + |= kyz=kiss + ^+ +> + ?- -.kyz + %flog !! + %noop +> + %belt :: terminal input + =. +>.$ + ?. ?=(?(%bac %del %ret %txt) -.p.kyz) +>.$ + ?: p.s.yar +>.$(s.yar [& now]) + %_ +>.$ + s.yar [& now] + mos + :_ :_ mos + [hen %pass /activity %t %wait (add ?:(p.s.yar q.s.yar now) ~s15)] + (poke %term-in -:!>(*term-in) / %type %&) + == + ?~ q.q.yar + %^ furl + "Downloading files from ticketing ship, please wait until" + "a prompt shows up. This could take several minutes." + ~ + ?^ hyr.u.q.q.yar :: live search + ?+ p.kyz $(hiz.u.q.q.yar 0, hyr.u.q.q.yar ~) + [%bac *] + ?: =(~ u.hyr.u.q.q.yar) + (curb [[%bel ~] ~]) + %- edit + %= u.q.q.yar + hyr [~ (scag (dec (lent u.hyr.u.q.q.yar)) u.hyr.u.q.q.yar)] + == + :: + [%txt *] (look hiz.u.q.q.yar (weld u.hyr.u.q.q.yar p.p.kyz)) + [%ctl %g] (edit u.q.q.yar(bul 0, bus 0, but ~, hiz 0, hyr ~)) + [%ctl %r] + ?: =(p.hyt.u.q.q.yar hiz.u.q.q.yar) + beep + (look +(hiz.u.q.q.yar) u.hyr.u.q.q.yar) + == + ?- -.p.kyz + %aro :: arrow + ?- p.p.kyz + %d :: down + ?: =(0 hiz.u.q.q.yar) + beep + (gore (dec hiz.u.q.q.yar)) + :: + %l :: left + ?: =(0 bus.u.q.q.yar) + beep + (edit u.q.q.yar(bus (dec bus.u.q.q.yar))) + :: + %r :: right + ?: =(bul.u.q.q.yar bus.u.q.q.yar) + beep + (edit u.q.q.yar(bus +(bus.u.q.q.yar))) + :: + %u + =+ hup=+(hiz.u.q.q.yar) + ?: =(hup p.hyt.u.q.q.yar) + beep + (gore hup) + == + :: + %bac :: backspace + ^+ +>.$ + ?: =(0 bus.u.q.q.yar) + (curb `(list blit)`[[%bel ~] ~]) + %- edit + %= u.q.q.yar + bus (dec bus.u.q.q.yar) + bul (dec bul.u.q.q.yar) + but + %+ weld + (scag (dec bus.u.q.q.yar) but.u.q.q.yar) + (slag bus.u.q.q.yar but.u.q.q.yar) + == + :: + %ctl :: control + ?+ p.p.kyz + beep + %a (edit u.q.q.yar(bus 0)) + %b $(kyz [%belt %aro %l]) + %d ?: ?& =(0 bul.u.q.q.yar) + =(0 bus.u.q.q.yar) + == + +>.$(mos :_(mos (poke %term-in -:!>(*term-in) / %cmd %d))) + $(kyz [%belt %del ~]) + %e (edit u.q.q.yar(bus bul.u.q.q.yar)) + %f $(kyz [%belt %aro %r]) + %g +>.$(mos :_(mos (poke %term-in -:!>(*term-in) / %cmd %g))) + %k ?: =(bul.u.q.q.yar bus.u.q.q.yar) + beep + => .(+>.$ (kill (slag bus.u.q.q.yar but.u.q.q.yar))) + %- edit + ?> ?=(^ q.q.yar) + %= u.q.q.yar + bul bus.u.q.q.yar + but (scag bus.u.q.q.yar but.u.q.q.yar) + == + %t ?: (lth bul.u.q.q.yar 2) + beep + =+ ^= pos + ?: =(bul.u.q.q.yar bus.u.q.q.yar) + (sub bus.u.q.q.yar 2) + ?: =(0 bus.u.q.q.yar) + bus.u.q.q.yar + (dec bus.u.q.q.yar) + %- edit + %= u.q.q.yar + bus (add 2 pos) + but %+ weld + %+ weld + (scag pos but.u.q.q.yar) + ^- (list ,@c) :+ + (snag +(pos) but.u.q.q.yar) + (snag pos but.u.q.q.yar) + ~ + (slag (add 2 pos) but.u.q.q.yar) + == + %l +>.$(mos :_(mos [hen %give %blit [[%clr ~] ~]])) + %n $(kyz [%belt %aro %d]) + %o %_ +>.$ + mos + :_ :_ mos + [hen %pass /term-show %g %nuke [our /terminal] our] + [hen %pass /term-show %g %show [our /terminal] our /lines] + == + %p $(kyz [%belt %aro %u]) + %u ?: =(0 bus.u.q.q.yar) + beep + => .(+>.$ (kill (scag bus.u.q.q.yar but.u.q.q.yar))) + %- edit + ?> ?=(^ q.q.yar) + %= u.q.q.yar + bus 0 + bul (sub bul.u.q.q.yar bus.u.q.q.yar) + but (slag bus.u.q.q.yar but.u.q.q.yar) + == + %r (edit u.q.q.yar(hyr [~ ~])) + %w ?: =(0 bus.u.q.q.yar) + beep + =+ bow=(wob u.q.q.yar) + =+ sow=(sub bus.u.q.q.yar bow) + => .(+>.$ (kill (swag [bow sow] but.u.q.q.yar))) + %- edit + ?> ?=(^ q.q.yar) + %= u.q.q.yar + bus bow + bul (sub bul.u.q.q.yar sow) + but %+ welp + (scag bow but.u.q.q.yar) + (slag bus.u.q.q.yar but.u.q.q.yar) + == + %x +>.$(mos :_(mos (poke %term-in -:!>(*term-in) / %cmd %x))) + %y ?: =(0 p.r.q.yar) + beep + $(kyz [%belt %txt (snag q.r.q.yar r.r.q.yar)]) + == + :: + %del :: delete + ?: =(bul.u.q.q.yar bus.u.q.q.yar) + beep + %- edit + %= u.q.q.yar + bul (dec bul.u.q.q.yar) + but + %+ weld + (scag bus.u.q.q.yar but.u.q.q.yar) + (slag +(bus.u.q.q.yar) but.u.q.q.yar) + == + :: + %met :: meta + ?+ p.p.kyz + beep + %f + ?: =(bul.u.q.q.yar bus.u.q.q.yar) + beep + (edit u.q.q.yar(bus (wod u.q.q.yar))) + :: + %b + ?: =(0 bus.u.q.q.yar) + beep + (edit u.q.q.yar(bus (wob u.q.q.yar))) + :: + %y + ?: =(0 p.r.q.yar) + beep + =+ dol=(snag q.r.q.yar r.r.q.yar) + =+ leo=(lent dol) + ?. (gte bus.u.q.q.yar leo) + beep + =+ pey=(sub bus.u.q.q.yar leo) + ?. =(dol (swag [pey leo] but.u.q.q.yar)) + beep + =. q.r.q.yar ?:(=(p.r.q.yar +(q.r.q.yar)) 0 +(q.r.q.yar)) + =+ ney=(snag q.r.q.yar r.r.q.yar) + =+ lye=(lent ney) + %- edit + %= u.q.q.yar + bus (sub (add bus.u.q.q.yar lye) leo) + bul (sub (add bul.u.q.q.yar lye) leo) + but %+ weld + (scag pey but.u.q.q.yar) + %+ weld + `(list ,@c)`ney :: XX weird fuse-loop + (slag bus.u.q.q.yar but.u.q.q.yar) + == + == + :: + %ret :: return + ?: =(%none buy.u.q.q.yar) beep + =+ jab=(rap 3 (tufa but.u.q.q.yar)) + %= +>.$ + q.q.yar ~ + r.yar + ?: |(=(%$ jab) =(%pass buy.u.q.q.yar)) + r.yar + %+ ~(put by r.yar) + hux.u.q.q.yar + [p.hyt.u.q.q.yar [jab ?~(q.hyt.u.q.q.yar ~ +.q.hyt.u.q.q.yar)]] + :: + mos + :* (poke %term-ctrl -:!>(%hail) %hail) + [hen %give [%bbye ~]] + (poke %term-in -:!>(*term-in) / %line jab) + [hen %give [%blit [[%mor ~] ~]]] + mos + == + == + :: + %txt :: text keys + ?: =(%none buy.u.q.q.yar) beep + =+ let=(lent p.p.kyz) + %- edit + %= u.q.q.yar + bus (add let bus.u.q.q.yar) + bul (add let bul.u.q.q.yar) + but + ;: weld + (scag bus.u.q.q.yar but.u.q.q.yar) + p.p.kyz + (slag bus.u.q.q.yar but.u.q.q.yar) + == + == + == + :: + %blew +>.$(p.q.yar p.p.kyz) :: window size + %boot + %= +>.$ + mos + :_(mos [hen %pass ~ (note %a p.kyz)]) + == + :: + %crud :: error trace + =. q.kyz [[%leaf (trip p.kyz)] q.kyz] + |- ^+ +>.^$ + ?~ q.kyz +>.^$ + (fume:$(q.kyz t.q.kyz) '!' `tank`i.q.kyz) + :: + %hail :: refresh + +>.$ + ::+>.$(mos :_(mos (poke %term-ctrl -:!>(%hail) %hail))) + :: + %harm :: all terms hung up + =+ nug=((map duct yard) [[hen (~(get by dug) hen)] ~ ~]) + ^+ +>.$ + %= +>.$ + dug nug + ::S mos :_(mos [hen %pass ~ %b kyz]) + == + :: + %hook :: this term hung up + ~& %dill-hook-not-implemented + +>.$ + ::S +>.$(dug (~(del by dug) hen), mos :_(mos [hen %pass ~ %b kyz])) + :: + %init + =. def `(fall def +.hen) + %= +>.$ + our p.kyz + mos + :_ mos + [(need def) %pass / %c %warp [p.kyz p.kyz] %main `[%& %y [%ud 1] /]] + == + :: + %talk (furl (~(win re p.kyz) 0 p.q.yar)) :: program output + %text $(kyz [%talk %leaf p.kyz]) :: simple message + == + :: + ++ poke + |= msg=mess + ^- move + :^ hen %pass /term-mess + :^ %g %mess [our /terminal] + :- our msg + :: + ++ yerk :: complete core + ^- [p=(list move) q=ship r=(unit duct) s=(map duct yard)] + :^ (flop mos) our def + (~(put by dug) hen yar) + -- +-- +=| $: %1 :: + our=ship :: + def=(unit duct) :: + dug=(map duct yard) :: + == :: +|= [now=@da eny=@ ski=sled] :: current invocation +|% :: poke/peek pattern +++ call :: handle request + |= $: hen=duct + hic=(hypo (hobo kiss)) + == + ^- [p=(list move) q=_..^$] + => %= . :: XX temporary + q.hic + ^- kiss + ?: ?=(%soft -.q.hic) + :: ~& [%dill-call-soft (,@tas `*`-.p.q.hic)] + ((hard kiss) p.q.hic) + ?: (~(nest ut -:!>(*kiss)) | p.hic) q.hic + ~& [%dill-call-flub (,@tas `*`-.q.hic)] + ((hard kiss) q.hic) + == + ?: ?=(%flog -.q.hic) + :_ ..^$ + %+ turn (~(tap by dug) *(list ,[p=duct q=yard])) + |=([a=duct b=yard] [a %slip %d p.q.hic]) + =+ res=yerk:(lear:(dy hen our now def dug) q.hic) + [-.res ..^$(our +<.res, dug +>+.res, def +>-.res)] +:: +++ doze + |= [now=@da hen=duct] + ^- (unit ,@da) + ~ +:: +++ load :: XX LEGACY 12-16-2014 + |= $= old + $% [%0 our=ship def=(unit duct) dug=(map duct yord)] + [%1 our=ship def=(unit duct) dug=(map duct yard)] + == + ^+ ..^$ + ?- -.old + %1 %_(..^$ our our.old, def def.old, dug dug.old) + %0 %= $ + old + %= old + - %1 + dug (~(run by dug.old) |=(yor=yord [p q r | *@da]:yor)) + == + == + == +:: +++ scry + |= [fur=(unit (set monk)) ren=@tas his=ship syd=desk lot=coin tyl=path] + ^- (unit (unit (pair mark ,*))) + [~ ~ [%tank >dug<]] +:: +++ stay [%1 our def dug] +++ take :: process move + |= [tea=wire hen=duct hin=(hypo sign)] + ^- [p=(list move) q=_..^$] + =+ res=yerk:(leap:(dy hen our now def dug) tea q.hin) + [-.res ..^$(our +<.res, dug +>+.res, def +>-.res)] +-- diff --git a/arvo/dull.hoon b/arvo/dull.hoon index b0a815b5b1..cca8ed8110 100644 --- a/arvo/dull.hoon +++ b/arvo/dull.hoon @@ -158,6 +158,7 @@ == :: ++ sign-clay :: $% [%note p=@tD q=tank] :: + [%riot p=writ] :: == :: ++ sign-gall :: $% [%crud p=@tas q=(list tank)] :: @@ -193,6 +194,7 @@ ?+ -.kyz ~& [%strange-kiss -.kyz] +> %flow +> %belt (send `dill-belt`p.kyz) + %text (dump %blit [%lin (tuba p.kyz)]~) %crud (send `dill-belt`[%cru p.kyz q.kyz]) %blew (send %rez p.p.kyz q.p.kyz) %veer (dump kyz) diff --git a/arvo/gall.hoon b/arvo/gall.hoon index ec1d86f765..19a1a25290 100644 --- a/arvo/gall.hoon +++ b/arvo/gall.hoon @@ -361,7 +361,11 @@ :: ~& [%gape-took our imp hen] [~ ..^^$] =+ you=`ship`?-(-.kon %mess p.kon, %nuke p.kon, %show p.kon) - =+ mat=(~(got by pol.all) you) + =+ mut=(~(get by pol.all) you) + ?~ mut + ~& [%gape-lost you hen] + !! + =+ mat=u.mut =+ sad==+(sad=(~(get by sap.mat) our) ?^(sad u.sad [.(p 1)]:*scad)) =^ num sad =+ nym=(~(get by q.sad) hen) diff --git a/main/app/began/core.hook b/main/app/began/core.hook index 088cd98cc7..3b6394a179 100644 --- a/main/app/began/core.hook +++ b/main/app/began/core.hook @@ -44,4 +44,15 @@ %went ~ == :: +++ poke-will + |= [ost=bone you=ship wil=(unit will)] + :_ +>.$ + ?~ wil + [ust %give %mean ~ %rejected ~]~ + :~ [ust %pass / %a %cash his mac u.wil] + [ust %pass / %c %plug our.hid %main (sein our.hid) %main] + [ust %pass / %c %plug our.hid %arvo (sein our.hid) %arvo] + [ust %pass / %c %plug our.hid %try (sein our.hid) %try] + [ust %give %nice ~] + == -- diff --git a/main/app/helm/core.hook b/main/app/helm/core.hook index 596e9709ec..03a2ea9bc7 100644 --- a/main/app/helm/core.hook +++ b/main/app/helm/core.hook @@ -10,7 +10,7 @@ => |% :: principal structures ++ helm-house :: all state $: %0 :: state version - + bur=(unit (pair ship mace)) :: requesting ticket hoc=(map bone helm-session) :: consoles == :: ++ helm-session :: @@ -18,12 +18,12 @@ mud=(unit (console-dialog ,@ud)) :: == :: ++ funk (pair ,@ ,@) :: + ++ begs ,[his=@p tic=@p eny=@t ges=gens] :: begin data ++ helm-wish :: $| $? %reset :: reset kernel %verb :: verbose mode == :: $% [%reload p=(list term)] :: reload vanes - [%begin p=(qual ,@p ,@p ,@t gens)] :: start new ship == :: ++ dill-flog :: sent to %dill $% [%veer p=@ta q=path r=@t] :: install vane @@ -116,31 +116,12 @@ == == :: - ++ he-wish-begin - |= mes=(qual ,@p ,@p ,@t gens) - %_ +> - moz - :_ moz - [ost %pass /begin %g %mess [our.hid /began] our.hid %began-args !>(mes)] - == - :: ++ he-wish-verb %_ . moz :_ moz [ost %pass /verb %d %flog %verb ~] == - :: - ++ he-wish - |= wus=(unit helm-wish) - ^+ +> - ?~ wus +> - ?- u.wus - %verb he-wish-verb - %reset he-wish-reset - [%reload *] !! :: (he-wish-reload +.u.wus) - [%begin *] (he-wish-begin +.u.wus) - == -- :: ++ hake :: poke core @@ -157,4 +138,31 @@ |= [ost=bone her=ship all=(list term)] ~& %poke-helm-reload he-abet:(he-wish-reload:(hake ost her) all) +:: +++ poke-helm-begin + |= [ost=bone you=ship begs] + ~& %poke-helm-begin + ?> ?=(~ bur) + =+ buz=(shax :(mix (jam ges) eny)) + =+ loy=(bruw 2.048 buz) + :_ +>.$(bur `[his [0 sec:ex:loy]~]) + :~ :* ost %pass /ticketing %a %want [our.hid (sein his)] /q/ta + his tic ges pub:ex:loy + == + [ost %give %nice ~] + == +:: +++ poke-will + |= [ost=bone you=ship wil=(unit will)] + ~& %poke-helm-will + ?> ?=(^ bur) + :_ +>.$(bur ~) + ?~ wil + [ost %give %mean ~ %rejected ~]~ + :~ [ost %pass / %a %cash p.u.bur q.u.bur u.wil] + [ost %pass / %c %plug our.hid %main (sein our.hid) %main] + [ost %pass / %c %plug our.hid %arvo (sein our.hid) %arvo] + [ost %pass / %c %plug our.hid %try (sein our.hid) %try] + [ost %give %nice ~] + == -- diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook index 67d5d3eccc..86a9a62689 100644 --- a/main/sur/console/core.hook +++ b/main/sur/console/core.hook @@ -35,6 +35,10 @@ ?~ u.res [~ u=~] :: [~ u=[~ u=[p=[i=tan t=p.u.u.res] q=q.u.u.res]]] :: :: :: +++ console-lo :: construct prompt + |* [pom=console-prompt mor=(console-dialog)] :: + [~ u=[~ u=[p=*(list tank) q=[%| p=pom q=mor]]]] :: +:: :: ++ console-no :: empty result [~ u=[~ u=[p=*(list tank) q=~]]] :: :: :: From 8bc2fd90def5bcde0dccf7f0ae9aee29c7c5c330 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 17 Mar 2015 13:53:38 -0700 Subject: [PATCH 080/219] Adjust dill for forward compatibility. --- arvo/dill.hoon | 4 +++ arvo/doll.hoon | 4 +++ arvo/dull.hoon | 84 ++++++++++++++++++++++++++++++++++++-------------- 3 files changed, 69 insertions(+), 23 deletions(-) diff --git a/arvo/dill.hoon b/arvo/dill.hoon index a5afa719de..b16fef4b7d 100644 --- a/arvo/dill.hoon +++ b/arvo/dill.hoon @@ -18,6 +18,7 @@ [%boot p=*] :: weird %dill boot [%crud p=@tas q=(list tank)] :: error with trace [%flog p=flog] :: wrapped error + [%flow p=*] :: forward compat [%hail ~] :: terminal refresh [%hook ~] :: this term hung up [%harm ~] :: all terms hung up @@ -645,6 +646,9 @@ |- ^+ +>.^$ ?~ q.kyz +>.^$ (fume:$(q.kyz t.q.kyz) '!' `tank`i.q.kyz) + :: + %flow + +>.$ :: %hail :: refresh +>.$ diff --git a/arvo/doll.hoon b/arvo/doll.hoon index a5afa719de..b16fef4b7d 100644 --- a/arvo/doll.hoon +++ b/arvo/doll.hoon @@ -18,6 +18,7 @@ [%boot p=*] :: weird %dill boot [%crud p=@tas q=(list tank)] :: error with trace [%flog p=flog] :: wrapped error + [%flow p=*] :: forward compat [%hail ~] :: terminal refresh [%hook ~] :: this term hung up [%harm ~] :: all terms hung up @@ -645,6 +646,9 @@ |- ^+ +>.^$ ?~ q.kyz +>.^$ (fume:$(q.kyz t.q.kyz) '!' `tank`i.q.kyz) + :: + %flow + +>.$ :: %hail :: refresh +>.$ diff --git a/arvo/dull.hoon b/arvo/dull.hoon index cca8ed8110..925a0498e6 100644 --- a/arvo/dull.hoon +++ b/arvo/dull.hoon @@ -3,20 +3,6 @@ :: |= pit=vase => |% :: interface tiles -++ axle :: all dill state - $: %2 :: - ore=(unit ship) :: identity once set - hey=(unit duct) :: default duct - dug=(map duct axon) :: conversations - == :: -++ axon :: dill per duct - $: ram=term :: console program - wid=_80 :: terminal width - pos=@ud :: cursor position - see=(list ,@c) :: current line - == :: --- :: -=> |% :: console protocol ++ console-action :: console to app $% [%det console-change] :: edit prompt line [%inn ~] :: enter session @@ -69,6 +55,21 @@ [%sav p=path q=@] :: save to file == :: ++ gill ,@tas :: general contact +-- :: +=> |% :: console protocol +++ axle :: all dill state + $: %2 :: + ore=(unit ship) :: identity once set + hey=(unit duct) :: default duct + dug=(map duct axon) :: conversations + == :: +++ axon :: dill per duct + $: ram=term :: console program + tem=(unit (list dill-belt)) :: pending, reverse + wid=_80 :: terminal width + pos=@ud :: cursor position + see=(list ,@c) :: current line + == :: -- => :: |% :: protocol below ++ blew ,[p=@ud q=@ud] :: columns rows @@ -134,6 +135,9 @@ $% [%make p=(unit ,@t) q=@ud r=@ s=?] :: [%sith p=@p q=@uw r=?] :: == :: +++ note-clay :: wait for clay, hack + $% [%warp p=sock q=riff] :: + == :: ++ note-dill :: note to self, odd $% [%crud p=@tas q=(list tank)] :: [%text p=tape] :: @@ -149,16 +153,18 @@ == :: ++ note :: $% [%a note-ames] :: out request $-> + [%c note-clay] [%d note-dill] :: [%g note-gall] :: == :: ++ riff ,[p=desk q=(unit rave)] :: see %clay ++ sign-ames :: $% [%nice ~] :: + [%init p=ship] :: == :: ++ sign-clay :: $% [%note p=@tD q=tank] :: - [%riot p=writ] :: + [%writ p=riot] :: == :: ++ sign-gall :: $% [%crud p=@tas q=(list tank)] :: @@ -228,15 +234,31 @@ (done %blit [bit ~]) :: ++ init :: initialize + ~& [%dill-init our] + =+ myt=(flop (need tem)) + |- ^+ +> + ?~ myt +>(tem ~) + $(myt t.myt, +> (send i.myt)) + :: + ++ into :: preinitialize |= gyl=(list gill) - ^+ +> - =. moz :_(moz [hen %pass ~ %g %show [our [ram ~]] our ~]) - |- ^+ +>.^$ - ?~ gyl +>.^$ - $(gyl t.gyl, +>.^$ (send %yow i.gyl)) + ~& [%dill-into our] + %_ +> + tem `(turn gyl |=(a=gill [%yow a])) + moz + :_ moz + :* hen + %pass + / + %c + [%warp [our our] %main `[%& %y [%ud 1] /]] + == + == :: ++ send :: send action |= bet=dill-belt + ?^ tem + +>(tem `[bet u.tem]) %_ +> moz :_ moz @@ -250,9 +272,15 @@ [%a %nice *] :: ~& [%take-nice-ames sih] +> + :: + [%a %init *] + !! :: handled outside :: [%c %note *] (from %out (tuba ~(ram re q.+.sih))) + :: + [%c %writ *] + init :: [%g %crud *] (send %cru p.+.sih q.+.sih) @@ -282,7 +310,14 @@ ?. ?=(%flow -.kyz) ~ %- some %. q.kyz - ~(init as [~ hen u.ore.all] [p.kyz 80 0 (tuba "<{(trip p.kyz)}>")]) + %~ into as + :- [~ hen u.ore.all] + :* p.kyz + [~ ~] + 80 + 0 + (tuba "<{(trip p.kyz)}>") + == -- |% :: poke/peek pattern ++ call :: handle request @@ -306,6 +341,7 @@ :_(..^$ ?~(hey.all ~ [u.hey.all %slip %d p.q.hic]~)) ?: ?=(%init -.q.hic) [~ ..^$(ore.all `p.q.hic)] + ~& [%dill-call q.hic] =. hey.all ?^(hey.all hey.all `hen) =+ nus=(ax hen q.hic) ?~ nus @@ -320,8 +356,8 @@ ~ :: ++ load :: totally disabled - |= old=* - ..^$(ore.all `~zod) + |= old=axle + ..^$(all old) :: ++ scry |= [fur=(unit (set monk)) ren=@tas his=ship syd=desk lot=coin tyl=path] @@ -334,6 +370,8 @@ |= [tea=wire hen=duct hin=(hypo sign)] ^- [p=(list move) q=_..^$] ?: =(~ ore.all) + ?: ?=([%a %init *] q.hin) + [~ ..^$(ore.all `p.+.q.hin)] ~& [%take-back q.hin] [~ ..^$] ?. (~(has by dug.all) hen) From 497d869368cfa3af45842d78b21b836af7f5c2ff Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 17 Mar 2015 13:55:40 -0700 Subject: [PATCH 081/219] Consolidated depend requests --- arvo/eyre.hoon | 144 ++++++++++++++++++++++++++++++------------------- 1 file changed, 88 insertions(+), 56 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 614e9d4cf5..e968e73076 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -88,6 +88,7 @@ ++ whir $| ~ :: wire subset $% [%at p=hole q=whir] :: authenticated [%of p=ixor ~] :: associated view + [%on p=span:,@uvH ~] :: dependency [%to p=span:hasp q=span:ship ~] :: associated poke [%is p=ixor q=span:hasp r=path] :: subscription == :: @@ -100,7 +101,7 @@ ged=duct :: client interface ney=@uvI :: rolling entropy dop=(map host ship) :: host aliasing - liz=(jug beam (each duct oryx)) :: clay subscriptions + liz=(jug ,@uvH (each duct ixor)) :: ford depsets wup=(map hole cyst) :: secure sessions sop=(map hole ,[ship ?]) :: foreign session names wix=(map ixor stem) :: open views @@ -123,7 +124,7 @@ == :: ++ even :: client event - $% [%mod p=@uv] + $% [%news p=@uv] [%rush p=[hasp path] q=wain] [%mean p=[hasp path] q=ares] == @@ -137,6 +138,7 @@ [%bugs p=?(%as %to) ~] [%mess p=hasp q=mark r=json] [%subs p=ixor q=[hasp path]] + [%deps p=ixor q=@uvH r=?(%del %put)] [%view p=ixor q=[~ u=@ud]] == @@ -154,7 +156,6 @@ ++ pest :: result $% [%for p=whir q=beam r=term s=cred] :: %f block [%fot p=whir q=mark r=cage] :: %f translate - [%fow p=@uvH] :: %f deps [%gap p=hapt q=ship r=cage] :: %g message [%gas p=whir q=hapt r=ship s=path] :: %g subscription [%fin pest-fin] :: done @@ -343,7 +344,7 @@ :: ++ anon `@p`(add our ^~((bex 64))) :: pseudo-sub ++ axon :: accept response - |= [tea=wire typ=type sih=sign] + |= [tee=whir typ=type sih=sign] ^+ +> =. our ?~(hov our u.hov) :: XX ?- -.+.sih @@ -351,25 +352,35 @@ +>.$(mow [[hen %slip %d %flog +.sih] mow]) :: ?(%dumb %rush %rust) ~|(%gall-stub !!) - %nice ?>(?=(~ tea) nice-json) :: XX subscriptions - %mean ?>(?=(~ tea) (mean-json 500 p.sih)) - %wake - =+ tee=((soft whir) tea) - ?~ tee ~& e/temp/lost/hen +>.$ - ?> ?=([%of ^] u.tee) - => ~(wake ix p.u.tee (~(got by wix) p.u.tee)) + %nice ?>(?=(~ tee) (nice-json)) :: XX subscriptions + %mean ?>(?=(~ tee) (mean-json 500 p.sih)) + %wake + ?> ?=([%of ^] tee) + => ~(wake ix p.tee (~(got by wix) p.tee)) (give-json 200 ~ %b &) + :: + %news :: dependency updated + ?. ?=([%on ^] tee) + ~&(e/lost/[tee hen] +>.$) + =+ dep=(slav %uv p.tee) + %+ roll (~(tap in (~(get ju liz) dep))) + =< .(con ..axon(liz (~(del by liz) dep))) + |= [sus=(each duct ixor) con=_..axon] + ~& sus + ?- -.sus + %& (give-json(hen p.sus) 205 ~ %b &) + %| %- ~(get-even ix p.sus (~(got by wix) p.sus)) + [%news dep] + == :: %made - =+ tee=((soft whir) tea) - ?~ tee ~& e/ford/lost/hen +>.$ =. our (need hov) :: XX |- ^+ ..axon - ?- u.tee - [?(%of) *] ~|(e/ford/lost/-.u.tee !!) + ?- tee + [?(%of %on) *] ~|(e/ford/lost/-.tee !!) [%is ^] - %+ ~(get-rush ix p.u.tee (~(got by wix) p.u.tee)) - [(pick-hasp q.u.tee) r.u.tee] + %+ ~(get-rush ix p.tee (~(got by wix) p.tee)) + [(pick-hasp q.tee) r.tee] ?> ?=([%& %mime ^] q.sih) ?> ?=([@ @] |3.q.sih) |3.q.sih @@ -377,19 +388,19 @@ [%to ^] ?: ?=(%| -.q.sih) (mean-json 500 ~ %cast-fail p.q.sih) - ~| u.tee - =+ [[her app]=(pick-hasp p.u.tee) him=(slav %p q.u.tee)] + ~| tee + =+ [[her app]=(pick-hasp p.tee) him=(slav %p q.tee)] (pass-note ~ %g [%mess [her app ~] him p.q.sih]) :: [%at ^] ?. ?=([%& %js ^] q.sih) - ~& e/at-lost/p.u.tee - $(u.tee q.u.tee) + ~& e/at-lost/p.tee + $(tee q.tee) =* cag p.q.sih ?> ?=(@ q.q.cag) - =+ cyz=(~(got by wup) p.u.tee) - =^ jon ..ya ~(stat-json ya p.u.tee cyz) - $(u.tee q.u.tee, q.q.p.q.sih (jass jon q.q.cag)) + =+ cyz=(~(got by wup) p.tee) + =^ jon ..ya ~(stat-json ya p.tee cyz) + $(tee q.tee, q.q.p.q.sih (jass jon q.q.cag)) ~ :: ~& e/ford/hen ?- -.q.sih @@ -404,11 +415,8 @@ ~| q.q.cag =+ ((hard ,[mit=mite rez=octs]) q.q.cag) :: XX (give-gift %thou 200 [content-type/(moon mit)]~ ~ rez) - == == - == - :: - %news (give-json 205 ~ %b &) :: dependency updated - == + == == + == == :: ++ apex :: accept request |= kyz=kiss @@ -489,7 +497,7 @@ %+ add-cookies cug (make-resp-gift sas application//json (crip (pojo jon))) :: - ++ nice-json (give-json 200 ~ (joba %ok %b &)) + ++ nice-json |=(* (give-json 200 ~ (joba %ok %b &))) ++ mean-json |= [sas=@uG are=ares] =- (give-json sas ~ (jobe fail/s/typ mess/(jape err) ~)) @@ -605,13 +613,10 @@ :- ~ ^- perk =* pef i.t.q.pok =+ but=t.t.q.pok :: XX =* + ~| [pef %pad-path but quy] ?+ pef ~|(pfix-lost/`path`/~/[pef] !!) - %on - ~| on/bad-path/but - [%poll (raid but %uv ~)] - :: + %on [%poll (raid but %uv ~)] %of - ~| of/bad-path/[but quy] :+ %view ?>(?=([@ ~] but) i.but) ?> ?=([[%poll @] ~] quy) :: XX eventsource [~ (rash q.i.quy dem)] @@ -662,6 +667,14 @@ ?^ ful u.ful ~| bad-mess/but [our (raid but %tas %tas ~)] + :: + %in + ?> ?=([%post $|(~ [~ %json])] [mef p.pok]) + ?> ?=([@ @ ~] but) + :^ %deps + i.but + (slav %uv i.t.but) + ?+(quy !! [[%'DELETE' ~] ~] %del, [[%'PUT' ~] ~] %put) == :: ++ grab-body @@ -680,7 +693,6 @@ ?- -.p.pez %for (beam-into-ford +.p.pez) %fot (ford-req p.p.pez our [%cast q.p.pez %done ~ r.p.pez]) - %fow (pass-note ~ %f [%wasp our p.p.pez]) %gap (pass-note ~ %g [%mess +.p.pez]) %gas (pass-note p.p.pez %g [%show +>.p.pez]) %zap (fail p.p.pez 0v0 q.p.pez) @@ -732,34 +744,49 @@ :: ++ parse-to-oryx ;~(biff poja (ot oryx/so ~):jo) ++ root-beak `beak`[our %main ud/0] :: XX + ++ add-depend + |= [a=@uvH b=(each duct ixor)] ^+ done + ?~ a done + =+ had=(~(has by liz) a) + =. liz (~(put ju liz) a b) + ?: had done + (pass-note on//(scot %uv a) %f [%wasp our a]) + :: ++ process-parsed |= hem=perk ^- (each pest ,_done) ?- -.hem + %away [%& %fin %html logout-page:xml] ?(%spur %beam) =+ ext=(fall p.pok %urb) =+ bem=?-(-.hem %beam p.hem, %spur [root-beak p.hem]) [%& %for ~ bem ext ced.cyz:for-client] :: + %deps + =< [%| (nice-json)] + ?- r.hem + %del done(liz (~(del ju liz) q.hem %| p.hem)) + %put (add-depend q.hem %| p.hem) + == %poll - ?: ?=([~ %js] p.pok) :: XX treat non-json cases? - =+ polling-url=['/' (apex:earn %| pok(u.p %json) quy)] - :^ %& %fin %js - (jass (joba %poll (jape polling-url)) poll:js) - ?~ p.hem [%| done] - [%& %fow p.hem] + ?. ?=([~ %js] p.pok) :: XX treat non-json cases? + [%| (add-depend p.hem %& hen)] + =+ polling-url=['/' (apex:earn %| pok(u.p %json) quy)] + :^ %& %fin %js + (jass (joba %poll (jape polling-url)) poll:js) :: - %away [%& %fin %html logout-page:xml] - %bugs ?- p.hem - %as (show-login-page) - %to [%& %fin %html poke-test:xml] - == + %bugs + ?- p.hem + %as (show-login-page) + %to [%& %fin %html poke-test:xml] + == :: - %mess =+ cay=[%json !>(`json`r.hem)] - ?: ?=(%json q.hem) - [%& %gap [- + ~]:p.hem him cay] - =+ wir=to//(pack-hasp p.hem)/(scot %p him) - [%& %fot wir q.hem cay] + %mess + =+ cay=[%json !>(`json`r.hem)] + ?: ?=(%json q.hem) + [%& %gap [- + ~]:p.hem him cay] + =+ wir=to//(pack-hasp p.hem)/(scot %p him) + [%& %fot wir q.hem cay] :: %subs :^ %& %gas @@ -977,13 +1004,16 @@ :: ++ get-rush |= [a=[hasp path] b=octs] - =+ ven=`even`[%rush a [q.b]~] :: XX multiline - =. eve (get-even ven) + (get-even [%rush a [q.b]~]) :: XX multiline + :: + ++ get-even + |= ven=even ^+ ..ix + =. eve (add-even ven) =< abet ?~ ude done (give-even(hen p.u.ude, ude ~) q.u.ude ven) :: - ++ get-even + ++ add-even |= a=even ^+ eve [+(p.eve) (~(put by q.eve) p.eve a)] :: @@ -1051,9 +1081,11 @@ =. ney (shax :(mix (shax now) +(eny) ney)) :: XX!! shd not need ^- [p=(list move) q=_..^$] =. gub ?.(=(0 gub) gub (cat 3 (rsh 3 1 (scot %p (end 6 1 eny))) '-')) + =+ tee=((soft whir) tea) + ?~ tee ~& [%e %lost -.q.hin hen] [~ ..^$] =^ mos bol =< abet - %^ axon:~(adit ye [hen [now eny our sky] ~] bol) tea + %^ axon:~(adit ye [hen [now eny our sky] ~] bol) u.tee (~(peek ut p.hin) %free 3) q.hin [mos ..^$] From c0d2e33c1c96b21aa4ad614b89cc9fa5d2378714 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 17 Mar 2015 14:21:21 -0700 Subject: [PATCH 082/219] Extention option --- arvo/zuse.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arvo/zuse.hoon b/arvo/zuse.hoon index 68c0f1822a..a5d0c39a67 100644 --- a/arvo/zuse.hoon +++ b/arvo/zuse.hoon @@ -2079,7 +2079,7 @@ [~ [i.rax ~]] =+ `[ext=tape [@ @] fyl=tape]`u.q.raf :- ?:(=(~ ext) ~ [~ (crip (flop ext))]) - [(crip (flop fyl)) ~] + ?:(=(~ fyl) ~ [(crip (flop fyl)) ~]) :: ++ fuel :: parse fcgi |= [bem=beam but=path] From baf61981a0db100ca274029d605fbc6419864c1a Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 17 Mar 2015 14:38:13 -0700 Subject: [PATCH 083/219] Got to give-even --- arvo/eyre.hoon | 76 ++++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index e968e73076..17bd89e655 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -137,8 +137,8 @@ [%away ~] [%bugs p=?(%as %to) ~] [%mess p=hasp q=mark r=json] - [%subs p=ixor q=[hasp path]] - [%deps p=ixor q=@uvH r=?(%del %put)] + [%subs p=hasp q=path] + [%deps p=@uvH q=?(%del %put)] [%view p=ixor q=[~ u=@ud]] == @@ -314,8 +314,9 @@ ;pre:code#err; ;script@"/~/at/~/auth.js"; ;script:''' + show = function(t){err.innerText = ":) " + Date.now() + "\n" + t} urb.testPoke = function(url){ - req(url,{xyro:{test:true}}, function(t){err.innerText = t}) + req(url,{xyro:{test:true}}, show) } ''' == @@ -613,7 +614,7 @@ :- ~ ^- perk =* pef i.t.q.pok =+ but=t.t.q.pok :: XX =* - ~| [pef %pad-path but quy] + ~| [pef %bad-path but quy] ?+ pef ~|(pfix-lost/`path`/~/[pef] !!) %on [%poll (raid but %uv ~)] %of @@ -635,6 +636,21 @@ %at [%auth %at pok(q but)] %away [%away ~] %debug ;;(perk [%bugs but]) + %to + =- [%mess [- +<]:dir +>.dir (grab-body (ot:jo xyro/some ~))] + ^= dir + =+ ful=(read but %p %tas %tas ~) + ?^ ful u.ful + ~| bad-mess/but + [our (raid but %tas %tas ~)] + :: + %in + ~| expect/[%post '.json' /'@uv' '?PUT/DELETE'] + ?> ?=([%post $|(~ [~ %json])] [mef p.pok]) + :+ %deps + (raid but %uv ~) + ?+(quy !! [[%'DELETE' ~] ~] %del, [[%'PUT' ~] ~] %put) + :: %auth :- %auth |- ^- perk-auth @@ -657,31 +673,15 @@ ?> ?=(%o -.jon) =+ sip=(~(get by p.jon) %ship) [%del ?~(sip ~ [~ (need ((su:jo fed:ag) u.sip))])] - == == == - :: - %to - =- [%mess [- +<]:dir +>.dir (grab-body (ot:jo xyro/some ~))] - ^= dir - =+ ful=(read but %p %tas %tas ~) - ?^ ful u.ful - ~| bad-mess/but - [our (raid but %tas %tas ~)] - :: - %in - ?> ?=([%post $|(~ [~ %json])] [mef p.pok]) - ?> ?=([@ @ ~] but) - :^ %deps - i.but - (slav %uv i.t.but) - ?+(quy !! [[%'DELETE' ~] ~] %del, [[%'PUT' ~] ~] %put) - == + == == :: - ++ grab-body - |* a=fist:jo ^+ (need *a) - ~| parse-fail/bod - ?> &(?=(%post mef) ?=(^ bod)) - (need %.(q.u.bod ;~(biff poja a))) + ++ grab-body |*(a=fist:jo (need (parse-body a))) + ++ parse-body + |* a=fist:jo ^+ *a + ?. &(?=(%post mef) ?=(^ bod)) + ~ + %.(q.u.bod ;~(biff poja a)) :: ++ handle ^+ done @@ -738,11 +738,11 @@ ++ check-oryx :: | if json with bad oryx ^- ? ?. &(?=([~ %json] p.pok) ?=(%post mef) ?=(^ bod)) & - =+ oxe=(parse-to-oryx q.u.bod) + =+ oxe=(parse-body to-oryx) ?~ oxe | (~(has in vew.cyz:for-client) u.oxe) :: - ++ parse-to-oryx ;~(biff poja (ot oryx/so ~):jo) + ++ to-oryx (ot oryx/so ~):jo ++ root-beak `beak`[our %main ud/0] :: XX ++ add-depend |= [a=@uvH b=(each duct ixor)] ^+ done @@ -763,11 +763,13 @@ [%& %for ~ bem ext ced.cyz:for-client] :: %deps + =+ ire=(oryx-to-ixor (grab-body to-oryx)) =< [%| (nice-json)] - ?- r.hem - %del done(liz (~(del ju liz) q.hem %| p.hem)) - %put (add-depend q.hem %| p.hem) + ?- q.hem + %del done(liz (~(del ju liz) p.hem %| ire)) + %put (add-depend p.hem %| ire) == + :: %poll ?. ?=([~ %js] p.pok) :: XX treat non-json cases? [%| (add-depend p.hem %& hen)] @@ -789,9 +791,10 @@ [%& %fot wir q.hem cay] :: %subs + =+ ire=(oryx-to-ixor (grab-body to-oryx)) :^ %& %gas - [%is p.hem (pack-hasp -.q.hem) +.q.hem] - [[- + ~]:-.q.hem him +.q.hem] + [%is ire (pack-hasp p.hem) q.hem] + [[- + ~]:p.hem him q.hem] :: %view ~| lost-ixor/p.hem @@ -907,6 +910,7 @@ == -- :: + ++ oryx-to-ixor |=(a=oryx (rsh 3 1 (scot %p (end 6 1 (shas %ire a))))) ++ ya :: session engine =| [ses=hole cyst] =* cyz -> @@ -956,7 +960,7 @@ ^+ [*json ..ya] =+ orx=(rsh 3 1 (scot %p (shaf %orx eny))) =. vew (~(put in vew) orx) - =+ ire=(rsh 3 1 (scot %p (end 6 1 (shas %ire orx)))) + =+ ire=(oryx-to-ixor orx) =. wix (~(put by wix) ire [orx ~ now [1 ~]]) :_ abet %- jobe :~ @@ -995,7 +999,7 @@ ?: =(a p.eve) =. +> ?^ ude ~&(e/ix/wait/%replaced done) - wait-era(era (add ~s3 now)) :: XX ~s30 + wait-era(era (add ~s30 now)) abet(ude [~ hen &]) ?: (gth a p.eve) ~|(seq-high/cur=p.eve !!) =+ ven=~|(seq-low/cur=p.eve (~(got by q.eve) a)) From 8a8041f338084d4856a50ab5f4a384abfd463b76 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 17 Mar 2015 16:15:06 -0700 Subject: [PATCH 084/219] Reordered slam ~! to be more meaningful --- arvo/hoon.hoon | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index 471521d55a..9343e3d13f 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -6136,11 +6136,12 @@ :: [%cncb *] [%ktls [%cnzz p.gen] %cnts p.gen q.gen] [%cncl *] - =+ rem=[%cnsg [%$ ~] p.gen q.gen] - ?. ?=([%zpcb ^ %cnzz @ ~] p.gen) rem + :^ %cnsg [%$ ~] p.gen + ?. ?=([%zpcb ^ %cnzz @ ~] p.gen) q.gen => .(p.gen `[@ ^ @ p=@tas ~]`p.gen) :+ %sgzp [[%dtzz %tas 'slam'] [%dtzz %tas p.p.gen]] - rem + q.gen + :: [%cndt *] [%cnhp q.gen [p.gen ~]] [%cnkt *] [%cnhp p.gen q.gen r.gen s.gen ~] [%cnls *] [%cnhp p.gen q.gen r.gen ~] From 6ad6819867b88149cede4a12e8b588e33405202f Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 17 Mar 2015 16:41:10 -0700 Subject: [PATCH 085/219] Revert "Reordered slam ~! to be more meaningful": information lost on net This reverts commit 9a97d0801362829ca9a78dfe60a9d3c560853b35. --- arvo/hoon.hoon | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index 9343e3d13f..471521d55a 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -6136,12 +6136,11 @@ :: [%cncb *] [%ktls [%cnzz p.gen] %cnts p.gen q.gen] [%cncl *] - :^ %cnsg [%$ ~] p.gen - ?. ?=([%zpcb ^ %cnzz @ ~] p.gen) q.gen + =+ rem=[%cnsg [%$ ~] p.gen q.gen] + ?. ?=([%zpcb ^ %cnzz @ ~] p.gen) rem => .(p.gen `[@ ^ @ p=@tas ~]`p.gen) :+ %sgzp [[%dtzz %tas 'slam'] [%dtzz %tas p.p.gen]] - q.gen - :: + rem [%cndt *] [%cnhp q.gen [p.gen ~]] [%cnkt *] [%cnhp p.gen q.gen r.gen s.gen ~] [%cnls *] [%cnhp p.gen q.gen r.gen ~] From 00b9592f9fbda8effbf06b39356a4af25f47c968 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Wed, 18 Mar 2015 09:40:40 -0700 Subject: [PATCH 086/219] Various fixes and improvements. --- arvo/dill.hoon | 1064 +++++++++++++-------------------------- arvo/dull.hoon | 84 +--- main/app/seat/core.hook | 1 + 3 files changed, 371 insertions(+), 778 deletions(-) diff --git a/arvo/dill.hoon b/arvo/dill.hoon index b16fef4b7d..108306dd5b 100644 --- a/arvo/dill.hoon +++ b/arvo/dill.hoon @@ -3,702 +3,326 @@ :: |= pit=vase => |% :: interface tiles -++ gift :: out result <-$ - $% [%bbye ~] :: reset prompt - [%blit p=(list blit)] :: terminal output - [%init p=@p] :: report install - [%logo @] :: logout - [%veer p=@ta q=path r=@t] :: install vane - [%vega p=path] :: reboot by path - [%verb ~] :: - == :: -++ kiss :: in request ->$ - $% [%belt p=belt] :: terminal input - [%blew p=blew] :: terminal config - [%boot p=*] :: weird %dill boot - [%crud p=@tas q=(list tank)] :: error with trace - [%flog p=flog] :: wrapped error - [%flow p=*] :: forward compat - [%hail ~] :: terminal refresh - [%hook ~] :: this term hung up - [%harm ~] :: all terms hung up - [%init p=ship] :: after gall ready - [%noop ~] :: no operation - [%talk p=tank] :: - [%text p=tape] :: - == :: -++ flog :: sent to %dill - $% [%crud p=@tas q=(list tank)] :: - [%text p=tape] :: - == :: -++ mess :: message to terminal - $% [%term-ctrl p=(hypo ,%hail)] :: - [%term-in p=(hypo term-in)] :: - == :: -++ move ,[p=duct q=(mold note gift)] :: local move -++ note :: out request $-> - $% $: %a :: - $% [%make p=(unit ,@t) q=@ud r=@ s=?] :: - [%sith p=@p q=@uw r=?] :: - == == :: - $: %c :: - $% [%warp p=sock q=riff] :: - == == :: - $: %d :: - $% [%crud p=@tas q=(list tank)] :: - [%text p=tape] :: - [%logo ~] :: - == == :: - $: %g :: - $% [%mess p=[p=ship q=path] q=ship r=mess] :: - [%nuke p=[p=ship q=path] q=ship] :: - [%show p=[p=ship q=path] q=ship r=path] :: - [%took p=[p=ship q=path] q=ship] :: - == == :: - $: %t :: - $% [%wait p=@da] :: - == == == :: -++ riff ,[p=desk q=(unit rave)] :: see %clay -++ sign :: in result $<- - $? - $: %c :: - $% [%writ p=riot] :: - == == :: - $: %g :: - $% [%logo p=@] :: - [%mean p=ares] :: - [%nice ~] :: - $: %rush :: - $% [%term-line q=term-line] :: - [%hymn q=manx] :: - == == :: - [%verb ~] :: - [%sage p=path q=*] :: - [%veer p=@ta q=path r=@t] :: - [%vega p=path] :: - == == :: - $: %t :: - $% [%wake ~] :: - == == - $: @tas :: by any - $% [%crud p=@tas q=(list tank)] :: - [%init p=@p] :: - [%note p=@tD q=tank] :: - == == == :: -++ term-in :: - $: pax=path :: - $= jof :: - $% [%line p=cord] :: - [%res p=span] :: - [%cmd p=char] :: - [%type p=?] :: - == == :: -++ term-line ,[p=[p=cord q=prom r=cord] q=(list cord) r=(list tark)] -++ tark ?(tank [%stem p=@da q=tank r=tank]) :: -:::::::: :: dill tiles -++ bein :: terminal control - $: $: bul=@ud :: buffer length - bus=@ud :: cursor in buffer - but=(list ,@c) :: buffer text - buy=prom :: input style - == :: - $: hiz=@ud :: history depth - hux=path :: history path - hym=(map ,@ud (list ,@c)) :: history overlay - hyt=hist :: history object - hyr=(unit (list ,@c)) :: history search - == :: - $: pol=@ud :: length of prompt - pot=tape :: prompt text - == :: - == :: +++ console-action :: console to app + $% [%det console-change] :: edit prompt line + [%inn ~] :: enter session + [%out ~] :: exit session + [%ret ~] :: submit and clear + == :: +++ console-buffer (list ,@c) :: command state +++ console-change :: network change + $: ler=console-clock :: destination clock + haw=@uvH :: source hash + ted=console-edit :: state change + == :: +++ console-clock ,[own=@ud his=@ud] :: vector clock +++ console-edit :: shared state change + $% [%del p=@ud] :: delete one at + [%ins p=@ud q=@c] :: insert at + [%mor p=(list console-edit)] :: combination + [%nop ~] :: no-op + [%set p=console-buffer] :: discontinuity + == :: +++ console-effect :: app to console + $% [%bel ~] :: beep + [%blk p=@ud q=@c] :: blink/match char at + [%clr ~] :: clear screen + [%det console-change] :: edit input + [%nex ~] :: save and clear input + [%tan p=(list tank)] :: classic tank + :: [%taq p=tanq] :: modern tank + [%txt p=tape] :: text line + == :: +++ dill-belt :: console input + $% [%aro p=?(%d %l %r %u)] :: arrow key + [%bac ~] :: true backspace + [%cru p=@tas q=(list tank)] :: echo error + [%ctl p=@ud] :: control-key + [%del ~] :: true delete + [%met p=@ud] :: meta-key + [%ret ~] :: return + [%rez p=@ud q=@ud] :: resize, cols, rows + [%txt p=(list ,@c)] :: utf32 text + [%yow p=gill] :: connect to app + == :: +++ dill-blit :: console output + $% [%bel ~] :: make a noise + [%clr ~] :: clear the screen + [%hop p=@ud] :: set cursor position + [%pro p=(list ,@c)] :: show as cursor/line + [%out p=(list ,@c)] :: send output line + [%sag p=path q=*] :: save to jamfile + [%sav p=path q=@] :: save to file + == :: +++ gill ,@tas :: general contact +-- :: +=> |% :: console protocol +++ axle :: all dill state + $: %2 :: + ore=(unit ship) :: identity once set + hey=(unit duct) :: default duct + dug=(map duct axon) :: conversations + == :: +++ axon :: dill per duct + $: ram=term :: console program + tem=(unit (list dill-belt)) :: pending, reverse + wid=_80 :: terminal width + pos=@ud :: cursor position + see=(list ,@c) :: current line + == :: +-- => :: +|% :: protocol below ++ blew ,[p=@ud q=@ud] :: columns rows ++ belt :: raw console input - $% [%aro p=?(%d %l %r %u)] :: arrow key - [%bac ~] :: true backspace - [%ctl p=@ud] :: control-key - [%del ~] :: true delete - [%met p=@ud] :: meta-key - [%ret ~] :: return - [%txt p=(list ,@c)] :: utf32 text - == :: + $% [%aro p=?(%d %l %r %u)] :: arrow key + [%bac ~] :: true backspace + [%ctl p=@ud] :: control-key + [%del ~] :: true delete + [%met p=@ud] :: meta-key + [%ret ~] :: return + [%txt p=(list ,@c)] :: utf32 text + == :: ++ blit :: raw console output - $% [%bel ~] :: make a noise - [%clr ~] :: clear the screen - [%hop p=@ud] :: set cursor position - [%lin p=(list ,@c)] :: set current line - [%mor ~] :: newline - [%sag p=path q=*] :: save to jamfile - [%sav p=path q=@] :: save to file - == :: -++ blot :: kill ring - $: p=@ud :: length - q=@ud :: depth - r=(list (list ,@c)) :: kills - == :: -++ blur ,[p=@ud q=(unit bein) r=blot] :: columns, prompt -++ kyev :: - $: p=(set ?(%ctrl %shift %alt %meta)) :: - q=$|(cord [%act speck]) :: - == :: -++ speck :: - $? %ctrl %shift %alt %meta %entr %esc :: - %caps %uncap %pgup %pgdn %home %end :: - %baxp %del %ins %up %down %left :: - %right :: - == :: -++ yard :: terminal state - $: p=? :: verbose - q=blur :: display state - r=(map path hist) :: history - s=[p=? q=@da] :: typing?/last typed - == :: - :: XX LEGACY 12-16-2014 -++ yord :: old terminal state - $: p=? :: verbose - q=blur :: display state - r=(map path hist) :: history - == :: --- => -|% -++ dy - |= [hen=duct our=ship now=@da def=(unit duct) dug=(map duct yard)] - =+ ^= yar ^- yard - =+ yur=(~(get by dug) hen) - ?^ yur u.yur - ?^ def (~(got by dug) u.def) - [& [80 ~ *blot] ~ | *@da] - =| mos=(list move) - |% - ++ beep (curb [[%bel ~] ~]) :: send beep - ++ curb :: send blits - |= wab=(list blit) - ^+ +> - ?~ wab +> - +>(mos [[hen [%give %blit (flop wab)]] mos]) - :: - ++ wod :: word forward - |= bed=bein - ^- @ud - ?: =(bul.bed bus.bed) - bus.bed - ?: =(' ' (snag bus.bed but.bed)) - $(bus.bed +(bus.bed)) - |- - ^- @ud - ?: =(bul.bed bus.bed) - bus.bed - ?: =(' ' (snag bus.bed but.bed)) - bus.bed - $(bus.bed +(bus.bed)) - :: - ++ wob :: word backward - |= bed=bein - ^- @ud - ?: =(0 bus.bed) - bus.bed - ?: =(' ' (snag (dec bus.bed) but.bed)) - $(bus.bed (dec bus.bed)) - |- - ^- @ud - ?: =(0 bus.bed) - bus.bed - ?: =(' ' (snag (dec bus.bed) but.bed)) - bus.bed - $(bus.bed (dec bus.bed)) - :: - ++ edit :: change the bed - |= bed=bein - ^+ +> - =. q.q.yar [~ bed] - ?> ?=(^ q.q.yar) - %- curb - |- ^- (list blit) - ?^ hyr.u.q.q.yar - =+ ris=:(weld "(reverse-i-search)'" (tufa u.hyr.u.q.q.yar) "': ") - %= $ - pot.bed ris - pol.bed (lent ris) - hyr.u.q.q.yar ~ - == - :~ [%hop (add pol.bed bus.bed)] - :- %lin - %+ weld pot.bed - ?- buy.bed - %none but.bed - %text but.bed - %pass `(list ,@)`(runt [(lent but.bed) '*'] ~) - == - == - :: - ++ fume :: print tank, prefix - |= [pef=@tD tac=tank] - ^+ +> - =+ wol=(~(win re tac) 2 p.q.yar) - %- furl - %+ turn wol - |= a=tape ^- tape - ?> ?=([@ @ *] a) - [pef ' ' t.t.a] - :: - ++ furl :: print wall - |= wol=(list tape) - ^+ +> - =. +> - %- curb - %- flop - |- ^- (list blit) - ?~ wol ~ - [[%lin (tuba i.wol)] [%mor ~] $(wol t.wol)] - ?~ q.q.yar +> - (edit(q.q.yar ~) u.q.q.yar) - :: - ++ gore :: move in history - |= hup=@ud - ^+ +> - =+ but=(goth hup) - =+ bul=(lent but) - %- edit - ?> ?=(^ q.q.yar) - %= u.q.q.yar - hiz hup - hym %+ ~(put by hym.u.q.q.yar) - hiz.u.q.q.yar - but.u.q.q.yar - bus bul - bul bul - but but - == - :: - ++ goth :: extract history - |= hup=@ud - ?> ?=(^ q.q.yar) - =+ byt=(~(get by hym.u.q.q.yar) hup) - ?^ byt u.byt - (tuba (rip 3 (snag hup q.hyt.u.q.q.yar))) - :: - ++ kill :: add to kill ring - |= txt=(list ,@c) - ^+ +> - => ?. =(16 p.r.q.yar) . - .(p.r.q.yar 15, r.r.q.yar (scag 15 r.r.q.yar)) - %= +> - p.r.q.yar +(p.r.q.yar) - q.r.q.yar 0 - r.r.q.yar [txt r.r.q.yar] - == - :: - ++ look :: search in history - |= [hup=@ud txt=(list ,@c)] - ^+ +> - =+ ^= beg - |= [a=(list ,@c) b=(list ,@c)] ^- ? - ?~(a & ?~(b | &(=(i.a i.b) $(a t.a, b t.b)))) - =+ ^= mid - |= [a=(list ,@c) b=(list ,@c)] ^- ? - ?~(a & ?~(b | |((beg a b) $(b t.b)))) - ?> ?=(^ q.q.yar) - ?: =(hup p.hyt.u.q.q.yar) - beep - =+ but=(goth hup) - ?: (mid txt but) - (gore(hyr.u.q.q.yar [~ txt]) hup) - $(hup +(hup)) - :: - ++ leap :: accept response - |= [tea=wire sih=sign] - ^+ +> - ?- -.+.sih - %crud :: error trace - =. q.+.sih [[%leaf (trip p.+.sih)] q.+.sih] - |- ^+ +>.^$ - ?~ q.+.sih +>.^$ - (fume:$(q.+.sih t.q.+.sih) '!' `tank`i.q.+.sih) - :: - %mean ~& %dill-mean +>.$ - %nice +>.$ - %note ?.(p.yar +>.$ (fume p.+.sih q.+.sih)) :: debug message - ?(%rush %rust) :: XX reset prompt - =. mos :_(mos [hen %pass tea %g %took [our /terminal] our]) - ?> ?=(%term-line +>-.sih) - =. +>.$ - =+ lis=(scag 1.000 r.q.sih) - =- (furl (zing (turn (flop lis) -))) - |= a=tark - ^- wall - ?+ -.a (~(win re a) 0 p.q.yar) - %stem - ?: =(q.s.yar p.a) ~ - ~[(welp ~(ram re q.a) ~(ram re r.a))] - == - ?. (levy r.q.sih |=(a=tark ?=(%stem -.a))) - +>.$ :: XX separate prompt/history messages - %- edit - =| bed=bein - =+ ^= hyt ^- hist - =+ hyt=(~(get by r.yar) /) - ?~(hyt *hist u.hyt) - ?: &(?=(^ q.q.yar) =(/ hux.u.q.q.yar)) - =+ bun=(rip 5 (turf r.p.q.sih)) - %= u.q.q.yar - bul ?~ r.p.q.sih bul.u.q.q.yar (lent bun) - bus ?~ r.p.q.sih bus.u.q.q.yar (lent bun) - but ?~ r.p.q.sih but.u.q.q.yar bun - hyt [+(p.hyt) [%$ q.hyt]] - pot (trip p.p.q.sih) - pol (met 3 p.p.q.sih) - buy q.p.q.sih - == - %_ bed - bul (met 3 r.p.q.sih) - bus (met 3 r.p.q.sih) - but (rip 3 r.p.q.sih) - buy q.p.q.sih - hux / - hiz 0 - hyt [+(p.hyt) [%$ q.hyt]] - pot (trip p.p.q.sih) - pol (met 3 p.p.q.sih) - == - :: - %sage :: write a jamfile - %= +>.$ - mos :_(mos [hen [%give %blit [%sag p.+.sih q.+.sih] ~]]) - == - ?(%init %logo %veer %vega %verb) :: drop-throughs - +>(mos :_(mos [hen %give +.sih])) - %writ :: file exists - %_ +>.$ - mos - :_ mos - [hen %pass /term-show %g %show [our /terminal] our /lines] - == - :: - %wake - ?: (lte (sub now ~s15) q.s.yar) - %_ +>.$ - mos - :_ mos - [hen %pass /activity %t %wait (add q.s.yar ~s15)] - == - %_ +>.$ - p.s.yar | - mos :_(mos (poke %term-in -:!>(*term-in) / %type %|)) - == - == - :: - ++ lear :: handle request - |= kyz=kiss - ^+ +> - ?- -.kyz - %flog !! - %noop +> - %belt :: terminal input - =. +>.$ - ?. ?=(?(%bac %del %ret %txt) -.p.kyz) +>.$ - ?: p.s.yar +>.$(s.yar [& now]) - %_ +>.$ - s.yar [& now] - mos - :_ :_ mos - [hen %pass /activity %t %wait (add ?:(p.s.yar q.s.yar now) ~s15)] - (poke %term-in -:!>(*term-in) / %type %&) - == - ?~ q.q.yar - %^ furl - "Downloading files from ticketing ship, please wait until" - "a prompt shows up. This could take several minutes." - ~ - ?^ hyr.u.q.q.yar :: live search - ?+ p.kyz $(hiz.u.q.q.yar 0, hyr.u.q.q.yar ~) - [%bac *] - ?: =(~ u.hyr.u.q.q.yar) - (curb [[%bel ~] ~]) - %- edit - %= u.q.q.yar - hyr [~ (scag (dec (lent u.hyr.u.q.q.yar)) u.hyr.u.q.q.yar)] - == - :: - [%txt *] (look hiz.u.q.q.yar (weld u.hyr.u.q.q.yar p.p.kyz)) - [%ctl %g] (edit u.q.q.yar(bul 0, bus 0, but ~, hiz 0, hyr ~)) - [%ctl %r] - ?: =(p.hyt.u.q.q.yar hiz.u.q.q.yar) - beep - (look +(hiz.u.q.q.yar) u.hyr.u.q.q.yar) - == - ?- -.p.kyz - %aro :: arrow - ?- p.p.kyz - %d :: down - ?: =(0 hiz.u.q.q.yar) - beep - (gore (dec hiz.u.q.q.yar)) - :: - %l :: left - ?: =(0 bus.u.q.q.yar) - beep - (edit u.q.q.yar(bus (dec bus.u.q.q.yar))) - :: - %r :: right - ?: =(bul.u.q.q.yar bus.u.q.q.yar) - beep - (edit u.q.q.yar(bus +(bus.u.q.q.yar))) - :: - %u - =+ hup=+(hiz.u.q.q.yar) - ?: =(hup p.hyt.u.q.q.yar) - beep - (gore hup) - == - :: - %bac :: backspace - ^+ +>.$ - ?: =(0 bus.u.q.q.yar) - (curb `(list blit)`[[%bel ~] ~]) - %- edit - %= u.q.q.yar - bus (dec bus.u.q.q.yar) - bul (dec bul.u.q.q.yar) - but - %+ weld - (scag (dec bus.u.q.q.yar) but.u.q.q.yar) - (slag bus.u.q.q.yar but.u.q.q.yar) - == - :: - %ctl :: control - ?+ p.p.kyz - beep - %a (edit u.q.q.yar(bus 0)) - %b $(kyz [%belt %aro %l]) - %d ?: ?& =(0 bul.u.q.q.yar) - =(0 bus.u.q.q.yar) - == - +>.$(mos :_(mos (poke %term-in -:!>(*term-in) / %cmd %d))) - $(kyz [%belt %del ~]) - %e (edit u.q.q.yar(bus bul.u.q.q.yar)) - %f $(kyz [%belt %aro %r]) - %g +>.$(mos :_(mos (poke %term-in -:!>(*term-in) / %cmd %g))) - %k ?: =(bul.u.q.q.yar bus.u.q.q.yar) - beep - => .(+>.$ (kill (slag bus.u.q.q.yar but.u.q.q.yar))) - %- edit - ?> ?=(^ q.q.yar) - %= u.q.q.yar - bul bus.u.q.q.yar - but (scag bus.u.q.q.yar but.u.q.q.yar) - == - %t ?: (lth bul.u.q.q.yar 2) - beep - =+ ^= pos - ?: =(bul.u.q.q.yar bus.u.q.q.yar) - (sub bus.u.q.q.yar 2) - ?: =(0 bus.u.q.q.yar) - bus.u.q.q.yar - (dec bus.u.q.q.yar) - %- edit - %= u.q.q.yar - bus (add 2 pos) - but %+ weld - %+ weld - (scag pos but.u.q.q.yar) - ^- (list ,@c) :+ - (snag +(pos) but.u.q.q.yar) - (snag pos but.u.q.q.yar) - ~ - (slag (add 2 pos) but.u.q.q.yar) - == - %l +>.$(mos :_(mos [hen %give %blit [[%clr ~] ~]])) - %n $(kyz [%belt %aro %d]) - %o %_ +>.$ - mos - :_ :_ mos - [hen %pass /term-show %g %nuke [our /terminal] our] - [hen %pass /term-show %g %show [our /terminal] our /lines] - == - %p $(kyz [%belt %aro %u]) - %u ?: =(0 bus.u.q.q.yar) - beep - => .(+>.$ (kill (scag bus.u.q.q.yar but.u.q.q.yar))) - %- edit - ?> ?=(^ q.q.yar) - %= u.q.q.yar - bus 0 - bul (sub bul.u.q.q.yar bus.u.q.q.yar) - but (slag bus.u.q.q.yar but.u.q.q.yar) - == - %r (edit u.q.q.yar(hyr [~ ~])) - %w ?: =(0 bus.u.q.q.yar) - beep - =+ bow=(wob u.q.q.yar) - =+ sow=(sub bus.u.q.q.yar bow) - => .(+>.$ (kill (swag [bow sow] but.u.q.q.yar))) - %- edit - ?> ?=(^ q.q.yar) - %= u.q.q.yar - bus bow - bul (sub bul.u.q.q.yar sow) - but %+ welp - (scag bow but.u.q.q.yar) - (slag bus.u.q.q.yar but.u.q.q.yar) - == - %x +>.$(mos :_(mos (poke %term-in -:!>(*term-in) / %cmd %x))) - %y ?: =(0 p.r.q.yar) - beep - $(kyz [%belt %txt (snag q.r.q.yar r.r.q.yar)]) - == - :: - %del :: delete - ?: =(bul.u.q.q.yar bus.u.q.q.yar) - beep - %- edit - %= u.q.q.yar - bul (dec bul.u.q.q.yar) - but - %+ weld - (scag bus.u.q.q.yar but.u.q.q.yar) - (slag +(bus.u.q.q.yar) but.u.q.q.yar) - == - :: - %met :: meta - ?+ p.p.kyz - beep - %f - ?: =(bul.u.q.q.yar bus.u.q.q.yar) - beep - (edit u.q.q.yar(bus (wod u.q.q.yar))) - :: - %b - ?: =(0 bus.u.q.q.yar) - beep - (edit u.q.q.yar(bus (wob u.q.q.yar))) - :: - %y - ?: =(0 p.r.q.yar) - beep - =+ dol=(snag q.r.q.yar r.r.q.yar) - =+ leo=(lent dol) - ?. (gte bus.u.q.q.yar leo) - beep - =+ pey=(sub bus.u.q.q.yar leo) - ?. =(dol (swag [pey leo] but.u.q.q.yar)) - beep - =. q.r.q.yar ?:(=(p.r.q.yar +(q.r.q.yar)) 0 +(q.r.q.yar)) - =+ ney=(snag q.r.q.yar r.r.q.yar) - =+ lye=(lent ney) - %- edit - %= u.q.q.yar - bus (sub (add bus.u.q.q.yar lye) leo) - bul (sub (add bul.u.q.q.yar lye) leo) - but %+ weld - (scag pey but.u.q.q.yar) - %+ weld - `(list ,@c)`ney :: XX weird fuse-loop - (slag bus.u.q.q.yar but.u.q.q.yar) - == - == - :: - %ret :: return - ?: =(%none buy.u.q.q.yar) beep - =+ jab=(rap 3 (tufa but.u.q.q.yar)) - %= +>.$ - q.q.yar ~ - r.yar - ?: |(=(%$ jab) =(%pass buy.u.q.q.yar)) - r.yar - %+ ~(put by r.yar) - hux.u.q.q.yar - [p.hyt.u.q.q.yar [jab ?~(q.hyt.u.q.q.yar ~ +.q.hyt.u.q.q.yar)]] - :: - mos - :* (poke %term-ctrl -:!>(%hail) %hail) - [hen %give [%bbye ~]] - (poke %term-in -:!>(*term-in) / %line jab) - [hen %give [%blit [[%mor ~] ~]]] - mos - == - == - :: - %txt :: text keys - ?: =(%none buy.u.q.q.yar) beep - =+ let=(lent p.p.kyz) - %- edit - %= u.q.q.yar - bus (add let bus.u.q.q.yar) - bul (add let bul.u.q.q.yar) - but - ;: weld - (scag bus.u.q.q.yar but.u.q.q.yar) - p.p.kyz - (slag bus.u.q.q.yar but.u.q.q.yar) - == - == - == - :: - %blew +>.$(p.q.yar p.p.kyz) :: window size - %boot - %= +>.$ - mos - :_(mos [hen %pass ~ (note %a p.kyz)]) - == - :: - %crud :: error trace - =. q.kyz [[%leaf (trip p.kyz)] q.kyz] - |- ^+ +>.^$ - ?~ q.kyz +>.^$ - (fume:$(q.kyz t.q.kyz) '!' `tank`i.q.kyz) - :: - %flow - +>.$ - :: - %hail :: refresh - +>.$ - ::+>.$(mos :_(mos (poke %term-ctrl -:!>(%hail) %hail))) - :: - %harm :: all terms hung up - =+ nug=((map duct yard) [[hen (~(get by dug) hen)] ~ ~]) - ^+ +>.$ - %= +>.$ - dug nug - ::S mos :_(mos [hen %pass ~ %b kyz]) - == - :: - %hook :: this term hung up - ~& %dill-hook-not-implemented - +>.$ - ::S +>.$(dug (~(del by dug) hen), mos :_(mos [hen %pass ~ %b kyz])) - :: - %init - =. def `(fall def +.hen) - %= +>.$ - our p.kyz - mos - :_ mos - [(need def) %pass / %c %warp [p.kyz p.kyz] %main `[%& %y [%ud 1] /]] - == - :: - %talk (furl (~(win re p.kyz) 0 p.q.yar)) :: program output - %text $(kyz [%talk %leaf p.kyz]) :: simple message - == - :: - ++ poke - |= msg=mess - ^- move - :^ hen %pass /term-mess - :^ %g %mess [our /terminal] - :- our msg - :: - ++ yerk :: complete core - ^- [p=(list move) q=ship r=(unit duct) s=(map duct yard)] - :^ (flop mos) our def - (~(put by dug) hen yar) - -- + $% [%bel ~] :: make a noise + [%clr ~] :: clear the screen + [%hop p=@ud] :: set cursor position + [%lin p=(list ,@c)] :: set current line + [%mor ~] :: newline + [%sag p=path q=*] :: save to jamfile + [%sav p=path q=@] :: save to file + == :: +++ flog :: sent to %dill + $% [%crud p=@tas q=(list tank)] :: + [%text p=tape] :: + [%veer p=@ta q=path r=@t] :: install vane + [%vega p=path] :: reboot by path + [%verb ~] :: verbose mode + == :: +++ gift :: out result <-$ + $% [%bbye ~] :: reset prompt + [%blit p=(list blit)] :: terminal output + [%init p=@p] :: set owner + [%logo ~] :: logout + [%veer p=@ta q=path r=@t] :: install vane + [%vega p=path] :: reboot by path + [%verb ~] :: verbose mode + == :: +++ kiss :: in request ->$ + $% [%belt p=belt] :: terminal input + [%blew p=blew] :: terminal config + [%boot p=*] :: weird %dill boot + [%crud p=@tas q=(list tank)] :: error with trace + [%flog p=flog] :: wrapped error + [%flow p=@tas q=(list gill)] :: terminal config + [%hail ~] :: terminal refresh + [%hook ~] :: this term hung up + [%harm ~] :: all terms hung up + [%init p=ship] :: after gall ready + [%noop ~] :: no operation + [%talk p=tank] :: + [%text p=tape] :: + [%veer p=@ta q=path r=@t] :: install vane + [%vega p=path] :: reboot by path + [%verb ~] :: verbose mode + == :: +-- => :: +|% :: protocol outward +++ mess :: + $% [%dill-belt p=(hypo dill-belt)] :: + == :: +++ move ,[p=duct q=(mold note gift)] :: local move +++ note-ames :: weird ames move + $% [%make p=(unit ,@t) q=@ud r=@ s=?] :: + [%sith p=@p q=@uw r=?] :: + == :: +++ note-clay :: wait for clay, hack + $% [%warp p=sock q=riff] :: + == :: +++ note-dill :: note to self, odd + $% [%crud p=@tas q=(list tank)] :: + [%text p=tape] :: + [%veer p=@ta q=path r=@t] :: install vane + [%vega p=path] :: reboot by path + [%verb ~] :: verbose mode + == :: +++ note-gall :: outbound message + $% [%mess p=[ship q=path] q=ship r=mess] :: + [%nuke p=[p=ship q=path] q=ship] :: + [%show p=[p=ship q=path] q=ship r=path] :: + [%took p=[p=ship q=path] q=ship] :: + == :: +++ note :: + $% [%a note-ames] :: out request $-> + [%c note-clay] + [%d note-dill] :: + [%g note-gall] :: + == :: +++ riff ,[p=desk q=(unit rave)] :: see %clay +++ sign-ames :: + $% [%nice ~] :: + [%init p=ship] :: + == :: +++ sign-clay :: + $% [%note p=@tD q=tank] :: + [%writ p=riot] :: + == :: +++ sign-gall :: + $% [%crud p=@tas q=(list tank)] :: + [%mean p=ares] :: + [%nice ~] :: + [%rush %dill-blit dill-blit] :: + == :: +++ sign-time :: + $% [%wake ~] :: + == :: +++ sign :: in result $<- + $% [%a sign-ames] :: + [%c sign-clay] :: + [%g sign-gall] :: + [%t sign-time] :: + == :: +:::::::: :: dill tiles -- -=| $: %1 :: - our=ship :: - def=(unit duct) :: - dug=(map duct yard) :: - == :: +=| all=axle |= [now=@da eny=@ ski=sled] :: current invocation +=> |% + ++ as :: per cause + |_ $: [moz=(list move) hen=duct our=ship] + axon + == + ++ abet :: resolve + ^- [(list move) axle] + [(flop moz) all(dug (~(put by dug.all) hen +<+))] + :: + ++ call :: receive input + |= kyz=kiss + ^+ +> + ?+ -.kyz ~& [%strange-kiss -.kyz] +> + %flow +> + %harm +> + %hail +> + %belt (send `dill-belt`p.kyz) + %text (dump %blit [%lin (tuba p.kyz)]~) + %crud (send `dill-belt`[%cru p.kyz q.kyz]) + %blew (send %rez p.p.kyz q.p.kyz) + %veer (dump kyz) + %vega (dump kyz) + %verb (dump kyz) + == + :: + ++ dump :: pass down to hey + |= git=gift + ?> ?=(^ hey.all) + +>(moz [[u.hey.all %give git] moz]) + :: + ++ done :: return gift + |= git=gift + +>(moz :_(moz [hen %give git])) + :: + ++ from :: receive belt + |= bit=dill-blit + ^+ +> + ?: ?=(%out -.bit) + %+ done %blit + :~ [%lin p.bit] + [%mor ~] + [%lin see] + [%hop pos] + == + ?: ?=(%pro -.bit) + (done(see p.bit) %blit [[%lin p.bit] [%hop pos] ~]) + ?: ?=(%hop -.bit) + (done(pos p.bit) %blit [bit ~]) + (done %blit [bit ~]) + :: + ++ init :: initialize + ~& [%dill-init our] + =+ myt=(flop (need tem)) + =. tem ~ + =. moz :_(moz [hen %pass ~ %g %show [our [ram ~]] our ~]) + |- ^+ +> + ?~ myt +> + $(myt t.myt, +> (send i.myt)) + :: + ++ into :: preinitialize + |= gyl=(list gill) + %_ +> + tem `(turn gyl |=(a=gill [%yow a])) + moz + :_ moz + :* hen + %pass + / + %c + [%warp [our our] %main `[%& %y [%ud 1] /]] + == + == + :: + ++ send :: send action + |= bet=dill-belt + ?^ tem + +>(tem `[bet u.tem]) + %_ +> + moz + :_ moz + [hen %pass ~ %g %mess [our [ram ~]] our [%dill-belt -:!>(bet) bet]] + == + :: + ++ take :: receive + |= sih=sign + ^+ +> + ?- sih + [%a %nice *] + :: ~& [%take-nice-ames sih] + +> + :: + [%a %init *] + +>(moz :_(moz [hen %give +.sih])) + :: + [%c %note *] + (from %out (tuba ~(ram re q.+.sih))) + :: + [%c %writ *] + init + :: + [%g %crud *] + (send %cru p.+.sih q.+.sih) + :: + [%g %mean *] + +>(moz [[hen %give %logo ~] moz]) + :: + [%g %nice *] + :: ~& [%take-nice sih] + +> + :: + [%g %rush %dill-blit *] + =. moz :_(moz `move`[hen %pass ~ %g %took [our [ram ~]] our]) + (from +>+.sih) + :: + [%t %wake *] + :: ~& %dill-wake + +> + == + -- + :: + ++ ax :: make ++as + |= [hen=duct kyz=kiss] :: + ?~ ore.all ~ + =+ nux=(~(get by dug.all) hen) + ?^ nux + (some ~(. as [~ hen u.ore.all] u.nux)) + ?. ?=(%flow -.kyz) ~ + %- some + %. q.kyz + %~ into as + :- [~ hen u.ore.all] + :* p.kyz + [~ ~] + 80 + 0 + (tuba "<{(trip p.kyz)}>") + == + -- |% :: poke/peek pattern ++ call :: handle request |= $: hen=duct @@ -715,44 +339,52 @@ ~& [%dill-call-flub (,@tas `*`-.q.hic)] ((hard kiss) q.hic) == + ?: ?=(%boot -.q.hic) + :_(..^$ [hen %pass ~ (note %a p.q.hic)]~) ?: ?=(%flog -.q.hic) - :_ ..^$ - %+ turn (~(tap by dug) *(list ,[p=duct q=yard])) - |=([a=duct b=yard] [a %slip %d p.q.hic]) - =+ res=yerk:(lear:(dy hen our now def dug) q.hic) - [-.res ..^$(our +<.res, dug +>+.res, def +>-.res)] + :_(..^$ ?~(hey.all ~ [u.hey.all %slip %d p.q.hic]~)) + ?: ?=(%init -.q.hic) + [~ ..^$(ore.all `p.q.hic)] + =. hey.all ?^(hey.all hey.all `hen) + =+ nus=(ax hen q.hic) + ?~ nus + ~& [%dill-no-flow q.hic] + [~ ..^$] + =^ moz all abet:(call:u.nus q.hic) + [moz ..^$] :: ++ doze |= [now=@da hen=duct] ^- (unit ,@da) ~ :: -++ load :: XX LEGACY 12-16-2014 - |= $= old - $% [%0 our=ship def=(unit duct) dug=(map duct yord)] - [%1 our=ship def=(unit duct) dug=(map duct yard)] - == - ^+ ..^$ - ?- -.old - %1 %_(..^$ our our.old, def def.old, dug dug.old) - %0 %= $ - old - %= old - - %1 - dug (~(run by dug.old) |=(yor=yord [p q r | *@da]:yor)) - == - == - == +++ load :: totally disabled + |= old=* + :: |= old=axle + :: ..^$(all old) + ..^$(ore.all `~zod) :: ++ scry |= [fur=(unit (set monk)) ren=@tas his=ship syd=desk lot=coin tyl=path] ^- (unit (unit (pair mark ,*))) - [~ ~ [%tank >dug<]] + [~ ~] +:: +++ stay all :: -++ stay [%1 our def dug] ++ take :: process move |= [tea=wire hen=duct hin=(hypo sign)] ^- [p=(list move) q=_..^$] - =+ res=yerk:(leap:(dy hen our now def dug) tea q.hin) - [-.res ..^$(our +<.res, dug +>+.res, def +>-.res)] + ?: =(~ ore.all) + ?: ?=([%a %init *] q.hin) + [[[hen %give +.q.hin] ~] ..^$] + ~& [%take-back q.hin] + [~ ..^$] + ?. (~(has by dug.all) hen) + ~& [%take-weird-sign q.hin] + ~& [%take-weird-hen hen] + [~ ..^$] + =+ our=?>(?=(^ ore.all) u.ore.all) + =^ moz all + abet:(~(take as [~ hen our] (~(got by dug.all) hen)) q.hin) + [moz ..^$] -- diff --git a/arvo/dull.hoon b/arvo/dull.hoon index 925a0498e6..b0a815b5b1 100644 --- a/arvo/dull.hoon +++ b/arvo/dull.hoon @@ -3,6 +3,20 @@ :: |= pit=vase => |% :: interface tiles +++ axle :: all dill state + $: %2 :: + ore=(unit ship) :: identity once set + hey=(unit duct) :: default duct + dug=(map duct axon) :: conversations + == :: +++ axon :: dill per duct + $: ram=term :: console program + wid=_80 :: terminal width + pos=@ud :: cursor position + see=(list ,@c) :: current line + == :: +-- :: +=> |% :: console protocol ++ console-action :: console to app $% [%det console-change] :: edit prompt line [%inn ~] :: enter session @@ -55,21 +69,6 @@ [%sav p=path q=@] :: save to file == :: ++ gill ,@tas :: general contact --- :: -=> |% :: console protocol -++ axle :: all dill state - $: %2 :: - ore=(unit ship) :: identity once set - hey=(unit duct) :: default duct - dug=(map duct axon) :: conversations - == :: -++ axon :: dill per duct - $: ram=term :: console program - tem=(unit (list dill-belt)) :: pending, reverse - wid=_80 :: terminal width - pos=@ud :: cursor position - see=(list ,@c) :: current line - == :: -- => :: |% :: protocol below ++ blew ,[p=@ud q=@ud] :: columns rows @@ -135,9 +134,6 @@ $% [%make p=(unit ,@t) q=@ud r=@ s=?] :: [%sith p=@p q=@uw r=?] :: == :: -++ note-clay :: wait for clay, hack - $% [%warp p=sock q=riff] :: - == :: ++ note-dill :: note to self, odd $% [%crud p=@tas q=(list tank)] :: [%text p=tape] :: @@ -153,18 +149,15 @@ == :: ++ note :: $% [%a note-ames] :: out request $-> - [%c note-clay] [%d note-dill] :: [%g note-gall] :: == :: ++ riff ,[p=desk q=(unit rave)] :: see %clay ++ sign-ames :: $% [%nice ~] :: - [%init p=ship] :: == :: ++ sign-clay :: $% [%note p=@tD q=tank] :: - [%writ p=riot] :: == :: ++ sign-gall :: $% [%crud p=@tas q=(list tank)] :: @@ -200,7 +193,6 @@ ?+ -.kyz ~& [%strange-kiss -.kyz] +> %flow +> %belt (send `dill-belt`p.kyz) - %text (dump %blit [%lin (tuba p.kyz)]~) %crud (send `dill-belt`[%cru p.kyz q.kyz]) %blew (send %rez p.p.kyz q.p.kyz) %veer (dump kyz) @@ -234,31 +226,15 @@ (done %blit [bit ~]) :: ++ init :: initialize - ~& [%dill-init our] - =+ myt=(flop (need tem)) - |- ^+ +> - ?~ myt +>(tem ~) - $(myt t.myt, +> (send i.myt)) - :: - ++ into :: preinitialize |= gyl=(list gill) - ~& [%dill-into our] - %_ +> - tem `(turn gyl |=(a=gill [%yow a])) - moz - :_ moz - :* hen - %pass - / - %c - [%warp [our our] %main `[%& %y [%ud 1] /]] - == - == + ^+ +> + =. moz :_(moz [hen %pass ~ %g %show [our [ram ~]] our ~]) + |- ^+ +>.^$ + ?~ gyl +>.^$ + $(gyl t.gyl, +>.^$ (send %yow i.gyl)) :: ++ send :: send action |= bet=dill-belt - ?^ tem - +>(tem `[bet u.tem]) %_ +> moz :_ moz @@ -272,15 +248,9 @@ [%a %nice *] :: ~& [%take-nice-ames sih] +> - :: - [%a %init *] - !! :: handled outside :: [%c %note *] (from %out (tuba ~(ram re q.+.sih))) - :: - [%c %writ *] - init :: [%g %crud *] (send %cru p.+.sih q.+.sih) @@ -310,14 +280,7 @@ ?. ?=(%flow -.kyz) ~ %- some %. q.kyz - %~ into as - :- [~ hen u.ore.all] - :* p.kyz - [~ ~] - 80 - 0 - (tuba "<{(trip p.kyz)}>") - == + ~(init as [~ hen u.ore.all] [p.kyz 80 0 (tuba "<{(trip p.kyz)}>")]) -- |% :: poke/peek pattern ++ call :: handle request @@ -341,7 +304,6 @@ :_(..^$ ?~(hey.all ~ [u.hey.all %slip %d p.q.hic]~)) ?: ?=(%init -.q.hic) [~ ..^$(ore.all `p.q.hic)] - ~& [%dill-call q.hic] =. hey.all ?^(hey.all hey.all `hen) =+ nus=(ax hen q.hic) ?~ nus @@ -356,8 +318,8 @@ ~ :: ++ load :: totally disabled - |= old=axle - ..^$(all old) + |= old=* + ..^$(ore.all `~zod) :: ++ scry |= [fur=(unit (set monk)) ren=@tas his=ship syd=desk lot=coin tyl=path] @@ -370,8 +332,6 @@ |= [tea=wire hen=duct hin=(hypo sign)] ^- [p=(list move) q=_..^$] ?: =(~ ore.all) - ?: ?=([%a %init *] q.hin) - [~ ..^$(ore.all `p.+.q.hin)] ~& [%take-back q.hin] [~ ..^$] ?. (~(has by dug.all) hen) diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index cf1553bfc4..7e8114bbe7 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -512,6 +512,7 @@ :: ++ poke-dill-belt |= [ost=bone her=ship bet=dill-belt] + :: ~& %seat-poke ^- [(list move) _+>] =< se-abet =< se-view From 05bf34d1956fdd7f468160f6fcc171dcddb902f5 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Wed, 18 Mar 2015 09:42:15 -0700 Subject: [PATCH 087/219] Owen Rescher as owner of carriers 58 and 201. --- arvo/ames.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arvo/ames.hoon b/arvo/ames.hoon index 62d6de61be..ff277e37a0 100644 --- a/arvo/ames.hoon +++ b/arvo/ames.hoon @@ -227,7 +227,7 @@ 0w0 :: 55, ~tep, Curtis Yarvin (sator) 0w0 :: 56, ~bes, Curtis Yarvin (sator) 0w0 :: 57, ~dex, Jared Hance (aestas) - 0w0 :: 58, ~sef, Curtis Yarvin (sator) + 0w0 :: 58, ~sef, Owen Rescher (lex) 0w0 :: 59, ~wyc, Curtis Yarvin (sator) 0w0 :: 60, ~bur, Curtis Yarvin (sator) 0w0 :: 61, ~der, Curtis Yarvin (sator) @@ -370,7 +370,7 @@ 0w0 :: 198, ~len, Tlon (gleba) 0w0 :: 199, ~ner, Tlon (gleba) 0wv.aixe9.7gG2w.7cJiy.i3Mg8 :: 200, ~lex, Michael Hartl (donum) - 0w0 :: 201, ~rup, Tlon (gleba) + 0w0 :: 201, ~rup, Owen Rescher (lex) 0w0 :: 202, ~ned, Tlon (gleba) 0w0 :: 203, ~lec, Tlon (gleba) 0w0 :: 204, ~ryd, Tlon (gleba) From 845f09beffc92fee4e702e30ca1ae587a7b99137 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Wed, 18 Mar 2015 15:01:47 -0700 Subject: [PATCH 088/219] :begin on cruiser works. --- arvo/ames.hoon | 4 ++-- arvo/dill.hoon | 47 ++++++++++++++++++++++++++++++++--------- arvo/gall.hoon | 1 + main/app/dojo/core.hook | 3 ++- main/app/helm/core.hook | 6 ++++++ 5 files changed, 48 insertions(+), 13 deletions(-) diff --git a/arvo/ames.hoon b/arvo/ames.hoon index 62d6de61be..26a3632f8d 100644 --- a/arvo/ames.hoon +++ b/arvo/ames.hoon @@ -1662,7 +1662,7 @@ ?- -.bon %beer :_ fox(zac (~(put by zac.fox) p.bon `corn`[hen ~ ~ ~])) - :: ~& [%ames-clop p.bon hen] + ~& [%ames-clop p.bon hen] :* [hen [%slip %c %init p.bon]] [hen [%give %init p.bon]] [hen [%slip %a %kick now]] @@ -1696,7 +1696,7 @@ :+ (scot %p p.p.bon) (scot %p q.p.bon) q.q.bon - [hen %pass pax %g %rote p.bon /began 0 %m %will wil]~ + [hen %pass pax %g %rote p.bon /helm 0 %m %will wil]~ ?> ?=([@ @ *] t.q.q.bon) :_ fox =+ [cak=i.t.q.q.bon ven=i.t.t.q.q.bon] diff --git a/arvo/dill.hoon b/arvo/dill.hoon index 108306dd5b..fcd6d43f23 100644 --- a/arvo/dill.hoon +++ b/arvo/dill.hoon @@ -166,6 +166,9 @@ $% [%note p=@tD q=tank] :: [%writ p=riot] :: == :: +++ sign-dill :: + $% [%blit p=(list blit)] :: + == :: ++ sign-gall :: $% [%crud p=@tas q=(list tank)] :: [%mean p=ares] :: @@ -178,6 +181,7 @@ ++ sign :: in result $<- $% [%a sign-ames] :: [%c sign-clay] :: + [%d sign-dill] :: [%g sign-gall] :: [%t sign-time] :: == :: @@ -202,14 +206,24 @@ %harm +> %hail +> %belt (send `dill-belt`p.kyz) - %text (dump %blit [%lin (tuba p.kyz)]~) - %crud (send `dill-belt`[%cru p.kyz q.kyz]) + %text (from %out (tuba p.kyz)) + %crud :: (send `dill-belt`[%cru p.kyz q.kyz]) + (crud p.kyz q.kyz) %blew (send %rez p.p.kyz q.p.kyz) %veer (dump kyz) %vega (dump kyz) %verb (dump kyz) == :: + ++ crud + |= [err=@tas tac=(list tank)] + =+ ^= wol ^- wall + :- (trip err) + (zing (turn tac |=(a=tank (~(win re a) [0 wid])))) + |- ^+ +>.^$ + ?~ wol +>.^$ + $(wol t.wol, +>.^$ (from %out (tuba i.wol))) + :: ++ dump :: pass down to hey |= git=gift ?> ?=(^ hey.all) @@ -284,9 +298,13 @@ :: [%c %writ *] init + :: + [%d %blit *] + (done +.sih) :: [%g %crud *] - (send %cru p.+.sih q.+.sih) + (crud p.+.sih q.+.sih) + :: (send %cru p.+.sih q.+.sih) :: [%g %mean *] +>(moz [[hen %give %logo ~] moz]) @@ -342,10 +360,17 @@ ?: ?=(%boot -.q.hic) :_(..^$ [hen %pass ~ (note %a p.q.hic)]~) ?: ?=(%flog -.q.hic) + :: ~& [%dill-flog +.q.hic] :_(..^$ ?~(hey.all ~ [u.hey.all %slip %d p.q.hic]~)) - ?: ?=(%init -.q.hic) - [~ ..^$(ore.all `p.q.hic)] =. hey.all ?^(hey.all hey.all `hen) + ?: ?=(%init -.q.hic) + ?: =(ore.all `p.q.hic) + [~ ..^$] + =: ore.all `p.q.hic + dug.all ~ + == + =^ moz all abet:(need (ax (need hey.all) [%flow %seat %dojo ~])) + [moz ..^$] =+ nus=(ax hen q.hic) ?~ nus ~& [%dill-no-flow q.hic] @@ -358,11 +383,11 @@ ^- (unit ,@da) ~ :: -++ load :: totally disabled - |= old=* - :: |= old=axle - :: ..^$(all old) - ..^$(ore.all `~zod) +++ load :: trivial + |= old=axle + ..^$(all old) + :: |= old=* :: diable + :: ..^$(ore.all `~zod) :: ++ scry |= [fur=(unit (set monk)) ren=@tas his=ship syd=desk lot=coin tyl=path] @@ -376,6 +401,8 @@ ^- [p=(list move) q=_..^$] ?: =(~ ore.all) ?: ?=([%a %init *] q.hin) + ~& [%dill-take-dump-init hen +.q.hin] + =. hey.all ?^(hey.all hey.all `hen) [[[hen %give +.q.hin] ~] ..^$] ~& [%take-back q.hin] [~ ..^$] diff --git a/arvo/gall.hoon b/arvo/gall.hoon index 19a1a25290..168c423f9c 100644 --- a/arvo/gall.hoon +++ b/arvo/gall.hoon @@ -1231,6 +1231,7 @@ =+ sam=!>([p.kon q.kon]) ?> ?=(^ huv.sat) (yawl [%peek (scot %p p.kon) q.kon] leaf/"peeking" u.huv.sat sam) + ~& [%show-dumb app.sat imp q.kon] (give(qic.sat ~) %dumb ~) :: %sire diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index efbba9c805..19001baaa9 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -31,7 +31,8 @@ q=dojo-build :: general build == :: ++ dojo-build :: one ford step - $% [%ex p=twig] :: hoon expression + $% :: [%ca p=mark q=dojo-build] :: cast + [%ex p=twig] :: hoon expression [%di p=dojo-model] :: dialog [%dv p=path] :: gate from source [%fi p=(list dojo-filter) q=dojo-source] :: filter pipeline diff --git a/main/app/helm/core.hook b/main/app/helm/core.hook index 03a2ea9bc7..c5fda5df87 100644 --- a/main/app/helm/core.hook +++ b/main/app/helm/core.hook @@ -134,6 +134,11 @@ ~& %poke-helm-reset he-abet:he-wish-reset:(hake ost her) :: +++ poke-helm-verb + |= [ost=bone her=ship ~] + ~& %poke-helm-verb + he-abet:he-wish-verb:(hake ost her) +:: ++ poke-helm-reload |= [ost=bone her=ship all=(list term)] ~& %poke-helm-reload @@ -159,6 +164,7 @@ :_ +>.$(bur ~) ?~ wil [ost %give %mean ~ %rejected ~]~ + ~& [%poke-will-good bur] :~ [ost %pass / %a %cash p.u.bur q.u.bur u.wil] [ost %pass / %c %plug our.hid %main (sein our.hid) %main] [ost %pass / %c %plug our.hid %arvo (sein our.hid) %arvo] From 1a4c4825d336559fdd5230434f9a5b84db4b3775 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 18 Mar 2015 17:22:20 -0700 Subject: [PATCH 089/219] Subscription polling up --- arvo/eyre.hoon | 111 +++++++++++++++++++++++++++++++++---------------- arvo/hoon.hoon | 1 + 2 files changed, 77 insertions(+), 35 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 17bd89e655..27f05a5df8 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -137,7 +137,7 @@ [%away ~] [%bugs p=?(%as %to) ~] [%mess p=hasp q=mark r=json] - [%subs p=hasp q=path] + [%subs p=hasp %json q=path] [%deps p=@uvH q=?(%del %put)] [%view p=ixor q=[~ u=@ud]] == @@ -347,18 +347,26 @@ ++ axon :: accept response |= [tee=whir typ=type sih=sign] ^+ +> + ~? ?=(%g -.sih) e/+<.sih =. our ?~(hov our u.hov) :: XX ?- -.+.sih %crud +>.$(mow [[hen %slip %d %flog +.sih] mow]) :: - ?(%dumb %rush %rust) ~|(%gall-stub !!) - %nice ?>(?=(~ tee) (nice-json)) :: XX subscriptions + %dumb ~|(%gall-stub !!) + ?(%rush %rust) + ?> ?=([%is ^] tee) + %- ~(get-even ix p.tee (~(got by wix) p.tee)) + ?> ?=(%json p.sih) :: XX cage + =+ dat=[(crip (pojo ;;(json q.sih)))]~ + [%rush [(pick-hasp q.tee) r.tee] dat] + :: + %nice ?>(?=($|(~ [%is ^]) tee) (nice-json)) %mean ?>(?=(~ tee) (mean-json 500 p.sih)) %wake ?> ?=([%of ^] tee) => ~(wake ix p.tee (~(got by wix) p.tee)) - (give-json 200 ~ %b &) + (give-json 200 ~ (joba %beat %b &)) :: %news :: dependency updated ?. ?=([%on ^] tee) @@ -367,7 +375,6 @@ %+ roll (~(tap in (~(get ju liz) dep))) =< .(con ..axon(liz (~(del by liz) dep))) |= [sus=(each duct ixor) con=_..axon] - ~& sus ?- -.sus %& (give-json(hen p.sus) 205 ~ %b &) %| %- ~(get-even ix p.sus (~(got by wix) p.sus)) @@ -499,12 +506,13 @@ (make-resp-gift sas application//json (crip (pojo jon))) :: ++ nice-json |=(* (give-json 200 ~ (joba %ok %b &))) - ++ mean-json - |= [sas=@uG are=ares] - =- (give-json sas ~ (jobe fail/s/typ mess/(jape err) ~)) - ^- [typ=term err=tape] - ?~ are [%fail "Unknown Error"] - [p.u.are (wush 160 q.u.are)] + ++ mean-json |=([sas=@uG err=ares] (give-json sas ~ (ares-to-json err))) + ++ ares-to-json + |= err=ares + =- (jobe fail/s/typ mess/(jape mez) ~) + ^- [typ=term mez=tape] + ?~ err [%fail "Unknown Error"] + [p.u.err (wush 160 q.u.err)] :: ++ add-cookies |= [cug=(list ,@t) git=[%thou httr]] @@ -645,11 +653,21 @@ [our (raid but %tas %tas ~)] :: %in - ~| expect/[%post '.json' /'@uv' '?PUT/DELETE'] + ~| expect/[%post 'application/json' /'@uv' '?PUT/DELETE'] ?> ?=([%post $|(~ [~ %json])] [mef p.pok]) :+ %deps (raid but %uv ~) ?+(quy !! [[%'DELETE' ~] ~] %del, [[%'PUT' ~] ~] %put) + :: + %is + ?~ but + ~|(no-app/but=but !!) + |- ^- perk + ?~ p.pok $(p.pok [~ %json]) + ?> ?=(%json u.p.pok) :: XX marks + ?: ((sane %tas) i.but) + $(but [(scot %p our) but]) + [%subs [(slav %p i.but) (slav %tas -.t.but)] u.p.pok +.t.but] :: %auth :- %auth @@ -689,21 +707,24 @@ =. our ?~(oar our u.oar) :: XX =+ pez=process ?: ?=(%| -.pez) p.pez :: XX transitional - |- ^+ done - ?- -.p.pez - %for (beam-into-ford +.p.pez) - %fot (ford-req p.p.pez our [%cast q.p.pez %done ~ r.p.pez]) - %gap (pass-note ~ %g [%mess +.p.pez]) - %gas (pass-note p.p.pez %g [%show +>.p.pez]) - %zap (fail p.p.pez 0v0 q.p.pez) - %fin (finish +.p.pez) + (handle-pest p.pez) + :: + ++ handle-pest + |= pez=pest ^+ done + ?- -.pez + %for (beam-into-ford +.pez) + %fot (ford-req p.pez our [%cast q.pez %done ~ r.pez]) + %gap (pass-note ~ %g [%mess +.pez]) + %gas (pass-note p.pez %g [%show +>.pez]) + %zap (fail p.pez 0v0 q.pez) + %fin (finish +.pez) %red =+ url=(earn hat pok(p [~ %html]) quy) ?+ p.pok (fail 404 0v0 leaf/"bad redirect" leaf/ leaf/url ~) [~ %js] - $(p.pez [%fin %js (crip "document.location = '{url}'")]) + $(pez [%fin %js (crip "document.location = '{url}'")]) [~ %json] - $(p.pez [%fin %json (jobe ok/b/| red/(jape url) ~)]) + $(pez [%fin %json (jobe ok/b/| red/(jape url) ~)]) == == :: @@ -764,6 +785,7 @@ :: %deps =+ ire=(oryx-to-ixor (grab-body to-oryx)) + ?> (~(has by wix) ire) :: XX made redundant by oryx checking =< [%| (nice-json)] ?- q.hem %del done(liz (~(del ju liz) p.hem %| ire)) @@ -813,14 +835,17 @@ =. ..ya abet.yac =+ pez=process(pok p.hem) ?. ?=(%& -.pez) ~|(no-inject/p.hem !!) - ?+ -.p.pez ~&(bad-inject/p.pez !!) - ?(%zap %red) pez - %for pez(p.p [%at ses.yac p.p.pez]) - %fin - ~| %not-script - ?> ?=(%js &2.p.pez) - =^ jon ..ya stat-json:for-client - [%| (finish +.p.pez(p (jass jon p.p.pez)))] :: XX better storage? + ?+ -.p.pez ~&(bad-inject/p.pez !!) + ?(%zap %red) + pez + %for + =. ..ya abet:for-client + [%| (handle-pest p.pez(p [%at ses.yac p.p.pez]))] :: XX better storage? + %fin + ~| %not-script + ?> ?=(%js &2.p.pez) + =^ jon ..ya stat-json:for-client + [%| (finish +.p.pez(p (jass jon p.p.pez)))] :: XX better storage? == :: %try @@ -992,6 +1017,7 @@ ++ done . ++ abet ..ix(wix (~(put by wix) ire sem)) ++ teba |*(a=$+(* ..ix) |*(b=* %_(done ..ix (a b)))) + ++ give-json (teba ^give-json) ++ pass-note (teba ^pass-note) :: ++ poll @@ -1004,24 +1030,39 @@ ?: (gth a p.eve) ~|(seq-high/cur=p.eve !!) =+ ven=~|(seq-low/cur=p.eve (~(got by q.eve) a)) =. q.eve (~(del by q.eve) (dec a)) :: TODO ponder a-2 - abet:(give-even & ven) + abet:(give-even & a ven) :: ++ get-rush - |= [a=[hasp path] b=octs] + |= [a=[hasp path] b=octs] ^+ ..ix (get-even [%rush a [q.b]~]) :: XX multiline :: ++ get-even |= ven=even ^+ ..ix + =+ num=p.eve =. eve (add-even ven) =< abet ?~ ude done - (give-even(hen p.u.ude, ude ~) q.u.ude ven) + (give-even(hen p.u.ude, ude ~) q.u.ude num ven) :: ++ add-even |= a=even ^+ eve [+(p.eve) (~(put by q.eve) p.eve a)] :: - ++ give-even ,_`_.`!! + ++ give-even + |= [pol=? num=@u ven=even] ^+ done + ?> pol :: XX eventstream + %^ give-json 200 ~ + %^ jobe id/(jone num) type/[%s -.ven] + ?- -.ven + %news ~[from/[%s (scot %uv p.ven)]] + %rush ~[from/(subs-to-json p.ven) data/[%s (role q.ven)]] + %mean ~[from/(subs-to-json p.ven) data/(ares-to-json q.ven)] + == + :: + ++ subs-to-json + |= [a=hasp b=path] + (jobe ship/[%s (scot %p p.a)] appl/[%s q.a] path/(jape (spud b)) ~) + :: ++ wait-era (pass-note of//[ire] [%t %wait era]) ++ wake ^+(..ix abet(ude ~)) :: XX other effects? -- -- @@ -1062,7 +1103,7 @@ ~ :: ++ load :: clam previous state - |= old=_[%0 gub hov ged ney dop liz wup sop **] + |= old=_[%0 gub hov ged ney dop liz=liz wup sop wix] ^+ ..^$ ..^$(+>- (bolo old)) :: diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index 471521d55a..1eafd7971f 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -6141,6 +6141,7 @@ => .(p.gen `[@ ^ @ p=@tas ~]`p.gen) :+ %sgzp [[%dtzz %tas 'slam'] [%dtzz %tas p.p.gen]] rem + :: [%cndt *] [%cnhp q.gen [p.gen ~]] [%cnkt *] [%cnhp p.gen q.gen r.gen s.gen ~] [%cnls *] [%cnhp p.gen q.gen r.gen ~] From b5a4f6784a7ee5b71d632412493aab6b0e6fceb2 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Wed, 18 Mar 2015 21:12:23 -0700 Subject: [PATCH 090/219] Make prefix error system work properly. --- main/app/dojo/core.hook | 14 ++++++++------ main/lib/console/core.hook | 8 ++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 19001baaa9..343df5040a 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -420,9 +420,7 @@ ++ dy-edit :: handle edit |= cal=console-change ^+ +>+> - =+ old=buf.say - =^ dat say (~(receive cs say) cal) - =. dat (~(inverse cs say(buf old)) dat) + =^ dat say (~(transceive cs say) cal) ?: |(?=(^ per) ?=(^ pux) ?=(~ pro)) ~& %dy-edit-busy =^ lic say (~(transmit cs say) dat) @@ -602,10 +600,14 @@ ++ he-stir :: apply change |= cal=console-change ^+ +> - =^ dut say (~(remit cs say) cal he-like) - ?~ dut + =^ dat say (~(transceive cs say) cal) + ?. ?& ?=(%del -.dat) + =(+(p.dat) (lent buf.say)) + =(%| -:(he-dope (tufa buf.say))) + == +>.$ - (he-rush %mor [%det u.dut] [%bel ~] ~) + =^ lic say (~(transmit cs say) dat) + (he-rush %mor [%bel ~] [%det lic] ~) :: ++ he-plan :: execute command |= mad=dojo-command diff --git a/main/lib/console/core.hook b/main/lib/console/core.hook index 6d10796dd2..c85345163e 100644 --- a/main/lib/console/core.hook +++ b/main/lib/console/core.hook @@ -159,6 +159,7 @@ ++ inverse :: relative inverse |= ted=console-edit ^- console-edit + =. ted ?.(?=([%mor * ~] ted) ted i.p.ted) ?- -.ted %del [%ins p.ted (snag p.ted buf)] %ins [%del p.ted] @@ -177,6 +178,13 @@ ^- [console-change console-share] [[[his.ven own.ven] (sham buf) ted] (commit ted)] :: + ++ transceive :: receive and invert + |= console-change + ^- [console-edit console-share] + =+ old=buf + =^ dat +>+<.$ (receive +<.$) + [(inverse(buf old) dat) +>+<.$] + :: ++ receive :: naturalize event |= console-change ^- [console-edit console-share] From 818ff11b2f9a23f0f88ad98523e8924419bce926 Mon Sep 17 00:00:00 2001 From: Galen Wolfe-Pauly Date: Thu, 19 Mar 2015 11:29:20 -0700 Subject: [PATCH 091/219] hanging talk --- main/pub/talk/src/js/actions/MessageActions.coffee | 2 -- main/pub/talk/src/js/components/StationsComponent.coffee | 6 +++--- main/pub/talk/src/js/stores/StationStore.coffee | 7 +++++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/main/pub/talk/src/js/actions/MessageActions.coffee b/main/pub/talk/src/js/actions/MessageActions.coffee index d904fadcdb..da23ff5dad 100644 --- a/main/pub/talk/src/js/actions/MessageActions.coffee +++ b/main/pub/talk/src/js/actions/MessageActions.coffee @@ -1,7 +1,5 @@ MessageDispatcher = require '../dispatcher/Dispatcher.coffee' -# hm - module.exports = loadMessages: (grams,get) -> MessageDispatcher.handleServerAction diff --git a/main/pub/talk/src/js/components/StationsComponent.coffee b/main/pub/talk/src/js/components/StationsComponent.coffee index 1d1aea5866..7940a2aae5 100644 --- a/main/pub/talk/src/js/components/StationsComponent.coffee +++ b/main/pub/talk/src/js/components/StationsComponent.coffee @@ -13,9 +13,9 @@ module.exports = recl getInitialState: -> @stateFromStore() componentDidMount: -> - @$el = $(@getDOMNode()) - @$add = $('#stations .add') - @$input = @$el.find('input') + @$el = $ @getDOMNode() + @$add = $ '#stations .add' + @$input = @$el.find 'input' StationStore.addChangeListener @_onChangeStore componentWillUnmount: -> diff --git a/main/pub/talk/src/js/stores/StationStore.coffee b/main/pub/talk/src/js/stores/StationStore.coffee index c7b8940ca4..27a16970fa 100644 --- a/main/pub/talk/src/js/stores/StationStore.coffee +++ b/main/pub/talk/src/js/stores/StationStore.coffee @@ -111,7 +111,7 @@ StationStore.dispatchToken = StationDispatcher.register (payload) -> StationStore.setListening action.station StationStore.emitChange() break - when "config-load" + when "config-load" #[name:'loadConfig', args:['station', 'config']] StationStore.loadConfig action.station,action.config StationStore.emitChange() break @@ -119,7 +119,10 @@ StationStore.dispatchToken = StationDispatcher.register (payload) -> StationStore.loadStations action.stations StationStore.emitChange() break - when "stations-leave" + when "stations-leave" # stations-leave:[{name:'loadStations' args:['stations']} ['unsetStation' 'station']] + # ... + # for command in actionVtable[action.type] + # StationStore[command[0]].apply(command[1..].map(argname -> action[argname])) StationStore.loadStations action.stations StationStore.unsetStation action.station StationStore.emitChange() From 035230dd135ecc09bb109d26aec8faf8fa41688d Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Thu, 19 Mar 2015 11:53:05 -0700 Subject: [PATCH 092/219] Proper error handling in console. --- main/app/dojo/core.hook | 17 +++--- main/app/seat/core.hook | 6 +++ main/lib/console/core.hook | 104 +++++++------------------------------ main/sur/console/core.hook | 1 + 4 files changed, 31 insertions(+), 97 deletions(-) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 343df5040a..f18b8d9b70 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -523,8 +523,8 @@ ++ he-dope :: sole user of ++dp |= txt=tape :: ^- (each (unit dojo-command) hair) :: prefix/result - =+ vex=(dp-command:dp [1 1] txt) - ?. =(+((lent txt)) q.p.vex) :: fully parsed + =+ vex=(dp-command:dp [0 0] txt) :: + ?. =((lent txt) q.p.vex) :: fully parsed [%| p.vex] :: syntax error [%& ?~(q.vex ~ `p.u.q.vex)] :: prefix/complete :: @@ -603,11 +603,12 @@ =^ dat say (~(transceive cs say) cal) ?. ?& ?=(%del -.dat) =(+(p.dat) (lent buf.say)) - =(%| -:(he-dope (tufa buf.say))) == +>.$ + =+ foy=(he-dope (tufa buf.say)) + ?: ?=(%& -.foy) +>.$ =^ lic say (~(transmit cs say) dat) - (he-rush %mor [%bel ~] [%det lic] ~) + (he-rush %mor [%det lic] [%err q.p.foy] ~) :: ++ he-plan :: execute command |= mad=dojo-command @@ -620,13 +621,7 @@ ^+ +> =+ doy=(he-duke txt) ?- -.doy - %| - %- he-rush - :~ %mor - [%tan [%leaf "syntax error at {}"]~] - [%bel ~] - == - :: + %| (he-rush [%err p.doy]) %& =+ old=(weld "> " (tufa buf.say)) =^ cal say (~(transmit cs say) [%set ~]) diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index 7e8114bbe7..1cc3df1b15 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -343,6 +343,11 @@ .(+> (se-blit %bel ~)) (ta-hom %del pos.inp) :: + ++ ta-err :: hear error + |= pos=@ud + =. pos (~(transpose cs say.inp) pos) + ta-bel(pos.inp (min pos (lent buf.say.inp))) + :: ++ ta-fec :: apply effect |= fec=console-effect ^+ +> @@ -351,6 +356,7 @@ %blk +> %clr +>(+> (se-blit fec)) %det (ta-got +.fec) + %err (ta-err +.fec) %mor |- ^+ +>.^$ ?~ p.fec +>.^$ $(p.fec t.p.fec, +>.^$ ^$(fec i.p.fec)) diff --git a/main/lib/console/core.hook b/main/lib/console/core.hook index c85345163e..5d64871f5b 100644 --- a/main/lib/console/core.hook +++ b/main/lib/console/core.hook @@ -12,80 +12,6 @@ ++ cs :: shared-state engine |_ console-share ++ abet +< - ++ apex :: engine by rule - |* sef=_rule - |= act=console-action - ^+ [[p=*(list console-effect) q=(rust ~ sef)] *console-share] - ?- -.act - %det - =^ dut +<.apex - %+ remit +.act - |= buf=(list ,@c) - =+ txt=(tufa buf) - =((lent txt) q.p:(sef [0 0] txt)) - [[?~(dut ~ [[%det u.dut] [%bel ~] ~]) ~] +<.apex] - :: - %ret - =+ dod=(rust (tufa buf) sef) - ?~ dod - [[[%bel ~]~ ~] +<.apex] - =^ cal +<.apex (transmit [%set ~]) - :_ +<.apex - :_ dod - :~ [%det cal] - [%nex ~] - == - == - ++ apse :: dialog engine - |* dog=(console-dialog) - |= act=(unit console-action) - =< abet |% - ++ abet - ?~ act (ajar ~) - ?- -.u.act - %det - =^ dut +<.apse - %+ remit +.u.act - |= buf=(list ,@c) - !=(~ (dog `(tufa buf))) - :_ +<.apse - :_ dog - :_ q=[~ u=~] - ^= p ^- (list console-effect) - ?~(dut ~ [[%det u.dut] [%bel ~] ~]) - :: - %ret (ajar `(tufa buf)) - == - ++ ajar - |= unp=(unit console-input) - =+ god=(dog unp) - ?: |(?=(~ god) ?=(~ u.god)) - :_ +<.apse - :_ dog - :- p=`(list console-effect)`[%bel ~]~ - q=[~ u=~] - =+ fex=`(list console-effect)`[%tan p.u.u.god]~ - ?- -.q.u.u.god - %& - :_ +<.apse - :_ dog - :- p=fex - q=?~(p.q.u.u.god ~ [~ u=p.q.u.u.god]) - :: - %| - =^ cal +<.apse (transmit [%set ~]) - :_ +<.apse - :_ q.p.q.u.u.god - :_ q=[~ u=~] - ^= p ^+ fex - :* [%det cal] - [%nex ~] - [%pro p.p.q.u.u.god] - fex - == - == - -- - :: ++ apply |= ted=console-edit ^+ +> @@ -173,18 +99,6 @@ %set [%set buf] == :: - ++ transmit :: outgoing change - |= ted=console-edit - ^- [console-change console-share] - [[[his.ven own.ven] (sham buf) ted] (commit ted)] - :: - ++ transceive :: receive and invert - |= console-change - ^- [console-edit console-share] - =+ old=buf - =^ dat +>+<.$ (receive +<.$) - [(inverse(buf old) dat) +>+<.$] - :: ++ receive :: naturalize event |= console-change ^- [console-edit console-share] @@ -204,5 +118,23 @@ [~ +>+<.$] =^ lic +>+<.$ (transmit (inverse(buf old) dat)) [`lic +>+<.$] + :: + ++ transmit :: outgoing change + |= ted=console-edit + ^- [console-change console-share] + [[[his.ven own.ven] (sham buf) ted] (commit ted)] + :: + ++ transceive :: receive and invert + |= console-change + ^- [console-edit console-share] + =+ old=buf + =^ dat +>+<.$ (receive +<.$) + [(inverse(buf old) dat) +>+<.$] + :: + ++ transpose :: adjust position + |= pos=@ud + =+ dat=(transmute [%mor leg] [%ins pos `@c`0]) + ?> ?=(%ins -.dat) + p.dat -- -- diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook index 86a9a62689..84d0663b3d 100644 --- a/main/sur/console/core.hook +++ b/main/sur/console/core.hook @@ -63,6 +63,7 @@ [%blk p=@ud q=@c] :: blink/match char at [%clr ~] :: clear screen [%det console-change] :: edit command + [%err p=@ud] :: error point [%mor p=(list console-effect)] :: multiple effects [%nex ~] :: save, clear command [%pro console-prompt] :: set prompt From 07c8272986b6210971be18f3417c01eda7f1230f Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Thu, 19 Mar 2015 11:53:45 -0700 Subject: [PATCH 093/219] Forgot the ticket. --- main/gun/ticket/gate.hook | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 main/gun/ticket/gate.hook diff --git a/main/gun/ticket/gate.hook b/main/gun/ticket/gate.hook new file mode 100644 index 0000000000..39b9b2df8a --- /dev/null +++ b/main/gun/ticket/gate.hook @@ -0,0 +1,13 @@ +:: +:::: /hook/gate/ticket/gun + :: +/? 314 +/- *console +:: +:::: + !: +|= $: [now=@da bec=beak] + [[her=@p ~] ~] + == +%+ console-so %noun +((hard ,@p) .^(/a/(scot %p p.bec)/tick/(scot %da now)/(scot %p her))) From b65636a0bfbb62ce67c14f14a928b47ab5ac83b1 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Thu, 19 Mar 2015 12:58:54 -0700 Subject: [PATCH 094/219] Change prompt to ++tape. --- main/app/dojo/core.hook | 2 +- main/app/seat/core.hook | 13 ++++++------- main/sur/console/core.hook | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index f18b8d9b70..10c0f5790c 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -574,7 +574,7 @@ ++ he-prom :: send prompt %- he-rush :- %pro - [& %$ (tuba (weld (scow %p our.hid) ":dojo> "))] + [& %$ (weld (scow %p our.hid) ":dojo> ")] :: ++ he-made :: result from ford |= [pax=path rey=(each bead (list tank))] diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index 1cc3df1b15..45740e001d 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -476,16 +476,15 @@ ?^ ris %= $ ris ~ - cap.pom - `(list ,@)`:(welp "(reverse-i-search)'" str.u.ris "': ") + cad.pom + :(welp "(reverse-i-search)'" (tufa str.u.ris) "': ") == - =- [(add pos.inp (lent p.vew)) (weld p.vew q.vew)] - ^= vew ^- (pair (list ,@c) (list ,@c)) - ?: vis.pom [cap.pom buf.say.inp] + =- [(add pos.inp (lent p.vew)) (weld (tuba p.vew) q.vew)] + ^= vew ^- (pair tape (list ,@c)) + ?: vis.pom [cad.pom buf.say.inp] :- ;: welp - cap.pom + cad.pom ?~ buf.say.inp ~ - %- tuba ;: welp "<" (scow %p (end 4 1 (sham buf.say.inp))) diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook index 84d0663b3d..d06755051d 100644 --- a/main/sur/console/core.hook +++ b/main/sur/console/core.hook @@ -80,7 +80,7 @@ ++ console-prompt :: prompt definition $: vis=? :: command visible tag=term :: history mode - cap=(list ,@c) :: caption + cad=tape :: caption == :: ++ console-input tape :: prompt input ++ console-share :: symmetric state From 0e3706b22ff0a2ec9ac1894ad4a63534d3c98bad Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Thu, 19 Mar 2015 15:19:19 -0700 Subject: [PATCH 095/219] Fix network. --- arvo/ames.hoon | 6 +++--- main/app/dojo/core.hook | 8 ++++---- main/sur/console/core.hook | 29 +++++++++++++++-------------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/arvo/ames.hoon b/arvo/ames.hoon index 540f13e5f3..4842dc10bd 100644 --- a/arvo/ames.hoon +++ b/arvo/ames.hoon @@ -631,12 +631,12 @@ =^ gim ..weft wisp :_ +>.$ ^- (list rock) - =+ wit=(met ?:(fak.ton 18 13) q.gim) + =+ wit=(met ?:(fak.ton 16 13) q.gim) ?< =(0 wit) ?: =(1 wit) =+ yup=(spit [our her] p.gim q.gim) [yup ~] - =+ ruv=(rip ?:(fak.ton 18 13) q.gim) + =+ ruv=(rip ?:(fak.ton 16 13) q.gim) =+ gom=(shaf %thug q.gim) =+ inx=0 |- ^- (list rock) @@ -1409,7 +1409,7 @@ =+ [nix=0 rax=*(list ,@)] |- ^- @ ?: =(p.duv nix) - (can ?:(fak.ton.fox 18 13) (turn (flop rax) |=(a=@ [1 a]))) + (can ?:(fak.ton.fox 16 13) (turn (flop rax) |=(a=@ [1 a]))) $(nix +(nix), rax [(need (~(get by q.duv) nix)) rax]) -- :: --la:ho:um:am :: diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 10c0f5790c..ac7a2579d8 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -377,7 +377,7 @@ |= cag=cage ^+ +>+> ?> ?=(^ per) - ?^ q.q.cag + ?: |(?=(^ q.q.cag) =((lent buf.say) q.q.cag)) dy-abet(per ~) =^ lic say (~(transmit cs say) u.per) (dy-rush(per ~) %mor [%bel ~] [%det lic] ~) @@ -473,12 +473,12 @@ ++ dy-made-dial :: dialog product |= cag=cage ^+ +>+> - ?. ?=([~ ~ *] q.q.cag) + ?. ?=(^ q.q.cag) ~& %dy-made-dial-fail (dy-rash %bel ~) - =+ tan=((list tank) +14.q.q.cag) + =+ tan=((list tank) +2.q.q.cag) =. +>+>.$ (he-rush %tan tan) - =+ vax=(spec (slot 15 q.cag)) + =+ vax=(spec (slot 3 q.cag)) ?+ -.q.vax !! %& ?~ +.q.vax diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook index d06755051d..6b85e6ff91 100644 --- a/main/sur/console/core.hook +++ b/main/sur/console/core.hook @@ -17,38 +17,39 @@ |* out=$+(* *) :: output structure $+(console-input (console-result out)) :: output function :: :: -++ console-result :: standard output +++ console-result :: conditional result |* out=$+(* *) :: output structure - %- unit :: ~ is invalid - %- unit :: ~ is prefix - %+ pair (list tank) :: + $|(@ud (console-product out)) :: error position +:: :: +++ console-product :: success result + |* out=$+(* *) :: + %+ pair (list tank) :: %+ each (unit out) :: ~ is abort (pair console-prompt (console-dialog out)) :: ask and continue :: :: ++ console-so :: construct result |* pro=* :: - [~ u=[~ u=[p=*(list tank) q=[%& p=[~ u=pro]]]]] :: + [p=*(list tank) q=[%& p=[~ u=pro]]] :: :: :: ++ console-yo :: add output tank |* [tan=tank res=(console-result)] :: - ?~ res ~ :: - ?~ u.res [~ u=~] :: - [~ u=[~ u=[p=[i=tan t=p.u.u.res] q=q.u.u.res]]] :: + ?@ res res :: + [p=[i=tan t=p.res] q=q.res] :: :: :: ++ console-lo :: construct prompt |* [pom=console-prompt mor=(console-dialog)] :: - [~ u=[~ u=[p=*(list tank) q=[%| p=pom q=mor]]]] :: + [p=*(list tank) q=[%| p=pom q=mor]] :: :: :: ++ console-no :: empty result - [~ u=[~ u=[p=*(list tank) q=~]]] :: + [p=*(list tank) q=~] :: :: :: ++ console-go :: parse by rule |* [sef=_rule fun=$+(* *)] :: |= txt=console-input :: - =+ yid=(ruse txt sef) :: - ?~ yid ~ :: - ?~ u.yid [~ u=~] :: - (fun u.u.yid) :: + =+ vex=(sef [0 0] txt) :: + ?: |(!=((lent txt) q.p.vex) ?=(~ q.vex)) :: + q.p.vex :: + (fun p.u.q.vex) :: :: :: ++ console-clock ,[own=@ud his=@ud] :: vector clock ++ console-edit :: shared state change From 4a7b7ea1f401057e2540dccf3f116713a7256490 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 19 Mar 2015 15:21:14 -0700 Subject: [PATCH 096/219] urb.send --- arvo/eyre.hoon | 17 ++--- main/lib/urb.js | 180 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 172 insertions(+), 25 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 27f05a5df8..52047daccb 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -125,7 +125,7 @@ :: ++ even :: client event $% [%news p=@uv] - [%rush p=[hasp path] q=wain] + [%rush p=[hasp path] q=json] [%mean p=[hasp path] q=ares] == :: @@ -358,8 +358,7 @@ ?> ?=([%is ^] tee) %- ~(get-even ix p.tee (~(got by wix) p.tee)) ?> ?=(%json p.sih) :: XX cage - =+ dat=[(crip (pojo ;;(json q.sih)))]~ - [%rush [(pick-hasp q.tee) r.tee] dat] + [%rush [(pick-hasp q.tee) r.tee] (joba %json ((hard json) q.sih))] :: %nice ?>(?=($|(~ [%is ^]) tee) (nice-json)) %mean ?>(?=(~ tee) (mean-json 500 p.sih)) @@ -1034,7 +1033,7 @@ :: ++ get-rush |= [a=[hasp path] b=octs] ^+ ..ix - (get-even [%rush a [q.b]~]) :: XX multiline + (get-even [%rush a (joba %mime [%s q.b])]) :: XX multiline :: ++ get-even |= ven=even ^+ ..ix @@ -1055,13 +1054,11 @@ %^ jobe id/(jone num) type/[%s -.ven] ?- -.ven %news ~[from/[%s (scot %uv p.ven)]] - %rush ~[from/(subs-to-json p.ven) data/[%s (role q.ven)]] - %mean ~[from/(subs-to-json p.ven) data/(ares-to-json q.ven)] + %rush ~[from/(jape (print-subs p.ven)) data/q.ven] + %mean ~[from/(jape (print-subs p.ven)) data/(ares-to-json q.ven)] == :: - ++ subs-to-json - |= [a=hasp b=path] - (jobe ship/[%s (scot %p p.a)] appl/[%s q.a] path/(jape (spud b)) ~) + ++ print-subs |=([a=hasp b=path] "{}/{(trip q.a)}{(spud b)}") :: ++ wait-era (pass-note of//[ire] [%t %wait era]) ++ wake ^+(..ix abet(ude ~)) :: XX other effects? @@ -1103,7 +1100,7 @@ ~ :: ++ load :: clam previous state - |= old=_[%0 gub hov ged ney dop liz=liz wup sop wix] + |= old=_[%0 gub hov ged ney dop liz wup sop wix=**] ^+ ..^$ ..^$(+>- (bolo old)) :: diff --git a/main/lib/urb.js b/main/lib/urb.js index 7fbb4c7f0d..88ddc0a274 100644 --- a/main/lib/urb.js +++ b/main/lib/urb.js @@ -1,31 +1,181 @@ -window.urb.seqn_s = 0 +window.urb.seqn_u = 0 +window.urb.seqn_h = 0 +window.urb.dely = 0 +window.urb.puls = 0 +window.urb.cabs = {} +if(!window.urb.appl) window.urb.appl = null -window.urb.send = function(params,cb) { - if(!params) - throw new Error("You must supply params to urb.send.") - if(!params.appl) { - if(!urb.appl) - throw new Error("You must specify an appl for urb.send.") - params.appl = urb.appl +window.urb.req = function(method,url,params,json,cb) { + var xhr = new XMLHttpRequest() + xhr.open(method.toUpperCase(), url) + + if(json) + xhr.setRequestHeader("content-type", "text/json") + + _data = {oryx: window.urb.oryx} + if(params.xyro) { _data.xyro = params.xyro; } + if(params.ship) { _data.ship = params.ship; } + if(params.path) { _data.path = params.path; } + if(params.appl) { _data.appl = params.appl; } + if(params.mark) { _data.mark = params.mark; } + if(cb) { + xhr.onload = function() { + try { + err = null + res = { + status:this.status, + data: JSON.parse(this.responseText) + } + if(res.data.reload) + res.reload = res.data.reload + } catch(e) { + err = { + message:"Failed to parse JSON", + raw:this.responseText + } + res = null + } + cb(err,res) + } + xhr.onerror = function() { + cb({ + status:this.status, + data:this.responseText + }) + } } - if(!params.data) { params.data = {}; } + xhr.send(JSON.stringify(_data)) +} + +window.urb.reqq = [] +window.urb.qreq = function(method,url,params,json,cb) { + walk = function() { + qobj = {} + qobj.oargs = window.urb.reqq[0] + qobj.nargs = [].slice.apply(qobj.oargs,[0,4]) + qobj.nargs.push(function(){ + if(this.oargs[4]) + this.oargs[4].apply(window.urb,arguments) + window.urb.reqq.shift() + if(window.urb.reqq.length > 0) + walk() + }.bind(qobj)) + window.urb.req.apply(this,qobj.nargs) + } + l = window.urb.reqq.length + window.urb.reqq.push(arguments); + if(l == 0) { walk() } +} + +window.urb.gsig = function(params) { + var path = params.path + if(!path) path = "" + if(path[0] != "/") path = "/"+path + return params.ship+"/"+ + params.appl+ + path.replace(/[^\x00-\x7F]/g, "") +} + +window.urb.poll = function(params,cb) { + if(!params) + throw new Error("You must supply params to urb.poll.") var method, perm, url, $this - type = params.type ? params.type : "mes" - perm = this.perms[type] + seqn = this.seqn_u + if(params.seqn) + seqn = params.seqn() + + url = "/~/of/"+this.ixor + + this.puls = 1 + + $this = this + this.req(method,url,params,true,function(err,data) { + if(data){ + if (data.reload) { + return document.location.reload() + } else { + fn = $this.gsig(data.data) + if($this.cabs[fn]) { + $this.cabs[fn].call(this,err, + {status: data.status, data: data.data.data}) + } + } + } + + dely = params.dely ? params.dely : $this.dely + + if(err) + dely = dely+Math.ceil(dely*.02) + else { + $this.dely = 0 + if(params.incs) + params.incs() + else + $this.seqn_u++ + } + + setTimeout(function() { + $this.poll(params,cb) + },dely) + }) +} + +if (window.urb.auto) { + var tries = 0 + var cnt = 0 + var param = { + type:"pol" + } + window.urb.poll(param) +} + +// window.urb.heartbeat = function() { +// this.poll({ +// type:"heb", +// ship:this.ship, +// dely:30000, +// seqn:function() { +// return window.urb.seqn_h +// }, +// incs:function() { +// window.urb.seqn_h = window.urb.seqn_h+1 +// } +// },function() { +// console.log('heartbeat.') +// }) +// } +// window.urb.heartbeat() + +// // / // / // // +// end old %eyre code // +// // / // / // // + +window.urb.seqn_s = 0 + +// TODO urb.send(data, [params/params.appl]?, cb?) +window.urb.send = function(params,cb) { + if(!params) + throw new Error("You must supply params to urb.send.") + if(!params.appl && !this.appl){ + throw new Error("You must specify an appl for urb.send.") + } + + var url, $this params.ship = params.ship ? params.ship : this.ship + params.appl = params.appl ? params.appl : this.appl params.mark = params.mark ? params.mark : "json" + params.xyro = params.data ? params.data : {} - method = "put" - url = [perm,this.user,this.port,this.seqn_s] - url = "/"+url.join("/") + url = ["to",params.appl,params.mark] + url = "/~/"+url.join("/") this.seqn_s++ $this = this - this.qreq(method,url,params,true,function(err,data) { + this.qreq('post',url,params,true,function(err,data) { if(err) { $this.seqn_s--; } if(cb) { cb.apply(this,arguments); } }) From 1fe777dfb449f53086461ec79866de6e8078b433 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 19 Mar 2015 16:35:10 -0700 Subject: [PATCH 097/219] urb.subscribe --- arvo/eyre.hoon | 14 ++++-- main/lib/urb.js | 123 +++++++++++++++++++++++++----------------------- 2 files changed, 75 insertions(+), 62 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 52047daccb..e1bfe6affd 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -1054,12 +1054,20 @@ %^ jobe id/(jone num) type/[%s -.ven] ?- -.ven %news ~[from/[%s (scot %uv p.ven)]] - %rush ~[from/(jape (print-subs p.ven)) data/q.ven] - %mean ~[from/(jape (print-subs p.ven)) data/(ares-to-json q.ven)] + %rush ~[from/(subs-to-json p.ven) data/q.ven] + %mean ~[from/(subs-to-json p.ven) data/(ares-to-json q.ven)] == :: - ++ print-subs |=([a=hasp b=path] "{}/{(trip q.a)}{(spud b)}") + ++ subs-to-json + |= [a=hasp b=path] + %- jobe :~ + ship/[%s (rsh 3 1 (scot %p p.a))] + appl/[%s q.a] + path/(jape (spud b)) + == :: + :: XX unused + ++ print-subs |=([a=hasp b=path] "{}/{(trip q.a)}{(spud b)}") ++ wait-era (pass-note of//[ire] [%t %wait era]) ++ wake ^+(..ix abet(ude ~)) :: XX other effects? -- -- diff --git a/main/lib/urb.js b/main/lib/urb.js index 88ddc0a274..92fdb17d94 100644 --- a/main/lib/urb.js +++ b/main/lib/urb.js @@ -1,13 +1,15 @@ -window.urb.seqn_u = 0 -window.urb.seqn_h = 0 +window.urb.seqn_u = 1 window.urb.dely = 0 -window.urb.puls = 0 +window.urb.puls = false window.urb.cabs = {} if(!window.urb.appl) window.urb.appl = null window.urb.req = function(method,url,params,json,cb) { var xhr = new XMLHttpRequest() - xhr.open(method.toUpperCase(), url) + method = method.toUpperCase() + if(method == "PUT" || method == "DELETE") + xhr.open("POST", url+"?"+method) + else xhr.open(method, url) if(json) xhr.setRequestHeader("content-type", "text/json") @@ -29,6 +31,7 @@ window.urb.req = function(method,url,params,json,cb) { if(res.data.reload) res.reload = res.data.reload } catch(e) { + if(urb.wall || true) document.write(this.responseText) // XX err = { message:"Failed to parse JSON", raw:this.responseText @@ -71,40 +74,43 @@ window.urb.gsig = function(params) { var path = params.path if(!path) path = "" if(path[0] != "/") path = "/"+path - return params.ship+"/"+ + return "~"+params.ship+"/"+ params.appl+ path.replace(/[^\x00-\x7F]/g, "") } -window.urb.poll = function(params,cb) { - if(!params) - throw new Error("You must supply params to urb.poll.") +window.urb.poll = function(params) { + if(!params) throw new Error("You must supply params to urb.poll.") - var method, perm, url, $this + var url, $this seqn = this.seqn_u - if(params.seqn) - seqn = params.seqn() + if(params.seqn) seqn = params.seqn() - url = "/~/of/"+this.ixor + url = "/~/of/"+this.ixor+"?poll="+seqn - this.puls = 1 + this.puls = true $this = this - this.req(method,url,params,true,function(err,data) { - if(data){ - if (data.reload) { - return document.location.reload() - } else { - fn = $this.gsig(data.data) - if($this.cabs[fn]) { + this.req("get",url,params,true,function(err,resp) { + if(resp){ + if(resp.beat) + return $this.poll(params) + switch(resp.data.type){ + case "news": + return document.location.reload() // XX check autoreload + case "rush": + var fn = $this.gsig(resp.data.from) + if($this.cabs[fn]) $this.cabs[fn].call(this,err, - {status: data.status, data: data.data.data}) - } + {status: resp.status, data: resp.data.data.json}) // XX non-json + break; + default: + throw new Error("Lost event %"+resp.type) } } - dely = params.dely ? params.dely : $this.dely + dely = params.dely ? params.dely : $this.dely if(err) dely = dely+Math.ceil(dely*.02) @@ -112,24 +118,24 @@ window.urb.poll = function(params,cb) { $this.dely = 0 if(params.incs) params.incs() - else + else $this.seqn_u++ } setTimeout(function() { - $this.poll(params,cb) + $this.poll(params) },dely) }) } -if (window.urb.auto) { - var tries = 0 - var cnt = 0 - var param = { - type:"pol" - } - window.urb.poll(param) -} +// if (window.urb.auto) { // need dependencies +// var tries = 0 +// var cnt = 0 +// var param = { +// type:"pol" +// } +// window.urb.poll(param) +// } // window.urb.heartbeat = function() { // this.poll({ @@ -181,37 +187,36 @@ window.urb.send = function(params,cb) { }) } -window.urb.subscribe = function(params,cb) { - if(!cb) - throw new Error("You must supply a callback to urb.subscribe.") - if(!params) - throw new Error("You must supply params to urb.subscribe.") - if(!params.appl) { - if(!urb.appl) - throw new Error("You must specify an appl for urb.subscribe.") - params.appl = urb.appl - } - if(!params.path) - throw new Error("You must specify a path for urb.subscribe.") +window.urb.subscribe = function(params,cb) { // legacy interface + if(!params) throw new Error("You must supply params to urb.subscribe") + return window.urb.bind(params.path, params, cb) +} +window.urb.bind = function(path, cb){ // or bind(path, params, cb, nice-cb?) + var params = {appl: window.urb.appl} + if(arguments.length == 3){params = cb; cb = arguments[2]} + + if(!path) throw new Error("You must specify a path for urb.bind.") + if(!params.appl) throw new Error("You must specify an appl for urb.bind.") + if(!cb) throw new Error("You must supply a callback to urb.bind.") + + if(path[0] !== "/") path = "/"+path + + params.path = path params.ship = params.ship ? params.ship : this.ship + params.appl = params.appl ? params.appl : this.appl var method, perm, url, $this - params.type = "sub" - this.cabs[this.gsig(params)] = cb - url = [this.perms["sub"],this.user,this.port] - url = "/"+url.join("/") - method = "put" + url = "/~/is/"+this.gsig(params) $this = this - this.qreq(method,url,params,true,function(err,data) { - if(cb) { cb.apply(this,[err,{status: data.status, data: data.data}])} - if(!err && $this.puls == 0) { - params.type = "pol" - $this.poll(params) - } + this.qreq("put",url,params,true,function(err,resp) { + if(cb) { cb.apply(this,[err,{status: resp.status, data: resp.data}])} + // XX give raw data + // + if(!err && !$this.puls) $this.poll(params) }) } @@ -227,14 +232,14 @@ window.urb.unsubscribe = function(params,cb) { throw new Error("You must specify a path for urb.unsubscribe.") params.ship = params.ship ? params.ship : this.ship - method = "put" + method = "delete" type = "uns" url = [this.perms[type],this.user,this.port] url = "/"+url.join("/") var $this = this - this.req(method,url,params,true,function(err,data) { - cb(err,data) + this.req(method,url,params,true,function(err,resp) { + cb(err,resp) }) } From af65cca79a8b6fd2949fc647069bdcb4b6b25d3c Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Thu, 19 Mar 2015 16:56:46 -0700 Subject: [PATCH 098/219] Proper command line editing, part 1. --- main/app/dojo/core.hook | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index ac7a2579d8..08800467b4 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -377,10 +377,13 @@ |= cag=cage ^+ +>+> ?> ?=(^ per) - ?: |(?=(^ q.q.cag) =((lent buf.say) q.q.cag)) + ?: ?| ?=(^ q.q.cag) + =((lent buf.say) q.q.cag) + !&(?=(%del -.u.per) =(+(p.u.per) (lent buf.say))) + == dy-abet(per ~) =^ lic say (~(transmit cs say) u.per) - (dy-rush(per ~) %mor [%bel ~] [%det lic] ~) + (dy-rush(per ~) %mor [%det lic] [%err q.q.cag] ~) :: ++ dy-done :: dialog submit |= txt=tape @@ -474,8 +477,7 @@ |= cag=cage ^+ +>+> ?. ?=(^ q.q.cag) - ~& %dy-made-dial-fail - (dy-rash %bel ~) + (dy-rush %err q.q.cag) =+ tan=((list tank) +2.q.q.cag) =. +>+>.$ (he-rush %tan tan) =+ vax=(spec (slot 3 q.cag)) From 1ed24939db93ad98626a710d14931230a7ea2a69 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 19 Mar 2015 16:57:46 -0700 Subject: [PATCH 099/219] Separate subscription-success and data callbacks, leaving legacy interface in place --- main/lib/urb.js | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/main/lib/urb.js b/main/lib/urb.js index 92fdb17d94..adc86c7f9e 100644 --- a/main/lib/urb.js +++ b/main/lib/urb.js @@ -92,21 +92,21 @@ window.urb.poll = function(params) { this.puls = true $this = this - this.req("get",url,params,true,function(err,resp) { - if(resp){ - if(resp.beat) + this.req("get",url,params,true,function(err,res) { + if(res){ + if(res.data.beat) return $this.poll(params) - switch(resp.data.type){ + switch(res.data.type){ case "news": return document.location.reload() // XX check autoreload case "rush": - var fn = $this.gsig(resp.data.from) + var fn = $this.gsig(res.data.from) if($this.cabs[fn]) $this.cabs[fn].call(this,err, - {status: resp.status, data: resp.data.data.json}) // XX non-json + {status: res.status, data: res.data.data.json}) // XX non-json break; default: - throw new Error("Lost event %"+resp.type) + throw new Error("Lost event %"+res.type) } } @@ -189,22 +189,24 @@ window.urb.send = function(params,cb) { window.urb.subscribe = function(params,cb) { // legacy interface if(!params) throw new Error("You must supply params to urb.subscribe") - return window.urb.bind(params.path, params, cb) + return window.urb.bind(params.path, params, cb, cb) } -window.urb.bind = function(path, cb){ // or bind(path, params, cb, nice-cb?) - var params = {appl: window.urb.appl} - if(arguments.length == 3){params = cb; cb = arguments[2]} - +window.urb.bind = function(path, cb){ // or bind(path, params, cb, nicecb?) + var params, nicecb + if(arguments.length > 2) + {params = cb; cb = arguments[2], nicecb = arguments[3]} + else params = {} + + params.path = path + params.ship = params.ship ? params.ship : this.ship + params.appl = params.appl ? params.appl : this.appl + if(!path) throw new Error("You must specify a path for urb.bind.") if(!params.appl) throw new Error("You must specify an appl for urb.bind.") if(!cb) throw new Error("You must supply a callback to urb.bind.") if(path[0] !== "/") path = "/"+path - params.path = path - params.ship = params.ship ? params.ship : this.ship - params.appl = params.appl ? params.appl : this.appl - var method, perm, url, $this this.cabs[this.gsig(params)] = cb @@ -212,8 +214,8 @@ window.urb.bind = function(path, cb){ // or bind(path, params, cb, nice-cb?) url = "/~/is/"+this.gsig(params) $this = this - this.qreq("put",url,params,true,function(err,resp) { - if(cb) { cb.apply(this,[err,{status: resp.status, data: resp.data}])} + this.qreq("put",url,params,true,function(err,res) { + if(nicecb) { nicecb.apply(this,[err,{status: res.status, data: res.data}])} // XX give raw data // if(!err && !$this.puls) $this.poll(params) @@ -238,8 +240,8 @@ window.urb.unsubscribe = function(params,cb) { url = "/"+url.join("/") var $this = this - this.req(method,url,params,true,function(err,resp) { - cb(err,resp) + this.req(method,url,params,true,function(err,res) { + cb(err,res) }) } From d176884d53624de5813ca3c6be427ec8ec2f519e Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Fri, 20 Mar 2015 11:31:02 -0700 Subject: [PATCH 100/219] About to work :talk into the command line mix. --- main/app/dojo/core.hook | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 08800467b4..0283b460ee 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -621,6 +621,12 @@ ++ he-done :: parse command |= txt=tape ^+ +> + ?~ txt + %- he-rush + :~ %mor + [%txt "> "] + [%nex ~] + == =+ doy=(he-duke txt) ?- -.doy %| (he-rush [%err p.doy]) From 938836cb12ae5ee91e53e9c82b863d3472908d0e Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 20 Mar 2015 13:14:53 -0700 Subject: [PATCH 101/219] ames note indentation --- arvo/ames.hoon | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/arvo/ames.hoon b/arvo/ames.hoon index 04646dc63d..27b5e3674a 100644 --- a/arvo/ames.hoon +++ b/arvo/ames.hoon @@ -35,31 +35,34 @@ ++ move ,[p=duct q=(mold note gift)] :: local move ++ note :: out request $-> $? $: %d :: to %dill - $% [%flog p=flog] :: - == == :: + $% [%flog p=flog] :: + == == :: $: %a :: to %ames - $% [%kick p=@da] :: - == == :: + $% [%kick p=@da] :: + == == :: $: %g :: to %gall - $% [%rote p=sack q=path r=*] :: - [%roth p=sack q=path r=*] :: - [%mess p=[@p %ye ~] q=@p r=cage] :: - == == :: + $% [%rote p=sack q=path r=*] :: + [%roth p=sack q=path r=*] :: + [%mess p=[@p %ye ~] q=@p r=cage] :: + == == :: $: @tas :: to any - $% [%init p=@p] :: - [%want p=sock q=path r=*] :: - [%wart p=sock q=@tas r=path s=*] :: + $% [%init p=@p] :: + [%want p=sock q=path r=*] :: + [%wart p=sock q=@tas r=path s=*] :: == == == :: ++ sign :: in result $<- $? $: %a :: from %ames - $% [%went p=ship q=cape] :: - == == :: + $% [%went p=ship q=cape] :: + == == :: + $: %e :: from %eyre + $% [%thou p=httr] :: + == == :: $: %g :: from %gall - $% [%mean p=ares] :: - [%nice ~] :: - == == :: + $% [%mean p=ares] :: + [%nice ~] :: + == == :: $: @tas :: - $% [%crud p=@tas q=(list tank)] :: by any + $% [%crud p=@tas q=(list tank)] :: by any == == == :: -- :::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -1820,6 +1823,7 @@ ?- +<.sih %crud [[[hen [%slip %d %flog +.sih]] ~] +>] %went [~ +>] + %thou ~|(a/%eyre-stub !!) ?(%mean %nice) ?: ?=([%ye ~] tea) [~ +>.$] From 55786d6271c806ba44880fa2e072172692527e28 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Sat, 21 Mar 2015 14:00:38 -0700 Subject: [PATCH 102/219] Before reactivating gall queue backpressure. --- arvo/dill.hoon | 11 ++++++++--- arvo/gall.hoon | 9 ++++----- main/app/seat/core.hook | 5 ++++- main/app/talk/core.hook | 16 ++++++++-------- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/arvo/dill.hoon b/arvo/dill.hoon index fcd6d43f23..224c35191a 100644 --- a/arvo/dill.hoon +++ b/arvo/dill.hoon @@ -282,6 +282,12 @@ [hen %pass ~ %g %mess [our [ram ~]] our [%dill-belt -:!>(bet) bet]] == :: + ++ took :: send rush ack + %_ . + moz + :_(moz [hen %pass ~ %g %took [our [ram ~]] our]) + == + :: ++ take :: receive |= sih=sign ^+ +> @@ -314,8 +320,7 @@ +> :: [%g %rush %dill-blit *] - =. moz :_(moz `move`[hen %pass ~ %g %took [our [ram ~]] our]) - (from +>+.sih) + took:(from +>+.sih) :: [%t %wake *] :: ~& %dill-wake @@ -369,7 +374,7 @@ =: ore.all `p.q.hic dug.all ~ == - =^ moz all abet:(need (ax (need hey.all) [%flow %seat %dojo ~])) + =^ moz all abet:(need (ax (need hey.all) [%flow %seat %dojo %talk ~])) [moz ..^$] =+ nus=(ax hen q.hic) ?~ nus diff --git a/arvo/gall.hoon b/arvo/gall.hoon index 168c423f9c..fbebe5ac7a 100644 --- a/arvo/gall.hoon +++ b/arvo/gall.hoon @@ -1160,11 +1160,10 @@ :: ~& [%yawn-told-has ost qol [our hen]] =+ qul=?~(qol 1 +(u.qol)) =. qel.sat (~(put by qel.sat) ost qul) - :: XX turn me back on! - :: ?: =(10 qul) - :: ~& [%yawn-told-full ost our hen] - :: +>.$(qic.sat ~, vey.sat (~(put to vey.sat) hen %nuke p.kon)) - +>.$(qic.sat ~) + ?: =(10 qul) + ~& [%yawn-told-full ost our hen] + +>.$(qic.sat ~, vey.sat (~(put to vey.sat) hen %nuke p.kon)) + :: +>.$(qic.sat ~) :: %load =+ [hom=(slot 2 q.p.kon) old=(slot 3 q.p.kon)] diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index 45740e001d..ee741e989e 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -212,7 +212,7 @@ +>.$ :: %rush - ta-abet:(ta-fec:(se-tame nam) +>.sil) + ta-abet:ta-rap:(ta-fec:(se-tame nam) +>.sil) == :: ++ ta :: per target @@ -368,6 +368,9 @@ %txt $(fec [%tan [%leaf p.fec]~]) == :: + ++ ta-rap :: send %took + .(+> (se-send nam %took [her ~[nam]] her)) + :: ++ ta-dog :: change cursor |= ted=console-edit %_ +> diff --git a/main/app/talk/core.hook b/main/app/talk/core.hook index 951e045934..d9f3cc974d 100644 --- a/main/app/talk/core.hook +++ b/main/app/talk/core.hook @@ -11,11 +11,11 @@ => |% :: structures ++ town :: all client state $: %0 :: version - seat=console-share :: command lines + say=console-share :: command lines live=(unit span) :: present story stories=(map span story) :: all stories == :: - ++ grip :: subscription state + ++ grip :: synchronized state |* nub=$+(* *) :: wrapped state $| $? %warm :: activated %cool :: activating @@ -131,7 +131,7 @@ |=(tep=tape (hy-display [%leaf tep]~)) :: ++ hy-accept :: set prompt - |=(asq=cord (hy-general %pro & %gar (tuba (trip asq)))) + |=(asq=cord (hy-general %pro & %gar (trip asq))) -- :: ++ parse :: command parser @@ -598,7 +598,7 @@ =+ nuv=(novel ost ~) ?~ nuv :_ +>.$ - [ost %give %rush %console-effect %pro & %$ (tuba "no story ")]~ + [ost %give %rush %console-effect %pro & %$ "no story "]~ sy-abet:sy-awake:u.nuv :: ++ submit @@ -675,11 +675,11 @@ ++ poke-console-action |= [ost=bone her=ship act=console-action] =+ moz=`(list move)`[ost %give %nice ~]~ - ?+ -.act [moz +>.$] - %det [moz +>.$(seat abet:(~(receive cs seat) `console-change`+.act))] - %ret =+ sed=buf.seat + ?- -.act + %det [moz +>.$(say +:(~(receive cs say) `console-change`+.act))] + %ret =+ sed=buf.say =^ zom +>.$ (submit ost (crip (tufa sed))) - =^ cal seat =<([- abet:+] (~(transmit cs seat) [%set ~])) + =^ cal say (~(transmit cs say) [%set ~]) :_ +>.$ :* [ost %give %rush %console-effect %nex ~] [ost %give %rush %console-effect %det cal] From 0ea228c3609542d31bf3127e8585f52aa1adec9a Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Sun, 22 Mar 2015 15:46:42 -0700 Subject: [PATCH 103/219] Add remote to :seat. --- arvo/dill.hoon | 5 +- arvo/gall.hoon | 4 +- arvo/hoon.hoon | 7 ++- main/app/dojo/core.hook | 10 ++-- main/app/seat/core.hook | 119 +++++++++++++++++++++++++++---------- main/sur/console/core.hook | 2 +- 6 files changed, 103 insertions(+), 44 deletions(-) diff --git a/arvo/dill.hoon b/arvo/dill.hoon index 224c35191a..c270cf117e 100644 --- a/arvo/dill.hoon +++ b/arvo/dill.hoon @@ -54,7 +54,7 @@ [%sag p=path q=*] :: save to jamfile [%sav p=path q=@] :: save to file == :: -++ gill ,@tas :: general contact +++ gill (pair ship term) :: general contact -- :: => |% :: console protocol ++ axle :: all dill state @@ -374,7 +374,8 @@ =: ore.all `p.q.hic dug.all ~ == - =^ moz all abet:(need (ax (need hey.all) [%flow %seat %dojo %talk ~])) + =^ moz all + abet:(need (ax (need hey.all) [%flow %seat [p.q.hic %dojo] ~])) [moz ..^$] =+ nus=(ax hen q.hic) ?~ nus diff --git a/arvo/gall.hoon b/arvo/gall.hoon index fbebe5ac7a..757ac11bc8 100644 --- a/arvo/gall.hoon +++ b/arvo/gall.hoon @@ -1162,8 +1162,8 @@ =. qel.sat (~(put by qel.sat) ost qul) ?: =(10 qul) ~& [%yawn-told-full ost our hen] - +>.$(qic.sat ~, vey.sat (~(put to vey.sat) hen %nuke p.kon)) - :: +>.$(qic.sat ~) + +>.$(qic.sat ~, vey.sat (~(put to vey.sat) hen %nuke p.kon)) + +>.$(qic.sat ~) :: %load =+ [hom=(slot 2 q.p.kon) old=(slot 3 q.p.kon)] diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index 0c4d8a3374..b1decc6421 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -2862,10 +2862,11 @@ ++ rash |*([naf=@ sab=_rule] (scan (trip naf) sab)) :: ++ ruse |* [los=tape sab=_rule] =+ vex=(sab [[0 0] los]) - ?. =((lent los) q.p.vex) ~ + =+ len=(lent los) + ?. =(len q.p.vex) [%| p=q.p.vex] ?~ q.vex - [~ u=~] - [~ u=[~ u=p.u.q.vex]] + [%| p=len] + [%& p=p.u.q.vex] ++ rush |*([naf=@ sab=_rule] (rust (trip naf) sab)) ++ rust |* [los=tape sab=_rule] =+ vex=((full sab) [[1 1] los]) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 0283b460ee..0f453b530a 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -22,6 +22,7 @@ ++ dojo-command :: $% [%flat p=path q=dojo-source] :: noun to unix atom [%pill p=path q=dojo-source] :: noun to unix pill + :: [%tree p=path q=dojo-source] :: noun to unix tree [%poke p=goal q=dojo-source] :: make and poke [%show p=dojo-source] :: print [%verb p=term q=dojo-source] :: store variable @@ -31,19 +32,18 @@ q=dojo-build :: general build == :: ++ dojo-build :: one ford step - $% :: [%ca p=mark q=dojo-build] :: cast - [%ex p=twig] :: hoon expression + $% [%ex p=twig] :: hoon expression [%di p=dojo-model] :: dialog [%dv p=path] :: gate from source - [%fi p=(list dojo-filter) q=dojo-source] :: filter pipeline + [%fi p=dojo-filter q=dojo-source] :: filter [%sc p=dojo-model] :: script [%tu p=(list dojo-source)] :: tuple [%va p=term] :: dojo variable == :: ++ dojo-filter :: pipeline filter - $% [%a p=twig] :: direct gate + $% [%a p=twig] :: function gate [%b p=mark] :: simple transmute - [%c p=dojo-source] :: full filter + [%c p=dojo-model] :: formal filter == :: ++ dojo-model :: data construction $: p=dojo-server :: core source diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index ee741e989e..49006a50cf 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -15,10 +15,10 @@ $: edg=_79 :: terminal columns off=@ud :: window offset kil=(unit (list ,@c)) :: kill buffer - apt=(list term) :: application ring + apt=(list gill) :: application ring maz=(unit (list ,@c)) :: master window - feg=(map term target) :: live applications - mir=(pair ,@ud (list ,@c)) :: mirrored state + feg=(map gill target) :: live applications + mir=(pair ,@ud (list ,@c)) :: mirrored terminal == :: ++ master :: master buffer $: pos=@ud :: cursor position @@ -30,6 +30,10 @@ lay=(map ,@ud (list ,@c)) :: editing overlay old=(list (list ,@c)) :: entries proper == :: + ++ action :: user action + $% [%add p=(list gill)] :: add agents + [%del p=(list gill)] :: delete agents + == :: ++ search :: reverse-i-search $: pos=@ud :: search position str=(list ,@c) :: search string @@ -67,6 +71,33 @@ |_ $: hid=hide :: system state house :: program state == :: +++ sp + |% ++ sp-action + %+ knee *action |. ~+ + ;~ pose + (stag %add ;~(pfix lus sp-gills)) + (stag %del ;~(pfix hep sp-gills)) + == + :: + ++ sp-gills + ;~ pose + %+ cook + |= a=ship + [[a %dojo] [a %talk] ~] + ;~(pfix sig fed:ag) + :: + (most ;~(plug com ace) sp-gill) + == + :: + ++ sp-gill + ;~ pose + (stag our.hid sym) + ;~ plug + ;~(pfix sig fed:ag) + ;~(pfix fas sym) + == + == + -- ++ se :: per source |_ [moz=(list move) [her=ship ost=bone] source] ++ se-abet :: resolve @@ -115,37 +146,59 @@ == :: ++ se-drop :: passive drop - |= nam=term + |= gyl=gill ^+ +> - ?> (~(has by feg) nam) - =: feg (~(del by feg) nam) - apt (skip apt |=(a=term =(nam a))) + ?> (~(has by feg) gyl) + =: feg (~(del by feg) gyl) + apt (skip apt |=(a=gill =(gyl a))) == ?^ apt +> ?^ maz +> +>(maz `~) :: + ++ ruse |* [los=tape sab=_rule] :: XX + =+ vex=(sab [[0 0] los]) + =+ len=(lent los) + ?. =(len q.p.vex) [%| p=q.p.vex] + ?~ q.vex + [%| p=len] + [%& p=p.u.q.vex] + :: ++ se-join :: add connection - |= nam=term + |= gyl=gill ^+ +> - ?< (~(has by feg) nam) - +>(maz ~, apt [nam apt], feg (~(put by feg) nam *target)) + ?< (~(has by feg) gyl) + +>(maz ~, apt [gyl apt], feg (~(put by feg) gyl *target)) :: ++ se-nuke :: active drop - |= nam=term + |= gyl=gill ^+ +> - (se-drop:(se-send nam %nuke [her ~[nam]] her) nam) + (se-drop:(se-send gyl %nuke [p.gyl ~[q.gyl]] her) gyl) :: ++ se-like :: act in master |= buf=(list ,@c) - (se-link (crip (tufa buf))) + =+ fey=(ruse (tufa buf) sp-action:sp) + ?- -.fey + %| (se-blit %bel ~) + %& ?- -.p.fey + %add + |- ^+ +>.^$ + ?~ p.p.fey +>.^$ + $(p.p.fey t.p.p.fey, +>.^$ (se-link i.p.p.fey)) + :: + %del + |- ^+ +>.^$ + ?~ p.p.fey +>.^$ + $(p.p.fey t.p.p.fey, +>.^$ (se-drop i.p.p.fey)) + == + == :: ++ se-link :: connect to app - |= nam=term + |= gyl=gill ^+ +> - %. nam + %. gyl =< se-join - (se-send nam %show [her ~[nam]] her /console) + (se-send gyl %show [p.gyl ~[q.gyl]] her /console) :: ++ se-blit :: give output |= bil=dill-blit @@ -175,7 +228,7 @@ |- ^- (list ,@c) ?~ apt [`@c`0x23 `@c`0x20 ~] =+ nex=$(apt t.apt) - %+ welp (tuba (trip i.apt)) + %+ welp (tuba (trip q.i.apt)) ?~(t.apt nex `_nex`[`@c`0x2c `@c`0x20 nex]) ?~ apt ~&(%se-no-view [0 ~]) @@ -192,15 +245,16 @@ %_(+> moz [mov moz]) :: ++ se-send :: send a message - |= [nam=term nog=note-gall] - (se-emit ost %pass [(scot %p her) nam ~] %g nog) + |= [gyl=gill nog=note-gall] + (se-emit ost %pass [(scot %p her) (scot %p p.gyl) q.gyl ~] %g nog) :: ++ se-tame - |= nam=term - ~(. ta [& nam] (~(got by feg) nam)) + |= gyl=gill + ^+ ta + ~(. ta [& gyl] (~(got by feg) gyl)) :: ++ se-pour :: receive results - |= [nam=term sil=sign-gall] + |= [gyl=gill sil=sign-gall] ^+ +> ?- -.sil %mean @@ -212,24 +266,27 @@ +>.$ :: %rush - ta-abet:ta-rap:(ta-fec:(se-tame nam) +>.sil) + ta-abet:ta-rap:(ta-fec:(se-tame gyl) +>.sil) == :: ++ ta :: per target |_ $: $: liv=? :: don't delete - nam=term :: target app + gyl=gill :: target app == :: target :: target state == :: ++ ta-abet :: resolve ^+ ..ta - ?. liv (se-nuke nam) - %_(+> feg (~(put by feg) nam +<+)) + ?. liv (se-nuke gyl) + %_(+> feg (~(put by feg) gyl +<+)) :: ++ ta-act :: send action |= act=console-action ^+ +> - %_(+> +> (se-send nam %mess [her ~[nam]] her %console-action !>(act))) + %_ +> + +> + (se-send gyl %mess [p.gyl ~[q.gyl]] her %console-action !>(act)) + == :: ++ ta-aro :: hear arrow |= key=?(%d %l %r %u) @@ -369,7 +426,7 @@ == :: ++ ta-rap :: send %took - .(+> (se-send nam %took [her ~[nam]] her)) + .(+> (se-send gyl %took [p.gyl ~[q.gyl]] her)) :: ++ ta-dog :: change cursor |= ted=console-edit @@ -520,7 +577,6 @@ :: ++ poke-dill-belt |= [ost=bone her=ship bet=dill-belt] - :: ~& %seat-poke ^- [(list move) _+>] =< se-abet =< se-view @@ -530,10 +586,11 @@ |= [ost=bone pax=path sih=*] ^- [(list move) _+>] =+ sih=((hard sign) sih) - ?> ?=([@ @ ~] pax) + ?> ?=([@ @ @ ~] pax) =< se-abet =< se-view - (~(se-pour se ~ [(slav %p i.pax) ost] (~(got by bin) ost)) i.t.pax +.sih) + =+ gyl=[(slav %p i.t.pax) i.t.t.pax] + (~(se-pour se ~ [(slav %p i.pax) ost] (~(got by bin) ost)) gyl +.sih) :: ++ pull |= ost=bone diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook index 6b85e6ff91..2911169d00 100644 --- a/main/sur/console/core.hook +++ b/main/sur/console/core.hook @@ -110,5 +110,5 @@ [%sag p=path q=*] :: save to jamfile [%sav p=path q=@] :: save to file == :: -++ gill ,@tas :: general contact +++ gill (pair ship term) :: general contact -- From 0582bdfd79ac602315658acac689e17aa80abc32 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Sun, 22 Mar 2015 21:37:01 -0700 Subject: [PATCH 104/219] Fix up :seat a bunch. --- arvo/ames.hoon | 1 - arvo/dill.hoon | 13 ++- main/app/dojo/core.hook | 11 +++ main/app/seat/core.hook | 177 +++++++++++++++++++++++----------------- main/app/talk/core.hook | 16 ++-- 5 files changed, 133 insertions(+), 85 deletions(-) diff --git a/arvo/ames.hoon b/arvo/ames.hoon index 4842dc10bd..ae19824581 100644 --- a/arvo/ames.hoon +++ b/arvo/ames.hoon @@ -1662,7 +1662,6 @@ ?- -.bon %beer :_ fox(zac (~(put by zac.fox) p.bon `corn`[hen ~ ~ ~])) - ~& [%ames-clop p.bon hen] :* [hen [%slip %c %init p.bon]] [hen [%give %init p.bon]] [hen [%slip %a %kick now]] diff --git a/arvo/dill.hoon b/arvo/dill.hoon index c270cf117e..167bbd560f 100644 --- a/arvo/dill.hoon +++ b/arvo/dill.hoon @@ -250,7 +250,6 @@ (done %blit [bit ~]) :: ++ init :: initialize - ~& [%dill-init our] =+ myt=(flop (need tem)) =. tem ~ =. moz :_(moz [hen %pass ~ %g %show [our [ram ~]] our ~]) @@ -374,8 +373,15 @@ =: ore.all `p.q.hic dug.all ~ == - =^ moz all - abet:(need (ax (need hey.all) [%flow %seat [p.q.hic %dojo] ~])) + =+ ^= flo ^- (list (pair ship term)) + =+ myr=(clan p.q.hic) + ?: =(%pawn myr) + ~ + ?: =(%earl myr) + =+ fap=(sein p.q.hic) + [[fap %dojo] [fap %talk] ~] + [[p.q.hic %dojo] [p.q.hic %talk] ~] + =^ moz all abet:(need (ax (need hey.all) [%flow %seat flo])) [moz ..^$] =+ nus=(ax hen q.hic) ?~ nus @@ -407,7 +413,6 @@ ^- [p=(list move) q=_..^$] ?: =(~ ore.all) ?: ?=([%a %init *] q.hin) - ~& [%dill-take-dump-init hen +.q.hin] =. hey.all ?^(hey.all hey.all `hen) [[[hen %give +.q.hin] ~] ..^$] ~& [%take-back q.hin] diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 0f453b530a..2639450b28 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -560,6 +560,10 @@ ^+ +> (he-give %rush %console-effect fec) :: + ++ he-stop :: abort work + ^+ . + ?~(poy . ~(dy-stop dy u.poy)) + :: ++ he-peer :: subscribe to he-prom :: @@ -689,4 +693,11 @@ ~& [%dojo-pour sih] [~ +>.$] == +:: +++ pull + |= ost=bone + ^- [(list move) _+>] + =^ moz +> + he-abet:~(he-stop he [[ost ~] (~(got by hoc) ost)]) + [moz +>.$(hoc (~(del by hoc) ost))] -- diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index 49006a50cf..a6ee9ec7a9 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -16,13 +16,13 @@ off=@ud :: window offset kil=(unit (list ,@c)) :: kill buffer apt=(list gill) :: application ring - maz=(unit (list ,@c)) :: master window + maz=master :: master window feg=(map gill target) :: live applications mir=(pair ,@ud (list ,@c)) :: mirrored terminal == :: ++ master :: master buffer - $: pos=@ud :: cursor position - buf=(list ,@c) :: text entry + $: liv=? :: master is live + tar=target :: master target == :: ++ history :: past input $: pos=@ud :: input position @@ -30,10 +30,6 @@ lay=(map ,@ud (list ,@c)) :: editing overlay old=(list (list ,@c)) :: entries proper == :: - ++ action :: user action - $% [%add p=(list gill)] :: add agents - [%del p=(list gill)] :: delete agents - == :: ++ search :: reverse-i-search $: pos=@ud :: search position str=(list ,@c) :: search string @@ -44,6 +40,10 @@ pom=console-prompt :: static prompt inp=console-command :: input state == :: + ++ ukase :: master command + $% [%add p=(list gill)] :: add agents + [%del p=(list gill)] :: delete agents + == :: ++ gift :: out result <-$ $% [%mean p=ares] :: [%nice ~] :: @@ -72,8 +72,8 @@ house :: program state == :: ++ sp - |% ++ sp-action - %+ knee *action |. ~+ + |% ++ sp-ukase + %+ knee *ukase |. ~+ ;~ pose (stag %add ;~(pfix lus sp-gills)) (stag %del ;~(pfix hep sp-gills)) @@ -110,29 +110,8 @@ +>(edg (dec p.bet)) ?: ?=(%yow -.bet) (se-link p.bet) - ?^ maz - ?+ -.bet (se-blit %bel ~) - :: - %bac - ?: =(0 (lent u.maz)) - (se-blit %bel ~) - +>(u.maz (scag (dec (lent u.maz)) u.maz)) - :: - %ctl - ?+ p.bet (se-blit %bel ~) - %d (se-emit ost %give %mean ~) - %v +>.$(maz ~) - %x $(maz ~) - == - :: - %ret (se-like(maz ~) u.maz) - %txt +>(u.maz (weld u.maz p.bet)) - == - ?~ apt - ~& %console-no-terminal - (se-blit %bel ~) - =+ nam=i.apt - =+ taz=~(. ta [& nam] (~(got by feg) nam)) + =+ gyl=?^(apt i.apt [~zod %$]) + =+ taz=~(. ta [& gyl] ?:(liv.maz tar.maz (~(got by feg) gyl))) =< ta-abet ?- -.bet %aro (ta-aro:taz p.bet) @@ -148,13 +127,12 @@ ++ se-drop :: passive drop |= gyl=gill ^+ +> + =< se-prom ?> (~(has by feg) gyl) - =: feg (~(del by feg) gyl) - apt (skip apt |=(a=gill =(gyl a))) - == - ?^ apt +> - ?^ maz +> - +>(maz `~) + %_ +> + feg (~(del by feg) gyl) + apt (skip apt |=(a=gill =(gyl a))) + == :: ++ ruse |* [los=tape sab=_rule] :: XX =+ vex=(sab [[0 0] los]) @@ -167,8 +145,10 @@ ++ se-join :: add connection |= gyl=gill ^+ +> - ?< (~(has by feg) gyl) - +>(maz ~, apt [gyl apt], feg (~(put by feg) gyl *target)) + =< se-prom + ?: (~(has by feg) gyl) + (se-blit %bel ~) + +>(liv.maz |, apt [gyl apt], feg (~(put by feg) gyl *target)) :: ++ se-nuke :: active drop |= gyl=gill @@ -176,21 +156,42 @@ (se-drop:(se-send gyl %nuke [p.gyl ~[q.gyl]] her) gyl) :: ++ se-like :: act in master - |= buf=(list ,@c) - =+ fey=(ruse (tufa buf) sp-action:sp) - ?- -.fey - %| (se-blit %bel ~) - %& ?- -.p.fey - %add - |- ^+ +>.^$ - ?~ p.p.fey +>.^$ - $(p.p.fey t.p.p.fey, +>.^$ (se-link i.p.p.fey)) - :: - %del - |- ^+ +>.^$ - ?~ p.p.fey +>.^$ - $(p.p.fey t.p.p.fey, +>.^$ (se-drop i.p.p.fey)) - == + |= kus=ukase + ?- -.kus + %add + |- ^+ +>.^$ + ?~ p.kus +>.^$ + $(p.kus t.p.kus, +>.^$ (se-link i.p.kus)) + :: + %del + |- ^+ +>.^$ + ?~ p.kus +>.^$ + $(p.kus t.p.kus, +>.^$ (se-drop i.p.kus)) + == + :: + ++ se-prom :: set master prompt + ^+ . + %_ . + cad.pom.tar.maz + ^- tape + %+ welp + (scow %p our.hid) + =+ ^= mux + |- ^- tape + ?~ apt ~ + =+ ^= mor ^- tape + ?~ t.apt ~ + [',' ' ' $(apt t.apt)] + %+ welp + ^- tape + =+ txt=(trip q.i.apt) + ?: =(our.hid p.i.apt) + txt + :(welp "~" (scow %p p.i.apt) "/" txt) + mor + ?~ mux + "# " + :(welp ":" mux "# ") == :: ++ se-link :: connect to app @@ -219,19 +220,10 @@ (se-show (sub p.lin off) (scag edg (slag off q.lin))) :: ++ se-view :: flush buffer + ?: liv.maz + (se-just ~(ta-vew ta [& ~zod %$] tar.maz)) + ?~ apt . %- se-just - ?^ maz - =- [(lent zil) zil] - ^= zil ^- (list ,@c) - %- welp - :_ u.maz - |- ^- (list ,@c) - ?~ apt [`@c`0x23 `@c`0x20 ~] - =+ nex=$(apt t.apt) - %+ welp (tuba (trip q.i.apt)) - ?~(t.apt nex `_nex`[`@c`0x2c `@c`0x20 nex]) - ?~ apt - ~&(%se-no-view [0 ~]) ~(ta-vew ta [& i.apt] (~(got by feg) i.apt)) :: ++ se-kill :: kill a source @@ -258,8 +250,6 @@ ^+ +> ?- -.sil %mean - :: ~& [%seat-mean sil] - ~& %seat-mean +>.$ :: %nice @@ -277,12 +267,34 @@ == :: ++ ta-abet :: resolve ^+ ..ta - ?. liv (se-nuke gyl) + ?: liv.maz + ?. liv + (se-emit ost %give %mean ~) + +>(tar.maz +<+) + ?. liv + =. ..ta (se-nuke gyl) + ..ta(liv.maz =(~ apt)) %_(+> feg (~(put by feg) gyl +<+)) :: - ++ ta-act :: send action + ++ ta-ant :: toggle master + ^+ . + ?: liv.maz + ?~ apt ta-bel + %_ . + liv.maz | + +<+ (~(got by feg) gyl) + tar.maz +<+ + == + %_ . + liv.maz & + +<+ tar.maz + feg (~(put by feg) gyl +<+) + == + :: + ++ ta-act :: send ukase |= act=console-action ^+ +> + ?: liv.maz +> %_ +> +> (se-send gyl %mess [p.gyl ~[q.gyl]] her %console-action !>(act)) @@ -380,9 +392,9 @@ ta-bel %- ta-hom(pos.inp 0, kil `(scag pos.inp buf.say.inp)) (ta-cut 0 pos.inp) - %v +>(maz `~) + %v ta-ant %x ?: =(~ apt) ta-bel - ?^ maz ta-bel + ?: liv.maz ta-bel +>(apt (welp (slag 1 apt) [(snag 0 apt) ~])) %y ?~ kil ta-bel %- ta-hom(pos.inp (add pos.inp (lent u.kil))) @@ -490,7 +502,17 @@ |= pom=console-prompt +>(pom pom) :: - ++ ta-ret (ta-act %ret ~) :: hear return + ++ ta-ret :: hear return + ?. liv.maz + (ta-act %ret ~) + =+ fey=(ruse (tufa buf.say.inp) sp-ukase:sp) + ?- -.fey + %| (ta-err p.fey) + %& =. +>+ (se-like p.fey) + =. pom pom.tar.maz + (ta-hom:ta-nex %set ~) + == + :: ++ ta-ser :: reverse search |= ext=(list ,@c) ^+ +> @@ -569,7 +591,12 @@ 0 ~ ~ - `~ + :* %& + *(unit search) + *history + `console-prompt`[%& %seat "{(scow %p our.hid)} #"] + *console-command + == ~ [0 ~] == diff --git a/main/app/talk/core.hook b/main/app/talk/core.hook index d9f3cc974d..9515378e56 100644 --- a/main/app/talk/core.hook +++ b/main/app/talk/core.hook @@ -595,11 +595,17 @@ ++ peer |= [ost=bone you=ship pax=path] ^- [(list move) _+>] - =+ nuv=(novel ost ~) - ?~ nuv - :_ +>.$ - [ost %give %rush %console-effect %pro & %$ "no story "]~ - sy-abet:sy-awake:u.nuv + :_ +> :_ ~ + :* ost + %give + %rush + %console-effect + %pro + & + %talk + =+ nuv=(novel ost ~) + ?~(nuv "no story" (sy-prompt:u.nuv q.mike.u.nuv)) + == :: ++ submit |= [ost=bone txt=cord] From 1442075740d81c5a3a394b104ba64db178eeb109 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Sun, 22 Mar 2015 21:55:06 -0700 Subject: [PATCH 105/219] More seat fixes. --- main/app/seat/core.hook | 47 +++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index a6ee9ec7a9..d38b2b04e8 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -111,7 +111,7 @@ ?: ?=(%yow -.bet) (se-link p.bet) =+ gyl=?^(apt i.apt [~zod %$]) - =+ taz=~(. ta [& gyl] ?:(liv.maz tar.maz (~(got by feg) gyl))) + =+ taz=~(. ta [& liv.maz gyl] ?:(liv.maz tar.maz (~(got by feg) gyl))) =< ta-abet ?- -.bet %aro (ta-aro:taz p.bet) @@ -130,18 +130,11 @@ =< se-prom ?> (~(has by feg) gyl) %_ +> - feg (~(del by feg) gyl) - apt (skip apt |=(a=gill =(gyl a))) + feg (~(del by feg) gyl) + apt (skip apt |=(a=gill =(gyl a))) + liv.maz ?~(apt & liv.maz) == :: - ++ ruse |* [los=tape sab=_rule] :: XX - =+ vex=(sab [[0 0] los]) - =+ len=(lent los) - ?. =(len q.p.vex) [%| p=q.p.vex] - ?~ q.vex - [%| p=len] - [%& p=p.u.q.vex] - :: ++ se-join :: add connection |= gyl=gill ^+ +> @@ -166,7 +159,7 @@ %del |- ^+ +>.^$ ?~ p.kus +>.^$ - $(p.kus t.p.kus, +>.^$ (se-drop i.p.kus)) + $(p.kus t.p.kus, +>.^$ (se-nuke i.p.kus)) == :: ++ se-prom :: set master prompt @@ -221,10 +214,11 @@ :: ++ se-view :: flush buffer ?: liv.maz - (se-just ~(ta-vew ta [& ~zod %$] tar.maz)) - ?~ apt . + (se-just ~(ta-vew ta [& & ~zod %$] tar.maz)) + ?~ apt + se-view(liv.maz &) %- se-just - ~(ta-vew ta [& i.apt] (~(got by feg) i.apt)) + ~(ta-vew ta [& | i.apt] (~(got by feg) i.apt)) :: ++ se-kill :: kill a source =+ tup=apt @@ -243,7 +237,7 @@ ++ se-tame |= gyl=gill ^+ ta - ~(. ta [& gyl] (~(got by feg) gyl)) + ~(. ta [& %| gyl] (~(got by feg) gyl)) :: ++ se-pour :: receive results |= [gyl=gill sil=sign-gall] @@ -261,13 +255,15 @@ :: ++ ta :: per target |_ $: $: liv=? :: don't delete + mav=? :: showing master gyl=gill :: target app == :: target :: target state == :: ++ ta-abet :: resolve ^+ ..ta - ?: liv.maz + =. liv.maz mav + ?: mav ?. liv (se-emit ost %give %mean ~) +>(tar.maz +<+) @@ -278,23 +274,24 @@ :: ++ ta-ant :: toggle master ^+ . - ?: liv.maz + ?: mav ?~ apt ta-bel %_ . - liv.maz | + mav | +<+ (~(got by feg) gyl) tar.maz +<+ == %_ . - liv.maz & - +<+ tar.maz - feg (~(put by feg) gyl +<+) + mav & + +<+ tar.maz + feg (~(put by feg) gyl +<+) == :: ++ ta-act :: send ukase |= act=console-action ^+ +> - ?: liv.maz +> + ?: mav + +> %_ +> +> (se-send gyl %mess [p.gyl ~[q.gyl]] her %console-action !>(act)) @@ -394,7 +391,7 @@ (ta-cut 0 pos.inp) %v ta-ant %x ?: =(~ apt) ta-bel - ?: liv.maz ta-bel + ?: mav ta-bel +>(apt (welp (slag 1 apt) [(snag 0 apt) ~])) %y ?~ kil ta-bel %- ta-hom(pos.inp (add pos.inp (lent u.kil))) @@ -503,7 +500,7 @@ +>(pom pom) :: ++ ta-ret :: hear return - ?. liv.maz + ?. mav (ta-act %ret ~) =+ fey=(ruse (tufa buf.say.inp) sp-ukase:sp) ?- -.fey From 60789c2362f36f0396dc4a5fef2e7a12bd9700db Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Sun, 22 Mar 2015 21:57:44 -0700 Subject: [PATCH 106/219] A little more seating. --- main/app/seat/core.hook | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index d38b2b04e8..ed88a9d896 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -146,7 +146,7 @@ ++ se-nuke :: active drop |= gyl=gill ^+ +> - (se-drop:(se-send gyl %nuke [p.gyl ~[q.gyl]] her) gyl) + (se-drop:(se-send(liv.maz |) gyl %nuke [p.gyl ~[q.gyl]] her) gyl) :: ++ se-like :: act in master |= kus=ukase From 8e0ca4969fa7b30b18994dce195cb23111d71c2c Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Sun, 22 Mar 2015 22:18:04 -0700 Subject: [PATCH 107/219] Trivial cleanup. --- main/app/seat/core.hook | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index ed88a9d896..d2231decbd 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -287,11 +287,11 @@ feg (~(put by feg) gyl +<+) == :: - ++ ta-act :: send ukase + ++ ta-act :: send action |= act=console-action ^+ +> ?: mav - +> + +>.$ %_ +> +> (se-send gyl %mess [p.gyl ~[q.gyl]] her %console-action !>(act)) From f541021cc8939e085005fb6575c471eebe7afce5 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Mon, 23 Mar 2015 05:30:00 -0700 Subject: [PATCH 108/219] Various fixes and improvements. --- arvo/gall.hoon | 34 ++++++++----------------------- main/app/dojo/core.hook | 6 +++--- main/app/seat/core.hook | 5 ++--- main/app/talk/core.hook | 1 + main/mar/console-action/door.hook | 13 ++++++++++++ main/mar/console-effect/door.hook | 14 +++++++++++++ 6 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 main/mar/console-action/door.hook create mode 100644 main/mar/console-effect/door.hook diff --git a/arvo/gall.hoon b/arvo/gall.hoon index 757ac11bc8..ecc7873c2f 100644 --- a/arvo/gall.hoon +++ b/arvo/gall.hoon @@ -259,8 +259,8 @@ |= [pax=path hen=duct hin=(hypo sign)] :: ^- [p=(list move) q=_..^$] ?: ?=(%crud +<.q.hin) - :: ~& [%gall-crud-error pax hen] - :: ~& [%gall-crud-data (,[@tas (list tank)] +>.q.hin)] + ~& [%gall-crud-error pax hen] + ~& [%gall-crud-data (,[@tas (list tank)] +>.q.hin)] ?> ?=(%g -.q.hin) ?~ pax ~& %strange-path [~ ..^$] =+ lum=(lump t.pax) @@ -435,8 +435,10 @@ :_ ..^$ =+ rod=|=(ron=roon `note`[%a %wont [our you] [%q %gh imp] num ron]) ?+ -.pax !! - %m ?: ?=(%a -.sih) ~ - ?+ -.sih ~& [%gall-gave-m -.sih] !! + %z ?+ -.sih !! + %a :_ ~ :- hen + [%pass [%r pax] %g %took [our imp] you] + :: %f :_ ~ :- hen ?- -.p.+.sih @@ -446,27 +448,6 @@ :: %g :_ ~ :- hen - ?- -.+.sih - %crud !! - %dumb !! - %gone !! - %init !! - %logo !! - %mean [%give %mean p.+.sih] - %nice [%give %nice ~] - %rush !! - %rust !! - %sage !! - %verb !! - %veer !! - %vega !! - == - == - %s ?+ -.sih !! - %a :_ ~ :- hen - [%pass [%r pax] %g %took [our imp] you] - %g - :_ ~ :- hen ?- -.+.sih %crud !! %dumb !! @@ -511,7 +492,8 @@ ^- move :- hen :+ %pass :* %r - ?-(-.rok %m %m, %s %s, %u %s) + :: ?-(-.rok %m %m, %s %s, %u %s) + %z (scot %p p.saq) (scot %p q.saq) (scot %ud num) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 2639450b28..16620eeddc 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -394,7 +394,6 @@ ^+ +> ?- -.mad %poke - ~& [%dy-over-poke p.mad] %- he-pass(poy ~) :* /poke %g @@ -661,9 +660,10 @@ ++ peer |= [ost=bone her=ship pax=path] ^- [(list move) _+>] + ~? !=(her our.hid) [%dojo-peer ost her pax] ?< (~(has by hoc) ost) ?> =(/console pax) - ?> =(her our.hid) + :: ?> =(her our.hid) =< he-abet %~ he-peer he :- [ost ~] @@ -679,6 +679,7 @@ ++ poke-console-action |= [ost=bone her=ship act=console-action] ^- [(list move) _+>] + :: ~? !=(her our.hid) [%dojo-poke ost her] he-abet:(~(he-type he [ost [ost %give %nice ~]~] (~(got by hoc) ost)) act) :: ++ pour @@ -690,7 +691,6 @@ he-abet:(~(he-made he [[ost ~] (~(got by hoc) ost)]) pax +>.sih) :: %g - ~& [%dojo-pour sih] [~ +>.$] == :: diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index d2231decbd..5a08d8b98b 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -81,12 +81,11 @@ :: ++ sp-gills ;~ pose + (most ;~(plug com ace) sp-gill) %+ cook |= a=ship [[a %dojo] [a %talk] ~] ;~(pfix sig fed:ag) - :: - (most ;~(plug com ace) sp-gill) == :: ++ sp-gill @@ -591,7 +590,7 @@ :* %& *(unit search) *history - `console-prompt`[%& %seat "{(scow %p our.hid)} #"] + `console-prompt`[%& %seat "{(scow %p our.hid)}# "] *console-command == ~ diff --git a/main/app/talk/core.hook b/main/app/talk/core.hook index 9515378e56..df1f575fe2 100644 --- a/main/app/talk/core.hook +++ b/main/app/talk/core.hook @@ -595,6 +595,7 @@ ++ peer |= [ost=bone you=ship pax=path] ^- [(list move) _+>] + ~? !=(her our.hid) [%talk-peer ost her pax] :_ +> :_ ~ :* ost %give diff --git a/main/mar/console-action/door.hook b/main/mar/console-action/door.hook new file mode 100644 index 0000000000..c7679583d9 --- /dev/null +++ b/main/mar/console-action/door.hook @@ -0,0 +1,13 @@ +:: +:::: /hook/door/console-action/mar + :: +/? 314 +/- *console +!: +|_ cod=console-action +:: +++ grab :: convert from + |% + ++ noun console-action :: clam from %noun + -- +-- diff --git a/main/mar/console-effect/door.hook b/main/mar/console-effect/door.hook new file mode 100644 index 0000000000..c4ab49486c --- /dev/null +++ b/main/mar/console-effect/door.hook @@ -0,0 +1,14 @@ +:: +:::: /hook/door/console-effect/mar + :: +/? 310 +/- *console +!: +|_ cod=console-effect +:: +++ grab :: convert from + |% + ++ noun console-effect :: clam from %noun + -- +-- + From 369cc2ea0c2b70db0aa2d824ec8fc794081b8f99 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Mon, 23 Mar 2015 11:27:20 -0700 Subject: [PATCH 109/219] Remove printfs. --- main/app/talk/core.hook | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/app/talk/core.hook b/main/app/talk/core.hook index df1f575fe2..63ce249302 100644 --- a/main/app/talk/core.hook +++ b/main/app/talk/core.hook @@ -595,7 +595,7 @@ ++ peer |= [ost=bone you=ship pax=path] ^- [(list move) _+>] - ~? !=(her our.hid) [%talk-peer ost her pax] + ~? !=(you our.hid) [%talk-peer ost her pax] :_ +> :_ ~ :* ost %give From f10e4dea476cfdc093e435b247d49178d8573469 Mon Sep 17 00:00:00 2001 From: Galen Wolfe-Pauly Date: Mon, 23 Mar 2015 11:30:08 -0700 Subject: [PATCH 110/219] talking --- main/pub/talk/src/css/main.css | 1 - main/pub/talk/src/css/main.styl | 1 - .../src/js/components/MessagesComponent.coffee | 1 - .../talk/src/js/components/PageComponent.coffee | 15 --------------- main/pub/talk/src/js/main.js | 2 +- main/pub/talk/src/js/package.json | 4 ++++ 6 files changed, 5 insertions(+), 19 deletions(-) delete mode 100644 main/pub/talk/src/js/components/PageComponent.coffee diff --git a/main/pub/talk/src/css/main.css b/main/pub/talk/src/css/main.css index 68bc9539d1..171bf93172 100644 --- a/main/pub/talk/src/css/main.css +++ b/main/pub/talk/src/css/main.css @@ -261,7 +261,6 @@ body { } .mess, .iden, -.attr > div, #station .member div, #writing { display: inline-block; diff --git a/main/pub/talk/src/css/main.styl b/main/pub/talk/src/css/main.styl index a90c32a191..1b472ced02 100644 --- a/main/pub/talk/src/css/main.styl +++ b/main/pub/talk/src/css/main.styl @@ -180,7 +180,6 @@ body .mess .iden -.attr > div #station .member div #writing display inline-block diff --git a/main/pub/talk/src/js/components/MessagesComponent.coffee b/main/pub/talk/src/js/components/MessagesComponent.coffee index ad29d3233f..b86193a182 100644 --- a/main/pub/talk/src/js/components/MessagesComponent.coffee +++ b/main/pub/talk/src/js/components/MessagesComponent.coffee @@ -41,7 +41,6 @@ Message = recl (div {className:"attr"}, [ div {onClick:@_handleAudi,className:"audi"}, "#{audi}" (div {onClick:@_handlePm}, (Member {ship:@props.ship}, "")) - (br {},"") div {className:"time"}, @convTime @props.thought.statement.date ]) div {className:"mess"}, @props.thought.statement.speech.lin.txt diff --git a/main/pub/talk/src/js/components/PageComponent.coffee b/main/pub/talk/src/js/components/PageComponent.coffee deleted file mode 100644 index ca8898d83a..0000000000 --- a/main/pub/talk/src/js/components/PageComponent.coffee +++ /dev/null @@ -1,15 +0,0 @@ -recl = React.createClass -[div,input,textarea] = [React.DOM.div,React.DOM.input,React.DOM.textarea] - -StationComponent = require './StationComponent.coffee' -MessagesComponent = require './MessagesComponent.coffee' -WritingComponent = require './WritingComponent.coffee' - -module.exports = recl - render: -> - div {id:"d"}, "asdf" - # div {id:"d"}, [ - # (div {id:'station-container'}, (StationComponent {}, "")) - # (div {id:'messages-container'}, (MessagesComponent {}, "")) - # (div {id:'writing-container'}, (WritingComponent {}, "")) - # ] \ No newline at end of file diff --git a/main/pub/talk/src/js/main.js b/main/pub/talk/src/js/main.js index 81f1b1894f..074f79274a 100644 --- a/main/pub/talk/src/js/main.js +++ b/main/pub/talk/src/js/main.js @@ -268,7 +268,7 @@ Message = recl({ onClick: this._handlePm }, Member({ ship: this.props.ship - }, "")), br({}, ""), div({ + }, "")), div({ className: "time" }, this.convTime(this.props.thought.statement.date)) ]), div({ diff --git a/main/pub/talk/src/js/package.json b/main/pub/talk/src/js/package.json index b5f836ae13..dbb272beee 100644 --- a/main/pub/talk/src/js/package.json +++ b/main/pub/talk/src/js/package.json @@ -1,6 +1,10 @@ { "name": "urbit-radio", "version": "0.0.0", + "repository": { + "type":"git", + "url":"https://github.com/urbit/urbit" + }, "description": "urbit radio frontend", "main": "main.js", "dependencies": { From 1389c6118b93e62ec5308b3ae3a057d02687e47d Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 23 Mar 2015 12:35:25 -0700 Subject: [PATCH 111/219] eyre proxying --- arvo/ames.hoon | 4 ---- arvo/eyre.hoon | 53 ++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/arvo/ames.hoon b/arvo/ames.hoon index 27b5e3674a..4681c5828b 100644 --- a/arvo/ames.hoon +++ b/arvo/ames.hoon @@ -53,9 +53,6 @@ ++ sign :: in result $<- $? $: %a :: from %ames $% [%went p=ship q=cape] :: - == == :: - $: %e :: from %eyre - $% [%thou p=httr] :: == == :: $: %g :: from %gall $% [%mean p=ares] :: @@ -1823,7 +1820,6 @@ ?- +<.sih %crud [[[hen [%slip %d %flog +.sih]] ~] +>] %went [~ +>] - %thou ~|(a/%eyre-stub !!) ?(%mean %nice) ?: ?=([%ye ~] tea) [~ +>.$] diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index e1bfe6affd..f03c837a8c 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -15,6 +15,8 @@ $? [[%lon ~] p=hole] :: login request [[%aut ~] p=hole] :: login reply [[%hat ~] p=hole q=hart] :: login redirect + [[%get ~] p=@uvH q=[? clip httq]] :: remote request + [[%got ~] p=@uvH q=httr] :: remote response == :: ++ hasp ,[p=ship q=term] :: don't see %gall ++ hapt ,[p=ship q=path] :: do see %gall @@ -35,6 +37,9 @@ == == :: $: %d :: to %dill $% [%flog p=[%crud p=@tas q=(list tank)]] :: + == == :: + $: %e :: to self + $% [%this p=? q=clip r=httq] :: proxied request == == :: $: %f :: to %ford $% [%exec p=@p q=(unit silk)] :: @@ -67,7 +72,10 @@ [%vega p=path] :: == == == :: ++ sign :: in result $<- - $? $: %f :: by %ford + $? $: %e :: by self + $% [%thou p=httr] :: response for proxy + == == :: + $: %f :: by %ford $% [%made p=@uvH q=(each cage tang)] :: [%news ~] :: == == :: @@ -87,6 +95,7 @@ ++ ixor ,@t :: oryx hash ++ whir $| ~ :: wire subset $% [%at p=hole q=whir] :: authenticated + [%ay p=span:ship q=span:,@uvH ~] :: remote duct [%of p=ixor ~] :: associated view [%on p=span:,@uvH ~] :: dependency [%to p=span:hasp q=span:ship ~] :: associated poke @@ -99,6 +108,7 @@ gub=@t :: random identity hov=(unit ship) :: master for remote ged=duct :: client interface + pox=(map ,@uvH duct) :: proxied sessions ney=@uvI :: rolling entropy dop=(map host ship) :: host aliasing liz=(jug ,@uvH (each duct ixor)) :: ford depsets @@ -347,13 +357,15 @@ ++ axon :: accept response |= [tee=whir typ=type sih=sign] ^+ +> - ~? ?=(%g -.sih) e/+<.sih + ~? ?=(%g -.sih) e/&2.sih =. our ?~(hov our u.hov) :: XX - ?- -.+.sih - %crud - +>.$(mow [[hen %slip %d %flog +.sih] mow]) - :: + ?- &2.sih + %crud +>.$(mow [[hen %slip %d %flog +.sih] mow]) %dumb ~|(%gall-stub !!) + %thou + ?> ?=([%ay ^] tee) + (ames-gram (slav %p p.tee) got/~ (slav %uv q.tee) |2.sih) + :: ?(%rush %rust) ?> ?=([%is ^] tee) %- ~(get-even ix p.tee (~(got by wix) p.tee)) @@ -384,7 +396,7 @@ =. our (need hov) :: XX |- ^+ ..axon ?- tee - [?(%of %on) *] ~|(e/ford/lost/-.tee !!) + [?(%of %on %ay) *] ~|(e/ford/lost/-.tee !!) [%is ^] %+ ~(get-rush ix p.tee (~(got by wix) p.tee)) [(pick-hasp q.tee) r.tee] @@ -451,7 +463,12 @@ [[sec (rash i.hot thor:epur)] p.ryp q.ryp] == =. p.p.pul |(p.p.pul ?=(hoke r.p.pul)) - abet:~(handle rq pul [anon q.+.kyz] [p.heq maf s.heq]) + =+ her=(host-to-ship r.p.pul) + ?: |(?=(~ her) =(our u.her)) + abet:~(handle rq pul [anon q.+.kyz] [p.heq maf s.heq]) + =+ han=(sham hen) + =. pox (~(put by pox) han hen) + (ames-gram u.her [%get ~] han +.kyz) :: %thud :: cancel request ~& e/gone/hen @@ -471,6 +488,16 @@ (ames-gram q.p.kyz aut/~ p.u.mez) =. sop (~(put by sop) p.u.mez q.p.kyz |) (ames-gram q.p.kyz hat/~ p.u.mez our-host) + :: + %get + %+ pass-note ay//(scot %p q.p.kyz)/(scot %uv p.u.mez) + [%e %this q.u.mez] + :: + %got + =: hen (~(got by pox) p.u.mez) + pox (~(del by pox) p.u.mez) + == + (give-gift %thou q.u.mez) == == :: @@ -972,8 +999,10 @@ |= [him=ship hat=hart] ^+ ..ya ~| way =^ pul hen (~(got by way) him) - =. way (~(del by way) him) - =. q.q.pul ['~' %am ses q.q.pul] + =: way (~(del by way) him) + dop (~(put by dop) r.hat him) + q.q.pul ['~' %am ses q.q.pul] + == =+ url=(welp (earn pul(p hat)) '#' (head:earn p.pul)) %- give-gift %+ add-cookies cug @@ -1108,9 +1137,9 @@ ~ :: ++ load :: clam previous state - |= old=_[%0 gub hov ged ney dop liz wup sop wix=**] + |= old=bolo ::_[%0 gub hov ged ney dop liz wup sop wix=**] ^+ ..^$ - ..^$(+>- (bolo old)) + ..^$(+>- old) :: ++ scry |= [our=(unit (set monk)) ren=@tas who=ship syd=desk lot=coin tyl=path] From f7976ecdf48649cc00820b1f3e9bfe76a9029d03 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 23 Mar 2015 13:33:15 -0700 Subject: [PATCH 112/219] Handle %went acks --- arvo/eyre.hoon | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index f03c837a8c..591bff25be 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -72,7 +72,10 @@ [%vega p=path] :: == == == :: ++ sign :: in result $<- - $? $: %e :: by self + $? $: %a :: by %ames + $% [%went p=ship q=cape] :: + == == :: + $: %e :: by self $% [%thou p=httr] :: response for proxy == == :: $: %f :: by %ford @@ -362,6 +365,7 @@ ?- &2.sih %crud +>.$(mow [[hen %slip %d %flog +.sih] mow]) %dumb ~|(%gall-stub !!) + %went +>.$ %thou ?> ?=([%ay ^] tee) (ames-gram (slav %p p.tee) got/~ (slav %uv q.tee) |2.sih) From ba090061ea45882944ddbf6fe0a86635908e7daf Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Mon, 23 Mar 2015 13:56:00 -0700 Subject: [PATCH 113/219] Various fixes. --- main/app/dojo/core.hook | 6 +++++- main/app/talk/core.hook | 2 +- main/lib/console/core.hook | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 16620eeddc..188f844822 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -605,14 +605,18 @@ ++ he-stir :: apply change |= cal=console-change ^+ +> + :: ~& [%his-clock ler.cal] + :: ~& [%our-clock ven.say] =^ dat say (~(transceive cs say) cal) ?. ?& ?=(%del -.dat) - =(+(p.dat) (lent buf.say)) + :: =(+(p.dat) (lent buf.say)) == +>.$ =+ foy=(he-dope (tufa buf.say)) ?: ?=(%& -.foy) +>.$ + :: ~& [%bad-change dat ted.cal] =^ lic say (~(transmit cs say) dat) + :: ~& [%our-leg leg.say] (he-rush %mor [%det lic] [%err q.p.foy] ~) :: ++ he-plan :: execute command diff --git a/main/app/talk/core.hook b/main/app/talk/core.hook index 63ce249302..8348d0a17c 100644 --- a/main/app/talk/core.hook +++ b/main/app/talk/core.hook @@ -595,7 +595,7 @@ ++ peer |= [ost=bone you=ship pax=path] ^- [(list move) _+>] - ~? !=(you our.hid) [%talk-peer ost her pax] + ~? !=(you our.hid) [%talk-peer ost you pax] :_ +> :_ ~ :* ost %give diff --git a/main/lib/console/core.hook b/main/lib/console/core.hook index 5d64871f5b..6654549fbe 100644 --- a/main/lib/console/core.hook +++ b/main/lib/console/core.hook @@ -73,7 +73,7 @@ ++ commit :: local change |= ted=console-edit ^- console-share - abet:(apply(own.ven +(own.ven)) ted) + abet:(apply(own.ven +(own.ven), leg [ted leg]) ted) :: :::: :: ++inverse: inverse of change in context. @@ -106,7 +106,9 @@ ?> &(=(his.ler his.ven) (lte own.ler own.ven)) ?> |(!=(own.ler own.ven) =(haw (sham buf))) =. leg (scag (sub own.ven own.ler) leg) + :: ~? !=(own.ler own.ven) [%miss-leg leg] =+ dat=(transmute [%mor leg] ted) + :: ~? !=(~ leg) [%transmute from/ted to/dat ~] [dat abet:(apply(his.ven +(his.ven)) dat)] :: ++ remit :: conditional accept From eabebb27d2f63b3412a91d7f79b059f2768ba81c Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Mon, 23 Mar 2015 13:57:53 -0700 Subject: [PATCH 114/219] Change fake packet size to 16. --- arvo/ames.hoon | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arvo/ames.hoon b/arvo/ames.hoon index 144ced50c0..837449cbc6 100644 --- a/arvo/ames.hoon +++ b/arvo/ames.hoon @@ -631,12 +631,12 @@ =^ gim ..weft wisp :_ +>.$ ^- (list rock) - =+ wit=(met ?:(fak.ton 18 13) q.gim) + =+ wit=(met ?:(fak.ton 16 13) q.gim) ?< =(0 wit) ?: =(1 wit) =+ yup=(spit [our her] p.gim q.gim) [yup ~] - =+ ruv=(rip ?:(fak.ton 18 13) q.gim) + =+ ruv=(rip ?:(fak.ton 16 13) q.gim) =+ gom=(shaf %thug q.gim) =+ inx=0 |- ^- (list rock) @@ -1409,7 +1409,7 @@ =+ [nix=0 rax=*(list ,@)] |- ^- @ ?: =(p.duv nix) - (can ?:(fak.ton.fox 18 13) (turn (flop rax) |=(a=@ [1 a]))) + (can ?:(fak.ton.fox 16 13) (turn (flop rax) |=(a=@ [1 a]))) $(nix +(nix), rax [(need (~(get by q.duv) nix)) rax]) -- :: --la:ho:um:am :: From 8049e88543249d4f2dc2e2ec8c58c262a491ff55 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 23 Mar 2015 13:58:08 -0700 Subject: [PATCH 115/219] Restored outbound requests --- arvo/eyre.hoon | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 591bff25be..6966bff309 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -24,8 +24,8 @@ $% [%born ~] :: new unix process [%crud p=@tas q=(list tank)] :: XX rethink [%init p=@p] :: report install -:: [%them p=(unit hiss)] :: outbound request -:: [%they p=@ud q=httr] :: inbound response + [%them p=(unit hiss)] :: outbound request + [%they p=@ud q=httr] :: inbound response [%this p=? q=clip r=httq] :: inbound request [%thud ~] :: inbound cancel [%wart p=sack q=@tas r=_`[path *]`*gram] :: urbit message @@ -112,6 +112,8 @@ hov=(unit ship) :: master for remote ged=duct :: client interface pox=(map ,@uvH duct) :: proxied sessions + ask=[p=@ud q=(map ,@ud ,[p=duct q=hiss])] :: outgoing by number + kes=(map duct ,@ud) :: outgoing by duct ney=@uvI :: rolling entropy dop=(map host ship) :: host aliasing liz=(jug ,@uvH (each duct ixor)) :: ford depsets @@ -473,6 +475,30 @@ =+ han=(sham hen) =. pox (~(put by pox) han hen) (ames-gram u.her [%get ~] han +.kyz) + :: + %them :: outbound request + ?~ p.kyz + =+ sud=(need (~(get by kes) hen)) + %= +>.$ + mow :_(mow [ged [%give %thus sud ~]]) + q.ask (~(del by q.ask) sud) + kes (~(del by kes) hen) + == + :: ~& eyre-them/(earn p.u.p.kyz) + %= +>.$ + mow :_(mow [ged [%give %thus p.ask p.kyz]]) + p.ask +(p.ask) + q.ask (~(put by q.ask) p.ask hen u.p.kyz) + kes (~(put by kes) hen p.ask) + == + :: + %they :: inbound response + =+ kas=(need (~(get by q.ask) p.kyz)) + :: ~& > eyre-they/[p.q.kyz (earn p.q.kas)] + %= +>.$ + mow :_(mow [p.kas [%give %thou q.kyz]]) + q.ask (~(del by q.ask) p.kas) + == :: %thud :: cancel request ~& e/gone/hen @@ -931,6 +957,7 @@ ?^ lig =+ cyz=(~(got by wup) u.lig) ~(. ya u.lig cyz(cug ~)) + =. ..ya adit :: XX necessary? =+ ses=(rsh 3 1 (scot %p (end 6 1 ney))) ~(. ya ses (ses-cyst ses)) :: From 14f7a42c1e92eca1350d59f18ca7f94892e8b4ed Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Mon, 23 Mar 2015 20:50:01 -0700 Subject: [PATCH 116/219] Lose some printfs. --- main/app/dojo/core.hook | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 188f844822..5d63ff0479 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -609,7 +609,7 @@ :: ~& [%our-clock ven.say] =^ dat say (~(transceive cs say) cal) ?. ?& ?=(%del -.dat) - :: =(+(p.dat) (lent buf.say)) + =(+(p.dat) (lent buf.say)) == +>.$ =+ foy=(he-dope (tufa buf.say)) From f7b24b74ee68429c470ab7c34b638081a2688ff9 Mon Sep 17 00:00:00 2001 From: Galen Wolfe-Pauly Date: Tue, 24 Mar 2015 12:21:50 -0700 Subject: [PATCH 117/219] pruning --- main/pub/talk/src/css/main.css | 244 +++------------- main/pub/talk/src/css/main.styl | 266 ++++-------------- .../src/js/components/StationComponent.coffee | 9 +- .../src/js/components/WritingComponent.coffee | 1 - main/pub/talk/src/js/main.coffee | 22 +- main/pub/talk/src/js/main.js | 145 ++-------- 6 files changed, 124 insertions(+), 563 deletions(-) diff --git a/main/pub/talk/src/css/main.css b/main/pub/talk/src/css/main.css index 171bf93172..ddcf6047ee 100644 --- a/main/pub/talk/src/css/main.css +++ b/main/pub/talk/src/css/main.css @@ -112,6 +112,9 @@ input.join, #station { font-size: 0.7rem; } +.iden { + font-weight: 600; +} html, body { font-size: 18px; @@ -125,34 +128,29 @@ body { display: none; } #c { - top: 0; - background-color: #fff; + position: absolute; + top: 4rem; + left: 50%; + width: 58rem; + margin-left: -29rem; + margin-bottom: 4rem; } -#stations-container { +#station-container { position: absolute; top: 1rem; - left: 50%; - width: 24rem; - margin-left: -12rem; - font-size: 4rem; } #station #station-container { padding-top: 1rem; min-width: 30rem; text-align: right; } -#stations-container, +#writing-container { + bottom: 4rem; + margin-bottom: 1rem; +} #messages-container { vertical-align: top; } -#messaging-container { - position: absolute; - top: 4rem; - left: 50%; - width: 66rem; - margin-left: -46rem; - margin-bottom: 4rem; -} #station > div { display: inline-block; } @@ -164,48 +162,6 @@ body { width: 6rem; margin-left: 0.3rem; } -#sources-container { - position: fixed; - top: 0; - left: 50%; - margin-left: -35rem; - text-align: right; - background-color: #000; - color: #fff; - padding: 1rem; -} -#members { - margin-left: 2rem; -} -.station { - margin-bottom: 0.3rem; - cursor: pointer; - font-weight: 200; -} -#stations .station { - display: block; - width: 24rem; -} -.station .name { - padding: 0.3rem; - border-bottom: 6px solid transparent; -} -.station .name:hover { - background-color: #f5f5f5; - border-bottom: 6px solid #ededed; -} -.station > div { - display: inline-block; -} -.toggle { - width: 0.4rem; - height: 0.4rem; - border: 2px solid #000; - margin-right: 0.6rem; -} -.toggle.active { - background-color: #000; -} .station .remove { display: none; float: right; @@ -216,15 +172,6 @@ body { .station:hover .remove { display: inline; } -#sources-container .station { - font-family: "scp"; - font-weight: 500; - text-transform: lowercase; -} -.sour-ctrl { - margin-bottom: 0.16rem; -} -.join-ctrl input, .sour-ctrl input { border: none; font-weight: 400; @@ -277,7 +224,7 @@ body { text-align: right; display: inline-block; margin-right: 0.3rem; - min-width: 30rem; + min-width: 10rem; } .attr .iden { color: #000; @@ -291,23 +238,18 @@ body { max-width: 30rem; margin-left: 0.3rem; } -.ship { - font-weight: 600; +#writing { + font-size: 0.9rem; + min-height: 1.6rem; + min-width: 1.3rem; + outline: none; + background-color: #eee; + padding: 0.3rem 0.1rem; + margin-left: 0.2rem; + margin-top: -0.3rem; } -.ship.talk:before { - content: "..."; - margin-left: -1.3rem; - margin-right: 0.3rem; - width: 1rem; - margin-top: -0.4rem; - vertical-align: middle; - display: inline-block; - line-height: 0.2rem; - letter-spacing: -0.1rem; -} -#writing-container { - bottom: 4rem; - margin-bottom: 1rem; +#writing:focus { + background-color: #fff; } .writing { padding-top: 0.3rem; @@ -317,73 +259,25 @@ body { margin-left: 1rem; margin-top: 1.2rem; } +.writing .iden { + display: block; + text-align: right; + width: 100%; +} +.writing .iden .ship { + margin-right: 0.3rem; +} #audi { + display: inline-block; background-color: #eee; - padding: 0.3rem; + padding: 0.3rem 0.1rem; margin-top: -0.3rem; + margin-right: -0.2rem; outline: none; - margin-right: -0.3rem; } #audi.valid-false { color: #ff2f2f; } -#writing { - font-size: 0.9rem; - min-height: 1.6rem; - min-width: 1.3rem; - padding: 0; - outline: none; - background-color: #eee; - margin-left: 0.3rem; -} -#writing:focus { - background-color: #fff; -} -#station h1 { - display: inline-block; - margin: 0; - font-weight: 200; - font-size: 2rem; - text-transform: lowercase; -} -input.join { - text-align: right; - font-size: 4rem; - background-color: transparent; - outline: none; - width: 24rem; - color: #fff; -} -#station input.join { - font-family: "scp"; - font-size: 0.7rem; - line-height: 1rem; - width: 12rem; -} -input.join::-webkit-input-placeholder { - color: #fff; -} -input.join:focus::-webkit-input-placeholder { - color: #000; -} -.pending { - color: #ccc; -} -a.up { - height: 2rem; - margin-top: 0.6rem; - vertical-align: middle; - display: inline-block; -} -.arow-up { - display: inline-block; - margin: 0 0.5rem 0 0.5rem; - width: 0; - height: 0; - border-left: 9px solid transparent; - border-right: 9px solid transparent; - border-bottom: 9px solid #000; -} #scrolling { display: none; } @@ -399,67 +293,3 @@ a.up { font-size: 0.8rem; text-transform: uppercase; } -@media (max-width: 40rem) { - #c { - left: 0; - margin-left: 0; - width: 24rem; - } - #messages-container, - #writing-container { - margin-left: 1rem; - } - #stations-container, - #station-container { - position: relative; - float: left; - } - #stations-container { - width: 8rem; - } - #station-container { - left: auto; - } - .station { - width: 5rem; - } - .attr { - display: block; - text-align: left; - width: 2rem; - margin-right: 1rem; - } - .message { - height: 1.6rem; - } - .stations, - .iden, - #station { - font-size: 0.5rem; - } - .station .remove { - display: inline; - font-size: 0.6rem; - line-height: 0.6rem; - } - .ship.talk:before { - margin-left: -0.3rem; - margin-right: 0; - } - .attr { - width: 4rem; - } - .iden > div { - display: block; - } - .attr > .time { - display: none; - } - .mess { - max-width: 12rem; - margin-bottom: 1rem; - } - #writing { - max-width: 12rem; - } -} diff --git a/main/pub/talk/src/css/main.styl b/main/pub/talk/src/css/main.styl index 1b472ced02..8043712dc9 100644 --- a/main/pub/talk/src/css/main.styl +++ b/main/pub/talk/src/css/main.styl @@ -1,3 +1,7 @@ +// +// fonts first +// + @import 'fonts' .iden @@ -30,10 +34,17 @@ input.join #station font-size .7rem +.iden + font-weight 600 + html body font-size 18px +// +// containers +// + body background-color #fefefe padding 0 @@ -43,33 +54,32 @@ body display none #c - top 0 - background-color #fff + position absolute + top 4rem + left 50% + width 58rem + margin-left -29rem + margin-bottom 4rem -#stations-container +#station-container position absolute top 1rem - left 50% - width 24rem - margin-left -12rem - font-size 4rem #station #station-container padding-top 1rem min-width 30rem text-align right -#stations-container +#writing-container + bottom 4rem + margin-bottom 1rem + #messages-container vertical-align top -#messaging-container - position absolute - top 4rem - left 50% - width 66rem - margin-left -46rem - margin-bottom 4rem +// +// station +// #station > div display inline-block @@ -82,48 +92,6 @@ body width 6rem margin-left .3rem -#sources-container - position fixed - top 0 - left 50% - margin-left -35rem - text-align right - background-color #000 - color #fff - padding 1rem - -#members - margin-left 2rem - -.station - margin-bottom .3rem - cursor pointer - font-weight 200 - -#stations .station - display block - width 24rem - -.station .name - padding .3rem - border-bottom 6px solid transparent - -.station .name:hover - background-color #f5f5f5 - border-bottom 6px solid #ededed - -.station > div - display inline-block - -.toggle - width .4rem - height .4rem - border 2px solid #000 - margin-right .6rem - -.toggle.active - background-color #000 - .station .remove display none float right @@ -134,16 +102,7 @@ body .station:hover .remove display inline -#sources-container .station - font-family "scp" - font-weight 500 - text-transform lowercase - -// hate this. -.sour-ctrl - margin-bottom .16rem - -.join-ctrl input +// add source .sour-ctrl input border none font-weight 400 @@ -155,6 +114,10 @@ body margin-left .6rem color #0003FF +// +// messages +// + .message padding-top .3rem @@ -196,7 +159,7 @@ body text-align right display inline-block margin-right .3rem - min-width 30rem + min-width 10rem .attr .iden color #000 @@ -210,23 +173,22 @@ body max-width 30rem margin-left .3rem -.ship - font-weight 600 +// +// writing +// -.ship.talk:before - content "..." - margin-left -1.3rem - margin-right .3rem - width 1rem - margin-top -.4rem - vertical-align middle - display inline-block - line-height .2rem - letter-spacing -.1rem +#writing + font-size .9rem + min-height 1.6rem + min-width 1.3rem + outline none + background-color #eee + padding .3rem .1rem + margin-left .2rem + margin-top -.3rem -#writing-container - bottom 4rem - margin-bottom 1rem +#writing:focus + background-color #fff .writing padding-top .3rem @@ -236,72 +198,28 @@ body margin-left 1rem margin-top 1.2rem +.writing .iden + display block + text-align right + width 100% + +.writing .iden .ship + margin-right .3rem + #audi + display inline-block background-color #eee - padding .3rem + padding .3rem .1rem margin-top -.3rem + margin-right -.2rem outline none - margin-right -.3rem #audi.valid-false color #ff2f2f -#writing - font-size .9rem - min-height 1.6rem - min-width 1.3rem - padding 0 - outline none - background-color #eee - margin-left .3rem - -#writing:focus - background-color #fff - -#station h1 - display inline-block - margin 0 - font-weight 200 - font-size 2rem - text-transform lowercase - -input.join - text-align right - font-size 4rem - background-color transparent - outline none - width 24rem - color #fff - -#station input.join - font-family "scp" - font-size .7rem - line-height 1rem - width 12rem - -input.join::-webkit-input-placeholder - color #fff - -input.join:focus::-webkit-input-placeholder - color #000 - -.pending - color #ccc - -a.up - height 2rem - margin-top .6rem - vertical-align middle - display inline-block - -.arow-up - display inline-block - margin 0 .5rem 0 .5rem - width 0 - height 0 - border-left 9px solid transparent - border-right 9px solid transparent - border-bottom 9px solid #000 +// +// scrolling +// #scrolling display none @@ -316,68 +234,4 @@ a.up background-color #f9f9f9 font-weight 500 font-size .8rem - text-transform uppercase - -@media (max-width: 40rem) - #c - left 0 - margin-left 0 - width 24rem - - #messages-container - #writing-container - margin-left 1rem - - #stations-container - #station-container - position relative - float left - - #stations-container - width 8rem - - #station-container - left auto - - .station - width 5rem - - .attr - display block - text-align left - width 2rem - margin-right 1rem - - .message - height 1.6rem - - .stations - .iden - #station - font-size .5rem - - .station .remove - display inline - font-size .6rem - line-height .6rem - - .ship.talk:before - margin-left -.3rem - margin-right 0 - - .attr - width 4rem - - .iden > div - display block - - .attr > .time - display none - - .mess - max-width 12rem - margin-bottom 1rem - - #writing - max-width 12rem - \ No newline at end of file + text-transform uppercase \ No newline at end of file diff --git a/main/pub/talk/src/js/components/StationComponent.coffee b/main/pub/talk/src/js/components/StationComponent.coffee index b3a7f294e4..0d4f22cd67 100644 --- a/main/pub/talk/src/js/components/StationComponent.coffee +++ b/main/pub/talk/src/js/components/StationComponent.coffee @@ -68,7 +68,7 @@ module.exports = recl members = "" sourceInput = [(input {className:"join",onKeyUp:@_keyUp,placeholder:"+"}, "")] - sourceCtrl = div {className:"sour-ctrl"}, sourceInput + sourceCtrl = div {className:"sour-ctrl"},sourceInput sources = [] if @state.station and @state.configs[@state.station] @@ -79,16 +79,13 @@ module.exports = recl (div {className:"path"}, source), (div {className:"remove",onClick:_remove,"data-station":source},"×") ]) - else sources = "" station = [] - # station.push (a {className:"up",href:"\#/"}, [(div {className:"arow-up"}, "")]) - # station.push (h1 {},@state.station) station.push (div {id:"members"},members) - parts.push (div {id:"station-container"}, (div {id:"station-meta"},station)) - parts.push (div {id:"sources-container"}, [(div {class:"sources-list"},sources),sourceCtrl]) + parts.push (div {id:"audience"}, (div {},station)) + parts.push (div {id:"stations"}, [(div {},sources),sourceCtrl]) div {id:"station"},parts \ No newline at end of file diff --git a/main/pub/talk/src/js/components/WritingComponent.coffee b/main/pub/talk/src/js/components/WritingComponent.coffee index dd11844fda..4027f9b1a6 100644 --- a/main/pub/talk/src/js/components/WritingComponent.coffee +++ b/main/pub/talk/src/js/components/WritingComponent.coffee @@ -165,7 +165,6 @@ module.exports = recl onBlur:@_setAudi }, audi.join(" ")) (Member iden, "") - (br {},"") (div {className:"time"}, @getTime()) ]) (div { diff --git a/main/pub/talk/src/js/main.coffee b/main/pub/talk/src/js/main.coffee index 360fa1b77d..0df82a85d5 100644 --- a/main/pub/talk/src/js/main.coffee +++ b/main/pub/talk/src/js/main.coffee @@ -72,8 +72,7 @@ $(() -> send() getScroll: -> - @writingPosition = $('#messaging-container').outerHeight(true)+$('#messaging-container').offset().top-$(window).height() - #@writingPosition = $('#writing-container').position().top-$(window).height()+$('#writing-container').outerHeight(true) + @writingPosition = $('#c').outerHeight(true)+$('#c').offset().top-$(window).height() setScroll: -> window.util.getScroll() @@ -92,26 +91,21 @@ $(() -> window.chat.StationPersistence.listen() StationComponent = require './components/StationComponent.coffee' - StationsComponent = require './components/StationsComponent.coffee' MessagesComponent = require './components/MessagesComponent.coffee' WritingComponent = require './components/WritingComponent.coffee' $c = $('#c') clean = -> - React.unmountComponentAtNode $('#stations-container')[0] - React.unmountComponentAtNode $('#station-parts-container')[0] - React.unmountComponentAtNode $('#writing-container')[0] + React.unmountComponentAtNode $('#station-container')[0] React.unmountComponentAtNode $('#messages-container')[0] + React.unmountComponentAtNode $('#writing-container')[0] - $c.html "" - $c.append("
") - $d = $('#messaging-container') - $d.append("
") - $d.append("
") - $d.append("
") - $c.append("
BOTTOM
") - rend (StationComponent {}, ""),$('#station-parts-container')[0] + $c.append "
" + $c.append "
" + $c.append "
" + $c.append "
BOTTOM
" + rend (StationComponent {}, ""),$('#station-container')[0] rend (MessagesComponent {}, ""),$('#messages-container')[0] rend (WritingComponent {}, ""),$('#writing-container')[0] ) \ No newline at end of file diff --git a/main/pub/talk/src/js/main.js b/main/pub/talk/src/js/main.js index 074f79274a..331152ee0f 100644 --- a/main/pub/talk/src/js/main.js +++ b/main/pub/talk/src/js/main.js @@ -512,17 +512,11 @@ module.exports = recl({ id: "members" }, members)); parts.push(div({ - id: "station-container" - }, div({ - id: "station-meta" - }, station))); + id: "audience" + }, div({}, station))); parts.push(div({ - id: "sources-container" - }, [ - div({ - "class": "sources-list" - }, sources), sourceCtrl - ])); + id: "stations" + }, [div({}, sources), sourceCtrl])); return div({ id: "station" }, parts); @@ -531,109 +525,7 @@ module.exports = recl({ -},{"../actions/StationActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/actions/StationActions.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/stores/StationStore.coffee","./MemberComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/MemberComponent.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/StationsComponent.coffee":[function(require,module,exports){ -var StationActions, StationStore, div, input, recl, ref; - -recl = React.createClass; - -ref = [React.DOM.div, React.DOM.input], div = ref[0], input = ref[1]; - -StationStore = require('../stores/StationStore.coffee'); - -StationActions = require('../actions/StationActions.coffee'); - -module.exports = recl({ - stateFromStore: function() { - return { - stations: StationStore.getStations(), - station: "~zod/court" - }; - }, - getInitialState: function() { - return this.stateFromStore(); - }, - componentDidMount: function() { - this.$el = $(this.getDOMNode()); - this.$add = $('#stations .add'); - this.$input = this.$el.find('input'); - return StationStore.addChangeListener(this._onChangeStore); - }, - componentWillUnmount: function() { - return StationStore.removeChangeListener(this._onChangeStore); - }, - _onChangeStore: function() { - return this.setState(this.stateFromStore()); - }, - _click: function(e) { - var s; - s = $(e.target).closest('.station').find('.name').text(); - return window.location.hash = "/" + (s.toLowerCase()); - }, - _keyUp: function(e) { - var v; - if (e.keyCode === 13) { - v = this.$input.val().toLowerCase(); - if (this.state.stations.indexOf(v) === -1) { - StationActions.createStation(v); - this.$input.val(''); - return this.$input.blur(); - } - } - }, - _remove: function(e) { - var _station, _stations; - _station = $(e.target).parent().find('.name').text(); - _stations = _.without(this.state.stations, _station); - StationActions.removeStation(_station, _stations); - e.stopPropagation(); - return e.preventDefault(); - }, - render: function() { - var _click, _remove, station, stations; - station = this.state.station; - _click = this._click; - _remove = this._remove; - stations = this.state.stations.map(function(_station) { - var k, parts; - k = "station"; - parts = [ - div({ - className: "name" - }, _station.name) - ]; - if (_station.name !== window.util.mainStation()) { - parts.push(div({ - className: "remove", - onClick: _remove, - dataStation: _station.name - }, "×")); - } - return div({ - className: k, - onClick: _click - }, parts); - }); - return div({ - id: "stations" - }, [ - div({ - className: "stations" - }, stations), div({ - className: "join-ctrl" - }, [ - input({ - className: "join", - onKeyUp: this._keyUp, - placeholder: "+" - }, "") - ]) - ]); - } -}); - - - -},{"../actions/StationActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/actions/StationActions.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/stores/StationStore.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/WritingComponent.coffee":[function(require,module,exports){ +},{"../actions/StationActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/actions/StationActions.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/stores/StationStore.coffee","./MemberComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/MemberComponent.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/WritingComponent.coffee":[function(require,module,exports){ var Member, MessageActions, MessageStore, StationActions, StationStore, br, div, input, recl, ref, textarea; recl = React.createClass; @@ -844,7 +736,7 @@ module.exports = recl({ className: "audi valid-" + this.state.valid, contentEditable: true, onBlur: this._setAudi - }, audi.join(" ")), Member(iden, ""), br({}, ""), div({ + }, audi.join(" ")), Member(iden, ""), div({ className: "time" }, this.getTime()) ]), div({ @@ -889,7 +781,7 @@ module.exports = _.merge(new Dispatcher(), { },{"flux":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/node_modules/flux/index.js"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/main.coffee":[function(require,module,exports){ $(function() { - var $c, $d, MessagesComponent, StationActions, StationComponent, StationsComponent, WritingComponent, clean, rend; + var $c, MessagesComponent, StationActions, StationComponent, WritingComponent, clean, rend; StationActions = require('./actions/StationActions.coffee'); rend = React.render; window.chat = {}; @@ -980,7 +872,7 @@ $(function() { return send(); }, getScroll: function() { - return this.writingPosition = $('#messaging-container').outerHeight(true) + $('#messaging-container').offset().top - $(window).height(); + return this.writingPosition = $('#c').outerHeight(true) + $('#c').offset().top - $(window).height(); }, setScroll: function() { window.util.getScroll(); @@ -1000,31 +892,26 @@ $(function() { $(window).on('scroll', window.util.checkScroll); window.chat.StationPersistence.listen(); StationComponent = require('./components/StationComponent.coffee'); - StationsComponent = require('./components/StationsComponent.coffee'); MessagesComponent = require('./components/MessagesComponent.coffee'); WritingComponent = require('./components/WritingComponent.coffee'); $c = $('#c'); clean = function() { - React.unmountComponentAtNode($('#stations-container')[0]); - React.unmountComponentAtNode($('#station-parts-container')[0]); - React.unmountComponentAtNode($('#writing-container')[0]); - return React.unmountComponentAtNode($('#messages-container')[0]); + React.unmountComponentAtNode($('#station-container')[0]); + React.unmountComponentAtNode($('#messages-container')[0]); + return React.unmountComponentAtNode($('#writing-container')[0]); }; - $c.html(""); - $c.append("
"); - $d = $('#messaging-container'); - $d.append("
"); - $d.append("
"); - $d.append("
"); + $c.append("
"); + $c.append("
"); + $c.append("
"); $c.append("
BOTTOM
"); - rend(StationComponent({}, ""), $('#station-parts-container')[0]); + rend(StationComponent({}, ""), $('#station-container')[0]); rend(MessagesComponent({}, ""), $('#messages-container')[0]); return rend(WritingComponent({}, ""), $('#writing-container')[0]); }); -},{"./actions/StationActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/actions/StationActions.coffee","./components/MessagesComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/MessagesComponent.coffee","./components/StationComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/StationComponent.coffee","./components/StationsComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/StationsComponent.coffee","./components/WritingComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/WritingComponent.coffee","./persistence/MessagePersistence.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/persistence/MessagePersistence.coffee","./persistence/StationPersistence.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/persistence/StationPersistence.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/node_modules/flux/index.js":[function(require,module,exports){ +},{"./actions/StationActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/actions/StationActions.coffee","./components/MessagesComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/MessagesComponent.coffee","./components/StationComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/StationComponent.coffee","./components/WritingComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/components/WritingComponent.coffee","./persistence/MessagePersistence.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/persistence/MessagePersistence.coffee","./persistence/StationPersistence.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/persistence/StationPersistence.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/main/pub/talk/src/js/node_modules/flux/index.js":[function(require,module,exports){ /** * Copyright (c) 2014, Facebook, Inc. * All rights reserved. From 60a310df7236e6532f761eb5971281090c7fdb9a Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 24 Mar 2015 12:49:30 -0700 Subject: [PATCH 118/219] fix multi-long-poll --- arvo/eyre.hoon | 1 + 1 file changed, 1 insertion(+) diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 6966bff309..2888f366df 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -392,6 +392,7 @@ %+ roll (~(tap in (~(get ju liz) dep))) =< .(con ..axon(liz (~(del by liz) dep))) |= [sus=(each duct ixor) con=_..axon] + =. ..axon con ?- -.sus %& (give-json(hen p.sus) 205 ~ %b &) %| %- ~(get-even ix p.sus (~(got by wix) p.sus)) From 315c321d6509bdc90770034b26b4937901c32c82 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 24 Mar 2015 15:56:11 -0700 Subject: [PATCH 119/219] Fix gall backpressure from seat. --- arvo/dill.hoon | 8 +++++++- main/app/dojo/core.hook | 2 +- main/app/seat/core.hook | 21 +++++++++++++++------ main/sur/console/core.hook | 1 + 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/arvo/dill.hoon b/arvo/dill.hoon index 167bbd560f..b0df46de76 100644 --- a/arvo/dill.hoon +++ b/arvo/dill.hoon @@ -49,6 +49,7 @@ $% [%bel ~] :: make a noise [%clr ~] :: clear the screen [%hop p=@ud] :: set cursor position + [%mor p=(list dill-blit)] :: multiple blits [%pro p=(list ,@c)] :: show as cursor/line [%out p=(list ,@c)] :: send output line [%sag p=path q=*] :: save to jamfile @@ -236,6 +237,10 @@ ++ from :: receive belt |= bit=dill-blit ^+ +> + ?: ?=(%mor -.bit) + |- ^+ +>.^$ + ?~ p.bit +>.^$ + $(p.bit t.p.bit, +>.^$ ^$(bit i.p.bit)) ?: ?=(%out -.bit) %+ done %blit :~ [%lin p.bit] @@ -250,6 +255,7 @@ (done %blit [bit ~]) :: ++ init :: initialize + ~& [%dill-init our] =+ myt=(flop (need tem)) =. tem ~ =. moz :_(moz [hen %pass ~ %g %show [our [ram ~]] our ~]) @@ -376,7 +382,7 @@ =+ ^= flo ^- (list (pair ship term)) =+ myr=(clan p.q.hic) ?: =(%pawn myr) - ~ + [p.q.hic %dojo]~ ?: =(%earl myr) =+ fap=(sein p.q.hic) [[fap %dojo] [fap %talk] ~] diff --git a/main/app/dojo/core.hook b/main/app/dojo/core.hook index 5d63ff0479..0110e485f1 100644 --- a/main/app/dojo/core.hook +++ b/main/app/dojo/core.hook @@ -215,7 +215,7 @@ ++ dp-model-sic ;~(plug dp-server-sic dp-config) :: ++dojo-model ++ dp-server-gun (stag 0 (stag %gun dp-device)) :: ++dojo-server ++ dp-server-sic (stag 0 (stag %sic dp-device)) :: ++dojo-server - ++ dp-twig wide:(vang & ~) :: ++twig + ++ dp-twig long:(vang & ~) :: ++twig ++ dp-device (most fas sym) :: ++dojo-device ++ dp-value :: ++dojo-source %+ cook |=(a=dojo-source a) diff --git a/main/app/seat/core.hook b/main/app/seat/core.hook index 5a08d8b98b..c4990328bd 100644 --- a/main/app/seat/core.hook +++ b/main/app/seat/core.hook @@ -98,9 +98,16 @@ == -- ++ se :: per source - |_ [moz=(list move) [her=ship ost=bone] source] + |_ $: [moz=(list move) biz=(list dill-blit)] + [her=ship ost=bone] + source + == ++ se-abet :: resolve - [(flop moz) %_(+> bin (~(put by bin) ost +<+>))] + :_ %_(+> bin (~(put by bin) ost +<+>)) + %+ welp (flop moz) + ^- (list move) + ?~ biz ~ + [ost %give %rush %dill-blit ?~(t.biz i.biz [%mor (flop biz)])]~ :: ++ se-belt :: handle input |= bet=dill-belt @@ -195,7 +202,7 @@ :: ++ se-blit :: give output |= bil=dill-blit - (se-emit ost %give %rush %dill-blit bil) + +>(biz [bil biz]) :: ++ se-show :: show buffer, raw |= lin=(pair ,@ud (list ,@c)) @@ -577,6 +584,7 @@ ++ peer |= [ost=bone her=ship pax=path] ^- [(list move) _+>] + ~& [%seat-peer ost her pax] ?< (~(has by bin) ost) :- [ost %give %rush %dill-blit %pro [`@c`0x23 `@c`0x20 ~]]~ %= +> @@ -603,17 +611,18 @@ ^- [(list move) _+>] =< se-abet =< se-view - (~(se-belt se [ost %give %nice ~]~ [her ost] (~(got by bin) ost)) bet) + (~(se-belt se [[ost %give %nice ~]~ ~] [her ost] (~(got by bin) ost)) bet) :: ++ pour |= [ost=bone pax=path sih=*] ^- [(list move) _+>] + ~? =(~ (~(get by bin) ost)) [%seat-pour ost pax] =+ sih=((hard sign) sih) ?> ?=([@ @ @ ~] pax) =< se-abet =< se-view =+ gyl=[(slav %p i.t.pax) i.t.t.pax] - (~(se-pour se ~ [(slav %p i.pax) ost] (~(got by bin) ost)) gyl +.sih) + (~(se-pour se [~ ~] [(slav %p i.pax) ost] (~(got by bin) ost)) gyl +.sih) :: ++ pull |= ost=bone @@ -621,6 +630,6 @@ =^ moz +> =< se-abet =< se-view - ~(se-kill se ~ [our.hid ost] (~(got by bin) ost)) + ~(se-kill se [~ ~] [our.hid ost] (~(got by bin) ost)) [moz +>.$(bin (~(del by bin) ost))] -- diff --git a/main/sur/console/core.hook b/main/sur/console/core.hook index 2911169d00..fbb405e13a 100644 --- a/main/sur/console/core.hook +++ b/main/sur/console/core.hook @@ -105,6 +105,7 @@ $% [%bel ~] :: make a noise [%clr ~] :: clear the screen [%hop p=@ud] :: set cursor position + [%mor p=(list dill-blit)] :: multiple blits [%pro p=(list ,@c)] :: show as cursor/line [%out p=(list ,@c)] :: send output line [%sag p=path q=*] :: save to jamfile From 170f0602a3a7410fe26b338202b450cbe2dd6811 Mon Sep 17 00:00:00 2001 From: Galen Wolfe-Pauly Date: Tue, 24 Feb 2015 11:33:50 -0800 Subject: [PATCH 120/219] doc -> docs Conflicts: urb/zod/docs/psal.hook urb/zod/docs/pub/doc.md urb/zod/docs/pub/doc/arvo.md urb/zod/docs/pub/doc/arvo/ames.md urb/zod/docs/pub/doc/arvo/ames/commentary.md urb/zod/docs/pub/doc/arvo/arvo.md urb/zod/docs/pub/doc/arvo/arvo/commentary.md urb/zod/docs/pub/doc/arvo/clay.md urb/zod/docs/pub/doc/arvo/clay/commentary.md urb/zod/docs/pub/doc/arvo/dill.md urb/zod/docs/pub/doc/arvo/dill/commentary.md urb/zod/docs/pub/doc/arvo/eyre.md urb/zod/docs/pub/doc/arvo/eyre/commentary.md urb/zod/docs/pub/doc/arvo/ford.md urb/zod/docs/pub/doc/arvo/ford/commentary.md urb/zod/docs/pub/doc/arvo/gall.md urb/zod/docs/pub/doc/arvo/gall/gall.md urb/zod/docs/pub/doc/arvo/ives.md urb/zod/docs/pub/doc/arvo/ives/ives.md urb/zod/docs/pub/doc/arvo/jael.md urb/zod/docs/pub/doc/arvo/jael/jael.md urb/zod/docs/pub/doc/arvo/kahn.md urb/zod/docs/pub/doc/arvo/kahn/kahn.md urb/zod/docs/pub/doc/arvo/lunt.md urb/zod/docs/pub/doc/arvo/lunt/lunt.md urb/zod/docs/pub/doc/arvo/time.md urb/zod/docs/pub/doc/arvo/util.md urb/zod/docs/pub/doc/guide.md urb/zod/docs/pub/doc/guide/a-ford.md urb/zod/docs/pub/doc/guide/b-cli.md urb/zod/docs/pub/doc/guide/c-gall.md urb/zod/docs/pub/doc/guide/d-app.md urb/zod/docs/pub/doc/guide/e-dev.md urb/zod/docs/pub/doc/hoon.md urb/zod/docs/pub/doc/hoon/library.md urb/zod/docs/pub/doc/hoon/library/0.md urb/zod/docs/pub/doc/hoon/library/1.md urb/zod/docs/pub/doc/hoon/library/2a.md urb/zod/docs/pub/doc/hoon/library/2b.md urb/zod/docs/pub/doc/hoon/library/2c.md urb/zod/docs/pub/doc/hoon/library/2da.md urb/zod/docs/pub/doc/hoon/library/2db.md urb/zod/docs/pub/doc/hoon/library/2dc.md urb/zod/docs/pub/doc/hoon/library/2dd.md urb/zod/docs/pub/doc/hoon/library/2ea.md urb/zod/docs/pub/doc/hoon/library/2eb.md urb/zod/docs/pub/doc/hoon/library/2ec.md urb/zod/docs/pub/doc/hoon/library/2ed.md urb/zod/docs/pub/doc/hoon/library/2ee.md urb/zod/docs/pub/doc/hoon/library/2ef.md urb/zod/docs/pub/doc/hoon/library/2eg.md urb/zod/docs/pub/doc/hoon/library/2eh.md urb/zod/docs/pub/doc/hoon/library/2ei.md urb/zod/docs/pub/doc/hoon/library/2ej.md urb/zod/docs/pub/doc/hoon/library/2ek.md urb/zod/docs/pub/doc/hoon/library/2el.md urb/zod/docs/pub/doc/hoon/library/2em.md urb/zod/docs/pub/doc/hoon/library/2en.md urb/zod/docs/pub/doc/hoon/library/2eo.md urb/zod/docs/pub/doc/hoon/library/2ep.md urb/zod/docs/pub/doc/hoon/library/2ew.md urb/zod/docs/pub/doc/hoon/library/2ex.md urb/zod/docs/pub/doc/hoon/library/2ey.md urb/zod/docs/pub/doc/hoon/library/2ez.md urb/zod/docs/pub/doc/hoon/library/3ba.md urb/zod/docs/pub/doc/hoon/library/3bb.md urb/zod/docs/pub/doc/hoon/library/3bc.md urb/zod/docs/pub/doc/hoon/library/3bd.md urb/zod/docs/pub/doc/hoon/library/3be.md urb/zod/docs/pub/doc/hoon/library/3bf.md urb/zod/docs/pub/doc/hoon/library/3bg.md urb/zod/docs/pub/doc/hoon/library/3bh.md urb/zod/docs/pub/doc/hoon/library/3bi.md urb/zod/docs/pub/doc/hoon/reference.md urb/zod/docs/pub/doc/hoon/reference/odors.md urb/zod/docs/pub/doc/hoon/runes.md urb/zod/docs/pub/doc/hoon/runes/bc.md urb/zod/docs/pub/doc/hoon/runes/bc/bcbr.md urb/zod/docs/pub/doc/hoon/runes/bc/bccb.md urb/zod/docs/pub/doc/hoon/runes/bc/bccl.md urb/zod/docs/pub/doc/hoon/runes/bc/bccm.md urb/zod/docs/pub/doc/hoon/runes/bc/bccn.md urb/zod/docs/pub/doc/hoon/runes/bc/bckt.md urb/zod/docs/pub/doc/hoon/runes/bc/bcls.md urb/zod/docs/pub/doc/hoon/runes/bc/bcpm.md urb/zod/docs/pub/doc/hoon/runes/bc/bcpt.md urb/zod/docs/pub/doc/hoon/runes/bc/bctr.md urb/zod/docs/pub/doc/hoon/runes/bc/bcts.md urb/zod/docs/pub/doc/hoon/runes/bc/bcwt.md urb/zod/docs/pub/doc/hoon/runes/bc/bczp.md urb/zod/docs/pub/doc/hoon/runes/br.md urb/zod/docs/pub/doc/hoon/runes/br/brcb.md urb/zod/docs/pub/doc/hoon/runes/br/brcn.md urb/zod/docs/pub/doc/hoon/runes/br/brdt.md urb/zod/docs/pub/doc/hoon/runes/br/brfs.md urb/zod/docs/pub/doc/hoon/runes/br/brhp.md urb/zod/docs/pub/doc/hoon/runes/br/brkt.md urb/zod/docs/pub/doc/hoon/runes/br/brls.md urb/zod/docs/pub/doc/hoon/runes/br/brtr.md urb/zod/docs/pub/doc/hoon/runes/br/brts.md urb/zod/docs/pub/doc/hoon/runes/br/brwt.md urb/zod/docs/pub/doc/hoon/runes/cl.md urb/zod/docs/pub/doc/hoon/runes/cl/clcb.md urb/zod/docs/pub/doc/hoon/runes/cl/clfs.md urb/zod/docs/pub/doc/hoon/runes/cl/clhp.md urb/zod/docs/pub/doc/hoon/runes/cl/clkt.md urb/zod/docs/pub/doc/hoon/runes/cl/clls.md urb/zod/docs/pub/doc/hoon/runes/cl/clsg.md urb/zod/docs/pub/doc/hoon/runes/cl/cltr.md urb/zod/docs/pub/doc/hoon/runes/cn.md urb/zod/docs/pub/doc/hoon/runes/cn/cncb.md urb/zod/docs/pub/doc/hoon/runes/cn/cncl.md urb/zod/docs/pub/doc/hoon/runes/cn/cndt.md urb/zod/docs/pub/doc/hoon/runes/cn/cnhp.md urb/zod/docs/pub/doc/hoon/runes/cn/cnkt.md urb/zod/docs/pub/doc/hoon/runes/cn/cnls.md urb/zod/docs/pub/doc/hoon/runes/cn/cnsg.md urb/zod/docs/pub/doc/hoon/runes/cn/cntr.md urb/zod/docs/pub/doc/hoon/runes/cn/cnts.md urb/zod/docs/pub/doc/hoon/runes/cn/cnzy.md urb/zod/docs/pub/doc/hoon/runes/cn/cnzz.md urb/zod/docs/pub/doc/hoon/runes/dt.md urb/zod/docs/pub/doc/hoon/runes/dt/dtkt.md urb/zod/docs/pub/doc/hoon/runes/dt/dtls.md urb/zod/docs/pub/doc/hoon/runes/dt/dttr.md urb/zod/docs/pub/doc/hoon/runes/dt/dtts.md urb/zod/docs/pub/doc/hoon/runes/dt/dtwt.md urb/zod/docs/pub/doc/hoon/runes/dt/dtzy.md urb/zod/docs/pub/doc/hoon/runes/dt/dtzz.md urb/zod/docs/pub/doc/hoon/runes/hx.md urb/zod/docs/pub/doc/hoon/runes/hx/hxgl.md urb/zod/docs/pub/doc/hoon/runes/hx/hxgr.md urb/zod/docs/pub/doc/hoon/runes/kt.md urb/zod/docs/pub/doc/hoon/runes/kt/ktbr.md urb/zod/docs/pub/doc/hoon/runes/kt/ktdt.md urb/zod/docs/pub/doc/hoon/runes/kt/kthp.md urb/zod/docs/pub/doc/hoon/runes/kt/ktls.md urb/zod/docs/pub/doc/hoon/runes/kt/ktpm.md urb/zod/docs/pub/doc/hoon/runes/kt/ktsg.md urb/zod/docs/pub/doc/hoon/runes/kt/ktts.md urb/zod/docs/pub/doc/hoon/runes/kt/ktwt.md urb/zod/docs/pub/doc/hoon/runes/sg.md urb/zod/docs/pub/doc/hoon/runes/sg/sgbc.md urb/zod/docs/pub/doc/hoon/runes/sg/sgbr.md urb/zod/docs/pub/doc/hoon/runes/sg/sgcb.md urb/zod/docs/pub/doc/hoon/runes/sg/sgcn.md urb/zod/docs/pub/doc/hoon/runes/sg/sgfs.md urb/zod/docs/pub/doc/hoon/runes/sg/sggl.md urb/zod/docs/pub/doc/hoon/runes/sg/sggr.md urb/zod/docs/pub/doc/hoon/runes/sg/sgls.md urb/zod/docs/pub/doc/hoon/runes/sg/sgpm.md urb/zod/docs/pub/doc/hoon/runes/sg/sgts.md urb/zod/docs/pub/doc/hoon/runes/sg/sgwt.md urb/zod/docs/pub/doc/hoon/runes/sg/sgzp.md urb/zod/docs/pub/doc/hoon/runes/sm.md urb/zod/docs/pub/doc/hoon/runes/sm/smcl.md urb/zod/docs/pub/doc/hoon/runes/sm/smcn.md urb/zod/docs/pub/doc/hoon/runes/sm/smdq.md urb/zod/docs/pub/doc/hoon/runes/sm/smhp.md urb/zod/docs/pub/doc/hoon/runes/sm/smls.md urb/zod/docs/pub/doc/hoon/runes/sm/smsg.md urb/zod/docs/pub/doc/hoon/runes/sm/smsm.md urb/zod/docs/pub/doc/hoon/runes/sm/smtr.md urb/zod/docs/pub/doc/hoon/runes/sm/smzz.md urb/zod/docs/pub/doc/hoon/runes/ts.md urb/zod/docs/pub/doc/hoon/runes/ts/tsbr.md urb/zod/docs/pub/doc/hoon/runes/ts/tscl.md urb/zod/docs/pub/doc/hoon/runes/ts/tsdt.md urb/zod/docs/pub/doc/hoon/runes/ts/tsgl.md urb/zod/docs/pub/doc/hoon/runes/ts/tsgr.md urb/zod/docs/pub/doc/hoon/runes/ts/tshp.md urb/zod/docs/pub/doc/hoon/runes/ts/tskt.md urb/zod/docs/pub/doc/hoon/runes/ts/tsls.md urb/zod/docs/pub/doc/hoon/runes/ts/tssg.md urb/zod/docs/pub/doc/hoon/runes/ts/tstr.md urb/zod/docs/pub/doc/hoon/runes/wt.md urb/zod/docs/pub/doc/hoon/runes/wt/wtbr.md urb/zod/docs/pub/doc/hoon/runes/wt/wtcl.md urb/zod/docs/pub/doc/hoon/runes/wt/wtdt.md urb/zod/docs/pub/doc/hoon/runes/wt/wtgl.md urb/zod/docs/pub/doc/hoon/runes/wt/wtgr.md urb/zod/docs/pub/doc/hoon/runes/wt/wthp.md urb/zod/docs/pub/doc/hoon/runes/wt/wthz.md urb/zod/docs/pub/doc/hoon/runes/wt/wtkt.md urb/zod/docs/pub/doc/hoon/runes/wt/wtkz.md urb/zod/docs/pub/doc/hoon/runes/wt/wtls.md urb/zod/docs/pub/doc/hoon/runes/wt/wtlz.md urb/zod/docs/pub/doc/hoon/runes/wt/wtpm.md urb/zod/docs/pub/doc/hoon/runes/wt/wtpt.md urb/zod/docs/pub/doc/hoon/runes/wt/wtpz.md urb/zod/docs/pub/doc/hoon/runes/wt/wtsg.md urb/zod/docs/pub/doc/hoon/runes/wt/wtsz.md urb/zod/docs/pub/doc/hoon/runes/wt/wtts.md urb/zod/docs/pub/doc/hoon/runes/wt/wttz.md urb/zod/docs/pub/doc/hoon/runes/wt/wtzp.md urb/zod/docs/pub/doc/hoon/runes/zp.md urb/zod/docs/pub/doc/hoon/runes/zp/zpcb.md urb/zod/docs/pub/doc/hoon/runes/zp/zpcm.md urb/zod/docs/pub/doc/hoon/runes/zp/zpfs.md urb/zod/docs/pub/doc/hoon/runes/zp/zpgr.md urb/zod/docs/pub/doc/hoon/runes/zp/zpsm.md urb/zod/docs/pub/doc/hoon/runes/zp/zpts.md urb/zod/docs/pub/doc/hoon/runes/zp/zpwt.md urb/zod/docs/pub/doc/hoon/runes/zp/zpzp.md urb/zod/docs/pub/doc/nock.md urb/zod/docs/pub/doc/nock/reference.md urb/zod/docs/pub/doc/reference.md urb/zod/docs/pub/doc/reference/glossary.md urb/zod/docs/pub/doc/reference/vere.md urb/zod/docs/pub/tree/src/css/fonts.styl urb/zod/docs/pub/tree/src/css/main.css urb/zod/docs/pub/tree/src/css/main.styl urb/zod/docs/pub/tree/src/css/mobile.styl urb/zod/docs/pub/tree/src/js/actions/TreeActions.coffee urb/zod/docs/pub/tree/src/js/components/AnchorComponent.coffee urb/zod/docs/pub/tree/src/js/components/BodyComponent.coffee urb/zod/docs/pub/tree/src/js/components/KidsComponent.coffee urb/zod/docs/pub/tree/src/js/components/ListComponent.coffee urb/zod/docs/pub/tree/src/js/components/LoadComponent.coffee urb/zod/docs/pub/tree/src/js/dispatcher/Dispatcher.coffee urb/zod/docs/pub/tree/src/js/main.coffee urb/zod/docs/pub/tree/src/js/main.js urb/zod/docs/pub/tree/src/js/package.json urb/zod/docs/pub/tree/src/js/persistence/TreePersistence.coffee urb/zod/docs/pub/tree/src/js/stores/TreeStore.coffee urb/zod/docs/tree/hymn.hook urb/zod/docs/tree/json.hook urb/zod/docs/tree/util.hoon --- docs/psal.hook | 1 + docs/pub/doc.md | 16 + docs/pub/doc/arvo.md | 146 + docs/pub/doc/arvo/ames.md | 29 + docs/pub/doc/arvo/ames/commentary.md | 1815 ++++++++++++ docs/pub/doc/arvo/arvo.md | 8 + docs/pub/doc/arvo/arvo/commentary.md | 4 + docs/pub/doc/arvo/clay.md | 27 + docs/pub/doc/arvo/clay/commentary.md | 2007 +++++++++++++ docs/pub/doc/arvo/dill.md | 27 + docs/pub/doc/arvo/dill/commentary.md | 5 + docs/pub/doc/arvo/eyre.md | 58 + docs/pub/doc/arvo/eyre/commentary.md | 5 + docs/pub/doc/arvo/ford.md | 128 + docs/pub/doc/arvo/ford/commentary.md | 2571 +++++++++++++++++ docs/pub/doc/arvo/gall.md | 161 ++ docs/pub/doc/arvo/gall/gall.md | 5 + docs/pub/doc/arvo/ives.md | 8 + docs/pub/doc/arvo/ives/ives.md | 5 + docs/pub/doc/arvo/jael.md | 8 + docs/pub/doc/arvo/jael/jael.md | 5 + docs/pub/doc/arvo/kahn.md | 8 + docs/pub/doc/arvo/kahn/kahn.md | 5 + docs/pub/doc/arvo/lunt.md | 8 + docs/pub/doc/arvo/lunt/lunt.md | 5 + docs/pub/doc/arvo/time.md | 21 + docs/pub/doc/arvo/util.md | 229 ++ docs/pub/doc/guide.md | 15 + docs/pub/doc/guide/a-ford.md | 812 ++++++ docs/pub/doc/guide/b-cli.md | 251 ++ docs/pub/doc/guide/c-gall.md | 284 ++ docs/pub/doc/guide/d-app.md | 1 + docs/pub/doc/guide/e-dev.md | 100 + docs/pub/doc/hoon.md | 24 + docs/pub/doc/hoon/library.md | 4 + docs/pub/doc/hoon/library/0.md | 37 + docs/pub/doc/hoon/library/1.md | 1786 ++++++++++++ docs/pub/doc/hoon/library/2a.md | 450 +++ docs/pub/doc/hoon/library/2b.md | 897 ++++++ docs/pub/doc/hoon/library/2c.md | 2128 ++++++++++++++ docs/pub/doc/hoon/library/2da.md | 437 +++ docs/pub/doc/hoon/library/2db.md | 813 ++++++ docs/pub/doc/hoon/library/2dc.md | 221 ++ docs/pub/doc/hoon/library/2dd.md | 69 + docs/pub/doc/hoon/library/2ea.md | 162 ++ docs/pub/doc/hoon/library/2eb.md | 63 + docs/pub/doc/hoon/library/2ec.md | 652 +++++ docs/pub/doc/hoon/library/2ed.md | 289 ++ docs/pub/doc/hoon/library/2ee.md | 195 ++ docs/pub/doc/hoon/library/2ef.md | 648 +++++ docs/pub/doc/hoon/library/2eg.md | 160 + docs/pub/doc/hoon/library/2eh.md | 531 ++++ docs/pub/doc/hoon/library/2ei.md | 107 + docs/pub/doc/hoon/library/2ej.md | 561 ++++ docs/pub/doc/hoon/library/2ek.md | 162 ++ docs/pub/doc/hoon/library/2el.md | 1871 ++++++++++++ docs/pub/doc/hoon/library/2em.md | 758 +++++ docs/pub/doc/hoon/library/2en.md | 257 ++ docs/pub/doc/hoon/library/2eo.md | 453 +++ docs/pub/doc/hoon/library/2ep.md | 586 ++++ docs/pub/doc/hoon/library/2ew.md | 439 +++ docs/pub/doc/hoon/library/2ex.md | 717 +++++ docs/pub/doc/hoon/library/2ey.md | 399 +++ docs/pub/doc/hoon/library/2ez.md | 252 ++ docs/pub/doc/hoon/library/3ba.md | 67 + docs/pub/doc/hoon/library/3bb.md | 600 ++++ docs/pub/doc/hoon/library/3bc.md | 380 +++ docs/pub/doc/hoon/library/3bd.md | 1807 ++++++++++++ docs/pub/doc/hoon/library/3be.md | 1316 +++++++++ docs/pub/doc/hoon/library/3bf.md | 267 ++ docs/pub/doc/hoon/library/3bg.md | 943 ++++++ docs/pub/doc/hoon/library/3bh.md | 466 +++ docs/pub/doc/hoon/library/3bi.md | 1483 ++++++++++ docs/pub/doc/hoon/reference.md | 7 + docs/pub/doc/hoon/reference/odors.md | 686 +++++ docs/pub/doc/hoon/runes.md | 130 + docs/pub/doc/hoon/runes/bc.md | 49 + docs/pub/doc/hoon/runes/bc/bcbr.md | 51 + docs/pub/doc/hoon/runes/bc/bccb.md | 43 + docs/pub/doc/hoon/runes/bc/bccl.md | 44 + docs/pub/doc/hoon/runes/bc/bccm.md | 61 + docs/pub/doc/hoon/runes/bc/bccn.md | 64 + docs/pub/doc/hoon/runes/bc/bckt.md | 49 + docs/pub/doc/hoon/runes/bc/bcls.md | 62 + docs/pub/doc/hoon/runes/bc/bcpm.md | 39 + docs/pub/doc/hoon/runes/bc/bcpt.md | 37 + docs/pub/doc/hoon/runes/bc/bctr.md | 38 + docs/pub/doc/hoon/runes/bc/bcts.md | 53 + docs/pub/doc/hoon/runes/bc/bcwt.md | 48 + docs/pub/doc/hoon/runes/bc/bczp.md | 40 + docs/pub/doc/hoon/runes/br.md | 47 + docs/pub/doc/hoon/runes/br/brcb.md | 118 + docs/pub/doc/hoon/runes/br/brcn.md | 135 + docs/pub/doc/hoon/runes/br/brdt.md | 114 + docs/pub/doc/hoon/runes/br/brfs.md | 105 + docs/pub/doc/hoon/runes/br/brhp.md | 78 + docs/pub/doc/hoon/runes/br/brkt.md | 103 + docs/pub/doc/hoon/runes/br/brls.md | 63 + docs/pub/doc/hoon/runes/br/brtr.md | 73 + docs/pub/doc/hoon/runes/br/brts.md | 71 + docs/pub/doc/hoon/runes/br/brwt.md | 54 + docs/pub/doc/hoon/runes/cl.md | 44 + docs/pub/doc/hoon/runes/cl/clcb.md | 56 + docs/pub/doc/hoon/runes/cl/clfs.md | 47 + docs/pub/doc/hoon/runes/cl/clhp.md | 85 + docs/pub/doc/hoon/runes/cl/clkt.md | 68 + docs/pub/doc/hoon/runes/cl/clls.md | 61 + docs/pub/doc/hoon/runes/cl/clsg.md | 69 + docs/pub/doc/hoon/runes/cl/cltr.md | 57 + docs/pub/doc/hoon/runes/cn.md | 41 + docs/pub/doc/hoon/runes/cn/cncb.md | 74 + docs/pub/doc/hoon/runes/cn/cncl.md | 55 + docs/pub/doc/hoon/runes/cn/cndt.md | 57 + docs/pub/doc/hoon/runes/cn/cnhp.md | 40 + docs/pub/doc/hoon/runes/cn/cnkt.md | 41 + docs/pub/doc/hoon/runes/cn/cnls.md | 54 + docs/pub/doc/hoon/runes/cn/cnsg.md | 70 + docs/pub/doc/hoon/runes/cn/cntr.md | 60 + docs/pub/doc/hoon/runes/cn/cnts.md | 71 + docs/pub/doc/hoon/runes/cn/cnzy.md | 40 + docs/pub/doc/hoon/runes/cn/cnzz.md | 43 + docs/pub/doc/hoon/runes/dt.md | 33 + docs/pub/doc/hoon/runes/dt/dtkt.md | 56 + docs/pub/doc/hoon/runes/dt/dtls.md | 66 + docs/pub/doc/hoon/runes/dt/dttr.md | 57 + docs/pub/doc/hoon/runes/dt/dtts.md | 77 + docs/pub/doc/hoon/runes/dt/dtwt.md | 59 + docs/pub/doc/hoon/runes/dt/dtzy.md | 47 + docs/pub/doc/hoon/runes/dt/dtzz.md | 52 + docs/pub/doc/hoon/runes/hx.md | 19 + docs/pub/doc/hoon/runes/hx/hxgl.md | 62 + docs/pub/doc/hoon/runes/hx/hxgr.md | 83 + docs/pub/doc/hoon/runes/kt.md | 40 + docs/pub/doc/hoon/runes/kt/ktbr.md | 61 + docs/pub/doc/hoon/runes/kt/ktdt.md | 47 + docs/pub/doc/hoon/runes/kt/kthp.md | 65 + docs/pub/doc/hoon/runes/kt/ktls.md | 75 + docs/pub/doc/hoon/runes/kt/ktpm.md | 46 + docs/pub/doc/hoon/runes/kt/ktsg.md | 47 + docs/pub/doc/hoon/runes/kt/ktts.md | 52 + docs/pub/doc/hoon/runes/kt/ktwt.md | 45 + docs/pub/doc/hoon/runes/sg.md | 32 + docs/pub/doc/hoon/runes/sg/sgbc.md | 43 + docs/pub/doc/hoon/runes/sg/sgbr.md | 36 + docs/pub/doc/hoon/runes/sg/sgcb.md | 41 + docs/pub/doc/hoon/runes/sg/sgcn.md | 64 + docs/pub/doc/hoon/runes/sg/sgfs.md | 44 + docs/pub/doc/hoon/runes/sg/sggl.md | 50 + docs/pub/doc/hoon/runes/sg/sggr.md | 48 + docs/pub/doc/hoon/runes/sg/sgls.md | 50 + docs/pub/doc/hoon/runes/sg/sgpm.md | 64 + docs/pub/doc/hoon/runes/sg/sgts.md | 49 + docs/pub/doc/hoon/runes/sg/sgwt.md | 64 + docs/pub/doc/hoon/runes/sg/sgzp.md | 59 + docs/pub/doc/hoon/runes/sm.md | 42 + docs/pub/doc/hoon/runes/sm/smcl.md | 63 + docs/pub/doc/hoon/runes/sm/smcn.md | 93 + docs/pub/doc/hoon/runes/sm/smdq.md | 56 + docs/pub/doc/hoon/runes/sm/smhp.md | 55 + docs/pub/doc/hoon/runes/sm/smls.md | 58 + docs/pub/doc/hoon/runes/sm/smsg.md | 162 ++ docs/pub/doc/hoon/runes/sm/smsm.md | 52 + docs/pub/doc/hoon/runes/sm/smtr.md | 61 + docs/pub/doc/hoon/runes/sm/smzz.md | 84 + docs/pub/doc/hoon/runes/ts.md | 49 + docs/pub/doc/hoon/runes/ts/tsbr.md | 50 + docs/pub/doc/hoon/runes/ts/tscl.md | 57 + docs/pub/doc/hoon/runes/ts/tsdt.md | 55 + docs/pub/doc/hoon/runes/ts/tsgl.md | 63 + docs/pub/doc/hoon/runes/ts/tsgr.md | 68 + docs/pub/doc/hoon/runes/ts/tshp.md | 62 + docs/pub/doc/hoon/runes/ts/tskt.md | 55 + docs/pub/doc/hoon/runes/ts/tsls.md | 65 + docs/pub/doc/hoon/runes/ts/tssg.md | 49 + docs/pub/doc/hoon/runes/ts/tstr.md | 51 + docs/pub/doc/hoon/runes/wt.md | 39 + docs/pub/doc/hoon/runes/wt/wtbr.md | 55 + docs/pub/doc/hoon/runes/wt/wtcl.md | 54 + docs/pub/doc/hoon/runes/wt/wtdt.md | 53 + docs/pub/doc/hoon/runes/wt/wtgl.md | 47 + docs/pub/doc/hoon/runes/wt/wtgr.md | 47 + docs/pub/doc/hoon/runes/wt/wthp.md | 99 + docs/pub/doc/hoon/runes/wt/wthz.md | 52 + docs/pub/doc/hoon/runes/wt/wtkt.md | 65 + docs/pub/doc/hoon/runes/wt/wtkz.md | 34 + docs/pub/doc/hoon/runes/wt/wtls.md | 105 + docs/pub/doc/hoon/runes/wt/wtlz.md | 35 + docs/pub/doc/hoon/runes/wt/wtpm.md | 49 + docs/pub/doc/hoon/runes/wt/wtpt.md | 54 + docs/pub/doc/hoon/runes/wt/wtpz.md | 34 + docs/pub/doc/hoon/runes/wt/wtsg.md | 45 + docs/pub/doc/hoon/runes/wt/wtsz.md | 37 + docs/pub/doc/hoon/runes/wt/wtts.md | 45 + docs/pub/doc/hoon/runes/wt/wttz.md | 35 + docs/pub/doc/hoon/runes/wt/wtzp.md | 46 + docs/pub/doc/hoon/runes/zp.md | 23 + docs/pub/doc/hoon/runes/zp/zpcb.md | 57 + docs/pub/doc/hoon/runes/zp/zpcm.md | 36 + docs/pub/doc/hoon/runes/zp/zpfs.md | 64 + docs/pub/doc/hoon/runes/zp/zpgr.md | 62 + docs/pub/doc/hoon/runes/zp/zpsm.md | 43 + docs/pub/doc/hoon/runes/zp/zpts.md | 55 + docs/pub/doc/hoon/runes/zp/zpwt.md | 49 + docs/pub/doc/hoon/runes/zp/zpzp.md | 48 + docs/pub/doc/nock.md | 37 + docs/pub/doc/nock/reference.md | 730 +++++ docs/pub/doc/reference.md | 12 + docs/pub/doc/reference/glossary.md | 345 +++ docs/pub/doc/reference/vere.md | 183 ++ docs/pub/tree/src/css/fonts.styl | 69 + docs/pub/tree/src/css/main.css | 464 +++ docs/pub/tree/src/css/main.styl | 275 ++ docs/pub/tree/src/css/mobile.styl | 112 + .../tree/src/js/actions/TreeActions.coffee | 50 + .../src/js/components/AnchorComponent.coffee | 148 + .../src/js/components/BodyComponent.coffee | 39 + .../src/js/components/KidsComponent.coffee | 35 + .../src/js/components/ListComponent.coffee | 54 + .../src/js/components/LoadComponent.coffee | 17 + .../tree/src/js/dispatcher/Dispatcher.coffee | 13 + docs/pub/tree/src/js/main.coffee | 121 + docs/pub/tree/src/js/main.js | 1592 ++++++++++ docs/pub/tree/src/js/package.json | 26 + .../src/js/persistence/TreePersistence.coffee | 7 + docs/pub/tree/src/js/stores/TreeStore.coffee | 145 + docs/tree/hymn.hook | 41 + docs/tree/json.hook | 47 + docs/tree/util.hoon | 56 + 228 files changed, 44998 insertions(+) create mode 100644 docs/psal.hook create mode 100644 docs/pub/doc.md create mode 100644 docs/pub/doc/arvo.md create mode 100644 docs/pub/doc/arvo/ames.md create mode 100644 docs/pub/doc/arvo/ames/commentary.md create mode 100644 docs/pub/doc/arvo/arvo.md create mode 100644 docs/pub/doc/arvo/arvo/commentary.md create mode 100644 docs/pub/doc/arvo/clay.md create mode 100644 docs/pub/doc/arvo/clay/commentary.md create mode 100644 docs/pub/doc/arvo/dill.md create mode 100644 docs/pub/doc/arvo/dill/commentary.md create mode 100644 docs/pub/doc/arvo/eyre.md create mode 100644 docs/pub/doc/arvo/eyre/commentary.md create mode 100644 docs/pub/doc/arvo/ford.md create mode 100644 docs/pub/doc/arvo/ford/commentary.md create mode 100644 docs/pub/doc/arvo/gall.md create mode 100644 docs/pub/doc/arvo/gall/gall.md create mode 100644 docs/pub/doc/arvo/ives.md create mode 100644 docs/pub/doc/arvo/ives/ives.md create mode 100644 docs/pub/doc/arvo/jael.md create mode 100644 docs/pub/doc/arvo/jael/jael.md create mode 100644 docs/pub/doc/arvo/kahn.md create mode 100644 docs/pub/doc/arvo/kahn/kahn.md create mode 100644 docs/pub/doc/arvo/lunt.md create mode 100644 docs/pub/doc/arvo/lunt/lunt.md create mode 100644 docs/pub/doc/arvo/time.md create mode 100644 docs/pub/doc/arvo/util.md create mode 100644 docs/pub/doc/guide.md create mode 100644 docs/pub/doc/guide/a-ford.md create mode 100644 docs/pub/doc/guide/b-cli.md create mode 100644 docs/pub/doc/guide/c-gall.md create mode 100644 docs/pub/doc/guide/d-app.md create mode 100644 docs/pub/doc/guide/e-dev.md create mode 100644 docs/pub/doc/hoon.md create mode 100644 docs/pub/doc/hoon/library.md create mode 100644 docs/pub/doc/hoon/library/0.md create mode 100644 docs/pub/doc/hoon/library/1.md create mode 100644 docs/pub/doc/hoon/library/2a.md create mode 100644 docs/pub/doc/hoon/library/2b.md create mode 100644 docs/pub/doc/hoon/library/2c.md create mode 100644 docs/pub/doc/hoon/library/2da.md create mode 100644 docs/pub/doc/hoon/library/2db.md create mode 100644 docs/pub/doc/hoon/library/2dc.md create mode 100644 docs/pub/doc/hoon/library/2dd.md create mode 100644 docs/pub/doc/hoon/library/2ea.md create mode 100644 docs/pub/doc/hoon/library/2eb.md create mode 100644 docs/pub/doc/hoon/library/2ec.md create mode 100644 docs/pub/doc/hoon/library/2ed.md create mode 100644 docs/pub/doc/hoon/library/2ee.md create mode 100644 docs/pub/doc/hoon/library/2ef.md create mode 100644 docs/pub/doc/hoon/library/2eg.md create mode 100644 docs/pub/doc/hoon/library/2eh.md create mode 100644 docs/pub/doc/hoon/library/2ei.md create mode 100644 docs/pub/doc/hoon/library/2ej.md create mode 100644 docs/pub/doc/hoon/library/2ek.md create mode 100644 docs/pub/doc/hoon/library/2el.md create mode 100644 docs/pub/doc/hoon/library/2em.md create mode 100644 docs/pub/doc/hoon/library/2en.md create mode 100644 docs/pub/doc/hoon/library/2eo.md create mode 100644 docs/pub/doc/hoon/library/2ep.md create mode 100644 docs/pub/doc/hoon/library/2ew.md create mode 100644 docs/pub/doc/hoon/library/2ex.md create mode 100644 docs/pub/doc/hoon/library/2ey.md create mode 100644 docs/pub/doc/hoon/library/2ez.md create mode 100644 docs/pub/doc/hoon/library/3ba.md create mode 100644 docs/pub/doc/hoon/library/3bb.md create mode 100644 docs/pub/doc/hoon/library/3bc.md create mode 100644 docs/pub/doc/hoon/library/3bd.md create mode 100644 docs/pub/doc/hoon/library/3be.md create mode 100644 docs/pub/doc/hoon/library/3bf.md create mode 100644 docs/pub/doc/hoon/library/3bg.md create mode 100644 docs/pub/doc/hoon/library/3bh.md create mode 100644 docs/pub/doc/hoon/library/3bi.md create mode 100644 docs/pub/doc/hoon/reference.md create mode 100644 docs/pub/doc/hoon/reference/odors.md create mode 100644 docs/pub/doc/hoon/runes.md create mode 100644 docs/pub/doc/hoon/runes/bc.md create mode 100644 docs/pub/doc/hoon/runes/bc/bcbr.md create mode 100644 docs/pub/doc/hoon/runes/bc/bccb.md create mode 100644 docs/pub/doc/hoon/runes/bc/bccl.md create mode 100644 docs/pub/doc/hoon/runes/bc/bccm.md create mode 100644 docs/pub/doc/hoon/runes/bc/bccn.md create mode 100644 docs/pub/doc/hoon/runes/bc/bckt.md create mode 100644 docs/pub/doc/hoon/runes/bc/bcls.md create mode 100644 docs/pub/doc/hoon/runes/bc/bcpm.md create mode 100644 docs/pub/doc/hoon/runes/bc/bcpt.md create mode 100644 docs/pub/doc/hoon/runes/bc/bctr.md create mode 100644 docs/pub/doc/hoon/runes/bc/bcts.md create mode 100644 docs/pub/doc/hoon/runes/bc/bcwt.md create mode 100644 docs/pub/doc/hoon/runes/bc/bczp.md create mode 100644 docs/pub/doc/hoon/runes/br.md create mode 100644 docs/pub/doc/hoon/runes/br/brcb.md create mode 100644 docs/pub/doc/hoon/runes/br/brcn.md create mode 100644 docs/pub/doc/hoon/runes/br/brdt.md create mode 100644 docs/pub/doc/hoon/runes/br/brfs.md create mode 100644 docs/pub/doc/hoon/runes/br/brhp.md create mode 100644 docs/pub/doc/hoon/runes/br/brkt.md create mode 100644 docs/pub/doc/hoon/runes/br/brls.md create mode 100644 docs/pub/doc/hoon/runes/br/brtr.md create mode 100644 docs/pub/doc/hoon/runes/br/brts.md create mode 100644 docs/pub/doc/hoon/runes/br/brwt.md create mode 100644 docs/pub/doc/hoon/runes/cl.md create mode 100644 docs/pub/doc/hoon/runes/cl/clcb.md create mode 100644 docs/pub/doc/hoon/runes/cl/clfs.md create mode 100644 docs/pub/doc/hoon/runes/cl/clhp.md create mode 100644 docs/pub/doc/hoon/runes/cl/clkt.md create mode 100644 docs/pub/doc/hoon/runes/cl/clls.md create mode 100644 docs/pub/doc/hoon/runes/cl/clsg.md create mode 100644 docs/pub/doc/hoon/runes/cl/cltr.md create mode 100644 docs/pub/doc/hoon/runes/cn.md create mode 100644 docs/pub/doc/hoon/runes/cn/cncb.md create mode 100644 docs/pub/doc/hoon/runes/cn/cncl.md create mode 100644 docs/pub/doc/hoon/runes/cn/cndt.md create mode 100644 docs/pub/doc/hoon/runes/cn/cnhp.md create mode 100644 docs/pub/doc/hoon/runes/cn/cnkt.md create mode 100644 docs/pub/doc/hoon/runes/cn/cnls.md create mode 100644 docs/pub/doc/hoon/runes/cn/cnsg.md create mode 100644 docs/pub/doc/hoon/runes/cn/cntr.md create mode 100644 docs/pub/doc/hoon/runes/cn/cnts.md create mode 100644 docs/pub/doc/hoon/runes/cn/cnzy.md create mode 100644 docs/pub/doc/hoon/runes/cn/cnzz.md create mode 100644 docs/pub/doc/hoon/runes/dt.md create mode 100644 docs/pub/doc/hoon/runes/dt/dtkt.md create mode 100644 docs/pub/doc/hoon/runes/dt/dtls.md create mode 100644 docs/pub/doc/hoon/runes/dt/dttr.md create mode 100644 docs/pub/doc/hoon/runes/dt/dtts.md create mode 100644 docs/pub/doc/hoon/runes/dt/dtwt.md create mode 100644 docs/pub/doc/hoon/runes/dt/dtzy.md create mode 100644 docs/pub/doc/hoon/runes/dt/dtzz.md create mode 100644 docs/pub/doc/hoon/runes/hx.md create mode 100644 docs/pub/doc/hoon/runes/hx/hxgl.md create mode 100644 docs/pub/doc/hoon/runes/hx/hxgr.md create mode 100644 docs/pub/doc/hoon/runes/kt.md create mode 100644 docs/pub/doc/hoon/runes/kt/ktbr.md create mode 100644 docs/pub/doc/hoon/runes/kt/ktdt.md create mode 100644 docs/pub/doc/hoon/runes/kt/kthp.md create mode 100644 docs/pub/doc/hoon/runes/kt/ktls.md create mode 100644 docs/pub/doc/hoon/runes/kt/ktpm.md create mode 100644 docs/pub/doc/hoon/runes/kt/ktsg.md create mode 100644 docs/pub/doc/hoon/runes/kt/ktts.md create mode 100644 docs/pub/doc/hoon/runes/kt/ktwt.md create mode 100644 docs/pub/doc/hoon/runes/sg.md create mode 100644 docs/pub/doc/hoon/runes/sg/sgbc.md create mode 100644 docs/pub/doc/hoon/runes/sg/sgbr.md create mode 100644 docs/pub/doc/hoon/runes/sg/sgcb.md create mode 100644 docs/pub/doc/hoon/runes/sg/sgcn.md create mode 100644 docs/pub/doc/hoon/runes/sg/sgfs.md create mode 100644 docs/pub/doc/hoon/runes/sg/sggl.md create mode 100644 docs/pub/doc/hoon/runes/sg/sggr.md create mode 100644 docs/pub/doc/hoon/runes/sg/sgls.md create mode 100644 docs/pub/doc/hoon/runes/sg/sgpm.md create mode 100644 docs/pub/doc/hoon/runes/sg/sgts.md create mode 100644 docs/pub/doc/hoon/runes/sg/sgwt.md create mode 100644 docs/pub/doc/hoon/runes/sg/sgzp.md create mode 100644 docs/pub/doc/hoon/runes/sm.md create mode 100644 docs/pub/doc/hoon/runes/sm/smcl.md create mode 100644 docs/pub/doc/hoon/runes/sm/smcn.md create mode 100644 docs/pub/doc/hoon/runes/sm/smdq.md create mode 100644 docs/pub/doc/hoon/runes/sm/smhp.md create mode 100644 docs/pub/doc/hoon/runes/sm/smls.md create mode 100644 docs/pub/doc/hoon/runes/sm/smsg.md create mode 100644 docs/pub/doc/hoon/runes/sm/smsm.md create mode 100644 docs/pub/doc/hoon/runes/sm/smtr.md create mode 100644 docs/pub/doc/hoon/runes/sm/smzz.md create mode 100644 docs/pub/doc/hoon/runes/ts.md create mode 100644 docs/pub/doc/hoon/runes/ts/tsbr.md create mode 100644 docs/pub/doc/hoon/runes/ts/tscl.md create mode 100644 docs/pub/doc/hoon/runes/ts/tsdt.md create mode 100644 docs/pub/doc/hoon/runes/ts/tsgl.md create mode 100644 docs/pub/doc/hoon/runes/ts/tsgr.md create mode 100644 docs/pub/doc/hoon/runes/ts/tshp.md create mode 100644 docs/pub/doc/hoon/runes/ts/tskt.md create mode 100644 docs/pub/doc/hoon/runes/ts/tsls.md create mode 100644 docs/pub/doc/hoon/runes/ts/tssg.md create mode 100644 docs/pub/doc/hoon/runes/ts/tstr.md create mode 100644 docs/pub/doc/hoon/runes/wt.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtbr.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtcl.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtdt.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtgl.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtgr.md create mode 100644 docs/pub/doc/hoon/runes/wt/wthp.md create mode 100644 docs/pub/doc/hoon/runes/wt/wthz.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtkt.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtkz.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtls.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtlz.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtpm.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtpt.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtpz.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtsg.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtsz.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtts.md create mode 100644 docs/pub/doc/hoon/runes/wt/wttz.md create mode 100644 docs/pub/doc/hoon/runes/wt/wtzp.md create mode 100644 docs/pub/doc/hoon/runes/zp.md create mode 100644 docs/pub/doc/hoon/runes/zp/zpcb.md create mode 100644 docs/pub/doc/hoon/runes/zp/zpcm.md create mode 100644 docs/pub/doc/hoon/runes/zp/zpfs.md create mode 100644 docs/pub/doc/hoon/runes/zp/zpgr.md create mode 100644 docs/pub/doc/hoon/runes/zp/zpsm.md create mode 100644 docs/pub/doc/hoon/runes/zp/zpts.md create mode 100644 docs/pub/doc/hoon/runes/zp/zpwt.md create mode 100644 docs/pub/doc/hoon/runes/zp/zpzp.md create mode 100644 docs/pub/doc/nock.md create mode 100644 docs/pub/doc/nock/reference.md create mode 100644 docs/pub/doc/reference.md create mode 100644 docs/pub/doc/reference/glossary.md create mode 100644 docs/pub/doc/reference/vere.md create mode 100644 docs/pub/tree/src/css/fonts.styl create mode 100644 docs/pub/tree/src/css/main.css create mode 100644 docs/pub/tree/src/css/main.styl create mode 100644 docs/pub/tree/src/css/mobile.styl create mode 100644 docs/pub/tree/src/js/actions/TreeActions.coffee create mode 100644 docs/pub/tree/src/js/components/AnchorComponent.coffee create mode 100644 docs/pub/tree/src/js/components/BodyComponent.coffee create mode 100644 docs/pub/tree/src/js/components/KidsComponent.coffee create mode 100644 docs/pub/tree/src/js/components/ListComponent.coffee create mode 100644 docs/pub/tree/src/js/components/LoadComponent.coffee create mode 100644 docs/pub/tree/src/js/dispatcher/Dispatcher.coffee create mode 100644 docs/pub/tree/src/js/main.coffee create mode 100644 docs/pub/tree/src/js/main.js create mode 100644 docs/pub/tree/src/js/package.json create mode 100644 docs/pub/tree/src/js/persistence/TreePersistence.coffee create mode 100644 docs/pub/tree/src/js/stores/TreeStore.coffee create mode 100644 docs/tree/hymn.hook create mode 100644 docs/tree/json.hook create mode 100644 docs/tree/util.hoon diff --git a/docs/psal.hook b/docs/psal.hook new file mode 100644 index 0000000000..389ffc9828 --- /dev/null +++ b/docs/psal.hook @@ -0,0 +1 @@ +;list; \ No newline at end of file diff --git a/docs/pub/doc.md b/docs/pub/doc.md new file mode 100644 index 0000000000..55c6d4fae6 --- /dev/null +++ b/docs/pub/doc.md @@ -0,0 +1,16 @@ +urbit +===== + +is a general-purpose computing stack designed to live in the cloud. + + + +`arvo` is event driven and modular. `arvo` modules are called 'vanes'. + + + +------------------------------------------------------------------------ + +If you're new to the system, take a look at some of the +[guides](doc/guides) to get oriented. Come join us on `:chat` to ask +questions and get help. diff --git a/docs/pub/doc/arvo.md b/docs/pub/doc/arvo.md new file mode 100644 index 0000000000..acbbc92870 --- /dev/null +++ b/docs/pub/doc/arvo.md @@ -0,0 +1,146 @@ +arvo +==== + +arvo is our operating system. + +arvo is composed of modules called vanes: + + + +
+ +At a high level `%arvo` takes a mess of unix io events and turns them +into something clean and structured for the programmer. + +`%arvo` is designed to avoid the usual state of complex event networks: +event spaghetti. We keep track of every event's cause so that we have a +clear causal chain for every computation. At the bottom of every chain +is a unix io event, such as a network request, terminal input, file +sync, or timer event. We push every step in the path the request takes +onto the chain until we get to the terminal cause of the computation. +Then we use this causal stack to route results back to the caller. + +`++ducts` +--------- + +The `%arvo` causal stack is called a `++duct`. This is represented +simply as a list of paths, where each path represents a step in the +causal chain. The first element in the path is the first letter of +whichever vane handled that step in the computation, or the empty span +for unix. + +Here's a duct that was recently observed in the wild: + + ~[ + /g/a/~zod/4_shell_terminal/u/time + /g/a/~zod/shell_terminal/u/child/4/main + /g/a/~zod/terminal/u/txt + /d/term-mess + //term/1 + ] + +This is the duct the timer vane receives when "timer" sample app asks +the timer vane to set a timer. This is also the duct over which the +response is produced at the specified time. Unix sent a terminal +keystroke event (enter), and arvo routed it to %dill(our terminal), +which passed it on to the %gall app terminal, which sent it to shell, +its child, which created a new child (with process id 4), which on +startup asked the timer vane to set a timer. + +The timer vane saves this duct, so that when the specified time arrives +and unix sends a wakeup event to the timer vane, it can produce the +response on the same duct. This response is routed to the place we +popped off the top of the duct, i.e. the time app. This app produces the +text "ding", which falls down to the shell, which drops it through to +the terminal. Terminal drops this down to dill, which converts it into +an effect that unix will recognize as a request to print "ding" to the +screen. When dill produces this, the last path in the duct has an +initial element of the empty span, so this is routed to unix, which +applies the effects. + +This is a call stack, with a crucial feature: the stack is a first-class +citizen. You can respond over a duct zero, one, or many times. You can +save ducts for later use. There are definitely parallels to Scheme-style +continuations, but simpler and with more structure. + +Making Moves +------------ + +If ducts are a call stack, then how do we make calls and produce +results? Arvo processes "moves" which are a combination of message data +and metadata. There are two types of moves. A `%pass` move is analogous +to a call: + + [duct %pass return-path=path vane-name=@tD data=card] + +Arvo pushes the return path (preceded by the first letter of the vane +name) onto the duct and sends the given data, a card, to the vane we +specified. Any response will come along the same duct with the path +`return-path`. + +A `%give` move is analogous to a return: + + [duct %give data=card] + +Arvo pops the top path off the duct and sends the given card back to the +caller. + +Vanes +----- + +As shown above, we use arvo proper to route and control the flow of +moves. However, arvo proper is rarely directly responsible for +processing the event data that directly causes the desired outcome of a +move. This event data is contained within a card, which is simply a +`(pair term noun)`. Instead, arvo proper passes the card off to one of +its vanes, which each present an interface to clients for a particular +well-defined, stable, and general-purpose piece of functionality. + +As of this writing, we have seven vanes, which each provide the +following services: + +- `%ames` name of both our network and the vane that communicates over + it +- `%clay` version-controlled, referentially- transparent, and global + filesystem +- `%dill` terminal driver. Unix sends keyboard events to `%dill` from + either the console or telnet, and `%dill` produces terminal output. +- `%eyre` http server. Unix sends http messages to `%eyre`, and + `%eyre` produces http messages in response +- `%ford` handles resources and publishing +- `%gall` manages our userspace applications.. `%gall` keeps state and + manages subscribers +- `%time` a simple timer + +Cards +----- + +Cards are the vane-specific portion of a move. Each vane defines a +protocol for interacting with other vanes (via arvo) by defining four +types of cards: kisses, gifts, notes, and signs. + +When one vane is `%pass`ed a card in its `++kiss`, arvo activates the +`++call` gate with the card as its argument. To produce a result, the +vane `%give`s one of the cards defined in its `++gift`. If the vane +needs to request something of another vane, it `%pass`es it a `++note` +card. When that other vane returns a result, arvo activates the `++take` +gate of the initial vane with one of the cards defined in its `++sign`. + +In other words, there are only four ways of seeing a move: (1) as a +request seen by the caller, which is a ++note. (2) that same request as +seen by the callee, a `++kiss`. (3) the response to that first request +as seen by the callee, a `++gift`. (4) the response to the first request +as seen by the caller, a `++sign`. + +When a `++kiss` card is passed to a vane, arvo calls its `++call` gate, +passing it both the card and its duct. This gate must be defined in +every vane. It produces two things in the following order: a list of +moves and a possibly-modified copy of its context. The moves are used to +interact with other vanes, while the new context allows the vane to save +its state. The next time arvo activates the vane it will have this +context as its subject. + +This overview has detailed how to pass a card to a particular vane. To +see the cards each vane can be `%pass`ed as a `++kiss` or return as a +`++gift` (as well as the semantics tied to them), each vane's public +interface is explained in detail in its respective overview. diff --git a/docs/pub/doc/arvo/ames.md b/docs/pub/doc/arvo/ames.md new file mode 100644 index 0000000000..37a656ca1a --- /dev/null +++ b/docs/pub/doc/arvo/ames.md @@ -0,0 +1,29 @@ +
+ +`%ames` +======= + +`%ames` is our networking protocol. + +`%ames` is the name of both our network and the vane that communicates +over it. When Unix receives a packet over the correct UDP port, it pipes +it straight into `%ames` for handling. Also, all packets sent over the +`%ames` network are sent by the `%ames` vane. Apps and vanes may use +`%ames` to directly send messages to other ships. In general, apps use +gall and clay to communicate with other ships rather than using `%ames` +directly, but this isn't a requirement. Of course, gall and clay use +`%ames` behind the scenes to communicate across the network. These are +the only two vanes that use `%ames`. + +`%ames` includes several significant components. Although the actual +crypto algorithms are defined in zuse, they're used extensively in +`%ames` for encrypting and decrypting packets. Congestion control and +routing is handled entirely in `%ames`. Finally, the actual `%ames` +protocol itself, including how to route incoming packets to the correct +vane or app, is defined in `%ames`. + +
+ +
+ + diff --git a/docs/pub/doc/arvo/ames/commentary.md b/docs/pub/doc/arvo/ames/commentary.md new file mode 100644 index 0000000000..2b466e41a6 --- /dev/null +++ b/docs/pub/doc/arvo/ames/commentary.md @@ -0,0 +1,1815 @@ +`%ames` commentary +================== + +`%ames` is our networking protocol. + +First we give commentary on the code, the algorithms involved, and the +protocol. We trace through the code touched when a packet is sent, +received, acknowledged, and that acknowledgment applied. This is fairly +comprehensive, and contains many implementation details, but if you +understand this, then you understand `%ames`. + +If you've scrolled down this page, you may be intimidated by the amount +of Hoon code, especially if you are new to the language. Don't be afraid +of it, you don't have to read any of it if you don't want to -- every +interesting action the code takes is explained in plain English. In +fact, if you are new to the language, this may be a good learning +opportunity. Even if you don't understand every line of Hoon code, +you'll hopefully be able to follow most lines. By the time you've worked +through this, you'll have seen many common patterns and best practices. +Hoon, much more than other languages, is best learned by reading and +understanding large quantities of existing code. In this way, it is +similar to learning a natural language. All of this code is in +`arvo/ames.hoon`. + +After the commentary, we have reference documentation for all the data +structures that are specific to `%ames`. If you see a data structure or +a variable used that you don't recognize, search for it in the code, and +it's very likely defined in one of these data structures. We recommend +that another tab is kept open for easy access to the data structure +reference documentation. The code for these is split between +`arvo/ames.hoon` and `arvo/zuse.hoon`. + +The Lifecycle of a Packet (or, How a Packet Becomes Law) +-------------------------------------------------------- + +Here, we will trace a packet as it makes its way through ames. There are +actually two pathways through ames: the legacy path through `%want`, and +the modern way, entered through `%wont`, with full end-to-end +acknowledgments. Here we will only trace the modern way, though much of +the path is the same for both. + +When an app (or a vane) wishes to send a packet to another ship, it must +send a `%wont` card: + + [%wont p=sock q=path r=*] :: e2e send message + +This card takes three arguments. The `p` is a `sock`, that is, a pair of +two ships, the first of which is the sender and the second is the +receiver. But wait, you ask, why do I get to decide who is the sender? +Can I fake like I'm someone else? The reason is that there are +potentially multiple ships on the same pier, and the kernel can send a +message from any of them. If you attempt to send a message from a ship +not on your pier, then ames will refuse to send it. If you hack around +in your own copy of ames to go ahead and send it anyway, then the other +ship will reject it because your key is bad. Only send messages from +yourself. + +The `q` is a path, representing the place on the other side that you +want to receive your message. It is approximately equivalent to a port +number. Messages on the same path are guaranteed to arrive in the same +order as they were sent. No such guarantees are made across paths. + +The `r` is the actual data that you are sending. As the type implies, +this can be an arbitrary noun, and it will be transferred to the +receiver exactly as-is, in a well-typed way. Of course, this is data +that is sent over the wire, so be careful not to send anything too +massive unless you're willing to wait. + +But enough about the interface. Grepping in ames.hoon for `%wont`, we +find that it appears in exactly two places: at its definition in +`++kiss`, and in `++knob`, where it is handled. We see that we go +directly into `++wise:am`. + + ++ wise :: wise:am + |= [soq=sock hen=duct cha=path val=* ete=?] :: send a statement + ^- [p=(list boon) q=fort] + zork:zank:(wool:(ho:(um p.soq) q.soq) hen cha val ete) + +The inputs to this gate are exactly the sort of thing you'd expect. In +particular, everything in the `%wont` gate is here plus the calling duct +so that we know where to send the acknowledgment and `ete` to determine +if we're going to do the modern end-to-end acknowledgments. + +The actual line of code looks intimidating, but it's really not all that +bad. Working from the inside out, the call to `++um` sets up our +domestic server, and the call to `++ho` sets up our knowledge about the +neighbor we're sending to. From the outside, `++zork` and `++zank` just +apply the changes made to our `++um` and `++am` cores, respectively. If +you're familiar with the common idiom of `++abet`, that's all this is. +The code predates the widespread usage of that name. + +The interesting part, then, is in `++wool:ho:um:am`. Let's look at the +code. + + ++ wool :: wool:ho:um:am + |= [hen=duct cha=path val=* ete=?] :: send a statement + ^+ +> + =+ ^= rol ^- rill + =+ rol=(~(get by ryl.bah) cha) + ?~(rol *rill u.rol) + =+ sex=sed.rol + :: ~& [%tx [our her] cha sex] + =. ryl.bah + %+ ~(put by ryl.bah) cha + rol(sed +(sed.rol), san (~(put by san.rol) sex hen)) + =+ cov=[p=p:sen:gus q=clon:diz] + %+ wind [cha sex] + ?: ete + [%bund q.cov cha sex val] + [%bond q.cov cha sex val] + +This is slightly more complicated, but it's still not all that bad. Our +inputs, at least, are fairly obvious. + +If you glance at the code for a second, you'll see that +`++wind:ho:um:am` seems to be able to send a message, or `++meal`, given +a `++soup`. This gate, then, just sets up the things we need to for +`++wind` to do its job. + +We first get `rol`, which is a `++rill`, that is, a particular outbound +stream. This stream is specific to the path on which we're sending. If +the path hasn't been used before, then we create it. We let `sex` be the +number of messages we've already sent on this path. + +Then, we update the outbound stream by incrementing the number of +messages sent and placing an entry in `san.rol` that associates the +message number with the `duct` that sent the message. This allows us to +give the acknowledgment to the one who sent the message. + +We let `cov` be the current life of our crypto and our neighbor's +crypto. At the moment, we only need our neighbor's life, which we put +into the meal. + +Finally, we call `++wind:ho:um:am` with the `++soup` of the path and +message number and the `++meal` of the payload itself. For end-to-end +acknowledged messages, we use `%bund`. + + [%bund p=life q=path r=@ud s=*] :: e2e message + +Looking at how we create the `%bund`, we can easily see what each field +is for. + +Following the trail a little further, we go to `++wind:ho:um:am`. + + ++ wind :: wind:ho:um:am + |= [gom=soup ham=meal] + :: ~& [%wind her gom] + ^+ +> + =^ wyv diz (zuul:diz now ham) + =^ feh puz (whap:puz now gom wyv) + (busk xong:diz feh) + +`++wind` does three things: it (1) encodes the message into a list of +possibly-encrypted packets, (2) puts the message into the packet pump, +and (3) sends any packets that are ready to be sent. Yes, our nice +little linear run of each gate calling exactly one other interesting +gate is over. We'll go in order here. + +`++zuul:lax:as:go` is the what converts a `++meal` into a list of +actual, 1KB packets. + + ++ zuul :: zuul:lax:as:go + |= [now=@da ham=meal] :: encode message + ^- [p=(list rock) q=_+>] + =< weft + ++ wasp :: null security + ++ weft :: fragment message + ++ wisp :: generate message + +For organizational purposes, `++zuul` constructs an internal core with +three arms. `++wasp` encodes the meal into an atom with no encryption. +`++wisp` encodes a meal with possible encryption (else it simply calls +`++wasp`). `++weft` takes the result of `++wisp` and splits it into +actual packets. + + ++ wasp :: null security + ^-([p=skin q=@] [%none (jam ham)]) + +This simply jams the meal, wrapping it with the `skin` of `%none`, +meaning no encryption. + +Since `++wisp` is a little long, we'll go through it line-by-line. + + ++ wisp :: generate message + ^- [[p=skin q=@] q=_..wisp] + +`++wisp` produces a pair of a `skin` and an atom, which is the meal +encoded as a single atom and possibly encrypted. + + ?: =(%carp -.ham) + [wasp ..wisp] + +If the meal that we're encoding is a `%carp`, then we don't encrypt it. +A `%carp` meal is a partial meal, used when a message is more than 1KB. +Since the entire message is already encrypted, we don't need to encrypt +each packet individually again. + + ?: !=(~ yed.caq.dur) + ?> ?=(^ yed.caq.dur) + :_ ..wisp + :- %fast + %^ cat 7 + p.u.yed.caq.dur + (en:r:cluy q.u.yed.caq.dur (jam ham)) + +If we have a symmetric key set up with this neighbor, then we simply use +it. The skin `%fast` is used to indicate a symmetric key. + + ?: &(=(~ lew.wod.dur) |(=(%back -.ham) =(%buck -.ham))) + [wasp ..wisp] + +If we do not yet have our neighbor's will, then there is no way that we +can seal the message so that only they may read it. If what we're +sending is an acknowledgment, then we go ahead and just send it in the +clear. + + =^ tuy +>.$ + ?:(=(~ lew.wod.dur) [*code +>.$] (griz now)) + +If we don't have our neighbor's will, then we "encrypt" with a key of 0. +If we do have their will, then we generate a new symmetric key that we +will propose. + + :_ ..wisp + =+ yig=sen + =+ bil=law.saf :: XX send whole will + =+ hom=(jam ham) + +`yig` will be the life and engine for our current crypto. `bil` is our +will. `hom` is the meal encoded as a single atom. + + ?: =(~ lew.wod.dur) + :- %open + %^ jam + [~ `life`p.yig] + bil + (sign:as:q.yig tuy hom) + +If we do not have our neighbor's will, then we send our current life +along with our will and the message. The message itself is "signed" with +a key of 0. + + :- %full + =+ cay=cluy + %^ jam + [`life`p.cay `life`p.yig] + bil + (seal:as:q.yig pub:ex:r.cay tuy hom) + -- :: --zuul:lax:as:go + +If we do have our neighbor's will, then we send our perception of their +current life, our current life, our will, and the message. The message +is sealed with their public key so that only they can read our message. + +Once we have the message encoded as an atom, `++weft` goes to work. + + ++ weft :: fragment message + ^- [p=(list rock) q=_+>.$] + =^ gim ..weft wisp + :_ +>.$ + ^- (list rock) + +We're going to produce a list of the packets to send. First, we use the +aforementioned `++wisp` to get the message as an atom. + + =+ wit=(met 13 q.gim) + ?< =(0 wit) + +`wit` is the number of 1KB (2\^13 bit) blocks in the message. We assert +that there is at least one block. + + ?: =(1 wit) + =+ yup=(spit [our her] p.gim q.gim) + [yup ~] + +If there is exactly one block, then we just call `++spit` to turn the +message into a packet. We'll explain what `++spit` does momentarily. + + =+ ruv=(rip 13 q.gim) + =+ gom=(shaf %thug q.gim) + =+ inx=0 + +If there is more than one block, then we rip it into blocks in `ruv`. +`gom` is a hash of the message, used as an id. `inx` is the number of +packets we've already made. + + |- ^- (list rock) + ?~ ruv ~ + =+ ^= vie + %+ spit + [our her] + wasp(ham [%carp (ksin p.gim) inx wit gom i.ruv]) + :- vie + $(ruv t.ruv, inx +(inx)) + +Here we package each block into a packet with `++spit` and produce the +list of packets. + + ++ spit :: cake to packet + |= kec=cake ^- @ + =+ wim=(met 3 p.p.kec) + =+ dum=(met 3 q.p.kec) + =+ yax=?:((lte wim 2) 0 ?:((lte wim 4) 1 ?:((lte wim 8) 2 3))) + =+ qax=?:((lte dum 2) 0 ?:((lte dum 4) 1 ?:((lte dum 8) 2 3))) + =+ wix=(bex +(yax)) + =+ vix=(bex +(qax)) + =+ bod=:(mix p.p.kec (lsh 3 wix q.p.kec) (lsh 3 (add wix vix) r.kec)) + =+ tay=(ksin q.kec) + %+ mix + %+ can 0 + :~ [3 1] + [20 (mug bod)] + [2 yax] + [2 qax] + [5 tay] + == + (lsh 5 1 bod) + +This is how we turn a message into a real packet. This has the +definition of the packet format. + +`wim` is the length of the sending ship, and `dum` is the length of the +receiving ship. There are only five possibilities for each of those, +corresponding to carriers, cruisers, destroyers, yachts, and submarines. +These are encoded in `yax` and `qax` as 0, 0, 1, 2, and 3, respectively. +Thus, `wix` and `vix` are the number of bytes that must be reserved for +the ship names in a packet. + +Next, we construct `bod` by simply concatenating the sending ship, the +receiving ship, and the body of the message. Then, we get the encryption +mechanism from `++skin`, which may be a 0, 1, 2, or 3, and put it in +`tay`. + +Next, we concatenate together, bit by bit, some final metadata. We use +three bits for our protocol number, which is incremented modulo eight +when there is a continuity breach or the protocol changes. We use the +final twenty bits of a hash of the body (which, we suppose, makes it a +twenty bit hash) for error-checking. We use two bits to tell how much +room is used in the body for the sending ship, and another two bits for +the receiving ship. Finally, we use five bits to store the encryption +type. Note that since there are only two bits worth of encryption types, +there are three unused bits here. This adds up to 32 bits of header +data. Finally, we concatenate this onto the front of the packet. Thus, +we can summarize the packet header format as follows. + + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |Proto| Hash of Body |yax|qax| Crypto | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +After this, there are `yax` bits of the sender name, `qax` bits of the +receiver name, and up to 8192 bits of data. Thus, the maximum size of a +packet is achieved in a message between two submarines with 8192 bits of +data. This will require 32+128+128+8192 = 8480 bits, or 1060 bytes. + +This concludes our discussion of `++zuul:lax:as:go`. If you recall from +`++wind:ho:um:am`, the list of packets from `++zuul` is passed into +`++whap:pu` to update the packet pump and get any packets that can be +sent immediately. + + ++ whap :: whap:pu + |= [now=@da gom=soup wyv=(list rock)] :: send a message + ^- [(list rock) _+>] + =. pyz (~(put by pyz) gom (lent wyv)) + =. +> + |- ^+ +>.^$ + ?~ wyv +>.^$ + %= $ + wyv t.wyv + nus +(nus) + diq (~(put by diq) (shaf %flap i.wyv) nus) + puq (~(put to puq) [nus `soul`[gom 0 | ~2000.1.1 i.wyv]]) + == + (harv now) + +First, we put into `pyz` the id for this message and the number of its +packets that have not yet been acknowledged, which is of course the +total number of packets since we haven't even sent the packets. + +For every packet, we change three things in the state (`++shed`) of our +packet pump: (1) we increment `nus`, the number of packets sent; (2) we +put the packet number into `diq` keyed by a hash of the packet; and (3) +we put the packet into the packet queue, with the basic metadata of its +id `gom`, 0 transmissions, not live yet, last sent in the year 2000, and +the packet itself. + +Finally, we harvest the packet pump. + + ++ harv :: harv:pu + |= now=@da :: harvest queue + ^- [(list rock) _+>] + ?: =(~ puq) [~ +>(rtn ~)] + ?. (gth caw nif) [~ +>] + =+ wid=(sub caw nif) + =| rub=(list rock) + =< abet =< apse + |% + +`++harv` contains a core for most of its work. The meat is in `++apse`. +First, though, it sets itself up. If there aren't any packets in the +queue, then we simply do nothing except set `rtn`, our next timeout, to +nil because we don't have any packets that may need to be retransmitted. +If we have more live (that is, sent and unacknowledged) packets than our +window size, then we don't do anything. + +Otherwise, we let `wid` be the width of our remaining packet window, and +we initialize `rub` to nil. `rub` will be the list of packets that are +ready to be sent. We then call `++apse` and pass the result to `++abet`. +`++apse` decides which packets are ready to be sent. + + ++ apse + ^+ . + ?~ puq . + ?: =(0 wid) . + => rigt =< left + ?> ?=(^ puq) + ?: =(0 wid) . + ?. =(| liv.q.n.puq) . + :: ~& [%harv nux.q.n.puq p.n.puq] + %_ . + wid (dec wid) + rub [pac.q.n.puq rub] + nif +(nif) + liv.q.n.puq & + nux.q.n.puq +(nux.q.n.puq) + lys.q.n.puq now + == + +If there are no remaining packets to send, or if we've filled the packet +window, do nothing. We call `++rigt` and `++left` to process the left +and right branches of the packet queue. + +Now we assert that the queue is not empty, and we again check that we +haven't filled the packet window. We will operate on the head of the +queue. If the packet is live, then do nothing. Otherwise, we go ahead +and send it. + +To send, we (1) decrement `wid`, our packet window width; (2) cons the +packet onto the `rub`, which will be returned as the list of packets to +send; (3) increment `nif`, the number of live packets; (4) set the +packet to be live; (5) increment the number of transmissions of the +packet; and (6) set the last sent time of the packet to now. + + ++ left + ?> ?=(^ puq) + ^+(. =+(lef=apse(puq l.puq) lef(puq [n.puq puq.lef r.puq]))) + ++ rigt + ?> ?=(^ puq) + ^+(. =+(rig=apse(puq r.puq) rig(puq [n.puq l.puq puq.rig]))) + +These do exactly what you would expect: they traverse the packet queue +so that `++apse` gets called recursively through it. + +Finally, `++abet` gets called, which resolves the changes. + + ++ abet + ?~ rub [~ +>.$] + [(flop rub) +>.$(rtn [~ (add rto now)])] + +This returns the packets that we wish to send, and it updates the +timeout so that we know when to try resending unacknowledged packets. + +This concludes our discussion of `++whap:pu`. To finish +`++wind:ho:um:am`, we just need to delve into `++busk:ho:um:am`. But +wait, in the call to `++busk`, the first argument is `xong:diz`. What is +this? This, my dear reader, is one more detour, this time into +`++xong:lax:as:go`. + + ++ xong :: xong:lax:as:go + ^- (list ship) :: route unto + =+ [fro=xen too=xeno] + =+ ^= oot ^- (list ship) + =| oot=(list ship) + |- ^+ oot + ?~ too ~ + ?: (lien fro |=(a=ship =(a i.too))) ~ + [i.too $(too t.too)] + :: ~& [%xong-to [our her] (weld oot ?>(?=(^ fro) t.fro))] + (weld oot ?>(?=(^ fro) t.fro)) + +This gets the list of intermediate ships needed to get a packet from us +to our neighbor. First, we get `fro` and `too`, the "canons" of ourself +and our neighbor, respectively. + +What is this "canon", you ask? A canon is simply a ship plus its +"ancestors", as defined by `++sein`. For example, the canon of +`~hoclur-bicrel` is: + + ~hoclur-bicrel/try=> (saxo ~hoclur-bicrel) + ~[~hoclur-bicrel ~tasruc ~tug] + +If we follow the algorithm in `++xong`, we see that we are simply +creating a list of ships that form a path from our neighbor to ourself. +Essentially, we look through the canon of our neighbor until we find +something in our own cannon -- a common ancestor. Or, if we are from +different carriers, then there is no common ancestor. We then weld this +onto the tail of our own canon. In the end, this is simply a list of +possible ships to try to route via to get to our neighbor, ordered by +preferability (that is, closeness to our neighbor). We will end up +trying, in order, to find a lane to these. + +Now, we can finally get to `++busk:ho:um:am`. + + ++ busk :: busk:ho:um:am + |= [waz=(list ship) pax=(list rock)] :: send packets + %_ +> + bin + |- ^+ bin + ?~ pax bin + $(pax t.pax, bin (weld (flop (wist:diz now waz ~ i.pax)) bin)) + == + +Thankfully, `++busk` is fairly simple. We go through the list of packets +and convert them to `++boon`s with `++wist:lax:as:go`. These boons are +placed into `bin`, and they end up getting processed by `++clop` (this +happens in `++knob`). + + ++ wist :: wist:lax:as:go + |= $: now=@da :: route via + waz=(list ,@p) + ryn=(unit lane) + pac=rock + == + ^- (list boon) + ?: =(our her) [[%ouzo *lane pac] ~] + ?~ waz ~ + =+ dyr=?:(=(her i.waz) dur (gur i.waz)) + ?. ?& !=(our i.waz) + ?=(^ lun.wod.dyr) + == + $(waz t.waz) + :_ ?: ?=(%ix -.u.lun.wod.dyr) + $(waz t.waz) + ~ + :+ %ouzo u.lun.wod.dyr + ?: &(=(i.waz her) =(~ ryn)) pac + =+ mal=(jam `meal`[%fore her ryn pac]) + %- spit + ^- cake + :* [our i.waz] + ?~ yed.caq.dyr [%none mal] + :- %fast + %^ cat 7 + p.u.yed.caq.dyr + (en:crua q.u.yed.caq.dyr mal) + == + +This takes a sample of the current time, the list of ships that we just +generated, a lane if we already know it, and the packet itself. + +First, if we are sending a message to ourself, then we simply create a +`%ouzo` boon with a bunted lane. Otherwise, if there are no routing +candidates, there is nothing we can do, so we return nil. + +Next, we get the `dore` of the first routing candidate. If we're looking +at the neighbor to whom we're trying to send the message, then we simply +use the `dore` that we already have. Otherwise, we get a default `dore`. + +If we're the first routing candidate, or if we have don't have a lane to +this candidate, then we skip this candidate and move on to the next one. + +If we have only a provisional ip address, then we try to send on it, but +we also try to send on later routing candidates as well. Otherwise, we +only send on this one candidate. + +Finally, we create the actual `%ouzo` boon. The lane is the one from our +`dore`. If we're sending it directly to our intended recipient, and we +haven't been told to use a specific lane, then we just send the packet +directly. Otherwise, we wrap it in a little `%fore` meal, telling the +intermediary to whom we wish it to be sent. If we have already set up a +symmetric key with the intermediary, then we encrypt it with that. +Otherwise, we send it in the clear. + +Now, if you recall, we have traced all the way through from the +beginning when, in `++knob`, the `%wont` card was handled by a call to +`++wise`. There is only one more step before the packet is finally sent. +Looking in `++knob`, we see that the resultant list of boons is passed +into `++clop`, which will execute the correct actions and return a list +of moves. In `++clop`, we see the handling of each specific boon. The +one we are interested in is `%ouzo`, since that is the only one we have +sent thus far. + + %ouzo + :: ~& [%send now p.bon `@p`(mug (shaf %flap q.bon))] + :_ fox + [[gad.fox [%give %send p.bon q.bon]] ~] + +Very simply, we give a `%send` gift along the special duct that goes +straight into the bowels of unix. This is the last stop before we drop +into vere, and later libuv. And then... the world. + +The packet, after its creation, embarks on a journey across physical +time and space into the great unknown. Hurtling through fiber-optic +cables at hundreds of thousands of kilometers per second, it finally +arrives at our neighbor's network adapter. The adapter tells unix, unix +tells libuv, libuv tells vere, and vere sends a `%hear` kiss to ames. +And now we reenter the kernel. + +The `%hear` kiss goes straight to `++knob`, just as did the `%wont` kiss +earlier. + + %hear + (~(gnaw am [now fox]) %good p.kyz q.kyz) + +Here, though, we call `++gnaw:am` to process the packet. The arguments +to `++gnaw` are the same as those to the `%hear` kiss: the lane on which +the packet was received and the packet itself. The other argument is +just `%good`, which is a `++cape` saying that we expect the packet to +succeed. If a formal error occurs, then since we have a transactional +event system, the `%hear` event will never be considered to have +actually happened, and unix will send a `%hole` kiss so that we may send +a negative acknowledgment. + + ++ gnaw :: gnaw:am + |= [kay=cape ryn=lane pac=rock] :: process packet + ^- [p=(list boon) q=fort] + ?. =(2 (end 0 3 pac)) [~ fox] + =+ kec=(bite pac) + ?: (goop p.p.kec) [~ fox] + ?. (~(has by urb.ton.fox) q.p.kec) + [~ fox] + =< zork + =< zank + %- ~(chew la:(ho:(um q.p.kec) p.p.kec) kay ryn %none (shaf %flap pac)) + [q.kec r.kec] + +First, we check the protocol number. If it is not correct, then we +simply ignore the packet entirely. Otherwise, we parse the packet with +`++bite`, which converts a packet atom into a `cake`, that is, a triple +of the `sock` (pair of sender and receiver), the `skin` (encryption +type), and the data. + + ++ bite :: packet to cake + |= pac=rock ^- cake + =+ [mag=(end 5 1 pac) bod=(rsh 5 1 pac)] + =+ :* vez=(end 0 3 mag) :: protocol version + chk=(cut 0 [3 20] mag) :: checksum + wix=(bex +((cut 0 [23 2] mag))) :: width of receiver + vix=(bex +((cut 0 [25 2] mag))) :: width of sender + tay=(cut 0 [27 5] mag) :: message type + == + ?> =(2 vez) + ?> =(chk (end 0 20 (mug bod))) + :+ [(end 3 wix bod) (cut 3 [wix vix] bod)] + (kins tay) + (rsh 3 (add wix vix) bod) + +This is exactly the inverse of `++spit`. Note that here we check both +the protocol number and the hash, crashing on error. Remember that a +crash will result in a negative acknowledgment being sent. + +Continuing in `++gnaw`, we see that if the intended recipient is not on +our pier, then we drop the packet. + +If we've gotten this far, then we wish to process the packet. Recall +that `++ho` and `++um` set up the domestic server and foreign client +cores, respectively, and that `++zork` and `++zank` resolve any changes +to these cores. + +The new stuff here, then, is the `++la` core and the `++chew` arm. The +`++la` sets up a core for this particular packet, containing the current +success/failure `cape`, the lane it was sent on, the encryption type, +and a hash of the packet, used as an id. + +`++chew` is called with the encryption type and the message itself. It +contains a little helper core inside of it, which starts immediately +with `++apse`. + + ++ apse + ^+ +>.$ + =+ oub=bust:puz + =+ neg==(~ yed.caq.dur.diz) + =. +>.$ east + =+ eng==(~ yed.caq.dur.diz) + =+ bou=bust:puz + =. bin + ?. &(oub !bou) bin + :_(bin [%wine [our her] " is ok"]) + =. bin + ?. &(neg !eng) bin + :_(bin [%wine [our her] " is your neighbor"]) + +>.$ + +First, we let `oub` be true if our neighbor hasn't been responding to us +for more than sixteen seconds. Let `neg` be true if we haven't yet +proposed a symmetric key, meaning that we haven't yet corresponded with +this ship, so they are not our neighbor. Next, we run `++east`, which +we'll go into in just a minute. + +We now do the same two checks and store the results in `eng` and `bou`. +If our neighbor has, like the prodigal son, returned after an extended +absense, then we send a `%wine` boon as the proverbial fatted calf, +which is simply printed out to the console. Likewise, if we are meeting +one with whom we have never had the pleasure of acquainting ourselves, +we send a message to the console to that effect. + +We skipped over `++east`, which contains the meat of the processing. It +first decrypts the message, then calls `++chow:la:ho:um:am` with the +resultant meal. We'll go through each of the four cases in turn, but +first since each one calls `++bilk:pu`, we'll take a brief detour. + + ++ bilk :: bilk:pu + |= now=@da :: inbound packet + ^+ +> + =+ trt=(mul 2 rtt) + %= +>.$ + rue [~ now] + rto trt + rtn ?~(puq ~ [~ (add now trt)]) + == + +This updates the timing information in our packet pump. `rue`, the last +time we have heard from this neighbor, is set to now. `rto`, the +retransmit timeout is set to twice the current ping time, and if there +is anything in the packet queue, then we reset the next timeout, since +we've just heard a message. + +Back to `++east`. + + %none + =. puz (bilk:puz now) + (chow ((hard meal) (cue msg))) + +The simplest case is when the encryption type is `%none`. We first call +`++bilk` to update the packet pump, then we cue (unjam) the message into +a meal. We hard cast it into a meal -- if the cast fails, then we do +want to crash since someone is sending us malformed data. Finally, we +send the result to `++chow` for interpretation and handling. + + %fast + =+ [mag=`hand`(end 7 1 msg) bod=(rsh 7 1 msg)] + =+ dey=(kuch:diz mag) + ?~ dey + ~& [%bad-key her mag] + +>.$ :: ignore unknown key + =. puz (bilk:puz now) + =^ key diz u.dey + (chow(aut sin) ((hard meal) (cue (dy:q:sen:gus key bod)))) + +For symmetric encryption, we first get the `hand`, which is the hash of +the symmetric key. We pass it to `++kuch:lax:as:go`, which returns the +key if we either have used it before or we have proposed it. If we have +proposed it, then we change its status from proposed to real. If +`++kuch` fails, then we drop the packet and print out a `%bad-key` +message. + +Otherwise, we call `++bilk` as before to update the packet pump and pass +into `++chow` the decrypted data. + + %full + =+ mex=((hard ,[p=[p=life q=life] q=will r=@]) (cue msg)) + =. diz (deng:diz q.mex) + =+ wug=cluy:diz + ?> =(q.p.mex p.wug) + =+ gey=(sev:gus p.p.mex) + =+ mes=(need (tear:as:q.gey pub:ex:r.wug r.mex)) + =. diz (wasc:diz p.mes) + =. puz (bilk:puz now) + (west(msg q.mes)) + +For sealed asymmetric encryption, we first take off the the layer of +data that gives us the life and will of our neighbor, and we apply try +to extend their former will with the new data. `++deng` will fail if +this is impossible. + +Next, we get our most current understanding of our neighbor's crypto, +and we verify that it's the same life as what they're sending. Then, we +get our own crypto from `++sev` and decrypt the message with the public +key from our neighbor's crypto. We register the proposed symmetric key, +update the packet pump, and call `++west`, which simply casts the +message to a meal and calls `++chow`, reporting any error. + + %open + =+ mex=((hard ,[p=[~ q=life] q=will r=@]) (cue msg)) + =. diz (deng:diz q.mex) + =+ wug=cluy:diz + ?> =(q.p.mex p.wug) + =+ mes=(need (sure:as:r.wug *code r.mex)) + =. puz (bilk:puz now) + (west(msg mes)) + +Finally, for signed asymmetric encryption, we, as before, take off the +layer of data that gives us the life and will of our neighbor. This +time, of course, we do not get our own crypto -- only that of our +neighbor. + +The rest you have seen. We call `++deng` to extend the will, we verify +that their crypto life is what we think it ought to be, we "decrypt" the +data, we update the packet pump, and we call `++west` to call `++chow`. + + ++ chow :: chow:la:ho:um:am + |= fud=meal :: interpret meal + ^+ +> + =. diz ?:(=(%none aut) diz (wast:diz ryn)) + (dine fud) + +Here, if the message was encrypted at all, then we call +`++wast:lax:as:go`, which simply updates the lane (route) to our +neighbor (unless we're given a provisional route). This ensures that we +always have the most direct possible path to them. + +We've been handling this meal for so long, we've almost forgotten what +we want to do with it. The telos is of any meal to be dined on. We will +choose out the cases here that are important to our current +investigation. + + %fore + =+ ^= lyn ^- lane + ?~ q.fud ryn + ?. ?=(%if -.u.q.fud) u.q.fud + [%ix +.u.q.fud] + :: u.q.fud + ?: =(our p.fud) + (emit %mead lyn r.fud) + =+ zid=(myx:gus p.fud) + (emir (wist:zid now xong:zid [~ lyn] r.fud)) + +Forwarding is the simplest case, since we've seen all the arms before, +except perhaps `++emit` and `++emir`, which simply take a boon or list +of boons respectively and queue them up to be handled when the core +resolves. If we're told to forward a packet to ourselves, then we emit a +`%mead` boon which simply sends another `%hear` kiss to ourselves with +the data. Otherwise, we try to find a route to the recipient, as before. + + %carp + =+ zol=(~(get by olz.weg) s.fud) + ?^ zol cock(kay u.zol) + =^ neb nys.weg + =+ neb=(~(get by nys.weg) s.fud) + ?^ neb [u.neb nys.weg] + =+ neb=`bait`[(kins p.fud) 0 r.fud ~] + [neb (~(put by nys.weg) s.fud neb)] + ?> (lth q.fud p.r.neb) + ?> =((kins p.fud) p.neb) + ?> =(r.fud p.r.neb) + =+ doy=`(unit ,@)`(~(get by q.r.neb) q.fud) + ?^ doy cock + => ^+ . %= . + q.r.neb (~(put by q.r.neb) q.fud t.fud) + q.neb +(q.neb) + == + :: ~& [%carp q.fud s.fud q.neb p.r.neb] + ?: =(q.neb p.r.neb) + =: nys.weg (~(del by nys.weg) s.fud) + olz.weg (~(put by olz.weg) s.fud kay) + == + (golf p.neb r.neb) + =. +>.$ cock + +>.$(nys.weg (~(put by nys.weg) s.fud neb)) + +Here, we have received a partial message, and we're just assembling the +individual packets into a message. Most of this code is fairly +algorithmic, so we'll just hit the high points. In the beginning, we +check if we've already received this message, and if so, we resend the +acknowledgment. Remember, "always ack a dupe, never ack an ack". + +In `nys.weg` we keep track of an incoming set of partial packets, +indexed by the `flap` hash that comes with every packet. We check to see +if we have already received this partial message, and if so we +acknowledge it. Otherwise, we put it in `nys.weg` unless this is the +last message, in which case we ack the last partial message, move the +complete message into `olz.weg`, and call `++golf`, which assembles the +message and calls `++chew`, to start the dance again with the complete +message. + + %bund + :: ~& [%bund q.fud r.fud] + ?> =(p:sen:gus p.fud) + (deer q.fud r.fud ?-(kay %dead ~, %good [~ s.fud])) + +What if we're just receiving a regular old, garden variety message? We +call `++deer` with the data from the message. If we already know that +the message processing will fail (that is, if we got a `%hole` card from +unix rather than a `%hear` card), then we don't even send the data at +all. Remember, if a packet fails to process, it's as if it never even +arrived, except that we send a negative acknowledgment. + + ++ deer :: deer:la:ho:um:am + |= [cha=path num=@ud dut=(unit)] :: interpret message + ^+ +> + =+ rum=(fall (~(get by raz.bah) cha) *race) + %= +>.$ + +> + ?. (gte num did.rum) :: always ack a dup + (cook (~(get by bum.rum) num) cha ~ ryn dam) + ?: dod.rum + (coat cha rum(mis (~(put by mis.rum) num [kay ryn dam dut]))) + %= +>.+>.$ + raz.bah + %+ ~(put by raz.bah) cha + rum(mis (~(put by mis.rum) num [kay ryn dam dut])) + == + == + +First, we get the race for this particular triple of sender, receiver, +and path, creating it if it doesn't exist. If we've already acked the +message, then we resend the ack. Note that `did.rum` is the number of +packets we acknowledged, positively or negatively while `bum.rum` is a +map of message numbers to negative acknowledgments. Thus, if a message +number is less than `did.rum`, then if it's in `bum.rum` then it was +negatively acknowledged, otherwise it's postively acknowledged. Thus, we +are constant in space with the number of successful messages and linear +in the number of failed messages. We'll document `++cook` later on, but +suffice it to say that it sends an acknowledgment. It is to end-to-end +acknowledgments what `++cock` is to packet-level acknowledgments. + +If we are still processing a message (that is, `dod.rum` is false), then +we simply put this message in the map of misordered packets to be +processed when their time comes. "Processing a message" in this case +means that we've received the message and notified the correct +application, but we're still waiting for the application-level +acknowledgment. + +Otherwise, we're ready for a packet, so we process it. + + ++ coat :: coat:ho:um:am + |= [cha=path rum=race] :: update input race + ^+ +> + =+ cun=(~(get by mis.rum) did.rum) + ?~ cun + +>.$(raz.bah (~(put by raz.bah) cha rum)) + ?. =(%good p.u.cun) +>.$ + ?> ?=(^ s.u.cun) + %= +>.$ + raz.bah (~(put by raz.bah) cha rum(dod |)) + bin + :_ bin + :^ %mulk + [our her] + `soap`[[p:sen:gus clon:diz] cha did.rum] + u.s.u.cun + == + +First, we grab the message we want to process and store it in `cun`. If +it's a good packet, then we change `dod.rum` to false, meaning that +we're in the middle of processing a packet and should not start +processing another one. We also put a `%mulk` boon into the queue so +that, when it all resolves, we send a mesage to the intended recipient +application. The boon contains the sender, the receiver, the identity of +the message, and the message itself. + +This bubbles up all the way back to `++knob`, where we were handling the +`%hear` card. Following the logic in `++knob`, we can see that the boons +get sent into `++clop` to be turned into actual arvo-level moves. We've +been here before, if you recall, when we handled the `%cake` boon to +send a message. Now, we're handling the `%mulk` boon, which is +unfortunately slightly more complicated. + + %mulk + :: ~& [%mulk p.bon q.bon] + ?> ?=([@ @ *] q.q.bon) + ?> ?=(%q i.q.q.bon) + ?+ i.t.q.q.bon + ~& %mulk-bad + :_ fox + :~ :- (claw p.p.bon) + [%sick %wart p.bon i.t.q.q.bon t.t.q.q.bon r.bon] + == + %ge :: %gall request + ?> ?=([@ ~] t.t.q.q.bon) + =+ app=`term`(need ((sand %tas) i.t.t.q.q.bon)) + =+ ^= pax + :+ (scot %p p.p.bon) + (scot %p q.p.bon) + q.q.bon + :_ fox [hen %pass pax %g %rote p.bon app r.bon]~ + %gh :: %gall response + ?> ?=([@ ~] t.t.q.q.bon) + =+ app=`term`(need ((sand %tas) i.t.t.q.q.bon)) + =+ ^= pax + :+ (scot %p p.p.bon) + (scot %p q.p.bon) + q.q.bon + :_ fox [hen %pass pax %g %roth p.bon app r.bon]~ + == + +We're dispatching messages based on the prefix of their path. Since only +`%gall` apps use end-to-end acknowledgments at the moment, every path +must have at least two elements, and the first one must be `%q`. Beyond +that, we handle the `/q/ge` and `/q/gh` cases for gall requests and +responses, respectively. + +In both cases, we require the next term in the path to be the name of +the intended recipient `%gall` app. Thus, a message to `/q/ge/chat` for +example, will send a message to the chat app. + +We then send a message to the app itself. The message is either a +`%rote` or a `%roth` for a request and a response, respectively. The +content is the `rook` or `roon` that was sent (stored in `r.bon`), but +we don't actually handle that at all here. That's completely a +`%gall`-level thing. We're just the messenger. + +Notice the path we send this over. We encode the sender, the receiver, +and the path over which it was sent. This fully specifies the `race` so +that when the app gives us the acknowledgment we know where to send it. + +We now have another interlude. We have entrusted our precious data, so +carefully guarded and guided from the app on that far-away ship, to our +local app. It has the ability to do whatever it pleases with it. It may +take a significant amount of time to process. When the message has been +handled by this app, though, it must produce an acknowledgment. Our +final task is to deliver this acknowledgment to the sending app. + +We should describe here what exactly these oft-mentioned acknowledgments +actually consist of. There are two kinds of acknowledgments: positive +and negative. A positive acknowledgment contains no data other than its +existence. A negative acknowledgment may optionally include a reason for +said negativity. Formally, a negative acknowledgment is an `ares`, which +is a unit pair of a term and a list of tanks. If this is null, this is +simply a failure with no associated information. If the pair exists, the +term is a short error code that is usually both human and computer +readable. For example, if you try to send a message to a valid `%gall` +app that doesn't have any `++poke` to handle it, then `%gall` will give +a negative acknowledgment with error term `%poke-find-fail`. The list of +tanks is a human-readable description of the error. This often contains +a stack trace. At any rate, all this information is returned to the +sending app on the other end of the wire. + +After this brief interlude, our story resumes in `++knap`, where we +receive responses. In particular, a `%mean` indicates a negative +acknowledgment while a `%nice` indicates a positive acknowledgment. + + ?(%mean %nice) + ?> ?=([@ @ @ *] tea) + =+ soq=[(slav %p i.tea) (slav %p i.t.tea)] + =+ pax=t.t.tea + =+ ^= fuy + =< zork =< zank + %^ ~(rack am [now fox]) soq pax + ?-(+<.sih %mean `p.+.sih, %nice ~) + => %_(. fox q.fuy) + =| out=(list move) + |- ^- [p=(list move) q=_+>.^$] + ?~ p.fuy + [(flop out) +>.^$] + =^ toe fox (clop now hen i.p.fuy) + $(p.fuy t.p.fuy, out (weld (flop toe) out)) + +Recall the format of the path we sent the message on, and you'll +understand why `soq` and `pax` are the sender/receiver pair and path on +which the message was sent. The rest of this is structured much like +`++knob`, so we call `++rack:am` and send the resulting boons to +`++clop`. Business as usual. + + ++ rack :: rack:am + |= [soq=sock cha=path cop=coop] :: e2e ack + =+ oh=(ho:(um p.soq) q.soq) + =. oh (cook:oh cop cha ~) + (cans:oh cha) + +First, we set up `++um` and `++ho`, as we've done twice before, for our +domestic and foreign servers, respectively. The other two things are +new, though. Well, `++cook` is not actually new, but we delayed the +explanation saying only that it sends an acknowledgment. The time has +come. + + ++ cook :: cook:ho:um:am + |= [cop=coop cha=path ram=(unit ,[ryn=lane dam=flap])] + ^+ +> :: acknowledgment + =+ rum=(need (~(get by raz.bah) cha)) + =+ lat=(~(get by mis.rum) did.rum) + ?: &(?=(~ lat) ?=(~ ram)) ~&(%ack-late-or-redundant +>.$) + =+ ^- [ryn=lane dam=flap] + ?^ ram [ryn.u.ram dam.u.ram] + ?< ?=(~ lat) + [q r]:u.lat + =. raz.bah + ?^ ram raz.bah + %+ ~(put by raz.bah) cha + rum(dod &, bum ?~(cop bum.rum (~(put by bum.rum) did.rum u.cop))) + =^ roc diz (zuul:diz now [%buck cop dam ~s0]) + (busk(diz (wast:diz ryn)) xong:diz roc) + +If we are acknowledging a message that we have already acked, the `ram` +will contain the new lane and flap to send the duplicate ack to. This +happens if we call `++cook` in `++deer`, but it doesn't happen from +`++rack`. If there is no message waiting to be acknowledged and we're +not given an explicit lane and flap (that is, we're not sending a +duplicate ack), then the app must have sent us multiple acknowledgments. +We do the only sensible thing we can do and drop all acknowledgments +after the first, printing a message. This is, in fact, an error, so it +could be argued that we ought to crash. Whatever you do, don't depend on +this not crashing. + +First, we grab the race specified by the given path, and we get the most +recent in-order message, which must be the one which is being +acknowledged. + +Then, we decide which lane/flap to respond on/to. Basically, in the +usual case we respond on the lane through which the initial message was +sent, which is stored along with the other packet information in +`mis.rum`, since it has to be remembered across calls to ames. However, +if we receive a duplicate message, then we must respond to the new +message. It's quite possible the reason the other acknowledgment didn't +get returned was that the lane between the ships was broken. + +At any rate, we update the race by saying that we've finished processing +this packet (unless we're sending a duplicate ack) and, if we're sending +a negative acknowledgment, putting the negative ack into `bum.rum` so +that we can resend it if necessary. + +We encode our new message, updating the packet pump, with `++zuul`, as +before, and we send it off with `++busk`, routed via `++wast` to one of +the ships in `++xong`. Of course, in practice, we don't even look at the +ships in `++xong` because we already have a lane directly to our +neighbor (the one over which they sent their message to us). + +We glossed over the actual message we're sending back. We're sending a +`%buck` meal, which is an acknowledgment. The `cop` specifies whether +this is a positive or a negative ack, `dam` specifies the message we're +acknowledging, and the `~s0` is a placeholder for the processing time +required. This time is neither calculated (though it is hopefully +obvious how to do so) nor used at present, but this information may be +used in the future for improved congestion control. Since the round-trip +time for an end-to-end acknowledged packet includes the processing time +on the other end, most common congestion control algorithms will stumble +when some messages take much longer to process than others. As noted, +though, this is simply an opportunity for improvement -- our congestion +control algorithms are relatively naive at the moment. + +Recall that `++busk` calls `++wist` to put the actual `%ouzo` boon in +the queue, which gets handled by `++clop` to actually send the message. +This is the same pipeline as sending any other message, so we'll refer +you to the explanation above if you've forgotten it. + +The last thing we need to do on this ship is move on to the next packet +in the queue if there is one. If you recall, in `++rack` after the call +to `++cook` there was a call to `++cans:ho:um:am`. + + ++ cans :: cans:ho:um:am + |= cha=path + =+ rum=(need (~(get by raz.bah) cha)) + =. rum + %= rum + did +(did.rum) + mis (~(del by mis.rum) did.rum) + == + (coat cha rum) + +This is very simple. We increment the number of packets that we've +acknowledged on this race and we delete the packet that we just +acknowledged from the set of misordered packets. + +Then, we call `++coat` again to process the next packet if we've already +received it. And that's it for this. + +The acknowledgment now travels the same path that its forebearer, the +original message, once tread, but this time not into the great unknown. +The weary traveler is seeking out its familial roots, finding the app +from whom sprung forth the original message way back in paragraph three. +When it arrives at the network adapter of its ancestors, the adapter +tells unix, unix tells libuv, libuv tells vere, and vere sends a `%hear` +kiss to ames. Once more into the kernel. + +The `%hear` kiss is handled in `++knob` as before, leading to `++gnaw`, +going over to `++chew`, `++apse`, `++chow`, and eventualy to `++dine`. +We've seen most of the cases in `++dine`, but we haven't yet looked at +the handling of this `%buck` meal. + + %buck + =. +> ?.(=(%full aut) +> cock) :: finish key exch + +>(..la (tock p.fud q.fud r.fud)) + +We send a packet level acknowledgment if we're finishing a key exchange, +else we call `++tock` to process the acknowledgment. + +This will get a little involved, so if you don't much care about how +exactly an acknowledgment happens, just know that the result gets gifted +as a `%woot` card back to the app who sent it. For those brave souls who +wish to see this thing through to the end, it's once more into the +breach. + + ++ tock :: tock:ho:um:am + |= [cop=coop fap=flap cot=@dr] :: e2e ack by hash + ^+ +> + =^ yoh puz (bick:puz now fap) + =. +>.$ + ?~ p.yoh +>.$ + =^ hud +>.$ + (done p.u.p.yoh q.u.p.yoh) + ?~ hud +>.$ + %= +>.$ + bin + :_ bin + `boon`[%cake [our her] [[p:sen:gus clon:diz] u.p.yoh] cop u.hud] + == + (busk xong:diz q.yoh) + +We're going to work through this one a little backwards since it's +mostly fairly simple except the call to `++bick:pu`. In fact, we'll just +skip `++bick` for the moment and finish the rest. + +If `++bick` succesfully acks the message, then we call `++done`. + + ++ done :: done:ho:um:am + |= [cha=path num=@ud] :: complete outgoing + ^- [(unit duct) _+>] + =+ rol=(need (~(get by ryl.bah) cha)) + =+ rix=(~(get by san.rol) num) + ?~ rix [~ +>.$] + :- rix + %_ +>.$ + ryl.bah + (~(put by ryl.bah) cha rol(san (~(del by san.rol) num))) + == + +This very simply gets the rill (the outgoing counterpart to a race, if +you recall), pulls out of the map of outstanding messages the duct over +which the original message was sent, and produces this duct while +deleting that entry from the map of outstanding messages. + +Going back to `++tock`, we now have the duct we need to return the +result over. We do the very sensible thing and put a `%cake` boon in the +queue to be processed later by `++clop`. + +In `q.yoh` we have a list of messages that may need to be sent, which we +pass to `++busk` to send, as usual. When an acknowledgment arrives, that +may trigger other messages immediately. This often happens when sending +more messages than the width of the logical window since for congestion +control reasons another message cannot be sent until some of the earlier +ones have been acknowledged. + +We'll look at the processing of the `%cake` boon in `++clop` before we +get back to talking about `++bick`. + + %cake + :_ fox + :~ [s.bon %give %woot q.p.bon r.bon] + == + +We very simply give, along the duct we found above, a `%woot` card with +the ship who sent us the ack and the ack itself. This allows the +application to decide what to do about the result. In case of a failure, +we usually either resend the message or display it to the user. +Sometimes, we recognize the error term and handle it internally. In any +case, the decision of how to handle the acknowledgment is entirely up to +the application. Our job is done. + +Well, except that we skipped `++bick:pu`. Let's go back to that. + + ++ bick :: bick:pu + |= [now=@da fap=flap] :: ack by hash + ^- [[p=(unit soup) q=(list rock)] _+>] + =+ sun=(~(get by diq) fap) + ?~ sun + [[~ ~] +>.$] + =. diq (~(del by diq) fap) + =^ gub +>.$ (bock now u.sun) + =^ yop +>.$ (harv now) + [[gub yop] +>.$] + +If you recall, in `++whap:pu` we created the packet pump's +representation of the message, which included putting the message into +`diq`, which maps from packet hashes to packet sequence numbers. Thus, +`u.sun` is the sequence number of this particular message. + +We delete this message from `diq` since we have now received an ack for +it. We call `++bock` to perform the ack by sequence number. We call +`++harv` to harvest the packet queue, sending any messages that are now +able to be sent. + +In `++bock`, there are three arms we haven't seen before: `++bine`, +`+wept`, and `++beet`. We'll describe each of these before we get to +`++bock`. `++bine` looks scariest. + + ++ bine :: bine:pu + |= [now=@da num=@ud] :: apply ack + ^- [(unit soup) _+>] + ?~ puq !! + ?. =(num p.n.puq) + ?: (gth num p.n.puq) + =+ lef=$(puq l.puq) + [-.lef +.lef(puq [n.puq puq.lef r.puq])] + =+ rig=$(puq r.puq) + [-.rig +.rig(puq [n.puq l.puq puq.rig])] + =: rtt ?. &(liv.q.n.puq =(1 nux.q.n.puq)) rtt + =+ gap=(sub now lys.q.n.puq) + :: ~& [%bock-trip num (div gap (div ~s1 1.000))] + (div (add (mul 2 rtt) gap) 3) + nif (sub nif !liv.q.n.puq) + == + =+ lez=(dec (need (~(get by pyz) gom.q.n.puq))) + =^ gub pyz + ?: =(0 lez) + [[~ gom.q.n.puq] (~(del by pyz) gom.q.n.puq)] + [~ (~(put by pyz) gom.q.n.puq lez)] + :- gub + +>.$(puq ~(nap to puq)) + +The first few lines are simply looking through the packet queue until we +find the correct packet to ack. This is basic queue manipulation that +operates directly on the treap structure of the queue. If you understand +treap queues, the logic is easy to follow. Otherwise, just trust us that +by the time we get to the `=:`, the packet with sequence number `num` is +on the top of the packet queue (that is, at `n.puq`). + +We first update the round-trip time. If the packet is either not alive +or had to be transmitted more than once, then we don't have any reliable +way of calculating the round-trip time since we're unsure of exactly +which transmission was acknowledged. Otherwise, the round-trip time is +the difference between now and when the packet was last sent. We set +`rtt` by a little weighted average where the previous smoothed RTT is +weighted twice as much as the RTT of the current packet. Thus, +`(2*rtt+gap)/3`. This gives us a nice smooth RTT that is somewhat +resilient to outlier data while still being responsive to our +ever-changing world. + +If the packet wasn't already dead, then we decrement the number of live +packets, which may allow more packets to be sent. + +We decrement the number of unacknowledged packets in our `pyz` for this +particular message. If you recall, this was set in `++whap` to the +number of packets required to send a message. + +If that was the last packet in the messge that needed to be acked, then +we delete the messgae reference from `pyz` and produce the id of the +message. Otherwise, we simply update `pyz` with the new number of +unacked messages. In either case, we remove the packet from the packet +queue. + + ++ wept :: wept:pu + |= [fip=@ud lap=@ud] :: fip thru lap-1 + =< abet =< apse + |% + ++ abet +>.$ + ++ apse + ^+ . + ?~ puq . + ?: (lth p.n.puq fip) ?~(l.puq . left) + ?: (gte p.n.puq lap) ?~(r.puq . rigt) + => rigt =< left + ?> ?=(^ puq) + ?.(liv.q.n.puq . .(nif (dec nif), liv.q.n.puq |)) + :: + ++ left + ?> ?=(^ puq) + ^+(. =+(lef=apse(puq l.puq) lef(puq [n.puq puq.lef r.puq]))) + ++ rigt + ?> ?=(^ puq) + ^+(. =+(rig=apse(puq r.puq) rig(puq [n.puq l.puq puq.rig]))) + -- + +The algorithm is a simple case of traversing the packet queue. +Essentialy, we mark as dead all packets in the queue between `fip` and +`(dec lap)`. We also update `nif`, the number of live packets. Lest you +mourn too much the passing of these packets, know that they shall soon +rise again. Recall that in `++bick` after the call to `++bock` we call +`++harv`. This will resend the packets that have just been labeled dead. + + ++ beet :: beet:pu + ^+ . :: advance unacked + =- +(nep ?~(foh nus u.foh)) + ^= foh + |- ^- (unit ,@ud) + ?~ puq ~ + ?: (lte p.n.puq nep) $(puq l.puq) + =+ rig=$(puq r.puq) + ?^(rig rig [~ p.n.puq]) + +Here we search for the next expected packet number. Basically, we search +the queue for the leftmost packet whose number is greater than the +current `nep`. If we don't find any such packet, we just use the total +number of packets sent. + +We can now dive into `++bock`, our last arm. + + ++ bock :: bock:pu + |= [now=@da num=@ud] :: ack by sequence + ^- [(unit soup) _+>] + =^ gym +> (bine now num) + :- gym + ?: (gth num nep) + =+ cam=(max 2 (div caw 2)) + :: ~& [%bock-hole num nep cam] + beet:(wept(nep num, cag cam, caw cam) nep num) + =. caw ?: (lth caw cag) +(caw) + (add caw !=(0 (mod (mug now) caw))) + ?: =(num nep) + :: ~& [%bock-fine num nif caw cag] + beet + :: ~& [%bock-fill num nif caw cag] + +>.$ + +First, we call `++bine` to apply the ack to the packet pump information. +We produce `gym`, which, if it exists, is the id of the packet that was +acked. If we received an ack for a packet later than the one we +expected, then we halve the logical packet window and kill all the +earlier packets so that they may be resent. + +Otherwise, we possibly increase the congestion window. If the window is +less than the congestion threshold, then we increment the size of the +window. Otherwise, we only increment one out of every `caw` times. + +If we received an ack for the packet we expected, then we simply advance +`nep` with `++beet`. If we received an ack for a packet earlier than we +expected, we do nothing. + +It may be hard to believe, but we are, in fact, done. The message has +been sent, received, acknowledged, and the acknowledgment has been +returned to the original sender. We hope it's clear that, while the +process has been somewhat involved, the algorithms are not all that +complicated. If you've read this far, you know `%ames`. The only other +code involves initialization, timeouts, and the like. + +Below, we give detailed reference documentation for the data models +involved. + +Data Models +----------- + +### `++fort`, formal state + + ++ fort :: formal state + $: %0 :: version + gad=duct :: client interface + hop=@da :: network boot date + ton=town :: security + zac=(map ship corn) :: flows by server + == :: + +This is the state of our vane. Anything that must be remembered between +calls to ames must be stored in this state. + +`%0` is the version of the ames state model itself. If the data model +`++fort` changes, then this number needs to be incremented, and an +adapter must be written to upgrade the old state into the new state. +Note that this is the version number of the model itself, not the +contents. When the data changes, there is of course no need to change +this. + +`gad` is a `duct` over which we send `%send` cards to unix. This card is +initialized when unix sends a `%barn` card as vere starts up. Vere +treats this duct specially -- don't send anything weird over it. + +`hop` is the network boot date. This is set when the `%kick` card is +sent by vere on start up. + +`ton` is a `++town`, where we store all of our security/encryption +state. Note that this is shared across all ships on a pier. + +`zac` is a map of ships to `++corn`. This stores all the per-ship state. +The keys to this map are the ships on the current pier. + +### `++town`, all security state + + ++ town :: all security state + $: lit=@ud :: imperial modulus + any=@ :: entropy + urb=(map ship sufi) :: all keys and routes + fak=? :: + == :: + +This is the security state of our pier. + +`lit` is unused. + +`any` is 256 bits of entropy. This entropy is used and updated in +exactly two places: when we send a `%junk` card, and when we generate a +new symmetric key in `++griz:lax:as:go`. When it is updated, it is +updated by a SHA-256 hash of the current time and the old value of the +entropy. + +`urb` is a map of ships to `++sufi`. This is where we store all the +per-ship state for the pier. The keys to this map are the ships on the +current pier. + +`fak` is true if we are on a fake network. This disables certain +security checks so that anyone may run a fake `~zod`. This is used only +for development. To use, run vere with the `-F` option (and the +`-I ~zod` option for a fake `~zod`). + +### `++sufi`, domestic host + + ++ sufi :: domestic host + $: hoy=(list ship) :: hierarchy + val=wund :: private keys + law=will :: server will + seh=(map hand ,[p=ship q=@da]) :: key cache + hoc=(map ship dore) :: neighborhood + == :: + +This is the security state of a domestic server. + +`hoy` is a list of the ships directly above us in the hierarchy of +ships. For example, for `~hoclur-bicrel`, this would be `~tasruc` and +`~tug`. See `++sein`. + +`val` is a list of our private keys. + +`law` is our certificate, which is a list of the XXX + +`seh` + +`hoc` is a map of ships to `++dore`. The stores all the security +informatoin about foreign ships. The keys to this map are the neighbors +(ships we have been in contact with) of this domestic server. + +### `++wund`, private keys + + ++ wund (list ,[p=life q=ring r=acru]) :: mace in action + +This is a list of our own private keys, indexed by life. The key itself +is the `++ring`, and the `++acru` is the encryption engine. We generate +the `++acru` from the private key by calling `++weur`. Thus, we can at +any time regenerate our `++wund` from a `++mace`. The current crypto is +at the head of the list and can be accessed with `++sen:as:go`. + +### `++ring`, private key + + ++ ring ,@ :: private key + +This is a private key. The first byte is reserved to identify the type +of cryptography. Lower-case means public key, upper-case means public +key, and the letter identifies which `++acru` to use. + +### `++pass`, public key + + ++ pass ,@ :: public key + +This is a public key. The first byte is reserved to identify the type of +cryptography. Lower-case means public key, upper-case means public key, +and the letter identifies which `++acru` to use. + +### `++mace`, private secrets + + ++ mace (list ,[p=life q=ring]) :: private secrets + +This is a list of the our private keys, indexed by life. From this we +can generate a `++wund` for actual use. + +### `++skin`, encoding stem + + ++ skin ?(%none %open %fast %full) :: encoding stem + +This defines the type of encryption used for each message. `%none` +refers to messages sent in the clear, `%open` refers to signed messages, +`%full` refers to sealed messages, and `%fast` refers to symmetrically +encrypted messages. See `++acru` for details. + +### `++acru`, asymmetric cryptosuite + + ++ acru :: asym cryptosuite + $_ ^? |% :: opaque object + ++ as ^? :: asym ops + |% ++ seal |=([a=pass b=@ c=@] _@) :: encrypt to a + ++ sign |=([a=@ b=@] _@) :: certify as us + ++ sure |=([a=@ b=@] *(unit ,@)) :: authenticate from us + ++ tear |= [a=pass b=@] :: accept from a + *(unit ,[p=@ q=@]) :: + -- :: + ++ de |+([a=@ b=@] *(unit ,@)) :: symmetric de, soft + ++ dy |+([a=@ b=@] _@) :: symmetric de, hard + ++ en |+([a=@ b=@] _@) :: symmetric en + ++ ex ^? :: export + |% ++ fig _@uvH :: fingerprint + ++ pac _@uvG :: default passcode + ++ pub *pass :: public key + ++ sec *ring :: private key + -- + ++ nu ^? :: reconstructors + |% ++ pit |=([a=@ b=@] ^?(..nu)) :: from [width seed] + ++ nol |=(a=@ ^?(..nu)) :: from naked ring + ++ com |=(a=@ ^?(..nu)) :: from naked pass + -- + -- + +This is an opaque interface for a general asymmetric cryptosuite. Any +form of asymmetric cryptography can be dropped in to be used instead of +the default. Right now, there are two cryptosuites, `++crua`, which is +your standard RSA, and `++crub`, which is elliptic curve crypto but is +mostly stubbed out at the moment. + +#### `++as:acru`, asymmetric operations + + ++ as ^? :: asym ops + |% ++ seal |=([a=pass b=@ c=@] _@) :: encrypt to a + ++ sign |=([a=@ b=@] _@) :: certify as us + ++ sure |=([a=@ b=@] *(unit ,@)) :: authenticate from us + ++ tear |= [a=pass b=@] :: accept from a + *(unit ,[p=@ q=@]) :: + -- :: + +This is the core that defines the standard asymmetric cryptography +operations. + +`++seal:as:acru` allows us to send a message encrypted with someone's +public key so that only they may read it. If Alice seals a message with +Bob's public key, then she can be sure that Bob is the only one who can +read it. This is associated with the `++skin` `%full`. + +`++sign:as:acru` allows us to sign a message with our private key so +that others can verify that we sent the message. If Alice signs a +message with her private key, then Bob can verify with her public key +that it was indeed Alice who sent it. This is associated with the +`++skin` `%open`. + +`++sure:as:acru` is the dual to `++sign:as:acru`. It allows us to verify +that a message we have received is indeed from the claimed sender. If +Alice sends a message with her private key, then Bob can use this arm to +verify that it was indeed Alice who sent it. This is associated with the +`++skin` `%open`. + +`++tear:as:acru` is the dual to `++seal:as:acru`. It allows us to read a +message that we can be sure is only read by us. If Alice seals a message +with Bob's public key, then Bob can use this arm to read it. This is +associated with the `++skin` `%full`. + +#### `++de:acru`, `++dy:acru`, and `++en:acru`, symmetric encryption/decryption + + ++ de |+([a=@ b=@] *(unit ,@)) :: symmetric de, soft + ++ dy |+([a=@ b=@] _@) :: symmetric de, hard + ++ en |+([a=@ b=@] _@) :: symmetric en + +Symmetric encryption is associated with the `++skin` `%fast`. + +`++de:acru` decrypts a message with a symmetric key, returning `~` on +failure and `[~ u=data]` on success. + +`++dy:acru` decrypts a message with a symmetric key, crashing on +failure. This should almost always be defined as, and should always be +semantically equivalent to, `(need (de a b))`. + +`++en:acru` encrypts a message with a symmetric key. + +#### `++ex:acru`, exporting data + + ++ ex ^? :: export + |% ++ fig _@uvH :: fingerprint + ++ pac _@uvG :: default passcode + ++ pub *pass :: public key + ++ sec *ring :: private key + -- + +`++fig:ex:acru` is our fingerprint, usually a hash of our public key. +This is used, for example, in `++zeno`, where every carrier owner's +fingerprint is stored so that we can ensure that carriers are indeed +owned by their owners + +`++pac:ex:acru` is our default passcode, which is unused at present. + +`++pub:ex:acru` is the `++pass` form of our public key. + +`++sec:ex:acru` is the `++ring` form of our private key. + +#### `++nu:acru`, reconstructors + + ++ nu ^? :: reconstructors + |% ++ pit |=([a=@ b=@] ^?(..nu)) :: from [width seed] + ++ nol |=(a=@ ^?(..nu)) :: from naked ring + ++ com |=(a=@ ^?(..nu)) :: from naked pass + -- + +These arms allow us to reconstruct a `++acru` from basic data. + +`++pit:nu:acru` constructs a `++acru` from the width of our intended key +and seed entropy. This is usually used in the initial construction of +the `++acru`. + +`++nol:nu:acru` constructs a `++acru` from a "naked ring", meaning a +`++ring` without the initial byte identifying the type of crypto. There +is often a helper arm that that wraps this; see `++weur` for `++crua` +and `++wear` for `++crub`. + +`++com:nu:acru` constructs a `++acru` from a "naked pass", meaning a +`++ring` without the initial byte identifying the type of crypto. There +is often a helper arm that that wraps this; see `++haul` for `++crua` +and `++hail` for `++crub`. + +### `++will`, certificate + + ++ will (list deed) :: certificate + +This is a list of deeds associated with the current ship. There should +be an item in this list for every ship from this point up in the +hierarchy times the number of lives that each ship has had. For example, +\~hoclur-bicrel may have a will with three items: one for itself, one +for \~tasruc (who issued \~hoclur-bicrel's deed) and one for \~tug (who +issued \~tasruc's deed). + +### `++deed`, identity + + ++ deed ,[p=@ q=step r=?] :: sig, stage, fake? + +`p` is the signature of a particular deed, which is a signed copy of +`q`. + +`q` is the stage in the identity. + +`r` is true if we're working on a fake network, where we don't check +that the carrier fingerprints are correct. This allows us to create fake +networks for development without interfering with the real network. + +### `++step`, identity stage + + ++ step ,[p=bray q=gens r=pass] :: identity stage + +This is a single stage in our identity. Thus, this is specific to a +single life in a single ship. Everything in here may change between +lives. + +`p` + +`q` + +`r` is the public key for this stage in the identity. + +### `++bray` + + ++ bray ,[p=life q=(unit life) r=ship s=@da] :: our parent us now + +XXX + +### `++gens`, general identity + + ++ gens ,[p=lang q=gcos] :: general identity + +`p` is the IETF language code for the preferred language of this +identity. This is unused at the moment, but in the future text should be +localized based on this. + +`q` is the description of the ship. + +### `++gcos`, identity description + + ++ gcos :: id description + $% [%czar ~] :: 8-bit ship + [%duke p=what] :: 32-bit ship + [%earl p=@t] :: 64-bit ship + [%king p=@t] :: 16-bit ship + [%pawn p=(unit ,@t)] :: 128-bit ship + == :: + +This is the description of the identity of a ship. Most types of +identity have a `@t` field, which is their human-readable name. The +identity of a `%duke` is more involved. + +A `%czar`, a carrier, is a ship with an 8-bit address. Thus, there are +only 256 carriers. These are at the top of the namespace hierarchy, and +the fingerprint of each carrier is stored in `++zeno`. These are the +"senators" of Urbit. + +A `%king`, a cruiser, is a ship with a 16-bit address. Thus, there are +65,536 cruisers. Each carrier may issue 256 cruisers. These are the +infrastructure of Urbit. + +A `%duke`, a destroyer, is a ship with a 32-bit address. Thus, there are +4,294,967,296 destroyers. Each cruiser may issue 65,536 cruisers. These +are the individuals of Urbit. + +A `%earl`, a yacht, is a ship with a 64-bit address. Thus, there are +18,446,744,073,709,551,616 yachts. Each destroyer may issue +4,294,967,296 yachts. These are the devices of Urbit. + +A `%pawn`, a submarine, is a ship with a 128-bit address. Thus, there +are a lot of submarines. The chance of random name collision is +negligible, so submarines are not issued by any ship. They must simply +assert their presence, and they are all considered children of \~zod. +This is the underworld of Urbit, where anonymity reigns supreme. + +### `++what`, logical destroyer identity + + ++ what :: logical identity + $% [%anon ~] :: anonymous + [%lady p=whom] :: female person () + [%lord p=whom] :: male person [] + [%punk p=sect q=@t] :: opaque handle "" + == :: + +This is the logical identity of a destroyer. + +A `%anon` is a completely anonymous destroyer. The difference between +this and a submarine is that a submarine is ephemeral while a `%anon` +destroyer is not. Thus, we may not know who \~hoclur-bicrel is, but we +do know that it's always the same person. + +A `%lady` is a female person. The name used here should be a real name. + +A `%lord` is a male person. The name used here should be a real name. + +A `%punk` is a person who is identified only by a handle. + +### `++whom`, real person + + ++ whom ,[p=@ud q=govt r=sect s=name] :: year/govt/id + +Ths is the information associated with a real person. It is mostly +information that could be observed with the briefest of interactions. + +`p` is the birth year. + +`q` is the location of a user, usually of the form "country/zip". + +`r` is the sect of the user. + +`s` is the real name of the person. + +### `++govt` + + ++ govt path :: country/postcode + +This is the location of the user, usually of the form "country/zip". + +### `++sect` + + ++ sect ?(%black %blue %red %orange %white) :: banner + +XXX + +### `++name` + + ++ name ,[p=@t q=(unit ,@t) r=(unit ,@t) s=@t] :: first mid/nick last + +This is the given name, possible middle name/initial, possible nickname, +and surname of a user. diff --git a/docs/pub/doc/arvo/arvo.md b/docs/pub/doc/arvo/arvo.md new file mode 100644 index 0000000000..fd614d5568 --- /dev/null +++ b/docs/pub/doc/arvo/arvo.md @@ -0,0 +1,8 @@ +
+ +`%arvo` +======= + +`%arvo` is our operating system. + +
diff --git a/docs/pub/doc/arvo/arvo/commentary.md b/docs/pub/doc/arvo/arvo/commentary.md new file mode 100644 index 0000000000..361c436295 --- /dev/null +++ b/docs/pub/doc/arvo/arvo/commentary.md @@ -0,0 +1,4 @@ +`%arvo` commentary +================== + +`%arvo` is our operating system. diff --git a/docs/pub/doc/arvo/clay.md b/docs/pub/doc/arvo/clay.md new file mode 100644 index 0000000000..6efd69e3c9 --- /dev/null +++ b/docs/pub/doc/arvo/clay.md @@ -0,0 +1,27 @@ +
+ +`%clay` +======= + +`%clay` is our filesystem. + +`%clay` is version-controlled, referentially-transparent, and global. +While this filesystem is stored in `%clay`, it is mirrored to Unix for +convenience. Unix tells `%clay`s whenever a file changes in the Unix +copy of the filesystem so that the change may be applied. `%clay` tells +unix whenever an app or vane changes the filesystem so that the change +can be effected in Unix. Apps and vanes may use `%clay` to write to the +filesystem, query it, and subscribe to changes in it. Ford and gall use +`%clay` to serve up apps and web pages. + +`%clay` includes three components. First is the filesystem/version +control algorithms, which are mostly defined in `++ze` and `++zu` in +zuse. Second is the write, query, and subscription logic. Finally, there +is the logic for communicating requests to, and receiving requests from, +foreign ships. + +
+ +------------------------------------------------------------------------ + + diff --git a/docs/pub/doc/arvo/clay/commentary.md b/docs/pub/doc/arvo/clay/commentary.md new file mode 100644 index 0000000000..d0edfea2dd --- /dev/null +++ b/docs/pub/doc/arvo/clay/commentary.md @@ -0,0 +1,2007 @@ +`%clay` commentary +================== + +`%clay` is our filesystem. + +The first part of this will be reference documentation for the data +types used by our filesystem. In fact, as a general guide, we recommend +reading and attempting to understand the data structures used in any +Hoon code before you try to read the code itself. Although complete +understanding of the data structures is impossible without seeing them +used in the code, an 80% understanding greatly clarifies the code. As +another general guide, when reading Hoon, it rarely pays off to +understand every line of code when it appears. Try to get the gist of +it, and then move on. The next time you come back to it, it'll likely +make a lot more sense. + +After a description of the data models, we'll give an overview of the +interface that vanes and applications can use to interact with the +filesystem. + +Finally, we'll dive into the code and the algorithms themselves. You +know, the fun part. + +Data Models +----------- + +As you're reading through this section, remember you can always come +back to this when you run into these types later on. You're not going to +remember everything the first time through, but it is worth reading, or +at least skimming, this so that you get a rough idea of how our state is +organized. + +The types that are certainly worth reading are `++raft`, `++room`, +`++dome`, `++ankh`, `++rung`, `++rang`, `++blob`, `++yaki`, and `++nori` +(possibly in that order). All in all, though, this section isn't too +long, so many readers may wish to quickly read through all of it. If you +get bored, though, just skip to the next section. You can always come +back when you need to. + +### `++raft`, formal state + + ++ raft :: filesystem + $: fat=(map ship room) :: domestic + hoy=(map ship rung) :: foreign + ran=rang :: hashes + == :: + +This is the state of our vane. Anything that must be remembered between +calls to clay is stored in this state. + +`fat` is the set of domestic servers. This stores all the information +that is specfic to a particular ship on this pier. The keys to this map +are the ships on the current pier. all the information that is specific +to a particular foreign ship. The keys to this map are all the ships +whose filesystems we have attempted to access through clay. + +`ran` is the store of all commits and deltas, keyed by hash. The is +where all the "real" data we know is stored; the rest is "just +bookkeeping". + +### `++room`, filesystem per domestic ship + + ++ room :: fs per ship + $: hun=duct :: terminal duct + hez=(unit duct) :: sync duch + dos=(map desk dojo) :: native desk + == :: + +This is the representation of the filesystem of a ship on our pier. + +`hun` is the duct we use to send messages to dill to display +notifications of filesystem changes. Only `%note` gifts should be +produced along this duct. This is set by the `%init` kiss. + +`hez`, if present, is the duct we use to send sync messages to unix so +that they end up in the pier unix directory. Only `%ergo` gifts should +be producd along this duct. This is set by `%into` and `%invo` kisses. + +`dos` is a well-known operating system released in 1981. It is also the +set of desks on this ship, mapped to their data. + +### `++desk`, filesystem branch + + ++ desk ,@tas :: ship desk case spur + +This is the name of a branch of the filesystem. The default desks are +"arvo", "main", and "try". More may be created by simply referencing +them. Desks have independent histories and states, and they may be +merged into each other. + +### `++dojo`, domestic desk state + + ++ dojo ,[p=cult q=dome] :: domestic desk state + +This is the all the data that is specific to a particular desk on a +domestic ship. `p` is the set of subscribers to this desk and `q` is the +data in the desk. + +### `++cult`, subscriptions + + ++ cult (map duct rave) :: subscriptions + +This is the set of subscriptions to a particular desk. The keys are the +ducts from where the subscriptions requests came. The results will be +produced along these ducts. The values are a description of the +requested information. + +### `++rave`, general subscription request + + ++ rave :: general request + $% [& p=mood] :: single request + [| p=moat] :: change range + == :: + +This represents a subscription request for a desk. The request can be +for either a single item in the desk or else for a range of changes on +the desk. + +### `++rove`, stored general subscription request + + ++ rove (each mood moot) :: stored request + +When we store a request, we store subscriptions with a little extra +information so that we can determine whether new versions actually +affect the path we're subscribed to. + +### `++mood`, single subscription request + + ++ mood ,[p=care q=case r=path] :: request in desk + +This represents a request for the state of the desk at a particular +commit, specfied by `q`. `p` specifies what kind of information is +desired, and `r` specifies the path we are requesting. + +### `++moat`, range subscription request + + ++ moat ,[p=case q=case r=path] :: change range + +This represents a request for all changes between `p` and `q` on path +`r`. You will be notified when a change is made to the node referenced +by the path or to any of its children. + +### `++moot`, stored range subscription request + + ++ moot ,[p=case q=case r=path s=(map path lobe)] :: + +This is just a `++moat` plus a map of paths to lobes. This map +represents the data at the node referenced by the path at case `p`, if +we've gotten to that case (else null). We only send a notification along +the subscription if the data at a new revision is different than it was. + +### `++care`, clay submode + + ++ care ?(%u %v %w %x %y %z) :: clay submode + +This specifies what type of information is requested in a subscription +or a scry. + +`%u` requests the `++rang` at the current moment. Because this +information is not stored for any moment other than the present, we +crash if the `++case` is not a `%da` for now. + +`%v` requests the `++dome` at the specified commit. + +`%w` requests the revsion number of the desk. + +`%x` requests the file at a specified path at the specified commit. If +there is no node at that path or if the node has no contents (that is, +if `q:ankh` is null), then this produces null. + +`%y` requests a `++arch` of the specfied commit at the specified path. + +`%z` requests the `++ankh` of the specified commit at the specfied path. + +### `++arch`, shallow filesystem node + + ++ arch ,[p=@uvI q=(unit ,@uvI) r=(map ,@ta ,~)] :: fundamental node + +This is analogous to `++ankh` except that the we have neither our +contents nor the ankhs of our children. The other fields are exactly the +same, so `p` is a hash of the associated ankh, `u.q`, if it exists, is a +hash of the contents of this node, and the keys of `r` are the names of +our children. `r` is a map to null rather than a set so that the +ordering of the map will be equivalent to that of `r:ankh`, allowing +efficient conversion. + +### `++case`, specifying a commit + + ++ case :: ship desk case spur + $% [%da p=@da] :: date + [%tas p=@tas] :: label + [%ud p=@ud] :: number + == :: + +A commit can be referred to in three ways: `%da` refers to the commit +that was at the head on date `p`, `%tas` refers to the commit labeled +`p`, and `%ud` refers to the commit numbered `p`. Note that since these +all can be reduced down to a `%ud`, only numbered commits may be +referenced with a `++case`. + +### `++dome`, desk data + + ++ dome :: project state + $: ang=agon :: pedigree + ank=ankh :: state + let=@ud :: top id + hit=(map ,@ud tako) :: changes by id + lab=(map ,@tas ,@ud) :: labels + == :: + +This is the data that is actually stored in a desk. + +`ang` is unused and should be removed. + +`ank` is the current state of the desk. Thus, it is the state of the +filesystem at revison `let`. The head of a desk is always a numbered +commit. + +`let` is the number of the most recently numbered commit. This is also +the total number of numbered commits. + +`hit` is a map of numerical ids to hashes of commits. These hashes are +mapped into their associated commits in `hut:rang`. In general, the keys +of this map are exactly the numbers from 1 to `let`, with no gaps. Of +course, when there are no numbered commits, `let` is 0, so `hit` is +null. Additionally, each of the commits is an ancestor of every commit +numbered greater than this one. Thus, each is a descendant of every +commit numbered less than this one. Since it is true that the date in +each commit (`t:yaki`) is no earlier than that of each of its parents, +the numbered commits are totally ordered in the same way by both +pedigree and date. Of course, not every commit is numbered. If that +sounds too complicated to you, don't worry about it. It basically +behaves exactly as you would expect. + +`lab` is a map of textual labels to numbered commits. Note that labels +can only be applied to numbered commits. Labels must be unique across a +desk. + +### `++ankh`, filesystem node + + ++ ankh :: fs node (new) + $: p=cash :: recursive hash + q=(unit ,[p=cash q=*]) :: file + r=(map ,@ta ankh) :: folders + == :: + +This is a single node in the filesystem. This may be file or a directory +or both. In earth filesystems, a node is a file xor a directory. On +mars, we're inclusive, so a node is a file ior a directory. + +`p` is a recursive hash that depends on the contents of the this file or +directory and on any children. + +`q` is the contents of this file, if any. `p.q` is a hash of the +contents while `q.q` is the data itself. + +`r` is the set of children of this node. In the case of a pure file, +this is empty. The keys are the names of the children and the values +are, recursively, the nodes themselves. + +### `++cash`, ankh hash + + ++ cash ,@uvH :: ankh hash + +This is a 128-bit hash of an ankh. These are mostly stored within ankhs +themselves, and they are used to check for changes in possibly-deep +hierarchies. + +### `++rung`, filesystem per neighbor ship + + ++ rung $: rus=(map desk rede) :: neighbor desks + == :: + +This is the filesystem of a neighbor ship. The keys to this map are all +the desks we know about on their ship. + +### `++rede`, desk state + + ++ rede :: universal project + $: lim=@da :: complete to + qyx=cult :: subscribers + ref=(unit rind) :: outgoing requests + dom=dome :: revision state + == :: + +This is our knowledge of the state of a desk, either foreign or +domestic. + +`lim` is the date of the last full update. We only respond to requests +for stuff before this time. + +`qyx` is the list of subscribers to this desk. For domestic desks, this +is simply `p:dojo`, all subscribers to the desk, while in foreign desks +this is all the subscribers from our ship to the foreign desk. + +`ref` is the request manager for the desk. For domestic desks, this is +null since we handle requests ourselves. + +`dom` is the actual data in the desk. + +### `++rind`, request manager + + ++ rind :: request manager + $: nix=@ud :: request index + bom=(map ,@ud ,[p=duct q=rave]) :: outstanding + fod=(map duct ,@ud) :: current requests + haw=(map mood (unit)) :: simple cache + == :: + +This is the request manager for a foreign desk. + +`nix` is one more than the index of the most recent request. Thus, it is +the next available request number. + +`bom` is the set of outstanding requests. The keys of this map are some +subset of the numbers between 0 and one less than `nix`. The members of +the map are exactly those requests that have not yet been fully +satisfied. + +`fod` is the same set as `bom`, but from a different perspective. In +particular, the values of `fod` are the same as the values of `bom`, and +the `p` out of the values of `bom` are the same as the keys of `fod`. +Thus, we can map ducts to their associated request number and `++rave`, +and we can map numbers to their associated duct and `++rave`. + +`haw` is a map from simple requests to their values. This acts as a +cache for requests that have already been made. Thus, the second request +for a particular `++mood` is nearly instantaneous. + +### `++rang`, data store + + ++ rang $: hut=(map tako yaki) :: + lat=(map lobe blob) :: + == :: + +This is a set of data keyed by hash. Thus, this is where the "real" data +is stored, but it is only meaningful if we know the hash of what we're +looking for. + +`hut` is a map from hashes to commits. We often get the hashes from +`hit:dome`, which keys them by logical id. Not every commit has an id. + +`lat` is a map from hashes to the actual data. We often get the hashes +from a `++yaki`, a commit, which references this map to get the data. +There is no `++blob` in any `++yaki`. They are only accessible through +this map. + +### `++tako`, commit reference + + ++ tako ,@ :: yaki ref + +This is a hash of a `++yaki`, a commit. These are most notably used as +the keys in `hut:rang`, where they are associated with the actual +`++yaki`, and as the values in `hit:dome`, where sequential ids are +associated with these. + +### `++yaki`, commit + + ++ yaki ,[p=(list tako) q=(map path lobe) r=tako t=@da] :: commit + +This is a single commit. + +`p` is a list of the hashes of the parents of this commit. In most +cases, this will be a single commit, but in a merge there may be more +parents. In theory, there may be an arbitrary number of parents, but in +practice merges have exactly two parents. This may change in the future. +For commit 1, there is no parent. + +`q` is a map of the paths on a desk to the data at that location. If you +understand what a `++lobe` and a `++blob` is, then the type signature +here tells the whole story. + +`r` is the hash associated with this commit. + +`t` is the date at which this commit was made. + +### `++lobe`, data reference + + ++ lobe ,@ :: blob ref + +This is a hash of a `++blob`. These are most notably used in `lat:rang`, +where they are associated with the actual `++blob`, and as the values in +`q:yaki`, where paths are associated with their data in a commit. + +### `++blob`, data + + ++ blob $% [%delta p=lobe q=lobe r=udon] :: delta on q + [%direct p=lobe q=* r=umph] :: + [%indirect p=lobe q=* r=udon s=lobe] :: + == :: + +This is a node of data. In every case, `p` is the hash of the blob. + +`%delta` is the case where we define the data by a delta on other data. +In practice, the other data is always the previous commit, but nothing +depends on this. `q` is the hash of the parent blob, and `r` is the +delta. + +`%direct` is the case where we simply have the data directly. `q` is the +data itself, and `r` is any preprocessing instructions. These almost +always come from the creation of a file. + +`%indirect` is both of the preceding cases at once. `q` is the direct +data, `r` is the delta, and `s` is the parent blob. It should always be +the case that applying `r` to `s` gives the same data as `q` directly +(with the prepreprocessor instructions in `p.r`). This exists purely for +performance reasons. This is unused, at the moment, but in general these +should be created when there are a long line of changes so that we do +not have to traverse the delta chain back to the creation of the file. + +### `++udon`, abstract delta + + ++ udon :: abstract delta + $: p=umph :: preprocessor + $= q :: patch + $% [%a p=* q=*] :: trivial replace + [%b p=udal] :: atomic indel + [%c p=(urge)] :: list indel + [%d p=upas q=upas] :: tree edit + == :: + == :: + +This is an abstract change to a file. This is a superset of what would +normally be called diffs. Diffs usually refer to changes in lines of +text while we have the ability to do more interesting deltas on +arbitrary data structures. + +`p` is any preprocessor instructions. + +`%a` refers to the trival delta of a complete replace of old data with +new data. + +`%b` refers to changes in an opaque atom on the block level. This has +very limited usefulness, and is not used at the moment. + +`%c` refers to changes in a list of data. This is often lines of text, +which is your classic diff. We, however, will work on any list of data. + +`%d` refers to changes in a tree of data. This is general enough to +describe changes to any hoon noun, but often more special-purpose delta +should be created for different content types. This is not used at the +moment, and may in fact be unimplemented. + +### `++urge`, list change + + ++ urge |*(a=_,* (list (unce a))) :: list change + +This is a parametrized type for list changes. For example, `(urge ,@t)` +is a list change for lines of text. + +### `++unce`, change part of a list. + + ++ unce |* a=_,* :: change part + $% [%& p=@ud] :: skip[copy] + [%| p=(list a) q=(list a)] :: p -> q[chunk] + == :: + +This is a single change in a list of elements of type `a`. For example, +`(unce ,@t)` is a single change in a lines of text. + +`%&` means the next `p` lines are unchanged. + +`%|` means the lines `p` have changed to `q`. + +### `++umph`, preprocessing information + + ++ umph :: change filter + $| $? %a :: no filter + %b :: jamfile + %c :: LF text + == :: + $% [%d p=@ud] :: blocklist + == :: + +This space intentionally left undocumented. This stuff will change once +we get a well-typed clay. + +### `++upas`, tree change + + ++ upas :: tree change (%d) + $& [p=upas q=upas] :: cell + $% [%0 p=axis] :: copy old + [%1 p=*] :: insert new + [%2 p=axis q=udon] :: mutate! + == :: + +This space intentionally left undocumented. This stuff is not known to +work, and will likely change when we get a well-typed clay. Also, this +is not a complicated type; it is not difficult to work out the meaning. + +### `++nori`, repository action + + ++ nori :: repository action + $% [& q=soba] :: delta + [| p=@tas] :: label + == :: + +This describes a change that we are asking clay to make to the desk. +There are two kinds of changes that may be made: we can modify files or +we can apply a label to a commit. + +In the `|` case, we will simply label the current commit with the given +label. In the `&` case, we will apply the given changes. + +### `++soba`, delta + + ++ soba ,[p=cart q=(list ,[p=path q=miso])] :: delta + +This describes a set of changes to make to a desk. The `cart` is simply +a pair of the old hash and the new hash of the desk. The list is a list +of changes keyed by the file they're changing. Thus, the paths are paths +to files to be changed while `miso` is a description of the change +itself. + +### `++miso`, ankh delta + + ++ miso :: ankh delta + $% [%del p=*] :: delete + [%ins p=*] :: insert + [%mut p=udon] :: mutate + == :: + +There are three kinds of changes that may be made to a node in a desk. +We can insert a file, in which case `p` is the contents of the new file. +We can delete a file, in which case `p` is the contents of the old file. +Finally, we can mutate that file, in which case the `udon` describes the +changes we are applying to the file. + +### `++mizu`, merged state + + ++ mizu ,[p=@u q=(map ,@ud tako) r=rang] :: new state + +This is the input to the `%merg` kiss, which allows us to perform a +merge. The `p` is the number of the new head commit. The `q` is a map +from numbers to commit hashes. This is all the new numbered commits that +are to be inserted. The keys to this should always be the numbers from +`let.dom` plus one to `p`, inclusive. The `r` is the maps of all the new +commits and data. Since these are merged into the current state, no old +commits or data need be here. + +### `++riff`, request/desist + + ++ riff ,[p=desk q=(unit rave)] :: request/desist + +This represents a request for data about a particular desk. If `q` +contains a `rave`, then this opens a subscription to the desk for that +data. If `q` is null, then this tells clay to cancel the subscription +along this duct. + +### `++riot`, response + + ++ riot (unit rant) :: response/complete + +A riot is a response to a subscription. If null, the subscription has +been completed, and no more responses will be sent. Otherwise, the +`rant` is the produced data. + +### `++rant`, response data + + ++ rant :: namespace binding + $: p=[p=care q=case r=@tas] :: clade release book + q=path :: spur + r=* :: data + == :: + +This is the data at a particular node in the filesystem. `p.p` specifies +the type of data that was requested (and is produced). `q.p` gives the +specific version reported (since a range of versions may be requested in +a subscription). `r.p` is the desk. `q` is the path to the filesystem +node. `r` is the data itself (in the format specified by `p.p`). + +### `++nako`, subscription response data + + ++ nako $: gar=(map ,@ud tako) :: new ids + let=@ud :: next id + lar=(set yaki) :: new commits + bar=(set blob) :: new content + == :: + +This is the data that is produced by a request for a range of revisions +of a desk. This allows us to easily keep track of a remote repository -- +all the new information we need is contained in the `nako`. + +`gar` is a map of the revisions in the range to the hash of the commit +at that revision. These hashes can be used with `hut:rang` to find the +commit itself. + +`let` is either the last revision number in the range or the most recent +revision number, whichever is smaller. + +`lar` is the set of new commits, and `bar` is the set of new content. + +Public Interface +---------------- + +As with all vanes, there are exactly two ways to interact with clay. +`%clay` exports a namespace accessible through `.^`, which is described +above under `++care`. The primary way of interacting with clay, though, +is by sending kisses and receiving gifts. + + ++ gift :: out result <-$ + $% [%ergo p=@p q=@tas r=@ud] :: version update + [%note p=@tD q=tank] :: debug message + [%writ p=riot] :: response + == :: + ++ kiss :: in request ->$ + $% [%info p=@p q=@tas r=nori] :: internal edit + [%ingo p=@p q=@tas r=nori] :: internal noun edit + [%init p=@p] :: report install + [%into p=@p q=@tas r=nori] :: external edit + [%invo p=@p q=@tas r=nori] :: external noun edit + [%merg p=@p q=@tas r=mizu] :: internal change + [%wart p=sock q=@tas r=path s=*] :: network request + [%warp p=sock q=riff] :: file request + == :: + +There are only a small number of possible kisses, so it behooves us to +describe each in detail. + + $% [%info p=@p q=@tas r=nori] :: internal edit + + [%into p=@p q=@tas r=nori] :: external edit + +These two kisses are nearly identical. At a high level, they apply +changes to the filesystem. Whenever we add, remove, or edit a file, one +of these cards is sent. The `p` is the ship whose filesystem we're +trying to change, the `q` is the desk we're changing, and the `r` is the +request change. For the format of the requested change, see the +documentation for `++nori` above. + +When a file is changed in the unix filesystem, vere will send a `%into` +kiss. This tells clay that the duct over which the kiss was sent is the +duct that unix is listening on for changes. From within Arvo, though, we +should never send a `%into` kiss. The `%info` kiss is exactly identical +except it does not reset the duct. + + [%ingo p=@p q=@tas r=nori] :: internal noun edit + + [%invo p=@p q=@tas r=nori] :: external noun edit + +These kisses are currently identical to `%info` and `%into`, though this +will not always be the case. The intent is for these kisses to allow +typed changes to clay so that we may store typed data. This is currently +unimplemented. + + [%init p=@p] :: report install + +Init is called when a ship is started on our pier. This simply creates a +default `room` to go into our `raft`. Essentially, this initializes the +filesystem for a ship. + + [%merg p=@p q=@tas r=mizu] :: internal change + +This is called to perform a merge. This is most visibly called by +:update to update the filesystem of the current ship to that of its +sein. The `p` and `q` are as in `%info`, and the `r` is the description +of the merge. See `++mizu` above. + +XX +`XX [%wake ~] :: timer activate XX` +XX\ +XX This card is sent by unix at the time specified by `++doze`. This +time is XX usually the closest time specified in a subscription request. +When `%wake` is XX called, we update our subscribers if there have been +any changes. + + [%wart p=sock q=@tas r=path s=*] :: network request + +This is a request that has come across the network for a particular +file. When another ship asks for a file from us, that request comes to +us in the form of a `%wart` kiss. This is handled by trivially turning +it into a `%warp`. + + [%warp p=sock q=riff] :: file request + +This is a request for information about a particular desk. This is, in +its most general form, a subscription, though in many cases it is the +trivial case of a subscription -- a read. See `++riff` for the format of +the request. + +Lifecycle of a Local Read +------------------------- + +There are two real types of interaction with a filesystem: you can read, +and you can write. We'll describe each process, detailing both the flow +of control followed by the kernel and the algorithms involved. The +simpler case is that of the read, so we'll begin with that. + +When a vane or an application wishes to read a file from the filesystem, +it sends a `%warp` kiss, as described above. Of course, you may request +a file on another ship and, being a global filesystem, clay will happily +produce it for you. That code pathway will be described in another +section; here, we will restrict ourselves to examining the case of a +read from a ship on our own pier. + +The kiss can request either a single version of a file node or a range +of versions of a desk. Here, we'll deal only with a request for a single +version. + +As in all vanes, a kiss enters clay via a call to `++call`. Scanning +through the arm, we quickly see where `%warp` is handled. + + ?: =(p.p.q.hic q.p.q.hic) + =+ une=(un p.p.q.hic now ruf) + =+ wex=(di:une p.q.q.hic) + =+ ^= wao + ?~ q.q.q.hic + (ease:wex hen) + (eave:wex hen u.q.q.q.hic) + =+ ^= woo + abet:wao + [-.woo abet:(pish:une p.q.q.hic +.woo ran.wao)] + +We're following the familar patern of producing a list of moves and an +updated state. In this case, the state is `++raft`. + +We first check to see if the sending and receiving ships are the same. +If they're not, then this is a request for data on another ship. We +describe that process later. Here, we discuss only the case of a local +read. + +At a high level, the call to `++un` sets up the core for the domestic +ship that contains the files we're looking for. The call to `++di` sets +up the core for the particular desk we're referring to. + +After this, we perform the actual request. If there is no rave in the +riff, then that means we are cancelling a request, so we call +`++ease:de`. Otherwise, we start a subscription with `++eave:de`. We +call `++abet:de` to resolve our various types of output into actual +moves. We produce the moves we found above and the `++un` core resolved +with `++pish:un` (putting the modified desk in the room) and `++abet:un` +(putting the modified room in the raft). + +Much of this is fairly straightforward, so we'll only describe `++ease`, +`++eave`, and `++abet:de`. Feel free to look up the code to the other +steps -- it should be easy to follow. + +Although it's called last, it's usually worth examining `++abet` first, +since it defines in what ways we can cause side effects. Let's do that, +and also a few of the lines at the beginning of `++de`. + + =| yel=(list ,[p=duct q=gift]) + =| byn=(list ,[p=duct q=riot]) + =| vag=(list ,[p=duct q=gift]) + =| say=(list ,[p=duct q=path r=ship s=[p=@ud q=riff]]) + =| tag=(list ,[p=duct q=path c=note]) + |% + ++ abet + ^- [(list move) rede] + :_ red + ;: weld + %+ turn (flop yel) + |=([a=duct b=gift] [hun %give b]) + :: + %+ turn (flop byn) + |=([a=duct b=riot] [a %give [%writ b]]) + :: + %+ turn (flop vag) + |=([a=duct b=gift] [a %give b]) + :: + %+ turn (flop say) + |= [a=duct b=path c=ship d=[p=@ud q=riff]] + :- a + [%pass b %a %want [who c] [%q %re p.q.d (scot %ud p.d) ~] q.d] + :: + %+ turn (flop tag) + |=([a=duct b=path c=note] [a %pass b c]) + == + +This is very simple code. We see there are exactly five different kinds +of side effects we can generate. + +In `yel` we put gifts that we wish to be sent along the `hun:room` duct +to dill. See the documentation for `++room` above. This is how we +display messages to the terminal. + +In `byn` we put riots that we wish returned to subscribers. Recall that +a riot is a response to a subscription. These are returned to our +subscribers in the form of a `%writ` gift. + +In `vag` we put gifts along with the ducts on which to send them. This +allows us to produce arbitrary gifts, but in practice this is only used +to produce `%ergo` gifts. + +In `say` we put messages we wish to pass to ames. These messages are +used to request information from clay on other piers. We must provide +not only the duct and the request (the riff), but also the return path, +the other ship to talk to, and the sequence number of the request. + +In `tag` we put arbitrary notes we wish to pass to other vanes. For now, +the only notes we pass here are `%wait` and `%rest` to the timer vane. + +Now that we know what kinds of side effects we may have, we can jump +into the handling of requests. + + ++ ease :: release request + |= hen=duct + ^+ +> + ?~ ref +> + =+ rov=(~(got by qyx) hen) + =. qyx (~(del by qyx) hen) + (mabe rov (cury best hen)) + =. qyx (~(del by qyx) hen) + |- ^+ +>+.$ + =+ nux=(~(get by fod.u.ref) hen) + ?~ nux +>+.$ + %= +>+.$ + say [[hen [(scot %ud u.nux) ~] for [u.nux syd ~]] say] + fod.u.ref (~(del by fod.u.ref) hen) + bom.u.ref (~(del by bom.u.ref) u.nux) + == + +This is called when we're cancelling a subscription. For domestic desks, +`ref` is null, so we're going to cancel any timer we might have created. +We first delete the duct from our map of requests, and then we call +`++mabe` with `++best` to send a `%rest` kiss to the timer vane if we +have started a timer. We'll describe `++best` and `++mabe` momentarily. + +Although we said we're not going to talk about foreign requests yet, +it's easy to see that for foreign desks, we cancel any outstanding +requests for this duct and send a message over ames to the other ship +telling them to cancel the subscription. + + ++ best + |= [hen=duct tym=@da] + %_(+> tag :_(tag [hen /tyme %t %rest tym])) + +This simply pushes a `%rest` note onto `tag`, from where it will be +passed back to arvo to be handled. This cancels the timer at the given +duct (with the given time). + + ++ mabe :: maybe fire function + |* [rov=rove fun=$+(@da _+>.^$)] + ^+ +>.$ + %- fall :_ +>.$ + %- bind :_ fun + ^- (unit ,@da) + ?- -.rov + %& + ?. ?=(%da -.q.p.rov) ~ + `p.q.p.rov + %| + =* mot p.rov + %+ hunt + ?. ?=(%da -.p.mot) ~ + ?.((lth now p.p.mot) ~ [~ p.p.mot]) + ?. ?=(%da -.q.mot) ~ + ?.((lth now p.q.mot) [~ now] [~ p.q.mot]) + == + +This decides whether the given request can only be satsified in the +future. In that case, we call the given function with the time in the +future when we expect to have an update to give to this request. This is +called with `++best` to cancel timers and with `++bait` to start them. + +For single requests, we have a time if the request is for a particular +time (which is assumed to be in the future). For ranges of requests, we +check both the start and end cases to see if they are time cases. If so, +we choose the earlier time. + +If any of those give us a time, then we call the given funciton with the +smallest time. + +The more interesting case is, of course, when we're not cancelling a +subscription but starting one. + + ++ eave :: subscribe + |= [hen=duct rav=rave] + ^+ +> + ?- -.rav + & + ?: &(=(p.p.rav %u) !=(p.q.p.rav now)) + ~& [%clay-fail p.q.p.rav %now now] + !! + =+ ver=(aver p.rav) + ?~ ver + (duce hen rav) + ?~ u.ver + (blub hen) + (blab hen p.rav u.u.ver) + +There are two types of subscriptions -- either we're requesting a single +file or we're requesting a range of versions of a desk. We'll dicuss the +simpler case first. + +First, we check that we're not requesting the `rang` from any time other +than the present. Since we don't store that information for any other +time, we can't produce it in a referentially transparent manner for any +time other than the present. + +Then, we try to read the requested `mood` `p.rav`. If we can't access +the request data right now, we call `++duce` to put the request in our +queue to be satisfied when the information becomes available. + +This case occurs when we make a request for a case whose (1) date is +after the current date, (2) number is after the current number, or (3) +label is not yet used. + + ++ duce :: produce request + |= [hen=duct rov=rove] + ^+ +> + =. qyx (~(put by qyx) hen rov) + ?~ ref + (mabe rov (cury bait hen)) + |- ^+ +>+.$ :: XX why? + =+ rav=(reve rov) + =+ ^= vaw ^- rave + ?. ?=([%& %v *] rav) rav + [%| [%ud let.dom] `case`q.p.rav r.p.rav] + =+ inx=nix.u.ref + %= +>+.$ + say [[hen [(scot %ud inx) ~] for [inx syd ~ vaw]] say] + nix.u.ref +(nix.u.ref) + bom.u.ref (~(put by bom.u.ref) inx [hen vaw]) + fod.u.ref (~(put by fod.u.ref) hen inx) + == + +The code for `++duce` is nearly the exact inverse of `++ease`, which in +the case of a domestic desk is very simple -- we simply put the duct and +rave into `qyx` and possibly start a timer with `++mabe` and `++bait`. +Recall that `ref` is null for domestic desks and that `++mabe` fires the +given function with the time we need to be woken up at, if we need to be +woken up at a particular time. + + ++ bait + |= [hen=duct tym=@da] + %_(+> tag :_(tag [hen /tyme %t %wait tym])) + +This sets an alarm by sending a `%wait` card with the given time to the +timer vane. + +Back in `++eave`, if `++aver` returned `[~ ~]`, then we cancel the +subscription. This occurs when we make (1) a `%x` request for a file +that does not exist, (2) a `%w` request with a case that is not a +number, or (3) a `%w` request with a nonempty path. The `++blub` is +exactly what you would expect it to be. + + ++ blub :: ship stop + |= hen=duct + %_(+> byn [[hen ~] byn]) + +We notify the duct that we're cancelling their subscription since it +isn't satisfiable. + +Otherwise, we have received the desired information, so we send it on to +the subscriber with `++blab`. + + ++ blab :: ship result + |= [hen=duct mun=mood dat=*] + ^+ +> + +>(byn [[hen ~ [p.mun q.mun syd] r.mun dat] byn]) + +The most interesting arm called in `++eave` is, of course, `++aver`, +where we actually try to read the data. + + ++ aver :: read + |= mun=mood + ^- (unit (unit ,*)) + ?: &(=(p.mun %u) !=(p.q.mun now)) :: prevent bad things + ~& [%clay-fail p.q.mun %now now] + !! + =+ ezy=?~(ref ~ (~(get by haw.u.ref) mun)) + ?^ ezy ezy + =+ nao=(~(case-to-aeon ze lim dom ran) q.mun) + ?~(nao ~ [~ (~(read-at-aeon ze lim dom ran) u.nao mun)]) + +We check immediately that we're not requesting the `rang` for any time +other than the present. + +If this is a foreign desk, then we check our cache for the specific +request. If either this is a domestic desk or we don't have the request +in our cache, then we have to actually go read the data from our dome. + +We need to do two things. First, we try to find the number of the commit +specified by the given case, and then we try to get the data there. + +Here, we jump into `arvo/zuse.hoon`, which is where much of the +algorithmic code is stored, as opposed to the clay interface, which is +stored in `arvo/clay.hoon`. We examine `++case-to-aeon:ze`. + + ++ case-to-aeon :: case-to-aeon:ze + |= lok=case :: act count through + ^- (unit aeon) + ?- -.lok + %da + ?: (gth p.lok lim) ~ + |- ^- (unit aeon) + ?: =(0 let) [~ 0] :: avoid underflow + ?: %+ gte p.lok + =< t + %- tako-to-yaki + %- aeon-to-tako + let + [~ let] + $(let (dec let)) + :: + %tas (~(get by lab) p.lok) + %ud ?:((gth p.lok let) ~ [~ p.lok]) + == + +We handle each type of `case` differently. The latter two types are +easy. + +If we're requesting a revision by label, then we simply look up the +requested label in `lab` from the given dome. If it exists, that is our +aeon; else we produce null, indicating the requested revision does not +yet exist. + +If we're requesting a revision by number, we check if we've yet reached +that number. If so, we produce the number; else we produce null. + +If we're requesting a revision by date, we check first if the date is in +the future, returning null if so. Else we start from the most recent +revision and scan backwards until we find the first revision committed +before that date, and we produce that. If we requested a date before any +revisions were committed, we produce `0`. + +The definitions of `++aeon-to-tako` and `++tako-to-yaki` are trivial. + + ++ aeon-to-tako ~(got by hit) + + ++ tako-to-yaki ~(got by hut) :: grab yaki + +We simply look up the aeon or tako in their respective maps (`hit` and +`hut`). + +Assuming we got a valid version number, `++aver` calls +`++read-at-aeon:ze`, which reads the requested data at the given +revision. + + ++ read-at-aeon :: read-at-aeon:ze + |= [oan=aeon mun=mood] :: seek and read + ^- (unit) + ?: &(?=(%w p.mun) !?=(%ud -.q.mun)) :: NB only for speed + ?^(r.mun ~ [~ oan]) + (read:(rewind oan) mun) + +If we're requesting the revision number with a case other than by +number, then we go ahead and just produce the number we were given. +Otherwise, we call `++rewind` to rewind our state to the given revision, +and then we call `++read` to get the requested information. + + ++ rewind :: rewind:ze + |= oan=aeon :: rewind to aeon + ^+ +> + ?: =(let oan) +> + ?: (gth oan let) !! :: don't have version + +>(ank (checkout-ankh q:(tako-to-yaki (aeon-to-tako oan))), let oan) + +If we're already at the requested version, we do nothing. If we're +requesting a version later than our head, we are unable to comply. + +Otherwise, we get the hash of the commit at the number, and from that we +get the commit itself (the yaki), which has the map of path to lobe that +represents a version of the filesystem. We call `++checkout-ankh` to +checkout the commit, and we replace `ank` in our context with the +result. + + ++ checkout-ankh :: checkout-ankh:ze + |= hat=(map path lobe) :: checkout commit + ^- ankh + %- cosh + %+ roll (~(tap by hat) ~) + |= [[pat=path bar=lobe] ank=ankh] + ^- ankh + %- cosh + ?~ pat + =+ zar=(lobe-to-noun bar) + ank(q [~ (sham zar) zar]) + =+ nak=(~(get by r.ank) i.pat) + %= ank + r %+ ~(put by r.ank) i.pat + $(pat t.pat, ank (fall nak _ankh)) + == + +Twice we call `++cosh`, which hashes a commit, updating `p` in an +`ankh`. Let's jump into that algorithm before we describe +`++checkout-ankh`. + + ++ cosh :: locally rehash + |= ank=ankh :: NB v/unix.c + ank(p rehash:(zu ank)) + +We simply replace `p` in the hash with the `cash` we get from a call to +`++rehash:zu`. + + ++ zu !: :: filesystem + |= ank=ankh :: filesystem state + =| myz=(list ,[p=path q=miso]) :: changes in reverse + =| ram=path :: reverse path into + |% + ++ rehash :: local rehash + ^- cash + %+ mix ?~(q.ank 0 p.u.q.ank) + =+ axe=1 + |- ^- cash + ?~ r.ank _@ + ;: mix + (shaf %dash (mix axe (shaf %dush (mix p.n.r.ank p.q.n.r.ank)))) + $(r.ank l.r.ank, axe (peg axe 2)) + $(r.ank r.r.ank, axe (peg axe 3)) + == + +`++zu` is a core we set up with a particular filesystem node to traverse +a checkout of the filesystem and access the actual data inside it. One +of the things we can do with it is to create a recursive hash of the +node. + +In `++rehash`, if this node is a file, then we xor the remainder of the +hash with the hash of the contents of the file. The remainder of the +hash is `0` if we have no children, else we descend into our children. +Basically, we do a half SHA-256 of the xor of the axis of this child and +the half SHA-256 of the xor of the name of the child and the hash of the +child. This is done for each child and all the results are xored +together. + +Now we return to our discussion of `++checkout-ankh`. + +We fold over every path in this version of the filesystem and create a +great ankh out of them. First, we call `++lobe-to-noun` to get the raw +data referred to be each lobe. + + ++ lobe-to-noun :: grab blob + |= p=lobe :: ^- * + %- blob-to-noun + (lobe-to-blob p) + +This converts a lobe into the raw data it refers to by first getting the +blob with `++lobe-to-blob` and converting that into data with +`++blob-to-noun`. + + ++ lobe-to-blob ~(got by lat) :: grab blob + +This just grabs the blob that the lobe refers to. + + ++ blob-to-noun :: grab blob + |= p=blob + ?- -.p + %delta (lump r.p (lobe-to-noun q.p)) + %direct q.p + %indirect q.p + == + +If we have either a direct or an indirect blob, then the data is stored +right in the blob. Otherwise, we have to reconstruct it from the diffs. +We do this by calling `++lump` on the diff in the blob with the data +obtained by recursively calling the parent of this blob. + + ++ lump :: apply patch + |= [don=udon src=*] + ^- * + ?+ p.don ~|(%unsupported !!) + %a + ?+ -.q.don ~|(%unsupported !!) + %a q.q.don + %c (lurk ((hard (list)) src) p.q.don) + %d (lure src p.q.don) + == + :: + %c + =+ dst=(lore ((hard ,@) src)) + %- roly + ?+ -.q.don ~|(%unsupported !!) + %a ((hard (list ,@t)) q.q.don) + %c (lurk dst p.q.don) + == + == + +This is defined in `arvo/hoon.hoon` for historical reasons which are +likely no longer applicable. Since the `++umph` structure will likely +change we convert clay to be a typed filesystem, we'll only give a +high-level description of this process. If we have a `%a` udon, then +we're performing a trivial replace, so we produce simply `q.q.don`. If +we have a `%c` udon, then we're performing a list merge (as in, for +example, lines of text). The merge is performed by `++lurk`. + + ++ lurk :: apply list patch + |* [hel=(list) rug=(urge)] + ^+ hel + =+ war=`_hel`~ + |- ^+ hel + ?~ rug (flop war) + ?- -.i.rug + & + %= $ + rug t.rug + hel (slag p.i.rug hel) + war (weld (flop (scag p.i.rug hel)) war) + == + :: + | + %= $ + rug t.rug + hel =+ gur=(flop p.i.rug) + |- ^+ hel + ?~ gur hel + ?>(&(?=(^ hel) =(i.gur i.hel)) $(hel t.hel, gur t.gur)) + war (weld q.i.rug war) + == + == + +We accumulate our final result in `war`. If there's nothing more in our +list of merge instructions (unces), we just reverse `war` and produce +it. Otherwise, we process another unce. If the unce is of type `&`, then +we have `p.i.rug` lines of no changes, so we just copy them over from +`hel` to `war`. If the unice is of type `|`, then we verify that the +source lines (in `hel`) are what we expect them to be (`p.i.rug`), +crashing on failure. If they're good, then we append the new lines in +`q.i.rug` onto `war`. + +And that's really it. List merges are pretty easy. Anyway, if you +recall, we were discussing `++checkout-ankh`. + + ++ checkout-ankh :: checkout-ankh:ze + |= hat=(map path lobe) :: checkout commit + ^- ankh + %- cosh + %+ roll (~(tap by hat) ~) + |= [[pat=path bar=lobe] ank=ankh] + ^- ankh + %- cosh + ?~ pat + =+ zar=(lobe-to-noun bar) + ank(q [~ (sham zar) zar]) + =+ nak=(~(get by r.ank) i.pat) + %= ank + r %+ ~(put by r.ank) i.pat + $(pat t.pat, ank (fall nak _ankh)) + == + +If the path is null, then we calculate `zar`, the raw data at the path +`pat` in this version. We produce the given ankh with the correct data. + +Otherwise, we try to get the child we're looking at from our parent +ankh. If it's already been created, this succeeds; otherwise, we simply +create a default blank ankh. We place ourselves in our parent after +recursively computing our children. + +This algorithm really isn't that complicated, but it may not be +immediately obvious why it works. An example should clear everything up. + +Suppose `hat` is a map of the following information. + + /greeting --> "customary upon meeting" + /greeting/english --> "hello" + /greeting/spanish --> "hola" + /greeting/russian/short --> "привет" + /greeting/russian/long --> "Здравствуйте" + /farewell/russian --> "до свидания" + +Furthermore, let's say that we process them in this order: + + /greeting/english + /greeting/russian/short + /greeting/russian/long + /greeting + /greeting/spanish + /farewell/russian + +Then, the first path we process is `/greeting/english` . Since our path +is not null, we try to get `nak`, but because our ankh is blank at this +point it doesn't find anything. Thus, update our blank top-level ankh +with a child `%greeting`. and recurse with the blank `nak` to create the +ankh of the new child. + +In the recursion, we our path is `/english` and our ankh is again blank. +We try to get the `english` child of our ankh, but this of course fails. +Thus, we update our blank `/greeting` ankh with a child `english` +produced by recursing. + +Now our path is null, so we call `++lobe-to-noun` to get the actual +data, and we place it in the brand-new ankh. + +Next, we process `/greeting/russian/short`. Since our path is not null, +we try to get the child named `%greeting`, which does exist since we +created it earlier. We put modify this child by recursing on it. Our +path is now `/russian/short`, so we look for a `%russian` child in our +`/greeting` ankh. This doesn't exist, so we add it by recursing. Our +path is now `/short`, so we look for a `%short` child in our +`/greeting/russian` ankh. This doesn't exist, so we add it by recursing. +Now our path is null, so we set the contents of this node to `"привет"`, +and we're done processing this path. + +Next, we process `/greeting/russian/long`. This proceeds similarly to +the previous except that now the ankh for `/greeting/russian` already +exists, so we simply reuse it rather than creating a new one. Of course, +we still must create a new `/greeting/russian/long` ankh. + +Next, we process `/greeting`. This ankh already exists, so after we've +recursed once, our path is null, and our ankh is not blank -- it already +has two children (and two grandchildren). We don't touch those, though, +since a node may be both a file and a directory. We just add the +contents of the file -- "customary upon meeting" -- to the existing +ankh. + +Next, we process `/greeting/spanish`. Of course, the `/greeting` ankh +already exists, but it doesn't have a `%spanish` child, so we create +that, taking care not to disturb the contents of the `/greeting` file. +We put "hola" into the ankh and call it good. + +Finally, we process `/farewell/russian`. Here, the `/farewell` ankh +doesn't exist, so we create it. Clearly the newly-created ankh doesn't +have any children, so we have to add a `%russian` child, and in this +child we put our last content -- "до свидания". + +We hope it's fairly obvious that the order we process the paths doesn't +affect the final ankh tree. The tree will be constructed in a very +different order depending on what order the paths come in, but the +resulting tree is independent of order. + +At any rate, we were talking about something important, weren't we? If +you recall, that concludes our discussion of `++rewind`, which was +called from `++read-at-aeon`. In summary, `++rewind` returns a context +in which our current state is (very nearly) as it was when the specified +version of the desk was the head. This allows `++read-at-aeon` to call +`++read` to read the requested information. + + ++ read :: read:ze + |= mun=mood :: read at point + ^- (unit) + ?: ?=(%v p.mun) + [~ `dome`+<+<.read] + ?: &(?=(%w p.mun) !?=(%ud -.q.mun)) + ?^(r.mun ~ [~ let]) + ?: ?=(%w p.mun) + =+ ^= yak + %- tako-to-yaki + %- aeon-to-tako + let + ?^(r.mun ~ [~ [t.yak (forge-nori yak)]]) + ::?> ?=(^ hit) ?^(r.mun ~ [~ i.hit]) :: what do?? need [@da nori] + (query(ank ank:(descend-path:(zu ank) r.mun)) p.mun) + +If we're requesting the dome, then we just return that immediately. + +If we're requesting the revision number of the desk and we're not +requesting it by number, then we just return the current number of this +desk. Note of course that this was really already handled in +`++read-at-aeon`. + +If we're requesting a `%w` with a specific revision number, then we do +something or other with the commit there. It's kind of weird, and it +doesn't seem to work, so we'll ignore this case. + +Otherwise, we descend into the ankh tree to the given path with +`++descend-path:zu`, and then we handle specific request in `++query`. + + ++ descend-path :: descend recursively + |= way=path + ^+ +> + ?~(way +> $(way t.way, +> (descend i.way))) + +This is simple recursion down into the ankh tree. `++descend` descends +one level, so this will eventually get us down to the path we want. + + ++ descend :: descend + |= lol=@ta + ^+ +> + =+ you=(~(get by r.ank) lol) + +>.$(ram [lol ram], ank ?~(you [*cash ~ ~] u.you)) + +`ram` is the path that we're at, so to descend one level we push the +name of this level onto that path. We update the ankh with the correct +one at that path if it exists; else we create a blank one. + +Once we've decscended to the correct level, we need to actually deal +with the request. + + ++ query :: query:ze + |= ren=?(%u %v %x %y %z) :: endpoint query + ^- (unit ,*) + ?- ren + %u [~ `rang`+<+>.query] + %v [~ `dome`+<+<.query] + %x ?~(q.ank ~ [~ q.u.q.ank]) + %y [~ as-arch] + %z [~ ank] + == + +Now that everything's set up, it's really easy. If they're requesting +the rang, dome, or ankh, we give it to them. If the contents of a file, +we give it to them if it is in fact a file. If the `arch`, then we +calculate it with `++as-arch`. + + ++ as-arch :: as-arch:ze + ^- arch :: arch report + :+ p.ank + ?~(q.ank ~ [~ p.u.q.ank]) + |- ^- (map ,@ta ,~) + ?~ r.ank ~ + [[p.n.r.ank ~] $(r.ank l.r.ank) $(r.ank r.r.ank)] + +This very simply strips out all the "real" data and returns just our own +hash, the hash of the file contents (if we're a file), and a map of the +names of our immediate children. + +Lifecycle of a Local Subscription +--------------------------------- + +A subscription to a range of revisions of a desk initially follows the +same path that a single read does. In `++aver`, we checked the head of +the given rave. If the head was `&`, then it was a single request, so we +handled it above. If `|`, then we handle it with the following code. + + =+ nab=(~(case-to-aeon ze lim dom ran) p.p.rav) + ?~ nab + ?> =(~ (~(case-to-aeon ze lim dom ran) q.p.rav)) + (duce hen (rive rav)) + =+ huy=(~(case-to-aeon ze lim dom ran) q.p.rav) + ?: &(?=(^ huy) |((lth u.huy u.nab) &(=(0 u.huy) =(0 u.nab)))) + (blub hen) + =+ top=?~(huy let.dom u.huy) + =+ sar=(~(lobes-at-path ze lim dom ran) u.nab r.p.rav) + =+ ear=(~(lobes-at-path ze lim dom ran) top r.p.rav) + =. +>.$ + ?: =(sar ear) +>.$ + =+ fud=(~(make-nako ze lim dom ran) u.nab top) + (bleb hen u.nab fud) + ?^ huy + (blub hen) + =+ ^= ptr ^- case + [%ud +(let.dom)] + (duce hen `rove`[%| ptr q.p.rav r.p.rav ear]) + == + +Recall that `++case-to-aeon:ze` produces the revision number that a case +corresponds to, if it corresponds to any. If it doesn't yet correspond +to a revision, then it produces null. + +Thus, we first check to see if we've even gotten to the beginning of the +range of revisions requested. If not, then we assert that we haven't yet +gotten to the end of the range either, because that would be really +strange. If not, then we immediately call `++duce`, which, if you +recall, for a local request, simply puts this duct and rove into our +cult `qyx`, so that we know who to respond to when the revision does +appear. + +If we've already gotten to the first revision, then we can produce some +content immediately. If we've also gotten to the final revision, and +that revision is earlier than the start revision, then it's a bad +request and we call `++blub`, which tells the subscriber that his +subscription will not be satisfied. + +Otherwise, we find the data at the given path at the beginning of the +subscription and at the last available revision in the subscription. If +they're the same, then we don't send a notification. Otherwise, we call +`++gack`, which creates the `++nako` we need to produce. We call +`++bleb` to actually produce the information. + +If we already have the last requested revision, then we also tell the +subscriber with `++blub` that the subscription will receive no further +updates. + +If there will be more revisions in the subscription, then we call +`++duce`, adding the duct to our subscribers. We modify the rove to +start at the next revision since we've already handled all the revisions +up to the present. + +We glossed over the calls to `++lobes-at-path`, `++make-nako`, and +`++bleb`, so we'll get back to those right now. `++bleb` is simple, so +we'll start with that. + + ++ bleb :: ship sequence + |= [hen=duct ins=@ud hip=nako] + ^+ +> + (blab hen [%w [%ud ins] ~] hip) + +We're given a duct, the beginning revision number, and the nako that +contains the updates since that revision. We use `++blab` to produce +this result to the subscriber. The case is `%w` with a revision number +of the beginning of the subscription, and the data is the nako itself. + +We call `++lobes-at-path:ze` to get the data at the particular path. + + ++ lobes-at-path :: lobes-at-path:ze + |= [oan=aeon pax=path] :: data at path + ^- (map path lobe) + ?: =(0 oan) ~ + %- mo + %+ skim + %. ~ + %~ tap by + =< q + %- tako-to-yaki + %- aeon-to-tako + oan + |= [p=path q=lobe] + ?| ?=(~ pax) + ?& !?=(~ p) + =(-.pax -.p) + $(p +.p, pax +.pax) + == == + +At revision zero, the theoretical common revision between all +repositories, there is no data, so we produce null. + +We get the list of paths (paired with their lobe) in the revision +referred to by the given number and we keep only those paths which begin +with `pax`. Converting to a map, we now have a map from the subpaths at +the given path to the hash of their data. This is simple and efficient +to calculate and compare to later revisions. This allows us to easily +tell if a node or its children have changed. + +Finally, we will describe `++make-nako:ze`. + + ++ make-nako :: gack a through b + |= [a=aeon b=aeon] + ^- [(map aeon tako) aeon (set yaki) (set blob)] + :_ :- b + =- [(takos-to-yakis -<) (lobes-to-blobs ->)] + %+ reachable-between-takos + (~(get by hit) a) :: if a not found, a=0 + (aeon-to-tako b) + ^- (map aeon tako) + %- mo %+ skim (~(tap by hit) ~) + |= [p=aeon *] + &((gth p a) (lte p b)) + +We need to produce four things -- the numbers of the new commits, the +number of the latest commit, the new commits themselves, and the new +data itself. + +The first is fairly easy to produce. We simply go over our map of +numbered commits and produce all those numbered greater than `a` and not +greater than `b`. + +The second is even easier to produce -- `b` is clearly our most recent +commit. + +The third and fourth are slightly more interesting, though not too +terribly difficult. First, we call `++reachable-between-takos`. + + ++ reachable-between-takos + |= [a=(unit tako) b=tako] :: pack a through b + ^- [(set tako) (set lobe)] + =+ ^= sar + ?~ a ~ + (reachable-takos r:(tako-to-yaki u.a)) + =+ yak=`yaki`(tako-to-yaki b) + %+ new-lobes-takos (new-lobes ~ sar) :: get lobes + |- ^- (set tako) :: walk onto sar + ?: (~(has in sar) r.yak) + ~ + =+ ber=`(set tako)`(~(put in `(set tako)`~) `tako`r.yak) + %- ~(uni in ber) + ^- (set tako) + %+ roll p.yak + |= [yek=tako bar=(set tako)] + ^- (set tako) + ?: (~(has in bar) yek) :: save some time + bar + %- ~(uni in bar) + ^$(yak (tako-to-yaki yek)) + +We take a possible starting commit and a definite ending commit, and we +produce the set of commits and the set of data between them. + +We let `sar` be the set of commits reachable from `a`. If `a` is null, +then obviously no commits are reachable. Otherwise, we call +`++reachable-takos` to calculate this. + + ++ reachable-takos :: reachable + |= p=tako :: XX slow + ^- (set tako) + =+ y=(tako-to-yaki p) + =+ t=(~(put in _(set tako)) p) + %+ roll p.y + |= [q=tako s=_t] + ?: (~(has in s) q) :: already done + s :: hence skip + (~(uni in s) ^$(p q)) :: otherwise traverse + +We very simply produce the set of the given tako plus its parents, +recursively. + +Back in `++reachable-between-takos`, we let `yak` be the yaki of `b`, +the ending commit. With this, we create a set that is the union of `sar` +and all takos reachable from `b`. + +We pass `sar` into `++new-lobes` to get all the lobes referenced by any +tako referenced by `a`. The result is passed into `++new-lobes-takos` to +do the same, but not recomputing those in already calculated last +sentence. This produces the sets of takos and lobes we need. + + ++ new-lobes :: object hash set + |= [b=(set lobe) a=(set tako)] :: that aren't in b + ^- (set lobe) + %+ roll (~(tap in a) ~) + |= [tak=tako bar=(set lobe)] + ^- (set lobe) + =+ yak=(tako-to-yaki tak) + %+ roll (~(tap by q.yak) ~) + |= [[path lob=lobe] far=_bar] + ^- (set lobe) + ?~ (~(has in b) lob) :: don't need + far + =+ gar=(lobe-to-blob lob) + ?- -.gar + %direct (~(put in far) lob) + %delta (~(put in $(lob q.gar)) lob) + %indirect (~(put in $(lob s.gar)) lob) + == + +Here, we're creating a set of lobes referenced in a commit in `a`. We +start out with `b` as the initial set of lobes, so we don't need to +recompute any of the lobes referenced in there. + +The algorithm is pretty simple, so we won't bore you with the details. +We simply traverse every commit in `a`, looking at every blob referenced +there, and, if it's not already in `b`, we add it to `b`. In the case of +a direct blob, we're done. For a delta or an indirect blob, we +recursively add every blob referenced within the blob. + + ++ new-lobes-takos :: garg & repack + |= [b=(set lobe) a=(set tako)] + ^- [(set tako) (set lobe)] + [a (new-lobes b a)] + +Here, we just update the set of lobes we're given with the commits we're +given and produce both sets. + +This concludes our discussion of a local subscription. + +Lifecycle of a Foreign Read or Subscription +------------------------------------------- + +Foreign reads and subscriptions are handled in much the same way as +local ones. The interface is the same -- a vane or app sends a `%warp` +kiss with the request. The difference is simply that the `sock` refers +to the foreign ship. + +Thus, we start in the same place -- in `++call`, handling `%warp`. +However, since the two side of the `sock` are different, we follow a +different path. + + =+ wex=(do now p.q.hic p.q.q.hic ruf) + =+ ^= woo + ?~ q.q.q.hic + abet:(ease:wex hen) + abet:(eave:wex hen u.q.q.q.hic) + [-.woo (posh q.p.q.hic p.q.q.hic +.woo ruf)] + +If we compare this to how the local case was handled, we see that it's +not all that different. We use `++do` rather than `++un` and `++de` to +set up the core for the foreign ship. This gives us a `++de` core, so we +either cancel or begin the request by calling `++ease` or `++eave`, +exactly as in the local case. In either case, we call `++abet:de` to +resolve our various types of output into actual moves, as described in +the local case. Finally, we call `++posh` to update our raft, putting +the modified rung into the raft. + +We'll first trace through `++do`. + + ++ do + |= [now=@da [who=ship him=ship] syd=@tas ruf=raft] + =+ ^= rug ^- rung + =+ rug=(~(get by hoy.ruf) him) + ?^(rug u.rug *rung) + =+ ^= red ^- rede + =+ yit=(~(get by rus.rug) syd) + ?^(yit u.yit `rede`[~2000.1.1 ~ [~ *rind] *dome]) + ((de now ~ ~) [who him] syd red ran.ruf) + +If we already have a rung for this foreign ship, then we use that. +Otherwise, we create a new blank one. If we already have a rede in this +rung, then we use that, otherwise we create a blank one. An important +point to note here is that we let `ref` in the rede be `[~ *rind]`. +Recall, for domestic desks `ref` is null. We use this to distinguish +between foreign and domestic desks in `++de`. + +With this information, we create a `++de` core as usual. + +Although we've already covered `++ease` and `++eave`, we'll go through +them quickly again, highlighting the case of foreign request. + + ++ ease :: release request + |= hen=duct + ^+ +> + ?~ ref +> + =+ rov=(~(got by qyx) hen) + =. qyx (~(del by qyx) hen) + (mabe rov (cury best hen)) + =. qyx (~(del by qyx) hen) + |- ^+ +>+.$ + =+ nux=(~(get by fod.u.ref) hen) + ?~ nux +>+.$ + %= +>+.$ + say [[hen [(scot %ud u.nux) ~] for [u.nux syd ~]] say] + fod.u.ref (~(del by fod.u.ref) hen) + bom.u.ref (~(del by bom.u.ref) u.nux) + == + +Here, we still remove the duct from our cult (we maintain a cult even +for foreign desks), but we also need to tell the foreign desk to cancel +our subscription. We do this by sending a request (by appending to +`say`, which gets resolved in `++abet:de` to a `%want` kiss to ames) to +the foreign ship to cancel the subscription. Since we don't anymore +expect a response on this duct, we remove it from `fod` and `bom`, which +are the maps between ducts, raves, and request sequence numbers. +Basically, we remove every trace of the subscription from our request +manager. + +In the case of `++eave`, where we're creating a new request, everything +is exactly identical to the case of the local request except `++duce`. +We said that `++duce` simply puts the request into our cult. This is +true for a domestic request, but distinctly untrue for foreign requests. + + ++ duce :: produce request + |= [hen=duct rov=rove] + ^+ +> + =. qyx (~(put by qyx) hen rov) + ?~ ref +>.$ + |- ^+ +>+.$ :: XX why? + =+ rav=(reve rov) + =+ ^= vaw ^- rave + ?. ?=([%& %v *] rav) rav + [%| [%ud let.dom] `case`q.p.rav r.p.rav] + =+ inx=nix.u.ref + %= +>+.$ + say [[hen [(scot %ud inx) ~] for [inx syd ~ vaw]] say] + nix.u.ref +(nix.u.ref) + bom.u.ref (~(put by bom.u.ref) inx [hen vaw]) + fod.u.ref (~(put by fod.u.ref) hen inx) + == + +If we have a request manager (i.e. this is a foreign desk), then we do +the approximate inverse of `++ease`. We create a rave out of the given +request and send it off to the foreign desk by putting it in `say`. Note +that the rave is created to request the information starting at the next +revision number. Since this is a new request, we put it into `fod` and +`bom` to associate the request with its duct and its sequence number. +Since we're using another sequence number, we must increment `nix`, +which represents the next available sequence number. + +And that's really it for this side of the request. Requesting foreign +information isn't that hard. Let's see what it looks like on the other +side. When we get a request from another ship for information on our +ship, that comes to us in the form of a `%wart` from ames. + +We handle a `%wart` in `++call`, right next to where we handle the +`%warp` case. + + %wart + ?> ?=(%re q.q.hic) + =+ ryf=((hard riff) s.q.hic) + :_ ..^$ + :~ :- hen + :^ %pass [(scot %p p.p.q.hic) (scot %p q.p.q.hic) r.q.hic] + %c + [%warp [p.p.q.hic p.p.q.hic] ryf] + == + +Every request we receive should be of type `riff`, so we coerce it into +that type. We just convert this into a new `%warp` kiss that we pass to +ourself. This gets handled like normal, as a local request. When the +request produces a value, it does so like normal as a `%writ`, which is +returned to `++take` along the path we just sent it on. + + %writ + ?> ?=([@ @ *] tea) + =+ our=(need (slaw %p i.tea)) + =+ him=(need (slaw %p i.t.tea)) + :_ ..^$ + :~ :- hen + [%pass ~ %a [%want [our him] [%r %re %c t.t.tea] p.+.q.hin]] + == + +Since we encoded the ship we need to respond to in the path, we can just +pass our `%want` back to ames, so that we tell the requesting ship about +the new data. + +This comes back to the original ship as a `%waft` from ames, which comes +into `++take`, right next to where we handled `%writ`. + + %waft + ?> ?=([@ @ ~] tea) + =+ syd=(need (slaw %tas i.tea)) + =+ inx=(need (slaw %ud i.t.tea)) + =+ ^= zat + =< wake + (knit:(do now p.+.q.hin syd ruf) [inx ((hard riot) q.+.q.hin)]) + =^ mos ruf + =+ zot=abet.zat + [-.zot (posh q.p.+.q.hin syd +.zot ruf)] + [mos ..^$(ran.ruf ran.zat)] :: merge in new obj + +This gets the desk and sequence number from the path the request was +sent over. This determines exactly which request is being responded to. +We call `++knit:de` to apply the changes to our local desk, and we call +`++wake` to update our subscribers. Then we call `++abet:de` and +`++posh` as normal (like in `++eave`). + +We'll examine `++knit` and `++wake`, in that order. + + ++ knit :: external change + |= [inx=@ud rot=riot] + ^+ +> + ?> ?=(^ ref) + |- ^+ +>+.$ + =+ ruv=(~(get by bom.u.ref) inx) + ?~ ruv +>+.$ + => ?. |(?=(~ rot) ?=(& -.q.u.ruv)) . + %_ . + bom.u.ref (~(del by bom.u.ref) inx) + fod.u.ref (~(del by fod.u.ref) p.u.ruv) + == + ?~ rot + =+ rav=`rave`q.u.ruv + %= +>+.$ + lim + ?.(&(?=(| -.rav) ?=(%da -.q.p.rav)) lim `@da`p.q.p.rav) + :: + haw.u.ref + ?. ?=(& -.rav) haw.u.ref + (~(put by haw.u.ref) p.rav ~) + == + ?< ?=(%v p.p.u.rot) + =. haw.u.ref + (~(put by haw.u.ref) [p.p.u.rot q.p.u.rot q.u.rot] ~ r.u.rot) + ?. ?=(%w p.p.u.rot) +>+.$ + |- ^+ +>+.^$ + =+ nez=[%w [%ud let.dom] ~] + =+ nex=(~(get by haw.u.ref) nez) + ?~ nex +>+.^$ + ?~ u.nex +>+.^$ :: should never happen + =. +>+.^$ =+ roo=(edis ((hard nako) u.u.nex)) + ?>(?=(^ ref.roo) roo) + %= $ + haw.u.ref (~(del by haw.u.ref) nez) + == + +This is kind of a long gate, but don't worry, it's not bad at all. + +First, we assert that we're not a domestic desk. That wouldn't make any +sense at all. + +Since we have the sequence number of the request, we can get the duct +and rave from `bom` in our request manager. If we didn't actually +request this data (or the request was canceled before we got it), then +we do nothing. + +Else, we remove the request from `bom` and `fod` unless this was a +subscription request and we didn't receive a null riot (which would +indicate the last message on the subscription). + +Now, if we received a null riot, then if this was a subscription request +by date, then we update `lim` in our request manager (representing the +latest time at which we have complete information for this desk) to the +date that was requested. If this was a single read request, then we put +the result in our simple cache `haw` to make future requests faster. +Then we're done. + +If we received actual data, then we put it into our cache `haw`. Unless +it's a `%w` request, we're done. + +If it is a `%w` request, then we try to get the `%w` at our current head +from the cache. In general, that should be the thing we just put in a +moment ago, but that is not guaranteed. The most common case where this +is different is when we receive desk updates out of order. At any rate, +since we now have new information, we need to apply it to our local copy +of the desk. We do so in `++edis`, and then we remove the stuff we just +applied from the cache, since it's not really a true "single read", like +what should really be in the cache. + + ++ edis :: apply subscription + |= nak=nako + ^+ +> + %= +> + hit.dom (~(uni by hit.dom) gar.nak) + let.dom let.nak + lat.ran %+ roll (~(tap in bar.nak) ~) + =< .(yeb lat.ran) + |= [sar=blob yeb=(map lobe blob)] + =+ zax=(blob-to-lobe sar) + %+ ~(put by yeb) zax sar + hut.ran %+ roll (~(tap in lar.nak) ~) + =< .(yeb hut.ran) + |= [sar=yaki yeb=(map tako yaki)] + %+ ~(put by yeb) r.sar sar + == + +This shows, of course, exactly why nako is defined the way it is. To +become completely up to date with the foreign desk, we need to merge +`hit` with the foreign one so that we have all the revision numbers. We +update `let` so that we know which revision is the head. + +We merge the new blobs in `lat`, keying them by their hash, which we get +from a call to `++blob-to-lobe`. Recall that the hash is stored in the +actual blob itself. We do the same thing to the new yakis, putting them +in `hut`, keyed by their hash. + +Now, our local dome should be exactly the same as the foreign one. + +This concludes our discussion of `++knit`. Now the changes have been +applied to our local copy of the desk, and we just need to update our +subscribers. We do so in `++wake:de`. + + ++ wake :: update subscribers + ^+ . + =+ xiq=(~(tap by qyx) ~) + =| xaq=(list ,[p=duct q=rove]) + |- ^+ ..wake + ?~ xiq + ..wake(qyx (~(gas by *cult) xaq)) + ?- -.q.i.xiq + & + =+ cas=?~(ref ~ (~(get by haw.u.ref) `mood`p.q.i.xiq)) + ?^ cas + %= $ + xiq t.xiq + ..wake ?~ u.cas (blub p.i.xiq) + (blab p.i.xiq p.q.i.xiq u.u.cas) + == + =+ nao=(~(case-to-aeon ze lim dom ran) q.p.q.i.xiq) + ?~ nao $(xiq t.xiq, xaq [i.xiq xaq]) + $(xiq t.xiq, ..wake (balk p.i.xiq u.nao p.q.i.xiq)) + :: + | + =+ mot=`moot`p.q.i.xiq + =+ nab=(~(case-to-aeon ze lim dom ran) p.mot) + ?~ nab + $(xiq t.xiq, xaq [i.xiq xaq]) + =+ huy=(~(case-to-aeon ze lim dom ran) q.mot) + ?~ huy + =+ ptr=[%ud +(let.dom)] + %= $ + xiq t.xiq + xaq [[p.i.xiq [%| ptr q.mot r.mot s.mot]] xaq] + ..wake =+ ^= ear + (~(lobes-at-path ze lim dom ran) let.dom r.p.q.i.xiq) + ?: =(s.p.q.i.xiq ear) ..wake + =+ fud=(~(make-nako ze lim dom ran) u.nab let.dom) + (bleb p.i.xiq let.dom fud) + == + %= $ + xiq t.xiq + ..wake =- (blub:- p.i.xiq) + =+ ^= ear + (~(lobes-at-path ze lim dom ran) u.huy r.p.q.i.xiq) + ?: =(s.p.q.i.xiq ear) (blub p.i.xiq) + =+ fud=(~(make-nako ze lim dom ran) u.nab u.huy) + (bleb p.i.xiq +(u.nab) fud) + == + == + -- + +This is even longer than `++knit`, but it's pretty similar to `++eave`. +We loop through each of our subscribers `xiq`, processing each in turn. +When we're done, we just put the remaining subscribers back in our +subscriber list. + +If the subscriber is a single read, then, if this is a foreign desk +(note that `++wake` is called from other arms, and not only on foreign +desks). Obviously, if we find an identical request there, then we can +produce the result immediately. Referential transparency for the win. We +produce the result with a call to `++blab`. If this is a foreign desk +but the result is not in the cache, then we produce `++blub` (canceled +subscription with no data) for reasons entirely opaque to me. Seriously, +it seems like we should wait until we get an actual response to the +request. If someone figures out why this is, let me know. At any rate, +it seems to work. + +If this is a domestic desk, then we check to see if the case exists yet. +If it doesn't, then we simply move on to the next subscriber, consing +this one onto `xaq` so that we can check again the next time around. If +it does exist, then we call `++balk` to fulfill the request and produce +it. + +`++balk` is very simple, so we'll describe it here before we get to the +subscription case. + + ++ balk :: read and send + |= [hen=duct oan=@ud mun=mood] + ^+ +> + =+ vid=(~(read-at-aeon ze lim dom ran) oan mun) + ?~ vid (blub hen) (blab hen mun u.vid) + +We call `++read-at-aeon` on the given request and aeon. If you recall, +this processes a `mood` at a particular aeon and produces the result, if +there is one. If there is data at the requested location, then we +produce it with `++blab`. Else, we call `++blub` to notify the +subscriber that no data can ever come over this subscriptioin since it +is now impossible for there to ever be data for the given request. +Because referential transparency. + +At any rate, back to `++wake`. If the given rave is a subscription +request, then we proceed similarly to how we do in `++eave`. We first +try to get the aeon referred to by the starting case. If it doesn't +exist yet, then we can't do anything interesting with this subscription, +so we move on to the next one. + +Otherwise, we try to get the aeon referrred to by the ending case. If it +doesn't exist yet, then we produce all the information we can. We call +`++lobes-at-path` at the given aeon and path to see if the requested +path has actually changed. If it hasn't, then we don't produce anything; +else, we produce the correct nako by calling `++bleb` on the result of +`++make-nako`, as in `++eave`. At any rate, we move on to the next +subscription, putting back into our cult the current subscription with a +new start case of the next aeon after the present. + +If the aeon referred to by the ending case does exist, then we drop this +subscriber from our cult and satisfy its request immediately. This is +the same as before -- we check to see if the data at the path has +actually changed, producing it if it has; else, we call `++blub` since +no more data can be produced over this subscription. + +This concludes our discussion of foreign requests. diff --git a/docs/pub/doc/arvo/dill.md b/docs/pub/doc/arvo/dill.md new file mode 100644 index 0000000000..b386d744d7 --- /dev/null +++ b/docs/pub/doc/arvo/dill.md @@ -0,0 +1,27 @@ +
+ +`%dill` +======= + +`%dill` is our terminal driver. + +Unix sends keyboard events to `%dill` from either the console or telnet, +and `%dill` produces terminal output. The only app that should directly +talk to `%dill` is the terminal app. Command-line apps are run by, +receive input from, and produce output to, the `%shell` app, which is +controlled by `%terminal`, which talks to `%dill`, which talks to unix. +Clay also uses `%dill` directly to print out the filesystem change +events, but this is questionable behavior. + +`%dill` has two main components. First, it controls the terminal on a +very basic, event-by-event level. This includes keeping track of things +like the dimensions of the terminal, the prompt type (plain text or +password), which duct to produce effects on, and so forth. Second, it +handles terminal events, keystroke by keystroke. Most characters are +simply pushed onto the buffer and blitted to the screen, but some +characters, including control-modified keys, arrow keys, etc. require +special handling. Most of the readline functionality is in `%dill`. + +
+ +------------------------------------------------------------------------ diff --git a/docs/pub/doc/arvo/dill/commentary.md b/docs/pub/doc/arvo/dill/commentary.md new file mode 100644 index 0000000000..76264f05f6 --- /dev/null +++ b/docs/pub/doc/arvo/dill/commentary.md @@ -0,0 +1,5 @@ +Dill: Reference +=============== + +Dill: Commentary +================ diff --git a/docs/pub/doc/arvo/eyre.md b/docs/pub/doc/arvo/eyre.md new file mode 100644 index 0000000000..4b060e4895 --- /dev/null +++ b/docs/pub/doc/arvo/eyre.md @@ -0,0 +1,58 @@ +
+ +`%eyre` +======= + +`%eyre` is our http server. + +Unix sends http messages to `%eyre`, and `%eyre` produces http messages +in response. In general, apps and vanes do not call `%eyre`; rather, +`%eyre` calls apps and vanes. `%eyre` uses `%ford` and `%gall` to +functionally publish pages and facilitate communication with apps. + +`%eyre` primarily parses web requests and handles them in a variety of +ways, depending on the control string. Nearly all of these are +essentially stateless, like functional publishing with `%ford`. +Additionally, there's a fairly significant component that handles +`%gall` messaging and subscriptions, which must be stateful. + +
+ +------------------------------------------------------------------------ + +HTTP Methods +============ + +`GET` `gog` `https://[ship-name].urbit.org/gog/[service]` Owner +requesting a page on her own Urbit. `gig` +`https://[ship-name].urbit.org/gig/[user-name]/[service]` Another user +requesting a page on a foreign Urbit. + +`goe` +`https://[ship-name].urbit.org/goe/[service]/[port]/[stream]/[sequence]` +`https://[ship-name].urbit.org/goe/[service]/[port]/[stream]/[sequence].json` +Pulls a specific response to her subscription on her own Urbit. `gie` +`https://[ship-name].urbit.org/gie/[user-name]/[service]/[port]/[stream]/[sequence]` +`https://[ship-name].urbit.org/gie/[user-name]/[service]/[port]/[stream]/[sequence].json` +Pulls a specific response to her subscription on a foreign Urbit. + +`PUT` `tos` +`https://[ship-name].urbit.org/tos/[service]/[port]/[stream]/[path]` +`{oryx: [string]}` Initiate a subscription on her own Urbit. `tis` +`https://[ship-name].urbit.org/tis/[user-name]/[service]/[port]/[stream]/[path]` +`{oryx: [string]}` Initiate a subscription on a foreign Urbit. + +`tom` `https://[ship-name].urbit.org/tom/[service]/[port]/[sequence]` +`{oryx: [string], xyro: [json]}` Send a message to her Urbit with +sequence number `[sequence]`. `tim` +`https://[ship-name].urbit.org/tim/[user-name]/[service]/[port]/[sequence]` +`{oryx: [string], xyro: [json]}` Send a message to a foreign Urbit with +sequence number `[sequence]`. + +`tou` `https://[ship-name].urbit.org/tou/[service]/[port]/[stream]` +Unsubscribe from stream `[stream]` on her Urbit. `tiu` +`https://[ship-name].urbit.org/tiu/[user-name]/[service]/[port]/[stream]` +Unsubscribe from stream `[stream]` on a foreign Urbit. + +urb.js +====== diff --git a/docs/pub/doc/arvo/eyre/commentary.md b/docs/pub/doc/arvo/eyre/commentary.md new file mode 100644 index 0000000000..5be829426c --- /dev/null +++ b/docs/pub/doc/arvo/eyre/commentary.md @@ -0,0 +1,5 @@ +Eyre: Reference +=============== + +Eyre: Commentary +================ diff --git a/docs/pub/doc/arvo/ford.md b/docs/pub/doc/arvo/ford.md new file mode 100644 index 0000000000..be96820e07 --- /dev/null +++ b/docs/pub/doc/arvo/ford.md @@ -0,0 +1,128 @@ +
+ +`%ford` +======= + +`%ford` is our typed and marked computation engine. + +A variety of different services are provided by `%ford`, but they mostly +involve compiling hook files, slapping/slammming code with marked data, +and converting data between marks, including validating data to a mark. +Throughout every computation, `%ford` keeps track of which resources are +dependencies so that the client may be aware when one or more +dependencies are updated. + +`%ford` neither accepts unix events nor produces effects. It exists +entirely for the benefit of applications and other vanes, in particular +`%gall`. `%eyre` exposes the functional publishing aspects of `%ford` +while `%gall` uses `%ford` to control the execution of applications. +`%clay` is intended to use `%ford` to managed marked data, but this is +not yet reality. + +
+ +------------------------------------------------------------------------ + + + +------------------------------------------------------------------------ + +Cards +===== + +`%ford` accepts just one card, `%exec`. This is misleading, however, +since there are fourteen different `silk`s that may be used with it. In +every case, the expected response to a `%exec` card is a `%made` gift +with either an error or the produced result along with its set of +dependencies. + +Silks may autocons, so that the product of a cell of silks is a cell of +the product of the two silks. + +[`%bake`](#bake) +================ + +Tries to functionally produce the file at a given beam with the given +mark and heel. It fails if there is no way to translate at this level. + +[`%boil`](#boil) +================ + +Functionally produces the file at a given beam with the given mark and +heel. If there is no way to translate at this beam, we pop levels off +the stack and attempt to bake there until we find a level we can bake. +This should almost always be called instead of `%bake`. + +[`%call`](#call) +================ + +Slams the result of one silk against the result of another. + +[`%cast`](#cast) +================ + +Translates the given silk to the given mark, if possible. This is one of +the critical and fundamental operations of ford. + +[`%diff`](#diff) +================ + +Diffs the two given silks (which must be of the same mark), producing a +cage of the mark specified in `++mark` in `++grad` for the mark of the +two silks. + +[`%done`](#done) +================ + +Produces exactly its input. This is rarely used on its own, but many +silks are recursively defined in terms of other silks, so we often need +a silk that simply produces its input. A monadic return, if you will. + +[`%dude`](#dude) +================ + +Computes the given silk with the given tank as part of the stack trace +if there is an error. + +[`%dune`](#dune) +================ + +Produces an error if the cage is empty. Otherwise, it produces the value +in the unit. + +[`%mute`](#mute) +================ + +Takes a silk and a list of changes to make to the silk. At each wing in +the list we put the value of the associated silk. + +[`%pact`](#pact) +================ + +Applies the second silk as a patch to the first silk. The second silk +must be of the mark specified in `++mark` in `++grad` for the mark of +the first silk. + +[`%plan`](#plan) +================ + +Performs a structured assembly directly. This is not generally directly +useful because several other silks perform supersets of this +functionality. We don't usually have naked hoods outside ford. + +[`%reef`](#reef) +================ + +Produces a core containing the entirety of zuse and hoon, suitable for +running arbitrary code against. The mark is `%noun`. + +[`%ride`](#ride) +================ + +Slaps a twig against a subject silk. The mark of the result is `%noun`. + +[`%vale`](#vale) +================ + +Validates untyped data from a ship against a given mark. This is an +extremely useful function. diff --git a/docs/pub/doc/arvo/ford/commentary.md b/docs/pub/doc/arvo/ford/commentary.md new file mode 100644 index 0000000000..f87d778c6b --- /dev/null +++ b/docs/pub/doc/arvo/ford/commentary.md @@ -0,0 +1,2571 @@ +Reference +========= + +Data Models +----------- + +### `++axle`, formal state + + ++ axle :: all %ford state + $: %1 :: version for update + pol=(map ship baby) :: + == :: + +This is the formal state of our vane. Anything that must be remembered +between calls to ford must be stored here. The number `%1` is a version +number for our state that allows us to upgrade the structure of our +state in the future if we wish. + +`pol` is the a map from every ship on our pier to their individual ford +state. There is no shared ford state -- every ship is entirely separate. + +### `++baby`, state by ship + + ++ baby :: state by ship + $: tad=[p=@ud q=(map ,@ud task)] :: tasks by number + dym=(map duct ,@ud) :: duct to task number + jav=(map ,* calx) :: cache + == :: + +This is the state specific to each ship. + +`tad` and `dym` keep track of the tasks we're currently working on. +`dym` is a map from ducts to task numbers, and `q.tad` is a map from +task number to the task itself. `p.tad` is the next available task +number. Thus, the keys of `q.tad` are a subset of the numbers less than +`p.tad`, and ford has attempted exactly `p.tad` tasks so far. + +`jav` is the cache of previously-solved problems. The keys are a pair of +a term (either `%hood`, `%slap`, or `%slam`) and a noun that represents +the exact problem solved. In the case of a `%hood`, then, the key is of +the form `[%hood beam cage]`. For `%slap`, there is `[%slap vase twig]`. +For `%slam`, there is `[%slam vase vase]`. The values are the result of +solving the problem. Note that this cache is wiped in `++stay` when ford +is reloaded. + +### `++task`, problem in progress + + ++ task :: problem in progress + $: nah=duct :: cause + kas=silk :: problem + kig=[p=@ud q=(map ,@ud beam)] :: blocks + == :: + +This is all the state we keep regarding a particular task. `nah` is the +duct which asked us to solve the problem, and `kas` is the most recent +statement of the problem. + +`kig` keeps track of which resources we are blocked on. Our blocks are +stored by index in `q.kig`, and the next available index is `p.kig`. + +### `++silk`, problem + + ++ silk :: construction layer + $& [p=silk q=silk] :: cons + $% [%bake p=mark q=beam r=path] :: local synthesis + [%boil p=mark q=beam r=path] :: general synthesis + [%call p=silk q=silk] :: slam + [%cast p=mark q=silk] :: translate + [%diff p=silk q=silk] :: diff + [%done p=(set beam) q=cage] :: literal + [%dude p=tank q=silk] :: error wrap + [%dune p=(set beam) q=(unit cage)] :: unit literal + [%mute p=silk q=(list (pair wing silk))] :: mutant + [%pact p=silk q=silk] :: patch + [%plan p=beam q=spur r=hood] :: structured assembly + [%reef ~] :: kernel reef + [%ride p=twig q=silk] :: silk thru twig + [%vale p=mark q=ship r=*] :: validate [our his] + == :: + +This is the every type of problem we can solve. Every `%exec` kiss that +requests us to solve a problem must choose one of these problems to +solve. + +Because this is both an internal structure used in ford and the public +interface to ford, we choose to document this structure in our +discussion of the public interface to ford below. + +### `++calx`, cache line + + ++ calx :: concrete cache line + $% [%hood p=calm q=(pair beam cage) r=hood] :: compile + [%slap p=calm q=[p=vase q=twig] r=vase] :: compute + [%slam p=calm q=[p=vase q=vase] r=vase] :: compute + == :: + +There are three kinds of cache entries. Every entry includes some +metadata in `p` and is the combination of an input and its output. + +The input to a `%hood` is the location of the resource and a cage +representing the data at that location. The output is the hood found by +compiling the given cage at the given location. + +The input to a `%slap` is the vase of the subject and the twig of the +formula against which we are slapping the subject. The output is the +vase produced by slapping them. + +The input to a `%slam` is the vase of the subject and the vase of the +gate which we are slapping. The output is the vase produced by slamming +them. + +### `++calm`, cache line metadata + + ++ calm :: cache metadata + $: laz=@da :: last accessed + dep=(set beam) :: dependencies + == :: + +Every line in the cache needs to have two pieces of metadata. We must +know the last time this line in the cache was accessed, and we must know +what are the dependencies of this line. + +### `++hood`, assembly components + + ++ hood :: assembly plan + $: zus=@ud :: zuse kelvin + sur=(list hoot) :: structures + lib=(list hoof) :: libraries + fan=(list horn) :: resources + src=(list hoop) :: program + == :: + +When assembling a hook file, we split it into several sections. + +`zus` is the kelvin version of the required zuse. In general, we assume +that any newer (lower-numbered) zuse will retain backward compatibility, +so any newer zuse is also permissible. This number is set with a `/?` at +the beginning of the file. + +`sur` is the set of structures included. These are included with the +`/-` rune. When a structure is included, we look in `/=main=/sur` for +the given structure and we load the gate there. When compiling, all the +included structures are collected into a single core placed in the +subject of the body with a `=>`. + +`lib` is the set of librarires included. These are included with the +`/+` rune. When a library is included, we look in `/=main=/lib` for the +given library and we load the library there. As with structures, all the +included libraries are collected into a single core placed in the +subject of the body with a `=>`. + +`fan` is the set of resources included. These are loaded in many +different ways and may load resources from any location. These are +placed in the subject of the body with a `=~`. + +`src` is the set of twigs or references to twigs in the body of the +program. Generally, each of these will represent a core, but this is not +required. When compiling, these are strung together in a `=~`. + +### `++hoot` + + ++ hoot (pair bean hoof) :: structure gate/core + +A structures may be either a direct gate or a core. These are +syntactically distinguished by adding a `*` to the beginning of the +structure name for a core. The structure itself is a `hoof`. + +### `++hoof` + + ++ hoof (pair term (unit (pair case ship))) :: resource reference + +A hoof, which is either a structure or a library, has a name, and it may +also specify which version of the resource to use and which ship to +retrieve it from. + +### `++horn` + + ++ horn :: resource tree + $% [%ape p=twig] :: /~ twig by hand + [%arg p=twig] :: /$ argument + [%day p=horn] :: /| list by @dr + [%dub p=term q=horn] :: /= apply face + [%fan p=(list horn)] :: /. list + [%for p=path q=horn] :: /, descend + [%hub p=horn] :: /@ list by @ud + [%man p=(map span horn)] :: /* hetero map + [%nap p=horn] :: /% homo map + [%now p=horn] :: /& list by @da + [%saw p=twig q=horn] :: /; operate on + [%see p=beam q=horn] :: /: relative to + [%sic p=tile q=horn] :: /^ cast + [%toy p=mark] :: /mark/ static + == :: + +This is how we represent the static resources hook files can load. The +discussion of their use from a user's perspective is documented +elsewhere (link), so we will here only give a description of the data +structure itself. + +A `%ape` horn is simply a twig that gets evaluated and placed in the +subject. + +A `%arg` is a gate that gets evaluated with a sample of our location and +our heel. + +A `%day` is a horn that applies to each of a list of `@dr`-named files +in the directory. + +A `%dub` is a term and horn, where the result of a horn is given the +face of the term. + +A `%fan` is a list of horns, all at the current directory level. + +A `%for` is a path and a horn, where the horn is evaluated relative to +the given path, where the given path is relative to the current +location. + +A `%hub` is a horn that applies to each of a list of `@ud`-named files +in the directory. + +A `%man` is a map of spans to horns where the result is a set of each +horn applied to the current directory given the associated face. + +A `%nap` is a homogenous map where each entry in a directory is handled +with the same horn and is given a face according to its name. + +A `%now` is a horn that applies to each of a list of `@da`-named files +in the directory. + +A `%saw` is a twig and a horn, where the twig operates on the result of +the horn. + +A `%see` is a beam and a horn, where the horn is evaluated at a location +of the given beam. + +A `%sic` is a tile and a horn, where the horn is evaluated and cast to +the type associated with the tile. + +A `%toy` is simply a mark to be baked. + +### `++hoop`, body + + ++ hoop :: source in hood + $% [%& p=twig] :: direct twig + [%| p=beam] :: resource location + == :: + +This is an entry in the body of the hook file. The hoop can either be +defined directly in the given file or it can be a reference to another +file. The second is specified with a `//` rune. + +### `++bolt`, monadic edge + + ++ bolt :: gonadic edge + |* a=$+(* *) :: product clam + $: p=cafe :: cache + $= q :: + $% [%0 p=(set beam) q=a] :: depends/product + [%1 p=(set ,[p=beam q=(list tank)])] :: blocks + [%2 p=(list tank)] :: error + == :: + == :: + +Throughout our computation, we let our result flow through with the set +of dependencies of the value. At various times, we may wish to either +throw an error or declare that the actual result cannot be found until a +particular resource is retrieved. This is a perfect case for a monad, so +here we define a data structure for it. + +At every step, we have a cache, so we store that in `p`. In `q` we store +the data. + +In the case of `%0`, we have the result in `q` and the set of +dependencies in `p`. + +In the case of `%1`, we have a set of dependencies on which we are +blocking. When this happens, we make a call to clay to get the +dependencies, and we proceed with the computation when we receive them. +Technically, we restart the computation, but since every expensive step +is cached, there is no significant performance penalty to doing this. +Referential transparency has its uses. + +In the case of `%2`, we have a hit an error. This gets passed all the +way through to the calling duct. The list of tanks is some description +of what went wrong, often including a stack trace. + +### `++burg`, monadic rule + + ++ burg :: gonadic rule + |* [a=$+(* *) b=$+(* *)] :: from and to + $+([c=cafe d=a] (bolt b)) :: + :: :: + +To operate on bolts, we use `++cope` as our bind operator, and the +functions it works on are of type `burg`. Our functions that operate on +bolts should have a sample of the cache and a value. Their output should +be a bolt of the output value. Then, `++cope` will only call the +function when necessary (in the `%0` case), and it will do so without +the wrapping of a bolt. + +If you understand monads, this is probably fairly obvious. Otherwise, +see the discussion on `++cope` (link). + +Public Interface +---------------- + +Ford does not export a scry interface, so the only way to interact with +ford is by sending kisses and receiving gifts. In fact, ford only sends +accepts one kiss and gives one gift. This is, of course, misleading +because ford actually does many different things. It does, however, only +produce one type of thing -- a result of a computation, which is either +an error or the value produced along with the set of dependencies +referenced by it. + + ++ kiss :: in request ->$ + $% [%exec p=@p q=(unit silk)] :: make / kill + == :: + +The `%exec` gift requests ford to perform a computation on behalf of a +particular ship. `p` is the ship, and `q` is the computation. If `q` is +null, then we are requesting that ford cancel the computation that it is +currently being run along this duct. Thus, if you wish to cancel a +computation, you must send the kiss along the same duct as the original +request. + +Otherwise, we ask ford to perform a certain computation, as defined in +`++silk`. Since all computations produce the same type of result, we +will discuss that result before we jump into `++silk`. + + ++ gift :: out result <-$ + $% [%made p=(each bead (list tank))] :: computed result + == :: + +We give either a `bead`, which is a result, or a list of tanks, which is +an error messge, often including a stack trace. + + ++ bead ,[p=(set beam) q=cage] :: computed result + +This is a set of dependencies required to compute this value and a cage +of the result with its associated mark. + +There are twelve possible computations defined in `++silk`. + + ++ silk :: construction layer + $& [p=silk q=silk] :: cons + $% [%bake p=mark q=beam r=path] :: local synthesis + [%boil p=mark q=beam r=path] :: general synthesis + [%call p=silk q=silk] :: slam + [%cast p=mark q=silk] :: translate + [%done p=(set beam) q=cage] :: literal + [%dude p=tank q=silk] :: error wrap + [%dune p=(set beam) q=(unit cage)] :: unit literal + [%mute p=silk q=(list (pair wing silk))] :: mutant + [%plan p=beam q=spur r=hood] :: structured assembly + [%reef ~] :: kernel reef + [%ride p=twig q=silk] :: silk thru twig + [%vale p=mark q=ship r=*] :: validate [our his] + == :: + +First, we allow silks to autocons. A cell of silks is also a silk, and +the product vase is a cell of the two silks. This obviously extends to +an arbitrary number of silks. + +`%bake` tries to functionally produce the file at a given beam with the +given mark and heel. It fails if there is no way to translate at this +level. + +`%boil` functionally produces the file at a given beam with the given +mark and heel. If there is no way to translate at this beam, we pop +levels off the stack and attempt to bake there until we find a level we +can bake. This should almost always be called instead of `%bake`. + +`%call` slams the result of one silk against the result of another. + +`%cast` translates the given silk to the given mark, if possible. This +is one of the critical and fundamental operations of ford. + +`%done` produces exactly its input. This is rarely used on its own, but +many silks are recursively defined in terms of other silks, so we often +need a silk that simply produces its input. A monadic return, if you +will. + +`%diff` diffs the two given silks (which must be of the same mark), +producing a cage of the mark specified in `++mark` in `++grad` for the +mark of the two silks. + +`%dude` computes the given silk with the given tank as part of the stack +trace if there is an error. + +`%dune` produces an error if the cage is empty. Otherwise, it produces +the value in the unit. + +`%mute` takes a silk and a list of changes to make to the silk. At each +wing in the list we put the value of the associated silk. + +`%pact` applies the second silk as a patch to the first silk. The second +silk must be of the mark specified in `++mark` in `++grad` for the mark +of the first silk. + +`%plan` performs a structured assembly directly. This is not generally +directly useful because several other silks perform supersets of this +functionality. We don't usually have naked hoods outside ford. + +`%reef` produces a core containing the entirety of zuse and hoon, +suitable for running arbitrary code against. The mark is `%noun`. + +`%ride` slaps a twig against a subject silk. The mark of the result is +`%noun`. + +`%vale` validates untyped data from a ship against a given mark. This is +an extremely useful function. + +Commentary +========== + +Parsing Hook Files +------------------ + +In the commentary on other vanes, we have traced through the lifecycle +of various external requests. This is generally a very reasonable order +to examine vanes since it will eventually cover the entire vane, and we +are never left wondering why we are doing something. + +For ford, however, it makes more sense to begin by discussing the +parsing and assembliing of hook files. Many of the possible requests +require us to assemble hook files, so we may as well examine this +immediately. + +First, we will examine the parsing. We parse a file at a beam to a hood +in `++fade:zo:za`. The top-level parsing rule is `++fair`, which takes a +beam and produces a rule to parse an entire hood file. + +A note on the naming scheme: the parsing the combinators that parse into +a particular structure are conventionally given the same name as the +structure. Although this locally clobbers the type names, this pattern +makes obvious the intent of the parsing combinators. + +We kick off with `++hood:fair`. + + ++ hood + %+ ifix [gay gay] + ;~ plug + ;~ pose + (ifix [;~(plug fas wut gap) gap] dem) + (easy zuse) + == + :: + ;~ pose + (ifix [;~(plug fas hep gap) gap] (most ;~(plug com gaw) hoot)) + (easy ~) + == + :: + ;~ pose + (ifix [;~(plug fas lus gap) gap] (most ;~(plug com gaw) hoof)) + (easy ~) + == + :: + (star ;~(sfix horn gap)) + (most gap hoop) + == + +There are five sections to a hood: system version, structures, +libraries, resources, and body. + +First, we parse the requested version number of the system. This is +specified with a unary `/?` rune. If not present, then we default to the +current version. + +Second, we may have zero or more `/-` runes followed by a parsing of a +`++hoot`, which represents a shared structure. + +Third, we may have zero or more `/+` runes followed by a parsing of a +`++hoof`, which represents a shared library. + +Fourth, we may have zero or more other `/` runes (as described in +`++horn`), which represent program-specific resources to be loaded. + +Fifth and finally, we must have one or more body statements (hoops), +which are either direct twigs or `//` runes. + + ++ hoot + ;~ pose + (stag %| ;~(pfix tar hoof)) + (stag %& hoof) + == + +A structure can either be a direct gate, or it can be a simple core. +Either one is parsed with `++hoof`, so we distinguish the two cases by +requireing core references to be prefixed by a `*`. + + ++ hoof + %+ cook |=(a=^hoof a) + ;~ plug + sym + ;~ pose + %+ stag ~ + ;~(plug ;~(pfix fas case) ;~(pfix ;~(plug fas sig) fed:ag)) + (easy ~) + == + == + +A hoof must have a name, which is a term. Optionally, we also include a +case and a ship. This is marked by appending a `/` followed by a case to +denote the requested version of the resource and a `/` followed by a +ship name to denote the requested source of the resource. For example, +`resource/1/~zod` requests the first version of `resource` on `~zod`. + + ++ case + %- sear + :_ nuck:so + |= a=coin + ?. ?=([%$ ?(%da %ud %tas) *] a) ~ + [~ u=(^case a)] + +Here, we parse a literal with `++nuck:so`, and we accept the input if it +is either an absolute date, an unsigned decimal, or a label. + +This leaves only horns and hoops to parse. Hoops are much simple to +parse, so we'll discuss those first. + + ++ hoop + ;~ pose + (stag %| ;~(pfix ;~(plug fas fas gap) have)) + (stag %& tall:vez) + == + +There are two types of hoops. Direct twigs are parsed with +`++tall:vast`, which is the just the hoon parser for a tall-form twig. + +References to external twigs are marked with a `//` rune followed by a +beam, which is parsed with `++have`. + + ++ hath (sear plex:voz (stag %clsg poor:voz)) :: hood path + ++ have (sear tome ;~(pfix fas hath)) :: hood beam + +`++have` parses a path with `++hath`, and then it converts the path into +a beam with `++tome`. + +`++hath` parses a `/`-separated list with `++poor:vast`, then converts +it to an actual path with `++plex:vast`. + +This leaves only horns to parse. + + ++ horn + =< apex + =| tol=? + |% + ++ apex + %+ knee *^horn |. ~+ + ;~ pfix fas + ;~ pose + (stag %toy ;~(sfix sym fas)) + (stag %ape ;~(pfix sig ape:read)) + (stag %arg ;~(pfix buc ape:read)) + (stag %day ;~(pfix bar day:read)) + (stag %dub ;~(pfix tis dub:read)) + (stag %fan ;~(pfix dot fan:read)) + (stag %for ;~(pfix com for:read)) + (stag %hub ;~(pfix pat day:read)) + (stag %man ;~(pfix tar man:read)) + (stag %nap ;~(pfix cen day:read)) + (stag %now ;~(pfix pam day:read)) + (stag %saw ;~(pfix sem saw:read)) + (stag %see ;~(pfix col see:read)) + (stag %sic ;~(pfix ket sic:read)) + == + == + +Horn parsing is slightly complex, so we create an internal core to +organize our code. Our core has a global variable of `tol`, which is +true if tall form is permissible and false if we're already in wide +form. We kick off the parsing with `++apex`. + +`++apex` specifies how each rune is parsed. This allows us to offload +the different ways of parsing the arguments to these runes into separate +arms. The exception here is that the `%toy` horn is simply of the form +`/mark/`. + +We'll examine each of the horn parsing arms right after we discuss +`++rail`, which is used in each one. + + ++ rail + |* [wid=_rule tal=_rule] + ?. tol wid + ;~(pose wid tal) + +This takes a wide-form and a tall-form parsing rule. If tall form is +permissible, then it allows either rule to match; else, it allows only +the wide form rule. + + ++ read + |% ++ ape + %+ rail + (ifix [sel ser] (stag %cltr (most ace wide:vez))) + ;~(pfix gap tall:vez) + +`++ape:read` parses for both the `/~` and the `/$` runes. It produces a +twig. The wide form is a tuple of one or more ace-separated wide-form +twigs parsed with `++wide:vast` and surrounded by `[` and `]`. The tall +form is a single tall form twig parsed by `++tall:vast` + + ++ day + %+ rail + apex(tol |) + ;~(pfix gap apex) + +This parses for the `/|`, `/@`, `/%`, and `/&` runes. It produces a +horn. The wide form is, recursively, the entire horn parser with tall +form disabled. The tall form is a gap followed by, recursively, the +entire horn parser. + + ++ dub + %+ rail + ;~(plug sym ;~(pfix tis apex(tol |))) + ;~(pfix gap ;~(plug sym ;~(pfix gap apex))) + +This parses for the `/=` rune. It produces a term followed by a horn. +The wide form is a symbol name followed by a `=` and, recursively, the +entire horn parser with tall form disabled. The tall form is a gap +followed by a symbol name, another gap, and, recursively, the entire +horn parser. + + ++ fan + %+ rail fail + ;~(sfix (star ;~(pfix gap apex)) ;~(plug gap duz)) + +This parses for the `/.` rune. It produces a list of horns. There is no +wide form. The tall form is a stet-terminated series of gap-separated +recursive calls to the entire horn parser. + + ++ for + %+ rail + ;~(plug (ifix [sel ser] hath) apex(tol |)) + ;~(pfix gap ;~(plug hath ;~(pfix gap apex))) + +This parses for the `/,` rune. It produces a path and a horn. The wide +form is a `[`-`]`-surrounded path followed by, recursively, the entire +horn parser with tall form disabled. The tall form is a gap followed by +a path, another gap, and, recursively, the entire horn parser. + + ++ man + %+ rail fail + %- sear + :_ ;~(sfix (star ;~(pfix gap apex)) ;~(plug gap duz)) + |= fan=(list ^horn) + =| naf=(list (pair term ^horn)) + |- ^- (unit (map term ^horn)) + ?~ fan (some (~(gas by *(map term ^horn)) naf)) + ?. ?=(%dub -.i.fan) ~ + $(fan t.fan, naf [[p.i.fan q.i.fan] naf]) + +This parses for the `/*` rune. It produces a map of spans to horns. +There is no wide form. The tall form is a stet-terminated series of +gap-separated recursive calls to the entire horn parser. All produced +horns are expected to be from `/=` runes. The term and horn in each `/=` +horn is inserted into the produced map as a key-value pair. + + ++ saw + %+ rail + ;~(plug ;~(sfix wide:vez sem) apex(tol |)) + ;~(pfix gap ;~(plug tall:vez ;~(pfix gap apex))) + +This parses for the `/;` rune. It produces a twig and a horn. The wide +form is a wide-form twig followed by a `;` and, recursively, the entire +horn parser with tall form disabled. The tall form is a gap followed by +a tall-form twig, another gap, and, recursively, the entire horn parser. + + ++ see + %+ rail + ;~(plug ;~(sfix have col) apex(tol |)) + ;~(pfix gap ;~(plug have ;~(pfix gap apex))) + +This parses for the `/:` rune. It produces a beam and a horn. The wide +form is a beam followed by a `;` and, recursively, the entire horn +parser with tall form disabled. The tall form is a gap followed by a +beam, another gap, and, recursively, the entire horn parser. + + ++ sic + %+ rail + ;~(plug ;~(sfix toil:vez ket) apex(tol |)) + ;~(pfix gap ;~(plug howl:vez ;~(pfix gap apex))) + -- + +This parses for the `/^` rune. It produces a tile and a horn. The wide +form is a wide-form tile, parsed with `++toil:vast`, followed by a `^` +and, recursively, the entire horn parser with tall form disabled. The +tall form is a gap followed by a tall-form tile, parsed with +`++howl:vast`, another gap, and, recursively, the entire horn parser. + +Assembling Hook Files +--------------------- + +At this point, we've parsed a hook file into a hood. We will now +describe exactly how this hood is assembled into a vase. The problem of +assembling is handled entirely within the `++meow:zo:za` core. + + ++ meow :: assemble + |= [how=beam arg=heel] + =| $: rop=(map term (pair hoof twig)) :: structure/complex + zog=(set term) :: structure guard + bil=(map term (pair hoof twig)) :: libraries known + lot=(list term) :: library stack + zeg=(set term) :: library guard + boy=(list twig) :: body stack + hol=? :: horns allowed? + == + |% + +We take two arguments and keep seven pieces of state. `how` is the +location of the hook file we're assembling, and `arg` is the heel, or +virtual path extension, of the file. + +In `rop`, we maintain a map of terms to pairs of hooves and twigs to +represent the structures we've encountered that we will put together in +a core at the top of the file. + +In `zog`, we maintain the set of structures we're in the middle of +loading. If we try to load a structure already in our dependency +ancestry, then we fail because we do not allow circular dependencies. +This enforces that our structure dependency graph is a DAG. + +In `bil`, we maintain a map of terms to pairs of hooves and twigs to +represent the libraries we've encountered that we will put together in a +series of cores after the structure core. + +In `lot`, we maintain a stack of library names as they are encountered +during a depth-first search. More precisely, we push a library onto the +stack after we've processed all its children. Thus, every library +depends only on things deeper in the list. The libraries must be loaded +in the reverse of this order. Concisely, this is a topological sort of +the library dependency partial ordering. + +In `zeg`, we maintain the set of libraries we're in the middle of +loading. If we try to load a library already in our dependency ancestry, +then we fail because we do not allow circular dependencies. This +enforces that our library dependency graph is a DAG. + +In `boy`, we maintain a stack of body twigs, which we'll put together in +a series of cores at the end of the file. + +In `hol`, we decide if we're allowed to contain horns. Libraries and +structures are not allowed to contain horns. + +We in every case enter `++meow` through `++abut`. You'll notice that +there are four (count 'em, four!) calls to `++cope` in `++abut`. If +you've glanced at the ford code in general, you've probably seen cope +over and over. It is called in 79 different places. We need to discuss +the use of this critical function in detail, so we may as well do it +here. + + ++ cope :: bolt along + |* [hoc=(bolt) fun=(burg)] + ?- -.q.hoc + %2 hoc + %1 hoc + %0 =+ nuf=(fun p.hoc q.q.hoc) + :- p=p.nuf + ^= q + ?- -.q.nuf + %2 q.nuf + %1 q.nuf + %0 [%0 p=(grom `_p.q.nuf`p.q.hoc p.q.nuf) q=q.q.nuf] + == == + +In monad-speak, this is the bind operator for the bolt monad. If monads +aren't your thing, don't worry, we're going to explain the use of cope +without further reference to them. + +Recall that there are three different types of bolt. A `%2` error bolt +contains a list of tanks describing the error, a `%1` block bolt +contains a set of resources we're blocked on, and a `%0` value bolt +contains an actual value and the set of its dependencies. + +We most commonly want to perform an operation on the value in a bolt if +it is a `%0` bolt. If it's not a `%0` bolt, we want to leave it alone. +This requires us to write a certain amount of boilerplate between each +of our operations to see if any of them produced a `%1` or a `%2` bolt. +This gets tiresome, so we pull it out into a separate arm and call it +`++cope`. + +Intuitively, we're calling the function `fun` with the value in `hoc`, +where `fun` takes an argument of type whatever is the value in a `%0` +case of `hoc`, and it produces a bolt of some (possibly different) type. +For brevity, we will refer to the type of the of the value in the `%0` +case of a bolt as the "type of the bolt". + +If the `hoc` bolt we're given as input to `fun` is already a `%1` or a +`%2` bolt, then we simply produce that. We don't even try to run `fun` +on it. + +Otherwise, we run `fun` with the arguments from the bolt and, if it +produces a `%1` or a `%2` bolt, we simply produce that. If it produces a +`%0` bolt, then we produce that with the old set of dependencies merged +in with the new set. + +We'll see more about how the bolt monad works as we run into more +interesting uses of it. For now, this is sufficient to move on with +`++abut`. + + ++ abut :: generate + |= [cof=cafe hyd=hood] + ^- (bolt vase) + %+ cope (apex cof hyd) + |= [cof=cafe sel=_..abut] + =. ..abut sel + %+ cope (maim cof pit able) + |= [cof=cafe bax=vase] + %+ cope (chap cof bax [%fan fan.hyd]) + |= [cof=cafe gox=vase] + %+ cope (maim cof (slop gox bax) [%tssg (flop boy)]) + |= [cof=cafe fin=vase] + (fine cof fin) + +Our job is simple: we must assemble a hood file into a vase. Hopefully, +the usage of `++cope` is fairly understandable. The correct way to read +this is that it does essentially five things. + +First, we call `++apex` to process the structures, libraries, and body. +This changes our state, so we set our context to the produced context. +Second, we call `++able` to assemble the strucutres and libraries into a +twig, which we slap against zuse with `++maim`. Third, we call `++chap` +to process the resources in the context of the already-loaded structures +and libraries. Fourth, we slap the body against the structures, +libraries, and resources. Fifth and finally, we produce the resultant +vase. + + ++ apex :: build to body + |= [cof=cafe hyd=hood] + ^- (bolt ,_..apex) + ?. |(hol ?=(~ fan.hyd)) + %+ flaw cof :_ ~ :- %leaf + "horns not allowed in structures and libraries: {<[how arg]>}" + %+ cope (body cof src.hyd) + |= [cof=cafe sel=_..apex] + =. ..apex sel + %+ cope (neck cof lib.hyd) + |= [cof=cafe sel=_..apex] + =. ..apex sel(boy boy) + %+ cope (head cof sur.hyd) + |= [cof=cafe sel=_..apex] + (fine cof sel) + +First, we make sure that if we're not allowed to have horns, we don't. +Otherwise, we produce and error with `++flaw`. + + ++ flaw |=([a=cafe b=(list tank)] [p=a q=[%2 p=b]]) :: bolt from error + +This produces a `%2` error bolt from a list of tanks. Fairly trivial. + +We should be starting to get used to the cope syntax, so we can see that +we really only do three things here. We process the body with `++body`, +the libraries with `++neck`, and the structures with `++head`. + + ++ body :: produce functions + |= [cof=cafe src=(list hoop)] + ^- (bolt _..body) + ?~ src (fine cof ..body) + %+ cope (wilt cof i.src) + |= [cof=cafe sel=_..body] + ^$(cof cof, src t.src, ..body sel) + +We must process a list of hoops that represent our body. If there are no +more hoops, we just produce our context in a `%0` bolt with `++fine`. + + ++ fine |* [a=cafe b=*] :: bolt from data + [p=`cafe`a q=[%0 p=*(set beam) q=b]] :: + +In monad-speak, this is the return operator. For us, this just means +that we're producing a `%0` bolt, which contains a path and a set of +dependencies. We assume there are no dependencies for the given data, or +that they will be added later. + +If there are more hoops in `++body`, we call `++wilt` to process an +individual hoop and recurse. + + ++ wilt :: process body entry + |= [cof=cafe hop=hoop] + ^- (bolt _..wilt) + ?- -.hop + %& (fine cof ..wilt(boy [p.hop boy])) + %| + %+ cool |.(leaf/"ford: wilt {<[(tope p.hop)]>}") + %+ cope (lend cof p.hop) + |= [cof=cafe arc=arch] + ?: (~(has by r.arc) %hoon) + %+ cope (fade cof %hoon p.hop) + |= [cof=cafe hyd=hood] + %+ cope (apex(boy ~) cof hyd) + |= [cof=cafe sel=_..wilt] + (fine cof sel(boy [[%tssg boy.sel] boy])) + =+ [all=(lark (slat %tas) arc) sel=..wilt] + %+ cope + |- ^- (bolt (pair (map term foot) _..wilt)) + ?~ all (fine cof ~ ..wilt) + %+ cope $(all l.all) + |= [cof=cafe lef=(map term foot) sel=_..wilt] + %+ cope ^$(all r.all, cof cof, sel sel) + |= [cof=cafe rig=(map term foot) sel=_..wilt] + %+ cope + %= ^^^^$ + cof cof + ..wilt sel(boy ~) + s.p.hop [p.n.all s.p.hop] + == + |= [cof=cafe sel=_..wilt] + %+ fine cof + [`(map term foot)`[[p.n.all [%ash [%tssg boy.sel]]] lef rig] sel] + |= [cof=cafe mav=(map term foot) sel=_..wilt] + ?~ mav + (flaw cof [%leaf "source missing: {<(tope p.hop)>}"]~) + (fine cof sel(boy [[%brcn mav] boy])) + == + +In the case of a direct twig hoop, we just push it onto `boy` and we're +done. In the case of an indirect hoop, we must compile the referenced +file. + +First, we push onto the stack trace a message indicating which file +exactly we're compiling at the moment with `++cool`. + + ++ cool :: error caption + |* [cyt=trap hoc=(bolt)] + ?. ?=(%2 -.q.hoc) hoc + [p.hoc [%2 *cyt p.q.hoc]] + +If an error occurred in computing `hoc`, we put the bunt of `cyt` onto +the stack trace. Thus, `cyt` is not evaluated at all unless an error +occurred. + +Next in `++wilt`, we load the information about the filesystem node +referenced by the hoop with `++lend`. + + ++ lend :: load arch + |= [cof=cafe bem=beam] + ^- (bolt arch) + =+ von=(ska %cy (tope bem)) + ?~ von [p=cof q=[%1 [bem ~] ~ ~]] + (fine cof ((hard arch) (need u.von))) + +This is a simple call to the namespace. If the resource does not yet +exist, we block on it by producing a `%1` bolt. Otherwise, we cast it to +an arch and produce this. + +Continuing in `++wilt`, we examine the produced arch. If the referenced +filesystem node has a `hoon` child node, then we've found the required +source, so we parse it with `++fade`. Recall that we referred earlier to +`++fade`. The salient point there is that it takes a beam, reads in the +hook file there, and parses it into a hood file with `++fair`. + +Now, we simply recurse on `++apex` to compile the new hood. Note that, +while we do clear the `boy` list, we do not clear the other lists. Thus, +we are accumulating all the structures and libraries referenced in all +the referenced hook files in one group, which we will put at the top of +the product. + +After this, we put the new list of body twigs into a `=~`, push this +onto our old list of body twigs, and produce the result. + +If there is no hoon file here, then we descend into each of our children +until we find a hoon file. First, we produce a list of all our children +whose names are terms with `++lark`. + + ++ lark :: filter arch names + |= [wox=$+(span (unit ,@)) arc=arch] + ^- (map ,@ span) + %- ~(gas by *(map ,@ span)) + =| rac=(list (pair ,@ span)) + |- ^+ rac + ?~ r.arc rac + =. rac $(r.arc l.r.arc, rac $(r.arc r.r.arc)) + =+ gib=(wox p.n.r.arc) + ?~(gib rac [[u.gib p.n.r.arc] rac]) + +We traverse the children map of `arc` to filter out those children whose +names aren't accepted by `wox` and produce a map from the product of +`wox` to the original name. `++lark` is used in many cases to parse +names into other types, like numbers or dates, ignoring those which do +not fit the format. In `++wilt`, though, we simply want to filter out +those children whose names are not terms. + +Next, we will produce a map from terms to feet. Each of these feet will +be placed in a core named by the child name, and it will contain arms +according to its children. Thus, if the indirect hoop references +`/path`, then to access the twig defined in `/path/to/twig/hoon`, our +body must refer to `twig:to`. + +If there are no more children, then we are done, so we produce our +current context. + +Else, we recurse into the left and right sides of our map. Finally, we +process our current entry in the map. We first recurse by calling +`++wilt` one level down. Thus, in the previous example, the first time +we get to this point we are processing `/path`, so we recurse on +`++wilt` with path `/path/to`. We also remove our current body from the +recursion, so that we may add it back in later the way we want to. + +After recursing, we push the new body onto our map, keyed by its name. +We also produce the new context so that all external structures, +libraries, and resources are collected into the same place. + +Finally, we have a map of names to feet. If this map is empty, then +there were no twigs at the requested path, so we give an error with +`++flaw`. + +If the map is nonempty, then we finally produce our context with with +one thing pushed onto the front: a core made out of the map we just +produced. + +This concludes our discussion of `++wilt` and `++body`. Thus, it remains +in `++apex` to discuss `++neck` and `++head`. + + ++ neck :: consume libraries + |= [cof=cafe bir=(list hoof)] + ^- (bolt ,_..neck) + ?~ bir (fine cof ..neck) + ?: (~(has in zeg) p.i.bir) + (flaw cof [%leaf "circular library dependency: {}"]~) + =+ gez=(~(put in zeg) p.i.bir) + =+ byf=(~(get by bil) p.i.bir) + ?^ byf + ?. =(`hoof`i.bir `hoof`p.u.byf) + (flaw cof [%leaf "library mismatch: {<~[p.u.byf i.bir]>}"]~) + $(bir t.bir) + =+ bem=(hone %core %lib i.bir) + %+ cope (fade cof %hook bem) + |= [cof=cafe hyd=hood] + %+ cope (apex(zeg gez, hol |, boy ~) cof hyd) + |= [cof=cafe sel=_..neck] + =. ..neck + %= sel + zeg zeg + hol hol + lot [p.i.bir lot] + bil (~(put by bil) p.i.bir [i.bir [%tssg (flop boy.sel)]]) + == + ^^$(cof cof, bir t.bir) + +Here, we're going to consume the list of libraries and place them in +`bil`. If there are no more libraries, we're done, so we just produce +our current context. + +Otherwise, we check to see if the next library in the list is in `zeg`. +If so, then this library is one of the libraries that we're already in +the middle of compiling. There is a circular dependency, so we fail. + +Otherwise, we let `gez` be `zeg` plus the current library so that while +compiling the dependencies of this library we don't later create a +circular dependency. We check next to see if this library is alredy in +`bil`. If so, then we have already included this library earlier, so we +check to see if this is the same version of the library as we included +earlier. If so, we skip it. Else, we fail since we can't include two +different versions of a library. We really should allow for newer +versions of a library since in kelvin versioning we assume backwards +compatibility, but for now we require an exact match. + +If we haven't already included this library, then we're going to do +that. First, we get the location of the library with `++hone`. + + ++ hone :: plant hoof + |= [for=@tas way=@tas huf=hoof] + ^- beam + ?~ q.huf + how(s ~[for p.huf way]) + [[q.u.q.huf %main p.u.q.huf] ~[for p.huf way]] + +If we haven't specified the version of the library, we use the current +ship, desk, and case. Otherwise, we use the given ship and case on desk +`%main`. In either case, the path is `/way/p.huf/for`. In the case of +`++neck`, this means `/lib/core/[library name]`. + +In `++neck`, we next compile the hook file at that location with +`++fade`. Again, we will delay the discussion of `++fade`, noting only +that it takes a beam and parses the hook file there into a hood. + +We recurse on this to compile the library. During the compilation, we +let `zeg` be `gez` to avoid circular dependencies, we let `hol` be false +since we don't allow horns in libraries, and we let `boy` be null so +that we can isolate the new body twigs. + +Next, we reintegrate the new data into our context. We use the context +created by the recursion with four changes. First, we reset `zeg` to our +old `zeg`. Second, we reset `hol` to our old `hol`. Third, we put the +name of our library onto the stack of libraries. This means all of a +libraries dependencies will be earlier in `lot` than the library itself, +making `lot` a topological ordering on the dependency graph. Fourth, we +put in `bil` the library hoof and body (with all body twigs collected in +a `=~`), keyed by the library name. + +Finally, we recurse, processing the next library in our list. + +To complete our disucssion of `++apex`, we must process our structures. + + ++ head :: consume structures + |= [cof=cafe bir=(list hoot)] + |- ^- (bolt ,_..head) + ?~ bir + (fine cof ..head) + ?: (~(has in zog) p.q.i.bir) + (flaw cof [%leaf "circular structure dependency: {}"]~) + =+ goz=(~(put in zog) p.q.i.bir) + =+ byf=(~(get by rop) p.q.i.bir) + ?^ byf + ?. =(`hoof`q.i.bir `hoof`p.u.byf) + (flaw cof [%leaf "structure mismatch: {<~[p.u.byf q.i.bir]>}"]~) + $(bir t.bir) + =+ bem=(hone ?:(p.i.bir %gate %core) %sur q.i.bir) + %+ cope (fade cof %hook bem) + |= [cof=cafe hyd=hood] + %+ cope (apex(zog goz, hol |, boy ~) cof hyd) + |= [cof=cafe sel=_..head] + ?. =(bil bil.sel) + (flaw cof [%leaf "structures cannot include libraries: {}"]~) + =. ..head + %= sel + boy ?: p.i.bir + boy + (welp boy [[[%cnzy p.q.i.bir] [%$ 1]] ~]) + zog zog + hol hol + rop %+ ~(put by (~(uni by rop) rop.sel)) + p.q.i.bir + [q.i.bir [%tssg (flop boy.sel)]] + == + ^^$(cof cof, bir t.bir) + +The processing of our structures is very similar to that of our +libraries. For clarity, we'll use many of the same phrases in describing +the parallel natures. First, we check to see if there are more +structures to process. If not, we're done, so we produce our context. + +Otherwise, we let `goz` be `zog` plus the current structure so that +while compiling the dependencies of this structure we don't later create +a circular dependency. We check next to see if this structure is alredy +in `rop`. If so, then we have already included this structure earlier, +so we check to see if this is the same version of the structure as we +included earlier. If so, we skip it. Else, we fail since we can't +include two different versions of a structure. + +If we haven't loaded this structure, then we call `++hone` to get the +beam where the file structure should be. If the loobean in the hoot is +true, then we're looking for a gate; otherwise, we're looking for a +core. We parse this file with `++fade`. + +Now, we recurse on this to compile the structure. During the recursion, +there we have threee changes. Frist, we let `zog` be `goz` so that we +don't create a circular dependency. Second, we let `hol` be false since +we do not allow horns in structures. Third, we let `boy` be null so that +we can isolate the new body twigs. + +Next, we reintegrate the new data into our context. We use the context +cretaed by the recursion with four changes. First, if we're including a +gate structure, then we reset the body to its original body. Else we put +on the top of our list of body twigs what is essentially a +`=+ structure-name` to take off the face of the structure. Second, we +reset `zog` to our old `zog`. Third, we reset `hol` to our old `hol`. +Finally, we put in `rop` the structure hoof and body (with all body +twiggs collected in a `=~`), keyed by the structure name. + +Finally, we recurse, processing the next structure in our list. + +This concludes our discussion of `++apex`. + + ++ abut :: generate + |= [cof=cafe hyd=hood] + ^- (bolt vase) + %+ cope (apex cof hyd) + |= [cof=cafe sel=_..abut] + =. ..abut sel + %+ cope (maim cof pit able) + |= [cof=cafe bax=vase] + %+ cope (chap cof bax [%fan fan.hyd]) + |= [cof=cafe gox=vase] + %+ cope (maim cof (slop gox bax) [%tssg (flop boy)]) + |= [cof=cafe fin=vase] + (fine cof fin) + +Returning to `++abut`, we have now processed the structures, libraries +and body twigs. Next, we slap our preamble (structures and libraries) +against zuse. First, we construct our preamble in `++able`. + + ++ able :: assemble preamble + ^- twig + :+ %tsgr + ?:(=(~ rop) [%$ 1] [%brcn (~(run by rop) |=([* a=twig] [%ash a]))]) + [%tssg (turn (flop lot) |=(a=term q:(need (~(get by bil) a))))] + +We first put the structures in `rop` into a single `|%` at the top and +`=>` it onto a `=~` of our libraries, in the reverse order that they +appear in `lot`. Thus, the structures are in a single core while the +libraries are in consecutive cores. + +We slap the preamble against zuse with `++maim`. + + ++ maim :: slap + |= [cof=cafe vax=vase gen=twig] + ^- (bolt vase) + %+ (clef %slap) (fine cof vax gen) + |= [cof=cafe vax=vase gen=twig] + =+ puz=(mule |.((~(mint ut p.vax) [%noun gen]))) + ?- -.puz + | (flaw cof p.puz) + & %+ (coup cof) (mock [q.vax q.p.puz] (mole ska)) + |= val=* + `vase`[p.p.puz val] + == + +Here we start to get into ford's caching system. We wrap our computation +in a call to `++clef` so that we only actually compute it if the result +is not already in our cache. First we'll discuss the computation, then +we'll discuss the caching system. + +We call `++mule` with a call to `++mint:ut` on the type of our subject +vase against the given twig. In other words, we're compiling the twig +with against the subject type in the given subject vase. + +If compilation fails, then we produce an error bolt with the produced +stack trace. Otherwise, we run the produced nock with `++mock` and our +sky function. We convert the produced toon to a bolt with `++coup` and +use the type from `puz` combined with the value from `mock` to produce +our vase. + +If this process seems harder than just calling `++slap`, it's because it +is. We have two requirements that `++slap` doesn't satisfy. First, we +want the to use an explicit sky function for use with `.^`. With +`++slap`, you get whatever sky function is available in the calling +context, which in ford is none. Second, we want to explicitly handle the +stack trace on failure. `++slap` would cause crash on failure. + +We haven't yet discussed either `++clef` or `++coup`. We'll start with +`++coup` to finish the discussion of the computation. + +\``++ coup :: toon to bolt |= cof=cafe |* [ton=toon fun=$+(* *)] :- p=cof ^= q ?- -.ton %2 [%2 p=p.ton] %0 [%0 p=*(set beam) q=(fun p.ton)] %1 ~& [%coup-need ((list path) p.ton)] =- ?- -.faw & [%1 p=(sa (turn p.faw |=(a=beam [a *(list tank)])))] | [%2 p=p.faw] == ^= faw |- ^- (each (list beam) (list tank)) ?~ p.ton [%& ~] =+ nex=$(p.ton t.p.ton) =+ pax=(path i.p.ton) ?~ pax [%| (smyt pax) ?:(?=(& -.nex) ~ p.nex)] =+ zis=(tome t.pax) ?~ zis [%| (smyt pax) ?:(?=(& -.nex) ~ p.nex)] ?- -.nex & [%& u.zis p.nex] | nex == ==` + +Recall that a toon is either a `%0` value, a `%1` block, or a `%2` +failure. Converting a `%2` toon failure into a `%2` bolt failure is +trivial. Converting a `%0` toon value into a `%0` bolt value is easy +since we assume there were no dependencies. Converting the blocks is +rather more difficult. + +To compute `faw`, we recurse through the list of paths in the `%1` toon. +At each one, we make sure with `++tome` that it is, in fact, a beam. If +so, then we check to see if the later paths succeed as well. If so, we +append the current path to the list of other paths. If not, we produce +the error message we got from processing the rest of the paths. If this +path is not a beam, then we fail, producing a list of tanks including +this path and, if later paths fail too, those paths as well. + +If some paths were not beams, then we produce a `%2` error bolt. If all +paths were correct, then we produce a `%1` blocking bolt. + +We will now discuss `++clef`. This is where the cache magic happens. + + ++ clef :: cache a result + |* sem=* + |* [hoc=(bolt) fun=(burg)] + ?- -.q.hoc + %2 hoc + %1 hoc + %0 + =^ cux p.hoc ((calk p.hoc) sem q.q.hoc) + ?~ cux + =+ nuf=(cope hoc fun) + ?- -.q.nuf + %2 nuf + %1 nuf + %0 + :- p=(came p.nuf `calx`[sem `calm`[now p.q.nuf] q.q.hoc q.q.nuf]) + q=q.nuf + == + [p=p.hoc q=[%0 p=p.q.hoc q=((calf sem) u.cux)]] + == + +If the value is already an error or a block, we just pass that through. +Otherwise, we look up the request in the cache with `++calk`. + + ++ calk :: cache lookup + |= a=cafe :: + |= [b=@tas c=*] :: + ^- [(unit calx) cafe] :: + =+ d=(~(get by q.a) [b c]) :: + ?~ d [~ a] :: + [d a(p (~(put in p.a) u.d))] :: + +When looking up something in the cache, we mark it if we find it. This +way, we have in our cache the set of all cache entries that have been +referenced. While we do not at present do anything with this data, it +should be used to clear out old and unused entries in the cache. + +Moving on in `++clef`, we check to see if we actually found anything. If +we didn't find a cache entry, then we run the computation in `fun`, and +examine its result. If it produced a `%2` error or `%1` block bolt, we +just pass that through. Otherwise, we produce both the value and an +updated cache with this new entry. We add the entry with `++came`. + + ++ came :: + |= [a=cafe b=calx] :: cache install + ^- cafe :: + a(q (~(put by q.a) [-.b q.b] b)) :: + +We key cache entries by the type of computation (`-:calx`) and the +inputs to the computation (`q:calc`). This just puts the cache line in +the cache at the correct key. + +Back in `++clef`, if we did find a cache entry, then we just produce the +value at that cache line. We convert the cache line into a value with +`++calf`. + + ++ calf :: reduce calx + |* sem=* :: a typesystem hack + |= cax=calx + ?+ sem !! + %hood ?>(?=(%hood -.cax) r.cax) + %slap ?>(?=(%slap -.cax) r.cax) + %slam ?>(?=(%slam -.cax) r.cax) + == + +This is simply a typesystem hack. Because the `sem` is passed in through +a wet gate, we know at type time which of the three cases will be +chosen. Thus, the correct type of the value in the cache line gets +passed through to the caller. This also depends on the fact that +`++clef` is wet. The type stuff here is mathematically interesting, but +the action is simple: we get the value from the cache line. + +This concludes our discussion of `++clef` and `++maim`. + +Back in `++abut`, recall that we processed the structures, libraries, +and body with `++apex`. Then, we slapped our preamble (structures and +libraries) against zuse with `++maim`. Next, we process our resources +with `++chap`. Note that we pass in the preamble so that we may refer to +anything in there in our resources. + +`++chap` is broken up into a different case for each horn. We'll go +through them one by one. + + ++ chap :: produce resources + |= [cof=cafe bax=vase hon=horn] + ^- (bolt vase) + ?- -.hon + %ape (maim cof bax p.hon) + +This is `/~`. We slap the twig against our context. + + %arg + %+ cope (maim cof bax p.hon) + |= [cof=cafe gat=vase] + (maul cof gat !>([how arg])) + +This is `/$`. We slap the twig against our context, which we expect to +produce a gate. We slam this gate with a sample of `how` and `arg`, +which is our location and the heel (virtual path extension). + +`++maul` is similar to `++maim`, but it slams instead of slaps. + + ++ maul :: slam + |= [cof=cafe gat=vase sam=vase] + ^- (bolt vase) + %+ (clef %slam) (fine cof gat sam) + |= [cof=cafe gat=vase sam=vase] + =+ top=(mule |.((slit p.gat p.sam))) + ?- -.top + | (flaw cof p.top) + & %+ (coup cof) (mong [q.gat q.sam] (mole ska)) + |= val=* + `vase`[p.top val] + == + +We cache slams exactly as we cache slaps. We use `++slit` to find the +type of the product of the slam given the types of the gate and the +sample. + +If this type fails, we produce the given stack trace as a `%2` error +bolt. Otherwise, we produce the top produced above combined with the +value we get from slamming the values in the vases with `++mong`. + +Back to `++chap`. + + %day (chad cof bax %dr p.hon) + +This is `/|`. We call `++chad` to convert textual names to relative +dates and process the next horn against each of the discovered paths. + + ++ chad :: atomic list + |= [cof=cafe bax=vase doe=term hon=horn] + ^- (bolt vase) + %+ cope ((lash (slat doe)) cof how) + |= [cof=cafe yep=(map ,@ span)] + =+ ^= poy ^- (list (pair ,@ span)) + %+ sort (~(tap by yep) ~) + |=([a=[@ *] b=[@ *]] (lth -.a -.b)) + %+ cope + |- ^- (bolt (list (pair ,@ vase))) + ?~ poy (fine cof ~) + %+ cope $(poy t.poy) + |= [cof=cafe nex=(list (pair ,@ vase))] + %+ cope (chap(s.how [q.i.poy s.how]) cof bax hon) + |= [cof=cafe elt=vase] + (fine cof [[p.i.poy elt] nex]) + |= [cof=cafe yal=(list (pair ,@ vase))] + %+ fine cof + |- ^- vase + ?~ yal [[%cube 0 [%atom %n]] 0] + (slop (slop [[%atom doe] p.i.yal] q.i.yal) $(yal t.yal)) + +First, we call `++lash` to parse the children of the current beam and +pick out those ones that are of the requested format. + + ++ lash :: atomic sequence + |= wox=$+(span (unit ,@)) + |= [cof=cafe bem=beam] + ^- (bolt (map ,@ span)) + %+ cope (lend cof bem) + |= [cof=cafe arc=arch] + (fine cof (lark wox arc)) + +First, we get the arch with `++lend`, as described above. We filter and +parse the child names with `++lark` according to the given parser +function. + +In `++chad`, this parser function is `(slat doe)`, which will parse a +cord into an atom of the requested odor. For `%day` the odor is for +relative dates. + +Thus, we now have a map from atoms of the given odor to the actual child +names. We next turn this map into a list and sort it in increasing order +by the atom. + +We next convert this list of pairs of atoms and spans to a list of pairs +of atoms and vases. We process the given horn once at every child beam, +producing the resource at that location. + +Finally, we convert this list of pairs of atoms and vases to a vase of a +list of pairs of atoms to (well-typed) values. Each entry in the list is +of type atom with the given odor combined with the type of the produced +vase. + +Back in `++chap`, we continue parsing resources. + + %dub + %+ cope $(hon q.hon) + |= [cof=cafe vax=vase] + (fine cof [[%face p.hon p.vax] q.vax]) + +This is `/=`. We process the given horn, giving us a vase. We put as a +face on the vase so that it may be referred to later by name. + + %fan + %+ cope + |- ^- (bolt (list vase)) + ?~ p.hon (fine cof ~) + %+ cope ^$(hon i.p.hon) + |= [cof=cafe vax=vase] + %+ cope ^$(cof cof, p.hon t.p.hon) + |= [cof=cafe tev=(list vase)] + (fine cof [vax tev]) + |= [cof=cafe tev=(list vase)] + %+ fine cof + |- ^- vase + ?~ tev [[%cube 0 [%atom %n]] 0] + (slop i.tev $(tev t.tev)) + +This is `/.`. We first process each of the child horns, producing a list +of vases. This is done by just recursing on `++chap`. Then, we simply +fold over this list to create a vase of the list of values. + + %for $(hon q.hon, s.how (weld (flop p.hon) s.how)) + +This is `/,`. We simply recurse on the horn with the given path welded +onto our current beam. + + %hub (chad cof bax %ud p.hon) + +This is `/@`. This is exactly like the processing of `%day` except we +expect the children to be named as unsigned integers rather than +relative dates. We process the horn at each of the children's locations +and produce a list of pairs of absolute dates and values. + + %man + |- ^- (bolt vase) + ?~ p.hon (fine cof [[%cube 0 [%atom %n]] 0]) + %+ cope $(p.hon l.p.hon) + |= [cof=cafe lef=vase] + %+ cope ^$(cof cof, p.hon r.p.hon) + |= [cof=cafe rig=vase] + %+ cope ^^^$(cof cof, hon q.n.p.hon) + |= [cof=cafe vax=vase] + %+ fine cof + %+ slop + (slop [[%atom %tas] p.n.p.hon] vax) + (slop lef rig) + +This is `/*`. We process each of the horns in the given map by recursion +through `++chap`. Once we have these vases, we create a vase of a map +from the given textual names to the produced values. + + %now (chad cof bax %da p.hon) + +This is `/&`. This is exactly like the processing of `%now` except we +expect the children to be names as absolute dates rather than relative +dates. We process the horn at each of the children's locations and +produce a list of pairs of absolute dates and values. + + %nap (chai cof bax p.hon) + +This is `/%`. Here, we process the horn at each of our children with +`++chai`. + + ++ chai :: atomic map + |= [cof=cafe bax=vase hon=horn] + ^- (bolt vase) + %+ cope (lend cof how) + |= [cof=cafe arc=arch] + %+ cope + |- ^- (bolt (map ,@ vase)) + ?~ r.arc (fine cof ~) + %+ cope $(r.arc l.r.arc) + |= [cof=cafe lef=(map ,@ vase)] + %+ cope `(bolt (map ,@ vase))`^$(cof cof, r.arc r.r.arc) + |= [cof=cafe rig=(map ,@ vase)] + %+ cope (chap(s.how [p.n.r.arc s.how]) cof bax hon) + |= [cof=cafe nod=vase] + (fine cof [[p.n.r.arc nod] lef rig]) + |= [cof=cafe doy=(map ,@ vase)] + %+ fine cof + |- ^- vase + ?~ doy [[%cube 0 [%atom %n]] 0] + %+ slop + (slop [[%atom %a] p.n.doy] q.n.doy) + (slop $(doy l.doy) $(doy r.doy)) + +We get the arch at our current beam with `++lend`. Then, we process the +horn at each of our children to give us a map of atoms to vases. +Finally, we convert that into a vase of a map of these atoms to the +values. This is very similar to `++chad` and the handling of `%man`. + + %see $(hon q.hon, how p.hon) + +This is `/:`. We process the given horn at the given beam. + + %saw + %+ cope $(hon q.hon) + |= [cof=cafe sam=vase] + %+ cope (maim cof bax p.hon) + |= [cof=cafe gat=vase] + (maul cof gat sam) + +This is `/;`. First, we process the given horn. Then, we slap the given +twig against our context to produce (hopefully) a gate. Finally, we slam +the vase we got from processing the horn against the gate. + + %sic + %+ cope $(hon q.hon) + |= [cof=cafe vax=vase] + %+ cope (maim cof bax [%bctr p.hon]) + |= [cof=cafe tug=vase] + ?. (~(nest ut p.tug) | p.vax) + (flaw cof [%leaf "type error: {} {}"]~) + (fine cof [p.tug q.vax]) + +This is `/^`. First, we process the given horn. Then, we slap the the +bunt of the given tile against our context. This will produce a vase +with the correct type. We test to see if this type nests within the type +of the vase we got from processing the horn. If so, we produce the value +from the horn along with the type from the tile. Otherwise, we produce a +`%2` error bolt. + + %toy (cope (make cof %bake p.hon how ~) feel) + == + +This is `/mark/`. Here, we simply run the `%bake` silk on the given +mark, producing a cage. We convert this cage into a vase with `++feel`, +which is exactly as simple as it sounds like it should be. + + ++ feel |=([a=cafe b=cage] (fine a q.b)) :: cage to vase + +This is trivial. + +We will discuss later `++make` and how `%bake` is processed. Suffice it +to say that baking a resource with a given mark gets the resource and +converts it, if necessary, to the requested mark. + +This concludes our discussion of `++chap`. + +We return once more to `++abut`. + + ++ abut :: generate + |= [cof=cafe hyd=hood] + ^- (bolt vase) + %+ cope (apex cof hyd) + |= [cof=cafe sel=_..abut] + =. ..abut sel + %+ cope (maim cof pit able) + |= [cof=cafe bax=vase] + %+ cope (chap cof bax [%fan fan.hyd]) + |= [cof=cafe gox=vase] + %+ cope (maim cof (slop gox bax) [%tssg (flop boy)]) + |= [cof=cafe fin=vase] + (fine cof fin) + +Recall that we processed our structures, libraries and body with +`++apex`. We slapped our structures and libraries against zuse with +`++maim`. We processed our resources with `++chap`. Now, all our body +twigs are collected in a `=~` and slapped against our structures, +libraries, and resources. This produces our final result. + +The hook file has been assembled. And there was great rejoicing. + +Lifecycle of a Kiss +------------------- + +We're now going to go through a series of lifecycle descriptions. When a +user of ford sends a kiss, it is one of a dozen different types of silk. +We'll go through each one, tracing through the flow of control of each +of these. + +First, though, we'll describe the common handling to all kisses. + +The silk in a `%exec` kiss to ford ends up in `++apex`, so we'll enter +the narrative here. + + ++ apex :: call + |= kus=(unit silk) + ^+ +> + ?~ kus + =+ nym=(~(get by dym.bay) hen) + ?~ nym :: XX should never + ~& [%ford-mystery hen] + +>.$ + =+ tas=(need (~(get by q.tad.bay) u.nym)) + amok:~(camo zo [u.nym tas]) + =+ num=p.tad.bay + ?< (~(has by dym.bay) hen) + =: p.tad.bay +(p.tad.bay) + dym.bay (~(put by dym.bay) hen num) + == + ~(exec zo [num `task`[hen u.kus 0 ~]]) + +Recall that a `%exec` kiss actually sends a unit silk. If it's null, +we're trying to cancel the request. We first look up the task number +keyed by duct. If we don't find it, then we're trying to cancel a +request that either was never started or has already completed. We print +out `%ford-mystery` and do nothing. If we do find the task number, then +we look up the task from it, call `++camo:zo` to cancel pending +requests, and call `++amok:zo` to remove the task from our task lists. + + ++ camo :: stop requests + ^+ . + =+ kiz=(~(tap by q.kig) *(list ,[p=@ud q=beam])) + |- ^+ +> + ?~ kiz +> + %= $ + kiz t.kiz + mow :_ mow + :- hen + :^ %pass [(scot %p our) (scot %ud num) (scot %ud p.i.kiz) ~] + %c + [%warp [our p.q.i.kiz] q.q.i.kiz ~] + == + +Our list of blocks is in `q.kig`, so we iterate over it, cancelling our +pending requests for each block. Our requests are all to clay, so we +need only to send `%warp` kisses with a null instead of a rave. + + ++ amok + %_ ..zo + q.tad.bay (~(del by q.tad.bay) num) + dym.bay (~(del by dym.bay) nah) + == + +We remove the task number from the map of numbers to tasks and the duct +from the map of ducts to task numbers. + +Back in `++apex`, if we were given a silk, we need to process it. We add +the task to our maps, increment the next task number, and call +`++exec:zo` on the new task. + + ++ exec :: execute app + ^+ ..zo + ?: !=(~ q.kig) ..zo + |- ^+ ..zo + =+ bot=(make [~ jav.bay] kas) + =. ..exec (dash p.bot) + ?- -.q.bot + %0 amok:(expo [%made %& p.q.bot q.q.bot]) + %2 amok:(expo [%made %| p.q.bot]) + %1 =+ zuk=(~(tap by p.q.bot) ~) + =< abet + |- ^+ ..exec + ?~ zuk ..exec + =+ foo=`_..exec`(camp %x `beam`p.i.zuk) + $(zuk t.zuk, ..exec foo) + == + +If we're still blocked on something in `q.kig`, we don't do anything. + +Otherwise, we try to process the silk with `++make`. `++make` handles +each individual request and will be the entire focus of the remainder of +this doc after this section. It produces a bolt of a cage. + +We put the new cache in our state with `++dash`. + + ++ dash :: process cache + |= cof=cafe + ^+ +> + %_(+> jav.bay q.cof) + +The cache is put in the baby so that it gets stored across calls to +ford. + +In `++exec`, we process the bolt in three different ways according to +the type of bolt produced. If we produced a `%0` value bolt, we use +`++expo` to give the produced value and set of dependencies as a `%made` +gift, and we remove ourselves from the task list with `++amok`. + + ++ expo :: return gift + |= gef=gift + %_(+> mow :_(mow [hen %give gef])) + +We simply push the gift onto our list of moves. + +In `++exec`, if we produced a `%2` error bolt, we produce a `%made` gift +with the stack trace. + +If we produced a `%1` block bolt, we iterate through each of the blocks +and call `++camp` to produce a clay request for the resource. + + ++ camp :: request a file + |= [ren=care bem=beam] + ^+ +> + %= +> + kig [+(p.kig) (~(put by q.kig) p.kig bem)] + mow :_ mow + :- hen + :^ %pass [(scot %p our) (scot %ud num) (scot %ud p.kig) ~] + %c + [%warp [our p.bem] q.bem [~ %& %x r.bem s.bem]] + == + +We put the resource in our block list in `q.kig` so that we save the +fact that we're blocked. We then produce the `%warp` request to clay for +the resource. Our request path has the format +\`/[our-ship]/[task-number]/[block-number]'. + +We'll now describe how each of the individual silks are processed in +`++make`. + +Lifecycle of a Cell +------------------- + + ^ + %. [cof p.kas q.kas] + ;~ cope + ;~ coax + |=([cof=cafe p=silk q=silk] ^$(cof cof, kas p.kas)) + |=([cof=cafe p=silk q=silk] ^$(cof cof, kas q.kas)) + == + :: + |= [cof=cafe bor=cage heg=cage] ^- (bolt cage) + [p=cof q=[%0 ~ [%$ (slop q.bor q.heg)]]] + == + +Silks autocons. The product of a cell of silks is a cell of the products +of the silks, so we evaluate the two silks in parallel with `++coax` and +slop together the results in a cell vase. We mark the product with `%$`, +which means we know no more mark information than that it is a noun. + + ++ coax :: bolt across + |* [hoc=(bolt) fun=(burg)] + ?- -.q.hoc + %0 =+ nuf=$:fun(..+<- p.hoc) + :- p=p.nuf + ^= q + ?- -.q.nuf + %0 [%0 p=(grom p.q.hoc p.q.nuf) q=[q.q.hoc q.q.nuf]] + %1 q.nuf + %2 q.nuf + == + %1 =+ nuf=$:fun(..+<- p.hoc) + :- p=p.nuf + ^= q + ?- -.q.nuf + %0 q.hoc + %1 [%1 p=(grom p.q.nuf p.q.hoc)] + %2 q.nuf + == + %2 hoc + == + +If the first bolt is a value, we evaluate the burg to get the next bolt. +If that also produces a value, we merge the dependency sets and produce +a cell of the two values. Otherwise, we produce the block or error of +the second bolt. + +If the first bolt is a block, we evaluate the burg to get the next bolt. +If that produces a value, we just produce the block. If it produces a +block, we merge the two block sets. If it produces an error, we produce +that error. + +If the first bolt is already an error, we just pass that through. + +Note that `++coax` (and, indeed, `++cope`) is reasonable to use with +`;~`. + +Lifecycle of a `%bake` +---------------------- + + %bake + %+ cool |.(leaf/"ford: bake {} {<(tope q.kas)>}") + %+ cope (lima cof p.kas q.kas r.kas) + |= [cof=cafe vux=(unit vase)] + ?~ vux + (flaw cof (smyt (tope q.kas)) ~) + (fine cof [p.kas u.vux]) + +This is one of the most critical silks. We are going to functionally +produce the hook file at the given beam with the given heel. The result +will be of the correct mark, even if we need to run conversion +functions. The functionality is encapsulated in `++lime`. If it produces +null, then we produce an error. Otherwise, we take the vase produced and +give it the correct mark. + + ++ lima :: load at depth + |= [cof=cafe for=mark bem=beam arg=heel] + ^- (bolt (unit vase)) + %+ cope (lend cof bem) + |= [cof=cafe arc=arch] + ^- (bolt (unit vase)) + ?: (~(has by r.arc) for) + (lace cof for bem(s [for s.bem]) arg) + =+ haz=(turn (~(tap by r.arc) ~) |=([a=@tas b=~] a)) + ?~ haz (fine cof ~) + %+ cope (lion cof for -.bem haz) + |= [cof=cafe wuy=(unit (list ,@tas))] + ?~ wuy (fine cof ~) + ?> ?=(^ u.wuy) + %+ cope (make cof %bake i.u.wuy bem arg) + |= [cof=cafe hoc=cage] + %+ cope (lope cof i.u.wuy t.u.wuy -.bem q.hoc) + |= [cof=cafe vax=vase] + (fine cof ~ vax) + +First, we load the arch at the given beam with `++lend`. If we have a +child named the mark, our job is straightforward, so we go ahead and +load that with `++lace`. + +Otherwise, we iterate through our children. If we have no children, we +produce null, signifying that we didn't find any way to convert to the +requested mark. Otherwise, we call `++lion` to find a translation path +from one of the available marks into the target mark. We recursively +bake the child that has a path to the target mark, and then we call +`++lope` to translate this mark into the target mark. + +We'll first discuss the direct case of when one of our children is of +the correct mark. + + ++ lace :: load and check + |= [cof=cafe for=mark bem=beam arg=heel] + ^- (bolt (unit vase)) + =+ bek=`beak`[p.bem q.bem r.bem] + %+ cope (lend cof bem) + |= [cof=cafe arc=arch] + ?^ q.arc + (cope (cope (liar cof bem) (lake for bek)) fest) + ?: (~(has by r.arc) %hook) + %+ cope (fade cof %hook bem) + |= [cof=cafe hyd=hood] + (cope (cope (abut:(meow bem arg) cof hyd) (lake for bek)) fest) + (fine cof ~) + +First, we get the arch at the given beam with `++lend`. If this is a +file, we load the file with `++liar` and coerce the type with `++lake`. +Otherwise, we check to see if we have a hook file here. If so, we parse +it with `++fade`, compile it with `++abut:meow`, and coerce the type +with `++lake`. + +Otherwise, there is no way to translate this, so we produce null. + +`++fest` is one line, so we'll get that one out of the way first. + + ++ fest |*([a=cafe b=*] (fine a [~ u=b])) :: bolt to unit + +This is just `++some` for bolts. + +We've delayed the discussion of `++fade` far too many times. It's not +complicated, we just wanted to spare a premature discussion of `++make` +and the `%bake` silk. We 're now able to discuss everything in `++fade` +with ease. + + ++ fade :: compile to hood + |= [cof=cafe for=mark bem=beam] + ^- (bolt hood) + %+ cool |.(leaf/"ford: fade {<[(tope bem)]>}") + %+ cope (make cof [%bake for bem ~]) + |= [cof=cafe cay=cage] + %+ (clef %hood) (fine cof bem cay) + ^- (burg (pair beam cage) hood) + |= [cof=cafe bum=beam cay=cage] + =+ rul=(fair bem) + ?. ?=(@ q.q.cay) + (flaw cof ~) + =+ vex=((full rul) [[1 1] (trip q.q.cay)]) + ?~ q.vex + (flaw cof [%leaf "syntax error: {} {}"] ~) + (fine cof p.u.q.vex) + +We first push a line onto a stack trace to say that we're parsing into a +hood file. + +We bake the given beam with the given mark and no heel. Recall that +baking gate, core, door, hoon, and hook files produces simply an atom of +the text. We check to make sure that our value is an atom, failing +otherwise. + +The parsing step is run within `++clef` so that the result is cached. We +call `++fair` with the current beam to generate the parsing rule, and we +parse the file. If parsing fails, we fail giving a syntax error with the +line and column number. Otherwise, we produce the value. + + ++ liar :: load vase + |= [cof=cafe bem=beam] + ^- (bolt vase) + =+ von=(ska %cx (tope bem)) + ?~ von + [p=*cafe q=[%1 [[bem ~] ~ ~]]] + ?~ u.von + (flaw cof (smyt (tope bem)) ~) + (fine cof ?^(u.u.von [%cell %noun %noun] [%atom %$]) u.u.von) + +This takes a beam and loads the file at that location. If our sky +function produces null, that means the resource is currently +unavailable, so we block on it. If it produces `[~ ~]`, that means our +resource is permanently unavailable, so we produce an error. Otherwise, +we produce the value there with a type of either a cell of two nouns or +an atom, depending on whether the value is a cell or not. + +Back in `++lima`, recall that we call `++lion` to find a translation +path. + + ++ lion :: translation search + |= [cof=cafe too=@tas bek=beak fro=(list ,@tas)] + ^- (bolt (unit (list ,@tas))) + =| war=(set ,@tas) + =< -:(apex (fine cof fro)) + |% + ++ apex + |= rof=(bolt (list ,@tas)) + ^- [(bolt (unit (list ,@tas))) _+>] + ?. ?=(%0 -.q.rof) [rof +>.$] + ?~ q.q.rof + [[p.rof [%0 p.q.rof ~]] +>.$] + =^ orf +>.$ (apse cof i.q.q.rof) + ?. ?=(%0 -.q.orf) + [orf +>.$] + ?~ q.q.orf + $(cof p.orf, q.q.rof t.q.q.rof) + [[p.orf [%0 (grom p.q.rof p.q.orf) q.q.orf]] +>.$] + :: + ++ apse + |= [cof=cafe for=@tas] + ^- [(bolt (unit (list ,@tas))) _+>] + ?: =(for too) + [(fine cof [~ too ~]) +>.$] + ?: (~(has in war) for) [(fine cof ~) +>] + =. war (~(put in war) for) + =^ hoc +>.$ (apex (lily cof for bek)) + :_ +>.$ + %+ cope hoc + |= [cof=cafe ked=(unit (list ,@tas))] + (fine cof ?~(ked ~ [~ for u.ked])) + -- + +At a high level, we have `++apex` and `++apse`. `++apex` takes a list of +marks to try in succession until we find one that can be translated into +the target mark. On each one, it calls `++apse`, which takes a single +mark and tries to find a translation path from this mark to the target. +To do this, it sees which marks we know how to directly translate to, +and calls `++apex` on this list. The result of this mututal recursion is +a depth-first search of the translation graph to find the target mark. +Since the translation graph is not necessarily acyclic, we maintain a +set of marks that we've already tried. + +We kick off our search in `++apex`, starting with the given initial list +of marks that we know how to get to. + +If `++apex` is called with a bolt other than a `%0` value bolt, we +simply produce it. Otherwise, we check to see if the list of available +marks to investigate is null. If so, then we're done, so we produce a +`%0` bolt with a null list of accessible marks. + +Otherwise, we process this next mark with `++apse`, which will produce a +possible list of marks from this one to the target mark. If it fails to +produce a `%0` bolt, we just produce that. Otherwise, if it produces +null, we can't get to our target through this mark, so we move on to the +next one. + +If it doesn't produce null, then we have successfully found a +translation path, so we produce it. + +In `++apse`, we first test to see if we've arrived at the target path. +If so, we're done, so we produce a list including just ourself. +Otherwise, we check to see if we've already tried this mark. If so, we +know we can't succeed here, so we produce null. Otherwise, we put +ourselves in the set of already-tried marks, and we move on. + +We call `++lily` to get the list of marks we can translate this one +into. + + ++ lily :: translation targets + |= [cof=cafe for=mark bek=beak] + ^- (bolt (list ,@tas)) + =+ raf=(fang cof for bek) + ?: =(%2 -.q.raf) (fine p.raf ~) + %+ cope raf + |= [cof=cafe vax=vase] + %+ fine cof + %+ weld + ^- (list ,@tas) + ?. (slab %garb p.vax) ~ + =+ gav=((soft (list ,@tas)) q:(slap vax [%cnzy %garb])) + ?~(gav ~ u.gav) + ?. (slab %grow p.vax) ~ + =+ gow=(slap vax [%cnzy %grow]) + (sloe p.gow) + +We call `++fang` to get the mark definition door. This is documented +under `%vale`. If getting the mark fails, we produce null because we +can't translate a non-existent mark into anything. + +Otherwise, we examine the door. The door may have a `++garb`, which is +simply a list of marks which know how to translate from the current one. +There must be a corresponding `++grab` in the definition of the other +mark, though we don't check that here. + +The door may also have a `++grow`, which defines how to translate this +mark into another one. Each arm in `++grow` is the name of a mark we can +translate into. The call to `++sloe` simply produces a list of arm names +in `++grow`. + +Back in `++apse:lion`, we take the list of translation targets we just +found and call `++apex` on it. If we got back a null, we produce a null; +otherwise, we produce the list of marks we got back plus the current +mark. + +This concludes our discussion of `++lion`. + +The final piece of `++lima` is `++lope`, which performs the actual +translation along the path we just computed. + + ++ lope :: translation pipe + |= [cof=cafe for=mark yaw=(list mark) bek=beak vax=vase] + ^- (bolt vase) + ?~ yaw (fine cof vax) + %+ cope (link cof i.yaw for bek vax) + |= [cof=cafe yed=vase] + ^$(cof cof, for i.yaw, yaw t.yaw, vax yed) + +We iterate through our list, calling `++link` on every adjacent pair of +marks, translating from one mark to the next until we finish the list of +marks. A call to `++link` is equivalent to a `%cast` silk, so we +document it there. After we've called performed every step in the +translation pipeline, we're done. + +Lifecycle of a `%boil` +---------------------- + + %boil + %+ cool |.(leaf/"ford: boil {} {<(tope q.kas)>} {}") + %+ cope (lamp cof q.kas) + |= [cof=cafe bem=beam] + %+ cope (lime cof p.kas bem r.kas) + |= [cof=cafe vax=vase] + (fine cof `cage`[p.kas vax]) + +At a high level, we try to bake at the given beam, and if it fails, we +go up a level and try again. This is the usual semantics of ford, and +this should nearly always be preferred over directly baking. + +First, we normalize the version case to a number with `++lamp`. This +allows caching to be based on revision number rather than something more +ephemeral like a particular time. + + ++ lamp :: normalize version + |= [cof=cafe bem=beam] + ^- (bolt beam) + =+ von=(ska %cw (tope bem(s ~))) + ?~ von [p=cof q=[%1 [bem ~] ~ ~]] + (fine cof bem(r [%ud ((hard ,@) (need u.von))])) + +We call the sky function with `%cw`, asking clay for the revision number +at this case. If the case refers to a revision that isn't there yet, we +produce a `%1` blocking bolt. Otherwise, we require that the value exist +and that it's a number, both of which are guaranteed by clay. We produce +this number. + +Next for `%boil` we call `++lime` to try to load the beam. + + ++ lime :: load beam + |= [cof=cafe for=mark bem=beam arg=heel] + =+ [mob=bem mer=(flop arg)] + |- ^- (bolt vase) + %+ cope (lima cof for mob (flop mer)) + |= [cof=cafe vux=(unit vase)] + ?^ vux (fine cof u.vux) + ?~ s.mob + (flaw cof (smyt (tope bem)) ~) + ^$(s.mob t.s.mob, mer [i.s.mob mer]) + +We start at the given beam and try to bake it. If it succeeds, we're +good. Otherwise, we pop off the top level of the path and put it in our +heel (virtual path extension). We do this recursively until either we +find something we can bake or we've gone all the way up to the root path +of the desk, in which case we fail. + +Lifecycle of a `%call` +---------------------- + + %call + %+ cool |.(leaf/"ford: call {<`@p`(mug kas)>}") + %. [cof p.kas q.kas] + ;~ cope + ;~ coax + |=([cof=cafe p=silk q=silk] ^$(cof cof, kas p)) + |=([cof=cafe p=silk q=silk] ^$(cof cof, kas q)) + == + :: + |= [cof=cafe gat=cage sam=cage] + (maul cof q.gat q.sam) + :: + |= [cof=cafe vax=vase] + (fine cof %noun vax) + == + +This is slam for silks. We process both of the given silks in parallel +with `++coax`. We then slam the two produced vases together with +`++maul` and mark the produced vase with `%noun` since we don't know any +more specific mark. + +`++coax` is documented under Lifecycle of a Cell. + +Lifecycle of a `%cast` +---------------------- + + %cast + %+ cool |.(leaf/"ford: cast {}") + %+ cope $(kas q.kas) + |= [cof=cafe cay=cage] + %+ cope (link cof p.kas p.cay [our %main %da now] q.cay) + |= [cof=cafe vax=vase] + (fine cof [p.kas vax]) + +This is a request to convert data of one mark to another mark directly. +We evaluate the given silk and pass the result into `++link`, which +performs the actual translation. Note that this will not search for +indirect conversion paths, so the conversion must be defined either in +the `++grow` of the given mark or the `++grab` of the target mark. + + ++ link :: translate + |= [cof=cafe too=mark for=mark bek=beak vax=vase] + ^- (bolt vase) + ?: =(too for) (fine cof vax) + ?: |(=(%noun for) =(%$ for)) + ((lake too bek) cof vax) + %+ cope (fang cof for bek) + |= [cof=cafe pro=vase] + ?: &((slab %grow p.pro) (slab too p:(slap pro [%cnzy %grow]))) + %+ cope (keel cof pro [[%& 6]~ vax]~) + |= [cof=cafe pox=vase] + (maim cof pox [%tsgr [%cnzy %grow] [%cnzy too]]) + %+ cope (fang cof too bek) + |= [cof=cafe pro=vase] + =+ ^= zat ^- (unit vase) + ?. (slab %grab p.pro) ~ + =+ gab=(slap pro [%cnzy %grab]) + ?. (slab for p.gab) ~ + `(slap gab [%cnzy for]) + ?~ zat + (flaw cof [%leaf "ford: no link: {<[for too]>}"]~) + (maul cof u.zat vax) + +This performs one step in the translation pipeline. If the given and +target marks are the same, we're done. If we're translating from a noun +or the empty mark, we coerce with `++lake` (documented in `%vale`). +Otherwise, we're translating from a user-defined mark. + +We load the definition of the given mark with `++fang`, and we check to +see if it has an arm in `++grow` named the target mark. If so, we place +our data in the sample of the door with `++keel` and slap the arm. +`++keel` is equivalent to a `%mute` silk, so we document it there. + +If there is no arm in `++grow` of the given mark named the target mark, +we suppose there must be an arm in `++grab` of the target mark named the +given mark. We get the definition of the target mark and check to see if +it has the required arm, failing if it doesn't. Finally, we slam the +data against the correct arm, producing the translated data. + +If you're confused as to why the handling of `++grow` and `++grab` look +superficially so different, remember that the correct arm in `++grow` +does not have a sample while the one in `++grab` does. This means they +must be called rather differently. + +Lifecycle of a `%diff` +---------------------- + + %diff + %+ cool |.(leaf/"ford: diff {<`@p`(mug p.kas)>} {<`@p`(mug q.kas)>}") + (diff cof p.kas q.kas) + +We push debug information onto the trace and go right to `++diff`. + + ++ diff + |= [cof=cafe kas=silk kos=silk] + ^- (bolt cage) + %. [cof kas kos] + ;~ cope + ;~ coax + |=([cof=cafe p=silk q=silk] (make cof p)) + |=([cof=cafe p=silk q=silk] (make cof q)) + == + |= [cof=cafe cay=cage coy=cage] + +First, we process the two given silks to get our arguments. + + ?. =(p.cay p.coy) + %+ flaw cof :_ ~ + leaf/"diff on data of different marks: {(trip p.cay)} {(trip p.coy)}" + +If the two cages have different marks, then we can't diff them, so we +complain. + + %+ cope (fang cof p.cay [our %main %da now]) + |= [cof=cafe pro=vase] + +We pull in the relevant mark's definition. + + ?. (slab %grad p.pro) + (flaw cof leaf/"no ++grad" ~) + =+ gar=(slap pro [%cnzy %grad]) + ?. (slab %form p.gar) + ?. (slab %sted p.gar) + (flaw cof leaf/"no ++form:grad nor ++sted:grad" ~) + =+ for=((soft ,@tas) q:(slap gar [%cnzy %sted])) + ?~ for + (flaw cof leaf/"bad ++sted:grad" ~) + (make cof %diff [%cast u.for kas] [%cast u.for kos]) + +If there's no `++grad`, we complain. If there's no `++form:grad`, then +we look for a `++sted:grad`. If we can't find either, or if +`++sted:grad` isn't a term, then we complain. If `++sted:grad` exists +and is a term, then it represents the mark we should use as a proxy to +get our diff. So, we cast both our given cages to the new mark and start +the dance again. + + ?. (slab %diff p.gar) + (flaw cof leaf/"no ++diff:grad" ~) + +Otherwise, we expect a `++diff:grad`. + + %+ cope (keel cof pro [[%& 6]~ q.cay]~) + |= [cof=cafe pox=vase] + +We put the first cage's data into the sample of the given mark's +definition. + + %+ cope + %^ maul cof + (slap (slap pox [%cnzy %grad]) [%cnzy %diff]) + q.coy + |= [cof=cafe dif=vase] + +We run `++diff:grad` with a sample of the second cage's data. + + =+ for=((soft ,@tas) q:(slap gar [%cnzy %form])) + ?~ for + (flaw cof leaf/"bad ++form:grad" ~) + (fine cof u.for dif) + == + +We check that `++form:grad` exists, and we tag the result with it to +give the final cage. + +Lifecycle of a `%done` +---------------------- + + %done [cof %0 p.kas q.kas] + +This is trivial. We simply produce the given cage with the given set of +dependencies. This is used when we already have a cage that we want to +insert into another silk that requires a silk argument. It's analogous +to the return operator in a monad -- which makes it sound way more +complicated than it is. + +Lifecycle of a `%dude` +---------------------- + + %dude (cool |.(p.kas) $(kas q.kas)) + +This simply puts a given tank on the stack trace if the given silk +produces an error. This is implemented as a simple call to `++cool`. + +Lifecycle of a `%dune` +---------------------- + + %dune + ?~ q.kas [cof [%2 [%leaf "no data"]~]] + $(kas [%done p.kas u.q.kas]) + +This is a sort of a `++need` for silks. If there is no data in the unit +cage, we produce an error. Else, we simply produce the data in the cage. + +Lifcycle of a `%mute` +--------------------- + + %mute (kale cof p.kas q.kas) + +This mutates a silk by putting the values of other silks at particular +axes. This is useful in, for example, replacing the sample of the door +in a mark definition. + + ++ kale :: mutate + |= [cof=cafe kas=silk muy=(list (pair wing silk))] + ^- (bolt cage) + %+ cope + |- ^- (bolt (list (pair wing vase))) + ?~ muy (fine cof ~) + %+ cope (make cof q.i.muy) + |= [cof=cafe cay=cage] + %+ cope ^$(muy t.muy) + |= [cof=cafe rex=(list (pair wing vase))] + (fine cof [[p.i.muy q.cay] rex]) + |= [cof=cafe yom=(list (pair wing vase))] + %+ cope (make cof kas) + |= [cof=cafe cay=cage] + %+ cope (keel cof q.cay yom) + |= [cof=cafe vax=vase] + (fine cof p.cay vax) + +First, we process each of the silks by calling `++make` on them. We pass +the resultant vase and list of pairs of wings and silks to `++keel` to +do the actual mutation. We assume the mutation doesn't change the mark +of the main silk, so we mark the produced vase with the original mark. + + ++ keel :: apply mutations + |= [cof=cafe suh=vase yom=(list (pair wing vase))] + ^- (bolt vase) + %^ maim cof + %+ slop suh + |- ^- vase + ?~ yom [[%atom %n] ~] + (slop q.i.yom $(yom t.yom)) + ^- twig + :+ %cncb [%& 2]~ + =+ axe=3 + |- ^- (list (pair wing twig)) + ?~ yom ~ + :- [p.i.yom [%$ (peg axe 2)]] + $(yom t.yom, axe (peg axe 3)) + +We first put the vases together in one big tuple starting with the +subject and going through the mutations. We slap against this tuple a +`%_` twig we directly construct. Since a `%_` twig takes a list of pairs +of wings and twigs, we simply have to generate twigs referring to the +correct axes in the subject. This is very easy since we just recur on +axis 3 of whatever axis we were already at. + +Note the use of `%_` instead of `%=` enforces that our mutations don't +change the type of the subject, which justifies our use of the original +mark. + +Lifecycle of a `%pact` +---------------------- + + %pact + %+ cool |.(leaf/"ford: pact {<`@p`(mug p.kas)>} {<`@p`(mug q.kas)>}") + (pact cof p.kas q.kas) + +We push debug information onto the trace and go right to `++pact`. + + ++ pact :: patch + |= [cof=cafe kas=silk kos=silk] + ^- (bolt cage) + %. [cof kas kos] + ;~ cope + ;~ coax + |=([cof=cafe p=silk q=silk] (make cof p)) + |=([cof=cafe p=silk q=silk] (make cof q)) + == + |= [cof=cafe cay=cage coy=cage] + +First, we process the two given silks to get our arguments. + + %+ cope (fang cof p.cay [our %main %da now]) + |= [cof=cafe pro=vase] + +We pull in the relevant mark's definition. + + ?. (slab %grad p.pro) + (flaw cof leaf/"no ++grad" ~) + =+ gar=(slap pro [%cnzy %grad]) + ?. (slab %form p.gar) + ?. (slab %sted p.gar) + (flaw cof leaf/"no ++form:grad nor ++sted:grad" ~) + =+ for=((soft ,@tas) q:(slap gar [%cnzy %sted])) + ?~ for + (flaw cof leaf/"bad ++sted:grad" ~) + (make cof %cast p.cay %pact [%cast u.for kas] kos) + +If there's no `++grad`, we complain. If there's no `++form:grad`, then +we look for a `++sted:grad`. If we can't find either, or if +`++sted:grad` isn't a term, then we complain. If `++sted:grad` exists +and is a term, then it represents the mark we should use as a proxy to +get our diff. So, we cast the first argument to the new mark, then try +to patch. Afterward, we cast the result back to the original mark. + + =+ for=((soft ,@tas) q:(slap gar [%cnzy %form])) + ?~ for + (flaw cof leaf/"bad ++form:grad" ~) + ?. =(u.for p.coy) + %+ flaw cof :_ ~ + =< leaf/"pact on data with wrong form: {-} {+<} {+>}" + [(trip p.cay) (trip u.for) (trip p.coy)] + +If `++form:grad` isn't a term, or else our second argument isn't of that +mark, we complain. + + ?. (slab %pact p.gar) + (flaw cof leaf/"no ++pact:grad" ~) + +If we don't have a `++pact:grad`, we complain. + + %+ cope (keel cof pro [[%& 6]~ q.cay]~) + |= [cof=cafe pox=vase] + +We put the first cage's data into the sample of the given mark's +definition. + + %+ cope + %^ maul cof + (slap (slap pox [%cnzy %grad]) [%cnzy %pact]) + q.coy + |= [cof=cafe pat=vase] + +We run `++pact:grad` with a sample of the second cage's data, which is +the diff. + + (fine cof p.cay pat) + == + +We tag the result with the mark of our first argument. + +Lifecycle of a `%plan` +---------------------- + + %plan + %+ cope (abut:(meow p.kas q.kas) cof r.kas) + |= [cof=cafe vax=vase] + (fine cof %noun vax) + +This is a direct request to compile a hood at a given beam with a heel +of the given path. We comply by calling `++abut` with the given +arguments and producing the vase with a mark of `%noun`. + +Lifecycle of a `%reef` +---------------------- + + %reef (fine cof %noun pit) + +This is one of the simplest silks. We simply produce our context, which +is zuse compiled against hoon. The mark is a `%noun`. + +Lifcycle of a `%ride` +--------------------- + + %ride + %+ cool |.(leaf/"ford: ride {<`@p`(mug kas)>}") + %+ cope $(kas q.kas) + |= [cof=cafe cay=cage] + %+ cope (maim cof q.cay p.kas) + |= [cof=cafe vax=vase] + (fine cof %noun vax) + +This slaps evaluates the given silk, then it slaps the result against +the given twig. Since we don't know what of what mark (if any) is the +result, we give it a mark of `%noun`. + +Lifecycle of a `%vale` +---------------------- + + %vale + %+ cool |.(leaf/"ford: vale {} {} {<`@p`(mug r.kas)>}") + %+ cope (lave cof p.kas q.kas r.kas) + |= [cof=cafe vax=vase] + (fine cof `cage`[p.kas vax]) + +This checks whether given data is of the given mark. If we don't have +the definition of the mark, we check the given ship for it. + +We call `++lave` to perform the check, producing a vase. We produce this +vase tagged with the given mark. + + ++ lave :: validate + |= [cof=cafe for=mark his=ship som=*] + ^- (bolt vase) + ((lake for [our %main [%da now]]) cof [%noun som]) + +This is a thinly-veiled wrapper over `++lake`. Note that, contrary to +documented opinion, we do not in fact check the other ship's definition +of a mark. This is likely a bug. + +At any rate, `++lake` coerces a noun into the correct type for a mark. + + ++ lake :: check/coerce + |= [for=mark bek=beak] + |= [cof=cafe sam=vase] + ^- (bolt vase) + %+ cool |.(leaf/"ford: check {<[for bek `@p`(mug q.sam)]>}") + ?: ?=(?(%gate %core %door %hoon %hook) for) + :: ~& [%lake-easy for bek] + (fine cof sam) + %+ cope (fang cof for bek) + |= [cof=cafe tux=vase] + =+ bob=(slot 6 tux) + ?: (~(nest ut p.bob) | p.sam) + (fine cof sam) + ?. (slab %grab p.tux) + (flaw cof [%leaf "ford: no grab: {<[for bek]>}"]~) + =+ gab=(slap tux [%cnzy %grab]) + ?. (slab %noun p.gab) + (flaw cof [%leaf "ford: no noun: {<[for bek]>}"]~) + %+ cope (maul cof (slap gab [%cnzy %noun]) [%noun q.sam]) + |= [cof=cafe pro=vase] + ?: =(+<.q.pro q.sam) + (fine cof (slot 6 pro)) + (flaw cof [%leaf "ford: invalid content: {<[for bek]>}"]~) + +This is going to coerce the sample into the correct type for the mark. +First, we push a line onto the stack trace saying that we're checking +the type. If the requested mark is a gate, core, door, hoon, or hook, +then we don't do any more type information than just saying it's a noun, +so we're done. + +Otherwise, we get the mark definition from our `/=main=/mar` directory +with `++fang`, which we'll describe below. + +We check to see if our sample type nests within the type of the sample +to the door. If so, then we're already of the correct type, so we're +done. + +Otherwise, we check to see if there's a `++grab` in the door, and a +`++noun` in the `++grab`. If not, there's no way we can translate to +this mark, so we fail. + +If we have everything we need, we slam our sample (typed as a noun) +against the `++noun` in `++grab`. If the sample of the door is the same +as our sample, then the check succeeded, so we produce the well-typed +sample of the door. Otherwise, we fail. + + ++ fang :: protocol door + |= [cof=cafe for=mark bek=beak] + ^- (bolt vase) + =+ pax=/door/[for]/mar + =+ ^= bem ^- beam + :_ pax + ?: =(p.bek our) bek + =+ oak=[our %main %da now] + ?. =(~ (ska %cy (tope [oak pax]))) oak + bek + (cope (fade cof %hook bem) abut:(meow bem ~)) + +A mark's definition is generally in +`/=main=/mar/[mark-name]/door/hook'. If we don't find it there, we look in`/[given-beak]/mar/[mark-name]/door/hook'. +We parse the mark definition with `++fade` and assemble it with +`++abut:meow`. `++fade` is defined under the `%bake` silk. diff --git a/docs/pub/doc/arvo/gall.md b/docs/pub/doc/arvo/gall.md new file mode 100644 index 0000000000..523cf2fd68 --- /dev/null +++ b/docs/pub/doc/arvo/gall.md @@ -0,0 +1,161 @@ +
+ +`%gall` +======= + +`%gall` manages our userspace applications. + +It allows applications and vanes to send messages to applications and +subscribe to data streams. This requires `%gall` to be a sort of a +hypervisor. Messages coming into `%gall` are routed to the intended +application, and the response comes back along the same route. If the +intended target is on another ship, `%gall` will behind-the-scenes route +it through ames to the other ship to run. This provides an abstraction +where all apps on all ships are communicated with over the same +interface. + +`%gall` neither accepts events from unix nor produces effects. It exists +entirely for the benefit of other vanes and, in particular, +applications. Eyre exposes `%gall`'s interface over http, and ames does +the same over the ames network. `%gall` uses ford to compile and run the +applications. + +
+ +------------------------------------------------------------------------ + +Cards +===== + +`%gall` accepts the following cards. The first three are the most +commonly used, while the others are primarily used internally. + +[`%mess`](#mess) +================ + +Sends a message to an app. This will result in a call to the app's +`++poke` arm. The response is exactly one of a `%nice` if the action +succeeded or a `%mean` if not. + +------------------------------------------------------------------------ + +[`%show`](#show) +================ + +Subscribes to a stream from an app. This will result in a call to the +app's either `++peek` or `++peer` arm. The first response will always be +either a `%nice` or a `%mean`, indicating whether or not the +subscription was successful. After the first response, there will be +zero or more responses of either `%rush` or `%rust`, which communicate +either a differntial or full update to the data stream. There may be a +`%mean`, which indicates that the subscription has been canceled and no +more responses will be received along this stream. + +------------------------------------------------------------------------ + +[`%nuke`](#nuke) +================ + +Unsubscribes the current duct from its stream. This receives a response +of either a `%nice` or a `%mean`. Note that a response of `%nice` does +not imply that the current duct was in fact subscribed to any stream. + +------------------------------------------------------------------------ + +[`%init`](#init) +================ + +Initializes a ship's apps. This should be called exactly once for each +ship on the pier. This produces no moves in response. + +------------------------------------------------------------------------ + +[`%sire`](#sire) +================ + +Instantiates a child app. The app will be at path `[p parent-path]`, and +it will be an instance of the `q` app. The only response will be `%gone` +when the child dies. + +------------------------------------------------------------------------ + +[`%rote`](#rote) +================ + +Signifies a remote request from ames. `r` should be of type `rook`. This +how an app on a foreign ship may send a `%mess`, `%show`, or `%nuke` +card. Note that `%gall` automatically converts `%mess`, `%show`, and +`%nuke` into ames messages behind the scenes, so the only entity that +should use `%rote` and `%roth` is ames. Formally, the response is either +a `%nice` or a `%mean`, which ames uses to give a positive or negative +ack. A logical response comes by passing a `%roth` card. + +------------------------------------------------------------------------ + +[`%roth`](#roth) +================ + +Gives the response received from a remote request. `r` should be of type +`roon`. This is how an app responds to a foreign request with a `%rush`, +`%rust`, `%nice`, or `%mean`. The response is either a `%nice` or a +`%mean`. Even though we, as the proverb goes, "never ack an ack", we do +need to acknowledge these responses since they're really independent +one-way messages. + +------------------------------------------------------------------------ + +[`%wipe`](#wipe) +================ + +Wipes the given app from memory. This is generally considered a hack, +but it is sometimes useful during development to wipe the state of an +app. We don't guarantee that this actually completely wipes the app. +Generally, you want to use a `%cide` card if you actually want to kill +an app. This gives no response. + +------------------------------------------------------------------------ + +[`%cide`](#cide) +================ + +Kills an app and all its children. Even though it's not technically a +part of `%gall`'s interface since it's not in `++kiss` and can't be +called from the outside, it's worth mentioning `%cide`, which may be +called from within `%gall` apps. It should call `++part` to allow the +app any last words. This gives no response. + +------------------------------------------------------------------------ + +Service Gates +============= + +[`++poke`]() +============ + +Handles incoming messages. Most commonly with an associated `%logo`. For +example `++poke-json` handles an incoming JSON request from `%eyre`. + +[`++peer`]() +============ + +Handles incoming subscriptions. + +[`++pull`]() +============ + +Handles dropping subscribers. + +[`++pour`]() +============ + +Handles responses to `%pass` moves. + +[`++park`]() +============ + +Save state on update. + +[`++prep`]() +============ + +Load state on update. diff --git a/docs/pub/doc/arvo/gall/gall.md b/docs/pub/doc/arvo/gall/gall.md new file mode 100644 index 0000000000..254e67cb41 --- /dev/null +++ b/docs/pub/doc/arvo/gall/gall.md @@ -0,0 +1,5 @@ +Gall: Reference +=============== + +Gall: Commentary +================ diff --git a/docs/pub/doc/arvo/ives.md b/docs/pub/doc/arvo/ives.md new file mode 100644 index 0000000000..b2249dc795 --- /dev/null +++ b/docs/pub/doc/arvo/ives.md @@ -0,0 +1,8 @@ +
+ +`%ives` +======= + +`%ives` isn't finished yet. + +
diff --git a/docs/pub/doc/arvo/ives/ives.md b/docs/pub/doc/arvo/ives/ives.md new file mode 100644 index 0000000000..48016505c8 --- /dev/null +++ b/docs/pub/doc/arvo/ives/ives.md @@ -0,0 +1,5 @@ +Ives: Reference +=============== + +Ives: Commentary +================ diff --git a/docs/pub/doc/arvo/jael.md b/docs/pub/doc/arvo/jael.md new file mode 100644 index 0000000000..ad497b1d4d --- /dev/null +++ b/docs/pub/doc/arvo/jael.md @@ -0,0 +1,8 @@ +
+ +`%jael` +======= + +`%jael` isn't finished yet. + +
diff --git a/docs/pub/doc/arvo/jael/jael.md b/docs/pub/doc/arvo/jael/jael.md new file mode 100644 index 0000000000..655d98e64b --- /dev/null +++ b/docs/pub/doc/arvo/jael/jael.md @@ -0,0 +1,5 @@ +Jael: Reference +=============== + +Jael: Commentary +================ diff --git a/docs/pub/doc/arvo/kahn.md b/docs/pub/doc/arvo/kahn.md new file mode 100644 index 0000000000..b728fa02f5 --- /dev/null +++ b/docs/pub/doc/arvo/kahn.md @@ -0,0 +1,8 @@ +
+ +`%kahn` +======= + +`%kahn` isn't finished yet. + +
diff --git a/docs/pub/doc/arvo/kahn/kahn.md b/docs/pub/doc/arvo/kahn/kahn.md new file mode 100644 index 0000000000..8096fe83a3 --- /dev/null +++ b/docs/pub/doc/arvo/kahn/kahn.md @@ -0,0 +1,5 @@ +Kahn: Reference +=============== + +Kahn: Commentary +================ diff --git a/docs/pub/doc/arvo/lunt.md b/docs/pub/doc/arvo/lunt.md new file mode 100644 index 0000000000..45693ad06d --- /dev/null +++ b/docs/pub/doc/arvo/lunt.md @@ -0,0 +1,8 @@ +
+ +`%lunt` +======= + +`%lunt` isn't finished yet. + +
diff --git a/docs/pub/doc/arvo/lunt/lunt.md b/docs/pub/doc/arvo/lunt/lunt.md new file mode 100644 index 0000000000..ba19477bc2 --- /dev/null +++ b/docs/pub/doc/arvo/lunt/lunt.md @@ -0,0 +1,5 @@ +Lunt: Reference +=============== + +Lunt: Commentary +================ diff --git a/docs/pub/doc/arvo/time.md b/docs/pub/doc/arvo/time.md new file mode 100644 index 0000000000..f0f6ffbf27 --- /dev/null +++ b/docs/pub/doc/arvo/time.md @@ -0,0 +1,21 @@ +
+ +`%time` +======= + +`%time` is a simple timer. + +It allows vanes and applications to set and timer events, which are +managed in a simple priority queue. `%time` produces effects to start +the unix timer, and when the requested `%time` passes, unix sends wake +events to `%time`, which time routes back to original sender. We don't +guarantee that a timer event will happen at exactly the `%time` it was +set for, or even that it'll be particularly close. A timer event is a +request to not be woken until after the given time. + +`%eyre` uses `%time` for timing out sessions, and `%clay` uses `%time` +for keeping track of time-specified file requests. `%ames` should +probably use `%time` to keep track of things like network timeouts and +retry timing, but it currently uses its own alarm system. + +
diff --git a/docs/pub/doc/arvo/util.md b/docs/pub/doc/arvo/util.md new file mode 100644 index 0000000000..0546bf1faf --- /dev/null +++ b/docs/pub/doc/arvo/util.md @@ -0,0 +1,229 @@ +
+ +CLI Apps +======== + +These are our simple command-line applications. + +You can find them in `/main/app`. + +
+ +------------------------------------------------------------------------ + +### [`:begin`](#begin) + +`~zod/try=> :begin [~ship-name [~valid-ticket-for-ship]]` + +Start a ship. `:begin` collects all of the necesarry information to +start an Urbit ship. Takes an option `[~ship-name]` or +`[~ship-name [~valid-ticket-for-ship]]` pair. + +------------------------------------------------------------------------ + +### [`:cat`](#cat) + +`~zod/try=> :cat path-to-file [...]` + +"cat" a file. `:cat` either prints a file, or concatenates and then +prints multiple files to the terminal. + +------------------------------------------------------------------------ + +### [`:cp`](#cp) + +`~zod/try=> :cp /path/to/source /path/to/destination` + +Copy a file to a given location. + +------------------------------------------------------------------------ + +### [`:grep`](#grep) + +`~zod/try=> :grep 'literal'` + +"grep" a file or standard input. Currently only supports literals, but +will eventuall support regular expressions. + +------------------------------------------------------------------------ + +### [`:hi`](#hi) + +`~zod/try=> :hi ~ship ["message"]` + +Send a ship a message which is empty by default, becoming their neighbor +in the process. Often used to ping ships to check connectivity. + +------------------------------------------------------------------------ + +### [`:into`](#into) + +`~zod/try=> :into /path/to/file 'contents'` + +Write text to a file. If the specified file does not exist, create a +file by that name. + +------------------------------------------------------------------------ + +### [`:label`](#label) + +`~zod/try=> :label %path %label` + +"label". Add a label to a change number. + + ~zod/try=> :label %try %zebra + = new /~zod/try/3 + ~zod/try=> :ls /=try/zebra + readme + +Note that adding a label is part of the delta stream and creates a new +change number, `3`. + +------------------------------------------------------------------------ + +### [`:ls`](#ls) + +`~zod/try=> :ls path/to/directory` + +"ls". List files at a path. Unlike "ls" in Unix, the current path `%` +must be explicitly given (you cannot call `:ls` with no arguments to +display the files at the current path). + +------------------------------------------------------------------------ + +### [`:mv`](#mv) + +`~zod/try=> :mv /path/to/source /path/to/destination` + +Move a file to a given location, creating a new revision of the source +that omits the moved file. + +------------------------------------------------------------------------ + +### [`:reload`](#reload) + +`~zod/try=> :reload %vane-name [...]` + +Reload the standard library (zuse) and/or arvo vanes. If zuse is +reloaded, vanes depending on the changes must be reloaded as well. For +example `:reload %zuse %ford` is necessary to make use of changes in +application code or the REPL. + +Possible values for %vane-name see [Overview](overview.md "overview"): + +------------------------------------------------------------------------ + +### [`:reset`](#reset) + +`~zod/try=> :reset` + +Reloads all vanes. See [`:reset`] for reloading only or a specific vane. + +------------------------------------------------------------------------ + +### [`:rm`](#rm) + +`~zod/try=> :rm /path/to/source` + +Remove a file. + +------------------------------------------------------------------------ + +### [`:solid`](#solid) + +`~zod/try=> :solid` + +compiles a kernel into a new full urbit.pill + +------------------------------------------------------------------------ + +### [`:sync`](#sync) + +`:sync %source-desk ~hidduc-posmeg %target-desk` + +Sets up a subscription to the source desk on the target ship name to the +target desk on your ship. + +------------------------------------------------------------------------ + +### [`:ticket`](#ticket) + +`~zod/try=> :ticket ~ship-name` + +Creates a will for a ship. `:ticket` outputs the ticket for a Urbit +ship. Takes an option `[~ship-name]`. On destroyes this command creates +a yacht and takes the option \`[\~yacht-name-destroyer-name] + +------------------------------------------------------------------------ + +### [`:thumb`](#thumb) + +`~zod/try=> :thumb ~ship-name` + +Show the ships information. Only works if you issued a [`:hi`] +[\`\~ship-name] beforehand. + +This command is not avaible since the switch from batz to `%gall`! + +Use this for the time beeing: - will: +`~zod/try=> ((hard (unit gcos)) .^(%a /=gcos=/~ship-name))` - raw will: +`~zod/try=> ((hard will) .^(%a /=will=/~ship-name))` + +------------------------------------------------------------------------ + +### [`:unsync`](#unsync) + +`:unsync %source-desk ~hidduc-posmeg %target-desk` + +Cancels the subscription to the source desk on the target ship name to +the target desk on your ship. + +------------------------------------------------------------------------ + +### [`:verb`](#verb) + +`~zod/try=> :verb` + +Turn verbose arvo mode on/off. + +You'll see events, internal cards, and effects. + + [%unix p=%wake //temp] + [ %give + %t + %wake + ~[ + /c/tyme + /g/a/~zod/._~~.58_~~.shell_~~.terminal__/w/drug/~zod/main + /g/a/~harnyr-darlux-bitrux-litnum--falbec-tacsev-magdus-tobsyn/began/u + /g/a/~harnyr-darlux-bitrux-litnum--falbec-tacsev-magdus-tobsyn/._~~.2_~~.shell_~~.terminal__/u/to-gan + /g/a/~harnyr-darlux-bitrux-litnum--falbec-tacsev-magdus-tobsyn/._~~.shell_~~.terminal__/u/child/2/main + /g/a/~harnyr-darlux-bitrux-litnum--falbec-tacsev-magdus-tobsyn/terminal/u/txt + /d/term-mess + //term/1 + ] + ] + [ %give + %c + %writ + ~[ + /g/a/~zod/._~~.58_~~.shell_~~.terminal__/w/drug/~zod + /g/a/~harnyr-darlux-bitrux-litnum--falbec-tacsev-magdus-tobsyn/began/u + /g/a/~harnyr-darlux-bitrux-litnum--falbec-tacsev-magdus-tobsyn/._~~.2_~~.shell_~~.terminal__/u/to-gan + /g/a/~harnyr-darlux-bitrux-litnum--falbec-tacsev-magdus-tobsyn/._~~.shell_~~.terminal__/u/child/2/main + /g/a/~harnyr-darlux-bitrux-litnum--falbec-tacsev-magdus-tobsyn/terminal/u/txt + /d/term-mess + //term/1 + ] + ] + ... + +------------------------------------------------------------------------ + +### [`:ye`](#ye) + +`~zod/try=> :ye ["message"]` + +Send a message to all ships. Often used to announce a continuity breach. + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/guide.md b/docs/pub/doc/guide.md new file mode 100644 index 0000000000..961c8fb37e --- /dev/null +++ b/docs/pub/doc/guide.md @@ -0,0 +1,15 @@ +
+ +Guides +====== + +These guides are designed to get you oriented in urbit. + +Each one covers a specific topic. Although it's not necesarry to follow +them in order, they do get increasingly complex. + +
+ +------------------------------------------------------------------------ + + diff --git a/docs/pub/doc/guide/a-ford.md b/docs/pub/doc/guide/a-ford.md new file mode 100644 index 0000000000..94af2bbfd7 --- /dev/null +++ b/docs/pub/doc/guide/a-ford.md @@ -0,0 +1,812 @@ +`%ford` Guide +============= + +#### basic `hoon` and talking to the web + +
+ +`%ford` is the arvo vane that handles asset management and publishing. +We use `%ford` to compose our files when programming, and also to bundle +files together for the web. + +This guide assumes that you have installed and started your urbit. +Assuming you cloned the repo into `/$URB_DIR` you should be able to find +the unix mirror of your ship's filesystem in +`/$URB_DIR/$PIER/$SHIP-NAME`. All of the filesystem paths in this guide +are relative to that Unix directory. + +Also, we refer to `http://ship-name.urbit.org/` in our URLs, but you can +also use `http://localhost:8080/` if you prefer to just talk to your +machine directly. + +
+ +
+ +1. Let's publish a webpage +-------------------------- + +#### In + + /main/pub/fab/guide/exercise/1/hymn.hook + +#### Put + + ;html + ;head + ;meta(charset "utf-8"); + ;title: Exercise 1 + == + ;body + ;div + ;h1: Exercise 1 — Simple HTML + ;p: As you may notice, urbit has no problem talking to the web. + == + == + == + +#### Try it + + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/1/ + +#### What did you just do? + +The code you just wrote is urbit's native programming langauge, hoon. +Generating HTML with hoon is similar to writing [jade](link) or other +similar HTML shorthand. In hoon, this shorthand is called [`++sail`]() +and it's a native part of the hoon language. + +In `++sail` node-names are prefixed with a `;` and closed with a `==`. +Nodes that have text content and are only on one line use a `:`, such as +our `;h1:` above, and are closed implicitly with a new line. Nodes with +no content are closed with another `;`, such as `;br;`. + +You can find more information about `++sail` in our [rune library +documentation](link). + +
+ +2. Let's do some programming on the page. +----------------------------------------- + +#### In + + /pub/fab/guide/exercise/2/hymn.hook + +#### Put + + ;html + ;head + ;meta(charset "utf-8"); + ;title: Exercise 2 + == + ;body + ;div + ;h1: Exercise 2 — Call a function + ;p: Although it may be obvious, 2+2={<(add 2 2)>} + == + == + == + +#### Try it + + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/2/ + +### What's going on there? + +Clearly, the code `(add 2 2)` is generating `4`, and it's not too hard +to see why. `add` is one of the library functions that are a part of +`hoon.hoon`. Try replacing `(add 2 2)` with `(sub 2 (add 2 2))`. You can +find documentation for the full hoon library in the [library +reference](link). + +Since the product of `(add 2 2)` is a number, we need a few extra things +to have it print properly. In `++sail` we use `{` and `}` to do string +interpolation. Everything after the `:` is expected to be a string, so +we need to tell the parser when we start writing code. The `<` and `>` +inside our `{` `}` are converting our result `4`, a number, to the +string `"4"`. hoon is a strongly typed language kind of like haskell, so +we need to explicitly convert our types. + +
+ +3. Let's assign some variables. +------------------------------- + +#### In + + /pub/fab/guide/exercise/3/hymn.hook + +#### Put + + =+ ^= a 1 + =+ b=2 + :: + ^- manx + ;html + ;head + ;meta(charset "utf-8"); + ;title: Exercise 3 + == + ;body + ;div + ;h1: Exercise 3 — Assignment + ;p: a={
} + ;p: b={} + ;p: a+b={<(add a b)>} + == + == + == + +#### Try it + + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/3/ + +#### How does that work? + +The first thing you should notice in this example is the `=+` at the top +of our file. `=+` is a rune. hoon is a programming with no reserved +words. We don't use `if` `this` or `function` at all. Instead, runes +have their own pronunciation. `=+` is pronounced 'tislus'. You can find +the table of pronunciation [here](link). In hoon you construct your +programs using runes, which are two character ascii pairs. You can see +the whole set of runes in the [rune index](link). + +`=+` pushes an expression on to our subject. The subject in hoon is +similar to `this` in other languages. hoon being a functional language +if we want something to be available further on in our computation we +need to attach it to the subject first. + +The second thing you should notice is the `^- manx`. Here the rune +`[^-]()` is used to cast our product to a [++manx](), which you can +think of like the hoon MIME type for XML. Using a `^-` is not required, +but helps us produce more informative error messages when we generate a +type error or mismatch. + +Looking at the rendered page it's clear that we're assigning `a` to be +`1` and `b` to be `2`. Looking at the code, however, you can see that +we're doing this in two different ways. Runes in hoon can have irregular +forms, and `^=` is one of them. The first two lines of our example are +doing the same thing, where `a=2` is simply the irregular form of +`^= a 2`. You can see the full list of irregular forms [here](link). + +Looking at the simple computation on the page, you can try changing the +values of `a` and `b` to any integers to produce similar results. + +
+ +4. Let's build our own computation +---------------------------------- + +#### In + + /pub/fab/guide/exercise/4/hymn.hook + +#### Put + + |% + ++ start 1 + ++ end 10 + ++ length + |= [s=@ud e=@ud] + (sub e s) + -- + :: + ^- manx + ;html + ;head + ;meta(charset "utf-8"); + ;title: Exercise 4 + == + ;body + ;div + ;h1: Exercise 4 — Cores + ;p: We'll be starting at {} + ;p: And ending at {} + ;p: Looks like a length of {<(length start end)>} + == + == + == + +#### Try it + +(and be sure to put two spaces between `++` and arm names) + + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/4/ + +### What's happening? + +As you can see from the output, we have written a little function that +takes two numbers, `s` and `e` and returns their difference. The first +thing to notice about our code is the first rune. `|%` is a `core` rune. +You can think of cores like functions or objects in other languages. +`|%` runes contain an arbitrary number of arms, denoted with either `++` +or `+-` and closed with `--`. + +Each arm has a value, either static data (in the case of `++start` and +`++end`) or a gate (in the case of `++length`). A gate is a kind of +core. Gates only have one arm and are quite similar to a function in +other languages. We use `|=` to construct our gate. Runes in hoon are +generally categorized by their first character. `|` indicates a rune +having to do with cores. You can find all of the `|` runes in the [rune +library](link). + +Our `++length` [gate]() takes two arguments, `s` and `e`. In hoon we +call the data passed in to a gate the 'sample'. Every `|=` has two +parts: the sample type and the computation, also known as a `tile` and a +`twig`. Casually, `[s=@ud e=@ud]` means that the gate takes two +arguments, labelled going forward as `s` and `e`, and required to both +be `@ud` or unsigned decimal. Our computation, `(sub e s)` simply +computes the difference between `e` and `s`. + +`@ud` is an odor. Odors aren't quite types, but they're similar. You'll +learn the difference by example as we progress, and you can always refer +to the [odor index](link). + +You probably also noticed our indentation. In general hoon has both tall +and wide forms. In tall form, hoon uses two spaces for indentation and +is back-stepped so nested code doesn't drift away toward the right +margin. In wide form we use parenthesis just like almost everyone else. + +
+ +5. +-- + +#### In + + /pub/fab/guide/exercise/5/hymn.hook + +#### Put + + |% + ++ dist ,[start=@ud end=@ud] + ++ length + |= [d=dist] + (sub end.d start.d) + -- + :: + ^- manx + ;html + ;head + ;meta(charset "utf-8"); + ;title: Exercise 5 + == + ;body + ;div + ;h1: Exercise 5 — Cores + ;p: How long does it take to get from 2 to 20? {<(length 2 20)>} + == + == + == + +#### Try it + + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/5/ + +#### What's the difference? + +Clearly we're producing the same result as before, but we're doing it in +a different way. + +The first line in our gate, `++length` always specifies the sample tile. +As you can see here, our sample tile is actually a `++dist`, the body of +which, `,[start=@ud end=@ud]` looks very similar to our previous example +in that it accepts two `@ud`. The important difference is that `++dist` +is now defined in a way that can be re-used. hoon is a strongly typed +language, but it encourages the creation of your own types using what we +call tiles. + +At a high level you can think of hoon as being composed of two things, +tiles and twigs. Twigs are the actual AST structures that get consumed +by the compiler. Tiles reduce to twigs and provide major affordances for +the programmer. If you're interested in learning about tiles more deeply +you can find an in-depth explanation in the [tile overview](link). + +It should suffice, for now, to say that we create tiles in the same way +that you would think of creating type definitions in another language. +The primary way we do this is with `$` runes you can find more about +them in the [`$` section]() of the rune library. + +In this specific example we are using the `$,` tile rune in its +irregular form, `,`. `,` generates a validator from the given +expression. In effect, `++dist` uses the type system to only produce +cells that appear in the form `[start=@ud end=@ud]`. When we use it in +our `++length` gate we assert that our input must be validated by +`++dist`. To test that out, you can try passing something that isn't an +unsigned decimal (or `@ud`) to `++length`. Try replacing `(length 2 20)` +with `(length 2 'a')`. As we continue you'll see how this pattern can be +quite useful. + +One other thing to point out which may be immediately confusing coming +from other languages is the order of addressing `start` and `end`. We +call these labels faces, and we address them in the opposite order than +you're usually familiar with. We still separate our addressing with `.`, +but do it from the inside out. Given a tuple such as +`[a=1 b=[c=[d=2 e=3]]]` we can address the value of `e` with `e.c.b`. +You can read more about how faces work in the commentary on `++type` +[here](link). + +
+ +6. +-- + +#### In + + /pub/fab/guide/exercise/6/hymn.hook + +#### Put + + |% + ++ fib + |= x=@ + ?: (lte x 2) + 1 + (add $(x (dec x)) $(x (sub x 2))) + -- + :: + ^- manx + ;html + ;head + ;meta(charset "utf-8"); + ;title: Exercise 6 + == + ;body + ;div + ;h1: Exercise 6 — Loops + ;p: {<(fib 1)>}, {<(fib 2)>}, {<(fib 3)>}, {<(fib 4)>} + == + == + == + +#### Try it + + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/6/ + +#### What is that doing? + +We're printing a few members of the [fibonacci sequence](link) by +calling our arm `++fib` with a few values. The fibonacci sequence is a +fairly straight forward algorithm: `F(n-1) + F(n-2)` where `F(1) = 1` +and `F(2) = 1`. As is obvious from the formula, generating the fibonacci +value at any number requires us to recurse, or loop. Let's walk through +the code. + +Our example here should look similar to the previous one. We build a +core with `|%` and add the arm `++fib`. `++fib` is a gate which takes +one argument `x`, an atom. Using [`?:`](link) we test if `x` is less +than `2` with the library function [`lte`](link) to handle our seed +values of `F(1) = 1` and `F(2) = 1`. `?:` is a member of the [`?` +runes](link), related to true / false values, or loobeans. In hoon true +and false are `0` and `1` respectively and take the odor `@f`. We tend +to say 'yes' and 'no' instead of 'true' and 'false' to keep track of the +switch. Our built-in function `lte` produces a loobean, so we evaluate +our first line if true, and second if false. + +If `x` is not less than `2` we compute `F(n-1) + F(n-2)` by using `$`. +We mentioned previously that a gate is a special kind of core with only +one arm, called `$`. Here we're using `$` to mimic the behavior of a +loop. You can read the expression `$(x (dec x))` as 'call the gate again +with `x` replaced by `(dec x)`. For more on how this works, check out +the documentation of [`%=`](link) and [`%-`](link). With that in mind it +should be clear how the last line of `++fib` produces the member of the +sequence at a given value `x`. + +
+ +7. +-- + +#### In + + /pub/fab/guide/exercise/7/hymn.hook + +#### Put + + :: + :: + :::: /hook/hymn/7/exercise/guide/fab/pub/ + :: + /? 314 + /= gas /$ fuel + :: + ^- manx + ;html + ;head + ;meta(charset "utf-8"); + ;title: %ford Example 1 + == + ;body + ;div + ;h1: %ford Example 1 — Page Variables + ;div.who: {<(~(get ju aut.ced.gas) 0)>} + ;div.where: {(spud s.bem.gas)} rev {(scow %ud p.r.bem.gas)} + ;code + ;pre: {} + == + == + == + == + +#### Try it + + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/7/ + http://ship-name.urbit.org/gin/del/main/pub/fab/guide/exercise/7/ + +Here we're putting our publishing framework, `%ford` to work a little +bit. We're printing out some of the parameters our page is passed: who +is looking at it, where it is and what revision our desk is on. We have +also thrown in all our FCGI parameters in a codeblock for reference. + +To do this we have introduced some new runes, `/?`, `/=` and `/$`. We +tend to call runes with a leading `/` "`%ford` runes" since they are +used by the `%ford` vane for resource loading and composition. By +convention, we indent four spaces after them to make them more obvious. +They belong at the top of the file. + +`/?` simply checks for compatibility. In this case the line means 'need +urbit 314 or below', or in hoon: `(lte zuse 314)`. `314` is the number +in the kelvin versioning system, which you can read about [here](link). + +`/=` is similar to the combination of `=+ =^`, or assignment. `/$` +calls a parsing function, which we specify as [`++fuel`](link) with the +[`++beam`](link) and [`++path`](link) of our current file. +`/= gas /$ fuel` is a common way to open your page, since the +product of `++fuel` is useful when writing pages to the web. The use of +`++fuel` is not enforced — you can also write your own parser. + +Our page is made up of two generated parts: who requested the page, the +location of the page and its revision. Both are parsed out of the `gas` +variable using some straightforward library functions, [`++ju`](link), +[`++spud`](link) and [`++scow`](link). You can follow those links to the +library reference to learn more about them. You'll also notice our +addressing moving in the opposite direction as you may be used to. +`aut.ced.gas` pulls `aut` from inside `ced` from inside `gas`. + +Inside of the `;code` tag we also print (for our own reference) the +entire `gas`, so you can take a look at the contents. This can be a +helpful trick when debugging. To fully understand what gets put in +`gas`, we can take a look at `++fuel` and note that it produces a +[`++epic`](link), which also contains a [`++cred`](link). You can follow +those links to learn more about them. + +When we try changing the url from `gen/main` to `gin/del/main` we're +using some of the access methods from `%eyre` (the urbit webserver) to +pretend to be the urbit `~del`. You can find documentation on those +access methods in the `%eyre` commentary, [here](link). + +Path and identity are useful, but there are some other parameters worth +checking out as well. + +
+ +8. +-- + +#### In + + /pub/fab/guide/exercise/8/hymn.hook + +#### Put + + :: + :: + :::: /hook/hymn/8/exercise/guide/fab/pub/ + :: + /? 314 + /= gas /$ fuel + :: + ^- manx + ;html + ;head + ;title: %ford Example 2 + == + ;body + ;div: Do you have a code? + ;div: ?code={<(fall (~(get by qix.gas) %code) '')>} + == + == + +#### Try it + + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/8/ + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/8/?code=yes-i-do + +This is a simple example, showing off another use of +`/= gas /$ fuel`. In this case we're just pulling out the value of +the `code` query string parameter. You should be able to change that +value to any url-safe string and see it appear on the page. + +We're using a few simple library functions to actually pull the value +out, [`++fall`](link) and [`get:by`](link). Query string parameters are +stored in `qix.gas` as a `++map`, one of the main container constructs +used in hoon. We'll encounter a lot of maps along the way, and you can +learn more about them in the [map section](link) of the library doc. + +
+ +9. +-- + +#### In + + /pub/fab/guide/exercise/9/hymn.hook + +#### Put + + :: + :: + :::: /hook/hymn/exercise/9/guide/fab/pub/ + :: + /? 314 + :: + // /%%/lib + ^- manx + ;html + ;head + ;title: %ford Example 3 + == + ;body + ;h1: %ford Example 3 + ;p: {<(fib 1)>}, {<(fib 2)>}, {<(fib 3)>}, {<(fib 4)>} + == + == + +#### And in + + /pub/fab/guide/exercise/9/lib.hoon + +#### Put + + |% + ++ fib + |= x=@ + ?: (lte x 2) + 1 + (add $(x (dec x)) $(x (sub x 2))) + -- + +#### Try it + + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/9/ + +#### How are they getting combined? + +Clearly this looks a lot like our previous example using `++fib`, only +now we're using two separate files. The majority of this code should be +familiar to you from example 6, so let's focus on a single line, +`// /%%/lib`. + +`//` is a `%ford` rune that loads a resource from a given path. `//` is +used as a way to organize project code into separate files, not for +loading libraries and structures. We'll show some examples of how urbit +handles those things shortly. You can think of `//` as a kind of +`include` or `require`. `//` takes a `beam`, an absolute global path in +`%clay` — the global urbit filesystem. + +In `%clay` we use `%` to navigate relative paths. `%` is sort of like +`.` when moving around the unix file system. Although we put our code in +the unix path `/pub/fab/guide/exercise/9/hymn.hook` the file extension +is just a hint to the system. `/%/` (the equivalent of a unix `./`) +actually resolves to `/pub/fab/guide/exercise/9/hymn`. + +We commonly use two kinds of extensions, `.hoon` for source files and +`.hook` for files that generate something else. Since our hymn file is +generating html, it's a `.hook`, and our source file is just a `.hoon`. +In order to find our file one level up we need two `%%` to get to +`/pub/fab/guide/exercise/9/`. Adding `lib` resolve to our neighboring +file. You can read more about how `%clay` paths are parsed in the +[`%clay` overview](link). It's also pretty easy to try them out using +`:cd` and `:ls` in your `%arvo` terminal. + +
+ +10. +--- + +#### In + + /pub/fab/guide/exercise/10/hymn.hook + +#### Put + + :: + :: + :::: /hook/hymn/10/exercise/guide/fab/pub/ + :: + /? 314 + /= gas /$ fuel + // /%%/lib + :: + =+ ^= arg + %+ slav + %ud + %+ fall + %- ~(get by qix.gas) %number + '0' + :: + ^- manx + ;html + ;head + ;title: %ford Example 4 + == + ;body + ;div: {<(fib arg)>} + == + == + +#### And in + + /pub/fab/guide/exercise/10/lib.hoon + +#### Put + + |% + ++ fib + |= x=@ + ?: (lte x 2) + 1 + (add $(x (dec x)) $(x (sub x 2))) + -- + +#### Try it + + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/10/ + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/10/?number=7 + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/10/?number=12 + +As you can see by changing the URL, we're now passing our query string +parameter to our `++fib` script and printing the output. It's common to +pull some data out of the URL and do something with it, but we don't +have any type information about our query string parameters and hoon is +a strongly typed languge. As you can see, we're calling `++fib` with a +parameter `arg`. Let's look closely at how we generate `arg`. + +The first part of our assignment should look familiar from previous +example, `=+ ^= arg` puts the face `arg` on the product of our +remaining computation. In short, you can read the code that produces +`arg` as `(slav %ud (fall (~(get by qix.gas) %number) '0'))`. We use `%` +runes to write this in tall form. `%` runes are used for calling gates +or evaluating changes. `%+` 'slams' or calls a gate with two arguments, +and `%-` 'slams' or calls a gate with one argument. As usual, you can +find more about the `%` runes in the [`%` section](link) of the rune +library. + +To get a value out of our map of query string parameters `qix.gas` we +use a method from the [maps library](link) that produces a `++unit`. +`++unit`s are a common type in hoon used for optional values. A +[`++unit`](link) is either `~` or `[~ p=value]`. Since we need to +specify a value for `(fib arg)` even when someone doesn't enter the +query string we use [`++fall`](link), which produces either the value of +the unit, or the second argument if the `++unit` is null. Since our +`qix.gas` has string values in it we specify a string in our second +argument, `'0'`. As an aside, `'0'` is different from `"0"` in hoon. You +can read about the difference in [`++cord`](link) and [`++tape`](link). + +Our outermost call, to [`++slav`](link), casts our string to a `@ud` — +which is the type expected by `++fib`. `++slav` takes the name of an +odor and a value, and tries to cast the value to that odor. + +
+ +11. +--- + +#### In + + /pub/fab/guide/exercise/11/hymn.hook + +#### Put + + /= posts /: /%%/lib + /; |= a=(list (pair ,@ ,manx)) + %+ turn + a + |= [* b=manx] + b + /@ + /psal/ + :: + ^- manx + ;html + ;head + ;meta(charset "utf-8"); + ;title: %ford Example 11 + == + ;body + ;h1: Ford example — Loading Resources by Number + ;* posts + == + == + +#### In + + /pub/fab/guide/exercise/11/lib/1.md + +#### Put + + #1 + + This is my first post. + +#### In + + /pub/fab/guide/exercise/11/lib/2.md + +#### Put + + #2 + + This is my second post. + +#### Try it + + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/11/ + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/11/lib/1/ + http://ship-name.urbit.org/gen/main/pub/fab/guide/exercise/11/lib/2/ + +#### Experiment with it + +Try adding other `.md` files with numeric file names (such as `3.md`) to +the `11/lib/` directory to get a feel for what's going on. + +What's happening? + +As you can see, we're loading the markdown files in `11/lib` and putting +them in to our page. Let's dive into the code. + +We're using `/=` to assign the `posts` face. `/:` sets the `++beam` for +the computation below it. You can think of it sort of like setting an +environment variable. Everything below uses our `++beam` `/%%/lib`. + +If we take the next few lines and write them as pseudo code in wide form +they might look something like this, `(/; [gate] (/@ /psal/))`. That +being the case, let's start at the bottom and move upwards since that's +how our data flows. In depth documentation on individual `++horn` runes +can be found in the [horn section of the rune library](link). + +`/psal/` loads our `psal` mark. Marks are like content types, and we +keep them in `/main/mar/`. You can open `/main/mar/psal/door.hook` to +see that we specify the ways in which a particular mark can be converted +to produced well typed output. The general form of this is [`/mark/`]() +where `mark` exists in the `/main/mar/` directory. A `psal` is a partial +`hymn`, where `hymn` is the hoon structure for `html`. + +`/@` loads a list of files in numerical order from the previously +specified `++beam` using our mark, `psal`. `/@` has a few close +relatives. `/&`, for example, reads files by `@da` or absolute date. You +can see the rest in the [horn section of the library](link). + +`/;` takes the output from `/@` and `/psal/` and passes it to a twig. In +this case, a gate. Our `/@` actually produces a [`++list`](link) of +pairs of `[@ manx]` where the `@` is the filename, and the `manx` is the +converted contents. We use [`++turn`](link), one of our `++list` +operator functions, to iterate through the list and produce only a list +of `++manx`. This is the output assigned to `posts`. + +Then, further down, we use [`;*`](link) to write the list to the page. + +
+ +12. +--- + +#### Look in + + /pub/fab/guide/hymn.hook + /pub/fab/guide/main.css + /pub/fab/guide/main.js + +#### Try it + + http://ship-name.urbit.org/gen/main/pub/fab/guide/ + +#### Bring it all together + +It turns out it's pretty easy to pull our examples together into a +single blog-like page using what we just covered. We include some css to +make things a bit prettier, and this should give you a good jumping off +point for experimenting with your own publishing code. + +#### Have fun! diff --git a/docs/pub/doc/guide/b-cli.md b/docs/pub/doc/guide/b-cli.md new file mode 100644 index 0000000000..0d4370a68c --- /dev/null +++ b/docs/pub/doc/guide/b-cli.md @@ -0,0 +1,251 @@ +This guide is intended to get you oriented in the Arvo command prompt +and give you a tour of some basic utilities. The command prompt comes in +two flavors, in a web browser and in a terminal. For the most part +they're the same, except that in a browser you can evaluate tall-form +Hoon expressions but you can't run readline apps, such as `:chat`. + +Every Arvo command prompt is also a Hoon REPL. The command line is a +great place to test out your hoon knowledge. In this guide we're just +going to talk about some basic system utilities and get comfortable +moving around in `%clay`. If you'd just like to see a list of +command-line utilities, you can find the Arvo man pages [here](). + +This rudimentary tour should work well in both places. + +1 + +Move around `%clay` + +After finishing the [setup instructions]() you should have an Arvo +prompt that looks like this: + + ~talsur-todres/try=> + +The path at the beginning of your prompt is actually a path in the +global filesystem of Urbit, called `%clay`. Since `%clay` is universal +across all of Urbit, each full path starts with a ship name. `%clay` is +also versioned on a per-desk basis. Desks are the top-level directories +in your pier. + +Moving around `%clay` is simple. There is no equivalent of `cd`. +Instead, just type a valid path name at the prompt to move to that +directory. Here we'll move to our starting root path in the try desk, +`/try=` to the `main` desk: + + ~talsur-todres/try=> /=main= + =% /~talsur-todres/main/0 + ~talsur-todres/main=> + +We have two shortcuts in `%clay` that are worth noting, `=` and `%`. + +`=` copies in some corresponding part of our current path. In the second +line above you can see how the `=` in `/=main=` pull in the +`~talsur-todres` and `0` in from our starting directory, +`/~talsur-todres/try/0`. It's important to note that our full prompt to +start is `/~talsur-todres/try=`, where the trailing `=` indicates the +current revision. In the shell, revision `0` never exists — it's used as +a pointer to the head. + +`%` is similar to `.` in unix: + + ~talsur-todres/main=> % + =% /~talsur-todres/main/0 + ~talsur-todres/main=> %% + [~.~talsur-todres ~.main ~] + ~talsur-todres/main=> %%% + [~.~talsur-todres ~] + ~talsur-todres/main=> %%%% + ~ + +When using `%` to move around in `%clay` you need to make sure to use +leading and trailing `/` to ensure your path is interpolted correctly: + + ~talsur-todres/main=> /%%%/try= + =% /~talsur-todres/try/0 + ~talsur-todres/try=> + +2 + +Create some revisions + +Let's use `:into`, our simple utility for writing text to a file, to +create a new file: + + ~talsur-todres/try=> :into %/helo/txt 'helo mars' + written + ~talsur-todres/try=> + +To confirm that our file was written, we can use `:ls`. `:ls` prints a +list of directory contents, but requires that you specify a path. `%` +will suffice for the current path: + + ~talsur-todres/try=> :ls % + readme helo + ~talsur-todres/try=> + +Let's quickly switch back to a unix command prompt to see a few things +about both how files are synced between `%clay` and unix, and where your +apps live. + + my-pier/talsur-todres/$ ls try + helo.txt readme.md + my-pier/talsur-todres/$ cat try/helo.txt + helo mars + +Here you can see that our files are synced back to unix as they are +changed in urbit, and vice-versa. As you change files in unix you'll see +those changes appear in `%clay`. + + my-pier/talsur-todres/$ ls main/app/ + bang grep poke solid unsync + began hi radio sync verb + begin into reload talk ye + cat label reset terminal + chat ls rm test + cp mv shell ticket + my-pier/talsur-todres/$ cat main/app/ls/core.hook + !: + |_ [hid=hide ~] + ++ poke-ls-args + |= [ost=bone you=ship arg=path ~] + =+ lon=((hard arch) .^(%cy arg)) + :_ +>.$ + :* [ost %pass / %g %cide %$] + [ost %give %nice ~] + %+ turn (~(tap by sup.hid)) + |= [ost=bone *] + :^ ost %give %rush + :- %tang + :_ ~ + :+ %rose [" " ~ ~] + (turn (~(tap by r.lon) ~) |=([a=@ta b=*] leaf/(trip a))) + == + ++ peer + |= + * + `+> + -- + +Here you can see that `/main/app` is the main location where our apps +are stored, and the contents of the `:ls` app. urbit applications are of +course written in hoon, our naitive programming language. Don't worry +about the contents of the file for now. Since changes in unix are synced +back in to urbit, we can develop urbit programs by simply editing them +in our favorite editor and saving them. + +For the time being let's switch back to urbit and update our file with +some new content, so we can see how `%clay` stores revisions. + + ~talsur-todres/try=> :into %/helo/txt 'gbye mars' + written + ~talsur-todres/try=> :ls /=try/1 + readme helo + ~talsur-todres/try=> :cat /=try/1/helo/txt + /~talsur-todres/try/9/helo/txt + helo mars + ~talsur-todres/try=> :cat /=try/2/helo/txt + /~talsur-todres/try/10/helo/txt + gbye mars + ~talsur-todres/try=> :cat /=try=/helo/txt + /~talsur-todres/try/~2014.11.26..01.06.33..c93a/helo/txt + gbye mars + ~talsur-todres/try=> + +Here we use `:ls` to investigate the filesystem across versions. You can +see that our `helo` file exists in our first revision. Using the simple +`:cat` command we can print the contents of `/=try/helo/txt` in its two +separate, versioned states. + +We can even move to a different version of our desk and look around: + + ~talsur-todres/try=> /=try/1 + =% /~talsur-todres/try/1 + ~talsur-todres/try/1> :ls % + readme helo + ~talsur-todres/try/1> + +This is sort of like being in a detached HEAD in git. + +3 + +Start a yacht + +Each Urbit destroyer can delegate around four billion yachts. Yachts are +also urbit ships, but are pegged to their parent identity, and are set +up to mirror their filesystem. We can generate a `[ship: ticket]` pair +for a yacht by using the `:ticket` utility: + + ~talsur-todres/try=> :ticket ~talsur-todres-talsur-todres + ~talsur-todres-talsur-todres: ~figpem-fapmyl-wacsud-racwyd + +Every yacht for a particular destroyer ends in the same `ship-name`, and +has every possible destroyer prefix. For example, +`~tasfyn-partyv-talsur-todres` is also a valid yacht from +`~talsur-todres`. + +Start up a new `vere` process with something like `bin/vere -c yacht`. +Then run `:begin` and enter the `[ship: ticket]` pair you just generated +when prompted. When the process is complete you should get a +`; ~talsur-todres-talsur-todres :y1: is your neighbor` message on your +destroyer. To confirm that everything is working properly, you can use +`:hi` to send a message: + + ~talsur-todres/try=> :hi ~talsur-todres-talsur-todres "whats up" + hi ~talsur-todres-talsur-todres successful + ~talsur-todres/try=> + +Which will appear on your new yacht: + + < ~talsur-todres: whats up + ~talsur-todres-talsur-todres/try=> + +You should also see the contents of your `/try` desk mirrored on your +yacht: + + ~talsur-todres-talsur-todres/try=> :ls % + readme helo + ~talsur-todres-talsur-todres/try=> + +Making another change on your destroyer should automatically propagate +down to your yacht: + + ~talsur-todres/try=> :into %/helo/txt 'back to mars' + written + ~talsur-todres/try=> + + [%merge-fine ~talsur-todres %try] + ~talsur-todres-talsur-todres/try=> :cat %/helo/txt + back to mars + ~talsur-todres-talsur-todres/try=> + +4 + +Move files around + +Another familiar command line utility is `:mv`: + + ~talsur-todres/try=> :mv %/helo/txt %/test/helo/txt + moved + ~talsur-todres/try=> + + [%merge-fine ~talsur-todres %try] + ~talsur-todres-talsur-todres/try=> :cat %/test/helo/txt + back to mars + ~talsur-todres-talsur-todres/try=> + +In `%clay` we don't use file extensions or folders. A path either does +or does not have anything in it. There's no need to do the equivalent of +`mkdir` before moving something. + +We also implement the familiar `:rm`: + + ~talsur-todres/try=> :rm %/test/helo/txt + removed + ~talsur-todres/try=> :cat %/test/helo/txt + file /~talsur-todres/try/~2014.11.26..16.49.52..3f5e/test/helo/txt not available + ~talsur-todres/try=> + + [%merge-fine ~talsur-todres %try] + ~talsur-todres-talsur-todres/try=> :cat %/test/helo/txt + file /~tasfyn-partyv-talsur-todres/try/~2014.11.26..16.50.15..556b/test/helo/txt not available + ~talsur-todres-talsur-todres/try=> diff --git a/docs/pub/doc/guide/c-gall.md b/docs/pub/doc/guide/c-gall.md new file mode 100644 index 0000000000..53ff9c8acb --- /dev/null +++ b/docs/pub/doc/guide/c-gall.md @@ -0,0 +1,284 @@ +This guide is focussed on storing application state using the `%gall` +vane. To show off how we store and distribute data in Urbit we're going +to examine a simple webapp. Some of the material here expects that you +have looked over the [`%ford` guide](). If you haven't, it's a good idea +to start there. There's also more information in the [`%gall` +overview]() and [`%gall` commentary]() but it's not necesarry that you +read those before going forward. + +One important thing to keep in mind is that `%gall` services aren't +'started' or 'stopped' as in a unix system. When your files are copied +in they are compiled and begin running immediately and permanently. +`%gall` services simply wake up when certain events happen. + +If you need to make updates to the structure of your stored data, you +write connector functions or (when developing) just throw your existing +data away. We'll see examples of how this works, just keep in mind that +when we talk about a `%gall` 'service' it has no concept of 'running'. + +Going forward we'll refer to the directory you cloned the repo in as +`/$URB_DIR` and assume that your pier is listening for HTTP connections +on port `8080`. + +1. + +Get the code. + +Clone the GitHub repository and move the files into your `/main` desk, +under the corresponding paths. You will need four files: + +- /main/app/lead/core.hook +- /main/pub/lead/hymn.hook +- /main/pub/lead/src/main.css +- /main/pub/lead/src/main.js + +When everything is in place, try it: + + http://localhost:8080/gen/main/pub/lead/ + +That URL should render a page and be self explanatory. Try adding names +to the leaderboard and incrementing their scores. It's also fun to open +a few tabs and watch how the state gets updated simultaneously. + +2. + +How is the code structured? + +In our `%ford` guide we generated pages by defining all of their +possible states, but we didn't exactly store any data. When building +applications on top of Urbit we think of them as existing in two natural +parts: page resources and state services. Effectively, we think of any +Urbit app talking to the web as a single page app whose resources are +generated by `%ford` which talks to a `%gall` service if it needs to +persist any state. Let's look more closely at the specifics in this +simple app. + +When we load our page, we render the contents of our +`/main/pub/lead/hymn.hook`. This file should look familiar as +[`++sail`](). Our `hymn.hook` file writes the basic HTML elements to the +page, and pulls in our supporting CSS and JavaScript resources. + +Our application-specific resources are stored in `/main/pub/lead/src/`. +`/main/pub/lead/src/main.css` simply produces the page layout, while +`/main/pub/lead/src/main.js` updates the page and sends data. + +We also use two utility scripts: `/gop/hart.js` and +`/gen/main/lib/urb.js`. These are the standard libraries for handling +data transfer from a browser to Urbit, and are very frequently used. +`hart.js` handles the page heartbeat, making regular AJAX requests so we +can keep track of subscribers, and `urb.js` offers a more complete set +of helper functions. `urb.js` depends on `hart.js`, so that's why +`hart.js` always goes in the ``. For complete documentation, check +out the [`urb.js` reference](). + +Our application state is stored and distributed to connected clients by +`/main/app/lead/core.hook`. Let's take a closer look at how that works. + +At the top of our `core.hook` we have: + + /? 314 :: need urbit 314 + +This should be familiar from the `%ford` guide. Here we're requiring +that this code run on an Urbit ship where `(lte zuse 314)` is `yes`. In +this `core.hook` we only use one `%ford` rune, but this is where we +would also pull in any dependencies we might have or use other [`/` +runes](). + +Below our `/?` you can see that our code is divided into two sections: a +[`|%`]() where we define our models, and a [`|_`]() where we define the +body of our program. We'll look at these more closely one at a time. + +3. + +How is our state stored? + +In `/main/app/lead/core.hook`: + + ++ axle + $% [%0 p=(map ,@t ,@ud)] + == + +is the first arm inside our leading `|%` that's important to notice. +`++axle` defines the tile for our state. By convention we store our +state as a [`$%`](), or labelled cases. We assume that our state can be +versioned, so we want its model to be one of many tagged cases. This +makes it possible to migrate our state to a new version of the service. +Since this is the first version of our app, we tag our state with `%0`. + +In this simple application we're keeping track of pairs of names to +scores, and we define that here as `(map ,@t ,@ud)`. You can think of +this kind of like an associative array of strings to numbers, or an +object with string keys and numeric values. + +When we use `++axle` to define the type of our state it's kind of like +declaring a schema definition. There's no secondary data storage layer. +Since `%gall` services run permanently your data persists as normal +application state. We use tiles the way we normally would to declare the +type of data that we're passing around. + +Looking ahead, you can see that our main `|_` takes a `++axle` as part +of its sample. Let's look at how that core actually works, to get a +sense of what our application is doing. + +4. + +Where do requests go? + +In `/main/app/lead/core.hook`: + + ++ peer + |= [ost=bone you=ship pax=path] + ^- [(list move) _+>] + ?~ pax + [[ost %give %rust %json vat-json]~ +>.$] + :_ +>.$ + :_ ~ + ?+ -.pax + =- [ost %give %mean -] + `[%not-found [%leaf "you need to specify a path"]~] + %data + =- [ost %give %rush %json -] + (joba %conn %b &) + == + +is the most important arm to look at first. `++peer` is one of the +predefined arms that `%gall` calls when certain events happen. You can +find them all in the [`%gall` overview](). + +We 'get a `++peer`' when we get either a HTTP request, or a subscription +request. Each time this happens our main `|_` is populated with a +`++hide` and our current `++axle` in its sample and `++peer` gets passed +three things: `[ost=bone you=ship pax=path]`. The sample in the `|_` +that contains `++peer` is our application state and all of the contained +arms have access to that sample as part of their context. To change the +state we simply produce a new context with changed values. + +Let's look at each of these parts of our context and the sample in +`++peer`. + +`++hide`, labelled `hid` in peer's context, gives us some information +about the `++request` being passed in. You can look at the specifics in +the [`%arvo` `++models`](), but for our purposes we can think of it +simply as request metadata. + +`++axle`, labelled as `vat` in peer's context, should be familiar from +the discussion in the previous step. + +`ost` is a `++bone`, or an identifier for an `%arvo` duct. 'Duct' is +actually a pretty good word for what a ++duct does. Informally, when an +event is processed in `%arvo` we patch together our requisite +computations with `++ducts`. For example, when we get a network packet, +parse it, pass it to the webserver, and then pass it to the application +framework we use a `++duct` to make all those connections. In `++peer` +our ost just identifies the incoming request by number. We don't have +access to the connecting `++duct`, but we use `ost` in the effects we +produce so our responses are correctly coupled to the incoming request. + +`you` is a `++ship`, which is just a [`@p`]() or a phonemic string like +`~tasfyn- partyv`. `%eyre` does some work to figure out who this is, or +uses a submarine name if it can't be determined. You can read more about +how we parse identities in `%eyre` in the [`%eyre` reference](). + +`pax` is a `++path`, or a list of `@ta`. In Hoon we most often write +paths as you would expect, `/something/like/this`. In `%gall` services +requests come in on a specific path, like `/data` or `/`. + +`++peer`, as with any arm that handles events, must produce a pair of a +`(list ++move)` and our context, with any intended changes. In this peer +we handle two cases, when `pax` is empty, or `~`, when our `pax` is +`/data`. We throw an error if `pax` is anything else. + +5. + +What exactly is a list of moves? + +Try pointing your browser at: + + http://localhost:8082/lead/ + +to see our response when `pax` in `++peer` is `~`. In our case we use +this URL to load the initial state of the application as JSON. This is +produced by the line `[[ost %give %rust %json vat-json]~ +>.$]` which +produces a single `++move`, and our local context. Let's look more +closely at our `++move`. + + ++ move ,[p=bone q=[%give gift]] :: output operation + +From our prior discussion we're familiar with a `++bone`, and `++gift` +is defined right above in `core.hook`: + + ++ gift :: output action + $% [%rust gilt] :: total update + [%rush gilt] :: partial update + [%mean (unit (pair term (list tank)))] :: Error, maybe w/ msg + [%nice ~] :: Response message + == + :: + +Which clearly depends on `++gilt`: + + ++ gilt :: subscription frame + $% [%hymn p=manx] :: html tree + [%json p=json] :: json + == + :: + +`++gift` defines the possible actions we can take in the moves that we +produce. We can send either partial or total updates with `%rush` or +`%rust` respectively. We can also send either an error, `%mean` or +default acknowledgement, `%nice`. + +Returning to our original `++move`, `[ost %give %rust %json vat-json]` +we can now read it as 'send a total update with `++vat-json` as +`++json`'. `++vat-json` simply takes our `(map @t @ud)` and turns it in +to JSON. + +Looking at the remainer of `++peer` we can see that it is mostly +control-flow that produces a `%mean` if our `pax` is not matched, and a +`%rush` if our `pax` is `%data`. We'll revisit this `%data` path later +on. + +5. + +How do we change our state? + +All of our state changes happen in `++poke-json`. Incoming messages are +handled by `++poke` arms in `%gall` services. If an incoming message has +a `%logo` it is appeneded after a `-`. Messages from the web are often +sent as JSON, so `++poke- json` is common for services that face the +web. + +Let's walk through this part: + + =. p.vat + (~(put by p.vat) newl) + :_ +>.$ + :* [ost %give %nice ~] + (deliver %upd-lead (joba -.newl [%n (scot %ud +.newl)])) + == + +Using [`=.`]() we update the value of `p.vat` in our context using +[`put:by`](), one of our map container functions. Then, we produce +`+>.$` as our context. Since we have changed the value of `p.vat` within +our immediate context, `$`, this is equivalient to updating the state of +our service. Changing a value in your context and producing it is all +you need to do to update your permanent state. That's one of the main +goals of `%gall`, to be a single-level store. + +So, how did we get to this point in `++poke-json`? + + =+ ^= jop + ^- kiss + %- need %. jon + => jo %- of + :~ [%new-lead so] + [%add-lead so] + == + +6. + +`++deliver` + +7. + +main.js diff --git a/docs/pub/doc/guide/d-app.md b/docs/pub/doc/guide/d-app.md new file mode 100644 index 0000000000..27533d68c3 --- /dev/null +++ b/docs/pub/doc/guide/d-app.md @@ -0,0 +1 @@ +A fully featured app using %ford and %gall diff --git a/docs/pub/doc/guide/e-dev.md b/docs/pub/doc/guide/e-dev.md new file mode 100644 index 0000000000..b16902ca2d --- /dev/null +++ b/docs/pub/doc/guide/e-dev.md @@ -0,0 +1,100 @@ +Doing development can be a messy process. Since Urbit ships are meant to +last forever it can be convenient to development on a disposable ship as +to not permanently destroy any of your own part of the urbit network. In +this short guide we're going to go over how to set up a fake network for +development on a single physical machine. + +This guide assumes that you have already followed the [setup +instructions](). Going forward we'll refer to the directory you cloned +the repo in as `/$URB_DIR`. + +1. + +Start a fake `vere` for the carrier `~zod`. + +In `/$URB_DIR`, run + + $ bin/vere -F -I ~zod -c zod + +This will boot `vere` into the carrier `~zod`. Because we're using the +flag `-F` `vere` doesn't check any of the keys to confirm that we are in +fact the owner of `~zod`. We use `-I` here to signal to `vere` that we +want to start an 'imperial' ship, or carrier. `-I` takes a ship name. +You can enter any one of the 256 Urbit carriers. More information on +`vere` and its command line options can be found [here](). + +You should see `vere` start as usual, although instead of copying its +files from a parent ship the files are copied from `urb/zod` inside your +Urbit directory. + +For most development tasks, using a fake carrier works really well. You +get a very short name, and a safe testing environment. If you need to +test out a collection of ships talking to each other, let's keep going. + +2. + +Start a second fake `vere`. + +In a new terminal, cd to `/$URB_DIR` and run: + + $ bin/vere -F -c doznec + +Since we don't specify a carrier with `-I` here, this should boot into a +submarine, as if you had started vere normally. In your running fake +`~zod` you should see a [`~&`]() alerting you that the sub you just +started is your neighbor. This means that a key exchange has happened, +and your packets are being transmitted directly. Now, let's get a ticket +for a cruiser. + +In your fake `~zod`, ticket a cruiser: + + ~zod/try=> :ticket ~doznec + +This line should return a `[ship: ticket]` pair of [`@p`](). You can Now +you can return to your submarine and run: + + ~sipmyl-wolmeb-haswel-losmyl--dibten-holdyn-dacdyn-natsep/try=> :begin + +Use the `[ship: ticket]` pair you got from your fake `~zod` to complete +the `:begin` process for `~doznec`. When finished you should see +something like `; ~doznec _doz_ is your neighbor` on your fake `~zod`. + +You can repeat this process on `~doznec`, ticketing destroyers that are +children of `~doznec` by running `:ticket` with a valid destroyer. +`:ticket` actually takes two arguments, a ship name and a number +indicating how many tickets to generate. `~tasfyn-partyv` is the first +destroyer under `~doznec`, so you can run `:ticket ~tasfyn-partyv 5` to +get five `[ship: ticket]` pairs. + +3. + +Add some files, make sure the network if functioning. + +You should now have a directory `/$URB_DIR/zod`. + +In + + /$URB_DIR/zod/zod/try/test.txt + +Put + + hello from mars + +You should see a sync event on `~zod` indicated by a `+` with the file +path, and at least one `%merge-fine` messages on `~doznec`. On your +filesystem, you should see the file mirrored in +`/$URB_DIR/doznec/doznec/try/test.txt`. + +You can also send a few `:hi` messages over the network. On `~doznec` +try: + + ~doznec/try=> :hi ~zod "just checking in from urth" + +You should see the message appear on your `~zod` and get a +`hi ~zod successful` on your `~doznec`. + +This is a good way to set up a test environment where you can try +anything out and break anything you want. When working in these test +environments it is usually safest to keep your working files outside of +your pier and copy them in. This way you can quickly +`rm -rf zod/ && bin/vere -F -I ~zod -c zod` to start again. diff --git a/docs/pub/doc/hoon.md b/docs/pub/doc/hoon.md new file mode 100644 index 0000000000..7655a426ce --- /dev/null +++ b/docs/pub/doc/hoon.md @@ -0,0 +1,24 @@ +
+ +hoon +==== + +hoon is our programming language. + +hoon is a strict, typed, functional language that compiles itself to +nock. The hoon compiler is 4000 lines of hoon. Adding standard +libraries, the self-compiling kernel is 8000 lines. The hoon compiler is +located towards the bottom of `/=main=/arvo/hoon.hoon`. The standard +library is split between `/=main=/arvo/hoon.hoon` and +`/=main=/arvo/zuse.hoon`. + +hoon has no particular familial relationship to other languages you may +know. It uses its own type inference algorithm and is as different from +Haskell as from Lisp. hoon syntax is also completely unfamiliar. hoon +uses ascii digraphs, which we call 'runes', instead of reserved words. + +
+ +------------------------------------------------------------------------ + + diff --git a/docs/pub/doc/hoon/library.md b/docs/pub/doc/hoon/library.md new file mode 100644 index 0000000000..2820a28436 --- /dev/null +++ b/docs/pub/doc/hoon/library.md @@ -0,0 +1,4 @@ +Library +======= + + diff --git a/docs/pub/doc/hoon/library/0.md b/docs/pub/doc/hoon/library/0.md new file mode 100644 index 0000000000..0345065d2f --- /dev/null +++ b/docs/pub/doc/hoon/library/0.md @@ -0,0 +1,37 @@ +volume 0, Kelvin Versioning +=========================== + +### ++hoon + + ++ hoon %164 :: version stub + +Declares the current Hoon version number in degrees Kelvin. + +When normal people release normal software, they count by fractions, and +they count up. Thus, they can keep extending and revising their systems +incrementally. This is generally considered a good thing. It generally +is. + +In some cases, however, specifications needs to be permanently frozen. +This requirement is generally found in the context of standards. Some +standards are extensible or versionable, but some are not. ASCII, for +instance, is perma-frozen. So is IPv4 (its relationship to IPv6 is +little more than nominal - if they were really the same protocol, they'd +have the same ethertype). Moreover, many standards render themselves +incompatible in practice through excessive enthusiasm for extensibility. +They may not be perma-frozen, but they probably should be. + +The true, Martian way to perma-freeze a system is what I call Kelvin +versioning. In Kelvin versioning, releases count down by integer degrees +Kelvin. At absolute zero, the system can no longer be changed. At 1K, +one more modification is possible. And so on. For instance, Nock is at +5K. It might change, though it probably won't. Nouns themselves are at +0K - it is impossible to imagine changing anything about their three +sentence definition. + +------------------------------------------------------------------------ + + ~zod/try=> stub + 164 + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/1.md b/docs/pub/doc/hoon/library/1.md new file mode 100644 index 0000000000..db01c434fa --- /dev/null +++ b/docs/pub/doc/hoon/library/1.md @@ -0,0 +1,1786 @@ +volume 1, Hoon Structures +========================= + +------------------------------------------------------------------------ + +### ++abel + + ++ abel typo :: original sin: type + +Biblical names in hoon are primarily aliases for the compiler. + +See also: `++typo` + + ~zod/try=> *abel + %void + +------------------------------------------------------------------------ + +### ++axis + + ++ axis ,@ :: tree address + +A Nock axis inside a noun. After the leading 1, in binary, a 1 signfies +right and 0 left. + +See also: `++clue`, `++limb`, `++slot`, `++peg`, and Section 2fC + + ~zod/try=> *axis + 0 + + ~zod/try=> :: 0 is not actually a valid axis + ~zod/try=> [[4 5] 6 7] + [[4 5] 6 7] + ~zod/try=> `axis`0b110 + 6 + +------------------------------------------------------------------------ + +### ++also + + ++ also ,[p=term q=wing r=type] :: alias + +XX unused? + +------------------------------------------------------------------------ + +### ++base + + ++ base ?([%atom p=odor] %noun %cell %bean %null) :: axils, @ * ^ ? ~ + +A base type that nouns are built from. Either a noun, a cell, loobean or +null labelled with an odor. + +See also: `++tile`, `++twig` + + ~zod/try=> *base + %null + + ~zod/try=> (ream '=|(^ !!)') + [%tsbr p=[%axil p=%cell] q=[%zpzp ~]] + ~zod/try=> :: p.p is a ++base + ~zod/try=> (ream '=|(@t !!)') + [%tsbr p=[%axil p=[%atom p=~.t]] q=[%zpzp ~]] + ~zod/try=> (ream '=|(? !!)') + [%tsbr p=[%axil p=%bean] q=[%zpzp ~]] + +------------------------------------------------------------------------ + +### ++bean + + ++ bean ,? :: 0=&=yes, 1=|=no + +The Urbit version of a boolean, which we call a loobean. 0 or & is +"yes", 1 or | is "no". + + ~zod/try=> *bean + %.y + + ~zod/try=> `bean`& + %.y + ~zod/try=> `bean`| + %.n + +------------------------------------------------------------------------ + +### ++beer + + ++ beer $|(@ [~ p=twig]) :: simple embed + +Used to build tapes internally. + +See also: `++phax`, `++scat`, section 2fD + + ~zod/try=> `beer`'as' + 29.537 + ~zod/try=> `beer`[~ (ream 'lan')] + [~ p=[%cnzz p=~[%lan]]] + +------------------------------------------------------------------------ + +### ++beet + + ++ beet $| @ :: advanced embed + $% [%a p=twig] :: take tape + [%b p=twig] :: take manx + [%c p=twig] :: take marl + [%d p=twig] :: take $+(marl marl) + [%e p=twig q=(list tuna)] :: element literal + == :: + +Cases for XML interpolation. Used internally. + +See also: `++sail`, section 2fD + +------------------------------------------------------------------------ + +### ++bloq + + ++ bloq ,@ :: blockclass + +Atom representing a blocksize, by convention expressed as a power of 2. + +See also: section 2cA + + ~zod/try=> :: ++met measures how many bloqs long an atom is + ~zod/try=> (met 3 256) + 2 + ~zod/try=> :: 256 is 2 bloqs of 2^3 + +------------------------------------------------------------------------ + +### ++calf + + ++ calf ,[p=(map ,@ud wine) q=wine] :: + +Encodes cyclical backreferences in types. Used in pretty printing. + +See also: `++wine`, `++dole`, `++doge`, `++dish`, section 2fC + + ~zod/try=> `calf`[~ %atom %ta] + [p={} q=[%atom p=%ta]] + + ~zod/try=> `calf`~(dole ut p:!>(*^)) + [p={} q=[%plot p=~[%noun %noun]]] + + ~zod/try=> `calf`~(dole ut p:!>($:|-(?(~ [* $])))) + [ p={[p=1 q=[%pick p=~[[%pear p=%n q=0] [%plot p=~[%noun [%stop p=1]]]]]]} + q=[%stop p=1] + ] + +------------------------------------------------------------------------ + +### ++char + + ++ char ,@tD :: UTF-8 byte + +A single character. Odor `@tD` designates a single Unicode byte. All +parsers consume `++tape` (a list of `++char`). + +See also: `++tape`, `++lust`, `++just`, `++mask`, chapter 2f + + ~zod/try=> *char + ~~ + + ~zod/try=> (char 97) + ~~a + +------------------------------------------------------------------------ + +### ++chub + + ++ chub :: registered battery + $: p=(pair chum tyre) :: definition + q=* :: battery + r=(unit (pair axis chub)) :: parent + == :: + +Used by the compiler (implicitly by `%sgcn`) to attach jets. + +See also: Section 2fB. + +------------------------------------------------------------------------ + +### ++chum + + ++ chum $? lef=term :: jet name + [std=term kel=@] :: kelvin version + [ven=term pro=term kel=@] :: vendor and product + [ven=term pro=term ver=@ kel=@] :: all of the above + == :: + +Jet hint information that must be present in the body of a \~/ or \~% +rune. A `++chum` can optionally contain a kelvin version, jet vendor, +and major.minor version number. + +XX there's a ++chum in zuse that's politely causing this not to work + +See also: `++twig`, `++clue` + + ~zod/try=> `chum`'hi' + lef=%hi + + ~zod/try=> (ream '~/(%lob.314 !!)') + [%sgfs p=[std=%lob kel=314] q=[%zpzp ~]] + +------------------------------------------------------------------------ + +### ++clue + + ++ clue ,[p=axis q=chum r=tyre] :: battery definition + +Used by compiler to attach jets. + +XX implementation does not currenlty match docs + +See also: section 2fB + +------------------------------------------------------------------------ + +### ++coil + + ++ coil $: p=?(%gold %iron %lead %zinc) :: core type + q=type :: + r=[p=?(~ ^) q=(map term foot)] :: + == :: + +Core information tuple: variance, subject type, optional compiled nock, +and arms. Used as an intermediate step within Section 2fB. Converted by +`++core` to %core type. + +See also: `++core`, Section 2fB + +------------------------------------------------------------------------ + +### ++coin + + ++ coin $% [%$ p=dime] :: + [%blob p=*] :: + [%many p=(list coin)] :: + == :: + +Noun literal syntax cases: atoms, jammed nouns, and nestable tuples. +Parsed and printed using `++so` and `++co` cores in Section 2eL +respectively. + +See also: `++so`, `++co`, Section 2eL, `++dime` + + ~zod/try=> `coin`(need (slay '~s1')) + [%$ p=[p=~.dr q=18.446.744.073.709.551.616]] + ~zod/try=> `coin`(need (slay '0x2b59')) + [%$ p=[p=~.ux q=11.097]] + + ~zod/try=> ~(rend co [%many ~[[%$ %ud 1] [%$ %tas 'a'] [%$ %s -2]]]) + "._1_a_-2__" + ~zod/try=> ._1_a_-2__ + [1 %a -2] + + ~zod/try=> `@uv`(jam [3 4]) + 0v2cd1 + ~zod/try=> (slay '~02cd1') + [~ [%blob p=[3 4]]] + ~zod/try=> ~02cd1 + [3 4] + +------------------------------------------------------------------------ + +### ++cord + + ++ cord ,@t :: text atom (UTF-8) + +One of Hoon's two string types (the other being `++tape`). A cord is an +atom of UTF-8 text. `++trip` and `++crip` convert between cord and +`++tape` + +Odor `@t` designates a Unicode atom, little-endian: the first character +in the text is the low byte. + +See also: `++trip`, `++crip`, Section 2eJ + + ~zod/try=> `@ux`'foobar' + 0x7261.626f.6f66 + + ~zod/try=> `@`'urbit' + 499.984.265.845 + ~zod/try=> (cord 499.984.265.845) + 'urbit' + +------------------------------------------------------------------------ + +### ++date + + ++ date ,[[a=? y=@ud] m=@ud t=tarp] :: parsed date + +A point in time. A loobean designating AD or BC, a year atom, a month +atom, and a `++tarp`, which is a day atom and a time. + +See also: `++year`, `++yore`, Section 2cH, `++stud`, `++dust`, Section +3bc + + ~zod/try=> `date`(yore ~2014.6.6..21.09.15..0a16) + [[a=%.y y=2.014] m=6 t=[d=6 h=21 m=9 s=15 f=~[0xa16]]] + +------------------------------------------------------------------------ + +### ++dime + + ++ dime ,[p=@ta q=@] :: + +Odor-atom pair, used in `++coin`. + +Convenience methods `++scot` and `++scow` (in Section 2eL) print dimes +as cords/tapes, `++slat`, `++slav`, and `++slaw` are used to parse atoms +of specific odor. + +See also: `++so`, `++co`, Section 2eL, `++coin` + + ~zod/try=> +>:(slay '0x123') + p=[p=~.ux q=291] + +------------------------------------------------------------------------ + +### ++dram + + ++ dram $% [| p=(map ,@tas dram)] :: simple unix dir + [& p=@ud q=@] :: + == :: + +The structure of a unix filesystem tree. A `++dram` is one of two cases: +`|` a directory - a map of names to deeper tree structures, `&` a file - +a numbered atom of data. + +XX Unused + +------------------------------------------------------------------------ + +### ++each + + ++ each |*([a=$+(* *) b=$+(* *)] $%([& p=a] [| p=b])) :: either a or b + +Tile generator: produces a dicriminated fork between two types. + + ~zod/try=> :type; *(each cord time) + [%.y p=''] + {[%.y p=@t] [%.n p=@da]} + +------------------------------------------------------------------------ + +### ++edge + + ++ edge ,[p=hair q=(unit ,[p=* q=nail])] :: parsing output + +Parsing location metadata: optional result and parsing continuation. + +See also: Section 2eD, `++rule` + + ~zod/try=> *edge + [p=[p=0 q=0] q=~] + ~zod/try=> (tall:vast [1 1] "a b") + [p=[p=1 q=2] q=[~ [p=[%cnzz p=~[%a]] q=[p=[p=1 q=2] q=" b"]]]] + +------------------------------------------------------------------------ + +### ++foot + + ++ foot $% [%ash p=twig] :: dry arm, geometric + [%elm p=twig] :: wet arm, generic + [%oak ~] :: XX not used + [%yew p=(map term foot)] :: XX not used + == :: + +Cases of arms by variance model. + +See also: `++ap`, `++ut`, Section 2fB, Section 2fC + + ~zod/try=> *foot + [%yew p={}] + + ~zod/try=> (ream '|% ++ $ foo --') + [%brcn p={[p=%$ q=[%ash p=[%cnzz p=~[%foo]]]]}] + ~zod/try=> +<+:(ream '|% ++ $ foo --') + t=~[%ash %cnzz %foo] + ~zod/try=> (foot +<+:(ream '|% ++ $ foo --')) + [%ash p=[%cnzz p=~[%foo]]] + ~zod/try=> (foot +<+:(ream '|% +- $ foo --')) + [%elm p=[%cnzz p=~[%foo]]] + +------------------------------------------------------------------------ + +### ++gate + + ++ gate $+(* *) :: general gate + +An core with one arm, `$`, which transforms a sample noun into a product +noun. If used dryly as a type, subject must have a sample type of `*`. + +See also: `++lift`, `++cork`, Core Language Doc + + ~zod/try=> *gate + <1|mws [* <101.jzo 1.ypj %164>]> + ~zod/try=> `gate`|=(* 0) + <1|mws [* <101.jzo 1.ypj %164>]> + + ~zod/try=> (|=(a=* [a 'b']) 'c') + [99 'b'] + ~zod/try=> (`gate`|=(a=* [a 'b']) 'c') + [99 98] + +------------------------------------------------------------------------ + +### ++hair + + ++ hair ,[p=@ud q=@ud] :: parsing trace + +A pair of two `@ud` used in parsing indicating line and column number. + +See also: `++last`, Section 2eB + + ~zod/try=> *hair + [p=0 q=0] + + ~zod/try=> `hair`[1 1] :: parsing starts at [1 1] as a convention. + [p=1 q=1] + ~zod/try=> ((plus ace) [1 1] " --") + [p=[p=1 q=4] q=[~ u=[p=[~~. " "] q=[p=[p=1 q=4] q="--"]]]] + ~zod/try=> `hair`p:((plus ace) [1 1] " --") + [p=1 q=4] + +------------------------------------------------------------------------ + +### ++like + + ++ like |* a=_,* :: generic edge + |= b=_`*`[(hair) ~] :: + :- p=(hair -.b) :: + ^= q :: + ?@ +.b ~ :: + :- ~ :: + u=[p=(a +>-.b) q=[p=(hair -.b) q=(tape +.b)]] :: + +Tile generator for an `++edge`. `++like` generates an `++edge` with a +parsed result set to a specific type. + +See also: `++easy`, `++just`/`++jest`, `++knee`, `++mask`, `++shim`, +`++stir`, `++stun`, Section 2eC + + ~zod/try=> *(like char) + [p=[p=0 q=0] q=~] + + ~zod/try=> (ace [1 1] " a") + [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q="a"]]]] + ~zod/try=> `(like char)`(ace [1 1] " a") + [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q="a"]]]] + ~zod/try=> `(like ,@)`(ace [1 1] " a") + [p=[p=1 q=2] q=[~ [p=32 q=[p=[p=1 q=2] q="a"]]]] + +------------------------------------------------------------------------ + +### ++limb + + ++ limb $|(term $%([%& p=axis] [%| p=@ud q=term])) :: + +XX move to `++ut` + +Reference into subject by name/axis + +See also: section 2fC-2fD + + ~zod/try=> (ream '^^$') + [%cnzz p=~[[%.n p=2 q=%$]]] + ~zod/try=> (limb &2:(ream '^^$')) + [%.n p=2 q=%$] + ~zod/try=> (limb &2:(ream '^^^$')) + [%.n p=3 q=%$] + +------------------------------------------------------------------------ + +### ++line + + ++ line ,[p=[%leaf p=odor q=@] q=tile] :: %kelp case + +XX move to `++ut` + +Dicriminated union unionee XX + +Used in compilation and grammar, section 2fC-2fD + + ~zod/try=> (ream '$%([1 a] [%2 b])') + [ %bccm + p + [ %kelp + p + [ i=[p=[%leaf p=~.ud q=1] q=[%herb p=[%cnzz p=~[%a]]]] + t=~[[p=[%leaf p=~.ud q=2] q=[%herb p=[%cnzz p=~[%b]]]]] + ] + ] + ] + ~zod/try=> &3:(ream '$%([1 a] [%2 b])') + p=[p=[%leaf p=%ud q=1] q=[%herb p=[%cnzz p=~[%a]]]] + ~zod/try=> (line &3:(ream '$%([1 a] [%2 b])')) + [p=[%leaf p=~.ud q=1] q=[%herb p=[%cnzz p=~[%a]]]] + +------------------------------------------------------------------------ + +### ++list + + ++ list |* a=_,* :: null-term list + $|(~ [i=a t=(list a)]) :: + +Tile generator. `++list` generates a tile of a null-termanated list of +homogenous type. + +See also: `++turn`, `++snag`, section 2bB. + + ~zod/try=> *(list) + ~ + ~zod/try=> `(list ,@)`"abc" + ~[97 98 99] + ~zod/try=> (snag 0 "abc") + ~~a + +------------------------------------------------------------------------ + +### ++lone + + ++ lone |*(a=$+(* *) ,p=a) :: just one thing + +XX unused + +Tile generator. `++lone` puts face of `p` on something. + +------------------------------------------------------------------------ + +### ++mane + + ++ mane $|(@tas [@tas @tas]) :: XML name/space + +An XML name (tag name or attribute name) with an optional namespace. +Parsed by `++name`:poxa, rendered by `++name`:poxo. + +See also: `++sail` doc, Section 3bD + + ~zod/try=> *mane + %$ + + ~zod/try=> `mane`n.g:`manx`;div:namespace; + %div + ~zod/try=> `mane`n.g:`manx`;div_namespace; + [%div %namespace] + +------------------------------------------------------------------------ + +### ++manx + + ++ manx ,[g=marx c=marl] :: XML node + +XML node. + +Parsed by `++apex`:poxa, rendered by `++poxo`, section 3bD + +See also: `++sail` doc, Section 3bD + +------------------------------------------------------------------------ + +### ++marl + + ++ marl (list manx) :: XML node list + +List of XML nodes. + +Parsed within `++apex`:poxa, rendered by `++many`:poxo, section 3bD + +See also: `++sail` doc + +------------------------------------------------------------------------ + +### ++mars + + ++ mars ,[t=[n=%$ a=[i=[n=%$ v=tape] t=~]] c=~] :: XML cdata + +XML CDATA. Implicitly produced by `++chrd`:poxa + +See also: `++sail` doc + +------------------------------------------------------------------------ + +### ++mart + + ++ mart (list ,[n=mane v=tape]) :: XML attributes + +List of XML attributes. Each `++mart` is a list of pairs of `++mane` and +`++tape`. + +Parsed by `++attr`:poxa, rendered by `++attr`:poxo, section 3bD + +See also: `++sail` doc + +------------------------------------------------------------------------ + +### ++marx + + ++ marx ,[n=mane a=mart] :: XML tag + +XML tag. A `++marx` is a pair of a tag name, `++mane` and a list of +attributes, `++mart`. + +Parsed by `++head`:poxa, rendered within `++poxo`, section 3bD + +See also: `++sail` doc + +------------------------------------------------------------------------ + +### ++metl + + ++ metl ?(%gold %iron %zinc %lead) :: core variance + +XX move to `++ut` + +See also: `++coil` + +------------------------------------------------------------------------ + +### ++noun + + ++ noun ,* :: any noun + +Used nowhere XX + + ~zod/try=> `noun`~[1 2 3] + [1 2 3 0] + +------------------------------------------------------------------------ + +### ++null + + ++ null ,~ :: null, nil, etc + +Used nowhere XX + + ~zod/try=> :type; *null + ~ + %~ + +------------------------------------------------------------------------ + +### ++odor + + ++ odor ,@ta :: atom format + +By convetion, a short name for a category of atom. `++odor` is +circularly defined, `@ta` being the `++odor` of the ASCII subset +commonly used in urbit. + +See also: `++base`, odor reference + + ~zod/try=> `odor`%ux + ~.ux + +------------------------------------------------------------------------ + +### ++tarp + + ++ tarp ,[d=@ud h=@ud m=@ud s=@ud f=(list ,@ux)] :: parsed time + +The remaining part of a `++date`: day, hour, minute, second and a list +of `@ux` for precision. + +See also: `++date`, `++yell`/`++yule`, Section 2cH + + ~zod/try=> -<- + ~2014.9.20..00.43.33..b52a + ~zod/try=> :: the time is always in your context at -<- + ~zod/try=> (yell -<-) + [d=106.751.991.820.278 h=0 m=43 s=39 f=~[0x54d1]] + + ~zod/try=> (yell ~d20) + [d=20 h=0 m=0 s=0 f=~] + +------------------------------------------------------------------------ + +### ++time + + ++ time ,@da :: galactic time + +The `@da` odor designates an absolute date atom. + +See also: `++date`, odor reference + + ~zod/try=> `time`-<- + ~2014.9.25..20.01.47..eeac + ~zod/try=> :: the time is always in your context at -<- + ~zod/try=> `time`~2014.1.1 + ~2014.1.1 + +------------------------------------------------------------------------ + +### ++tree + + ++ tree |* a=_,* :: binary tree + $|(~ [n=a l=(tree a) r=(tree a)]) :: + +Tile generator. A `++tree` can be empty, or contain a node of a type and +left/right sub `++tree`s of the same type. Pretty-printed with `{}`. + + ~zod/try=> `(tree ,[@ tape])`[[1 "hi"] [[2 "bye"] ~ ~] ~] + {[2 "bye"] [1 "hi"]} + +------------------------------------------------------------------------ + +### ++nail + + ++ nail ,[p=hair q=tape] :: parsing input + +Location in parsed text, and remainder of it. Indicates parsing position +and remaining text to be parsed. + +See also: `++roll` + + ~zod/try=> +<:;~(plug cab cab) + c=tub=[p=[p=0 q=0] q=""] + ~zod/try=> :: tub is a ++nail + +------------------------------------------------------------------------ + +### ++numb + + ++ numb ,@ :: just a number + +Used nowhere XX + +------------------------------------------------------------------------ + +### ++pair + + ++ pair |*([a=$+(* *) b=$+(* *)] ,[p=a q=b]) :: just a pair + +Tile generator. Produces a tuple of two of the types passed in. + + ~zod/try=> *(pair bean cord) + [p=%.y q=''] + +------------------------------------------------------------------------ + +### ++pass + + ++ pass ,@ :: public key + +Atom alias. Used primarily in crypto. + +See also: `++acru`, `++crua`, `++crub` + +------------------------------------------------------------------------ + +### ++path + + ++ path (list span) :: filesys location + +A filesystem path. A `++path` is a list of `++span`, `@ta`. Used in +`%clay` and `%eyre` extensively. + + ~zod/try=> `path`"abc" + /a/b/c + +------------------------------------------------------------------------ + +### ++pint + + ++ pint ,[p=[p=@ q=@] q=[p=@ q=@]] :: line/column range + +A parsing range, mostly used for stacktraces. A `++pint` is a pair of +hairs indicating from - to. + + ~zod/try=> !:(!!) + ! /~zod/try/~2014.9.20..01.22.04..52e3/:<[1 4].[1 6]> + ~zod/try=> :: !! always produces a crash + ~zod/try=> `pint`[[1 4] [1 6]] + [p=[p=1 q=4] q=[p=1 q=6]] + +------------------------------------------------------------------------ + +### ++pole + + ++ pole |* a=_,* :: nameless list + $|(~ [a (pole a)]) :: + +A `++list` without the faces. A `++pole` is a null-terminated typle +without the `i=` and `t=`. + + ~zod/try=> `(pole char)`"asdf" + [~~a [~~s [~~d [~~f ~]]]] + +------------------------------------------------------------------------ + +### ++port + + ++ port $: p=axis :: + $= q :: + $% [%& p=type] :: + [%| p=axis q=(list ,[p=type q=foot])] :: + == :: + == :: + +XX move to `++ut` + +Type and location of core-shaped thing? XX Compiler Internals + + ~zod/try=> *port + [p=0 q=[%.y p=%void]] + +------------------------------------------------------------------------ + +### ++post + + ++ post $: p=axis :: + $= q :: + $% [0 p=type] :: + [1 p=axis q=(list ,[p=type q=foot])] :: + [2 p=twin q=type] :: + == :: + == :: + +XX move to `++ut` + +Type and location of possibly core-shaped thing? XX Compiler Internals + + ~zod/try=> *post + [p=0 q=[%0 p=%void]] + +------------------------------------------------------------------------ + +### ++prop + + ++ prop $: p=axis :: + $= q :: + [p=?(~ axis) q=(list ,[p=type q=foot])] :: + == :: + +XX move to `++ut` + +Verified core-shaped thing? XX Compiler Internals + + ~zod/try=> *prop + [p=0 q=[p=~ q=~]] + +------------------------------------------------------------------------ + +### ++qual + + ++ qual |* [a=$+(* *) b=$+(* *) c=$+(* *) d=$+(* *)] :: just a quadruple + ,[p=a q=b r=c s=d] :: + +Tile generator. A `++qual` is a tuple of four of the types passed in.. + + ~zod/try=> *(qual date time tape cord) + [p=[[a=%.y y=0] m=0 t=[d=0 h=0 m=0 s=0 f=~]] q=~292277024401-.1.1 r="" s=''] + +------------------------------------------------------------------------ + +### ++rege + + ++ rege $| ?(%dote %ende %sart %empt %boun %bout) :: parsed regex + $% [%lite p=char] :: literal + [%pair p=rege q=rege] :: ordering + [%capt p=rege q=@u] :: capture group + [%brac p=@] :: p is 256 bitmask + [%eith p=rege q=rege] :: either + [%mant p=rege] :: greedy 0 or more + [%plls p=rege] :: greedy 1 or more + [%betw p=rege q=@u r=@u] :: between q and r + [%bint p=rege q=@u] :: min q + [%bant p=rege q=@u] :: exactly q + [%manl p=rege] :: lazy 0 or more + [%plll p=rege] :: lazy 1 or more + [%betl p=rege q=@u r=@u] :: between q and r lazy + [%binl p=rege q=@u] :: min q lazy + == :: + +Regular expressions. `++rege` defines the cases of a regex. + +See also: `++rexp`, `++repg`, `++pars` + + ~zod/try=> (pars "[a-z]") + [~ [%brac p=10.633.823.807.823.001.954.701.781.295.154.855.936]] + ~zod/try=> (rexp "[a-z]" "abc1") + [~ [~ {[p=0 q="a"]}]] + +------------------------------------------------------------------------ + +### ++ring + + ++ ring ,@ :: private key + +Atom alias, used primarily in crypto. + +See also: `++acru`, `++crua`, `++crub`. + +------------------------------------------------------------------------ + +### ++rule + + ++ rule |=(tub=nail `edge`[p.tub ~ ~ tub]) :: parsing rule + +Parsing rule. `++rule` is an empty parsing rule, but it is used to check +that parsing rules match this with `_`. + +See also: `++cold`, Section 2eC + + ~zod/try=> *rule + [p=[p=0 q=0] q=[~ [p=0 q=[p=[p=0 q=0] q=""]]]] + + ~zod/try=> ^+(rule [|=(a=nail [p.a ~])]:|6) + <1.dww [tub=[p=[p=@ud q=@ud] q=""] <101.jzo 1.ypj %164>]> + ~zod/try=> (^+(rule [|=(a=nail [p.a ~ u=['a' a]])]:|6) [1 1] "hi") + [p=[p=1 q=1] q=[~ [p=97 q=[p=[p=1 q=1] q="hi"]]]] + ~zod/try=> ([|=(a=nail [p.a ~ u=['a' a]])]:|6 [1 1] "hi") + [[p=1 q=1] ~ u=['a' p=[p=1 q=1] q="hi"]] + +------------------------------------------------------------------------ + +### ++span + + ++ span ,@ta :: text-atom (ASCII) + +A restricted text atom for canonical atom syntaxes. The prefix is `~.`. +There are no escape sequences except `~~`, which means `~`, and `~-`, +which means `_`. `-` and `.` encode themselves. No other characters +besides numbers and lowercase letters are permitted. + + ~zod/try=> *span + ~. + + ~zod/try=> `@t`~.foo + 'foo' + ~zod/try=> `@t`~.foo.bar + 'foo.bar' + ~zod/try=> `@t`~.foo~~bar + 'foo~bar' + ~zod/try=> `@t`~.foo~-bar + 'foo_bar' + ~zod/try=> `@t`~.foo-bar + 'foo-bar' + +------------------------------------------------------------------------ + +### ++spot + + ++ spot ,[p=path q=pint] :: range in file + +Stack trace line. A `++spot` is what we print after crashing. + +See also: `++pint` + + ~zod/try=> :into /=main=/bin/fail/hoon '!: !!' + + /~zod/main/359/bin/fail/hoon + ~zod/try=> :fail + ! /~zod/main/~2014.9.22..18.40.56..ef04/bin/fail/:<[1 5].[1 7]> + ! exit + +------------------------------------------------------------------------ + +### ++tang + + ++ tang (list tank) :: general error + +Unused XX + +------------------------------------------------------------------------ + +### ++tank + + ++ tank $% [%leaf p=tape] :: printing formats + $: %palm :: + p=[p=tape q=tape r=tape s=tape] :: + q=(list tank) :: + == :: + $: %rose :: delimeted list + p=[p=tape q=tape r=tape] :: mid open close + q=(list tank) :: + == :: + == + +Pretty-printing structure. A `++tank` is one of three cases. A `%leaf` +is just a string. A `%palm` is XX need more information. A `%rose` is a +list of `++tank` delimted by the strings in `p`. + + ~zod/try=> >(bex 20) (bex 19)< + [%rose p=[p=" " q="[" r="]"] q=~[[%leaf p="1.048.576"] [%leaf p="524.288"]]] + ~zod/try=> (wash [0 80] >(bex 20) (bex 19)<) :: at 80 cols + <<"[1.048.576 524.288]">> + ~zod/try=> (wash [0 15] >(bex 20) (bex 19)<) :: at 15 cols (two lines) + <<"[ 1.048.576" " 524.288" "]">> + + ~zod/try=> [(bex 150) (bex 151)] :: at 80 cols + [ 1.427.247.692.705.959.881.058.285.969.449.495.136.382.746.624 + 2.854.495.385.411.919.762.116.571.938.898.990.272.765.493.248 + ] + +------------------------------------------------------------------------ + +### ++tape + + ++ tape (list char) :: like a string + +One of Hoon's two string types, the other being `++cord`. A tape is a +list of chars. + + ~zod/try=> `(list ,char)`"foobar" + "foobar" + ~zod/try=> `(list ,@)`"foobar" + ~[102 111 111 98 97 114] + +------------------------------------------------------------------------ + +### ++term + + ++ term ,@tas :: Hoon ASCII subset + +A restricted text atom for Hoon constants. The only characters permitted +are lowercase ASCII, - except as the first or last character, and 0-9 +except as the first character. The syntax for `@tas` is the text itself, +always preceded by `%`. This means a term is always cubical. The empty +`@tas` has a special syntax, `$`: + + ~zod/try=> *term + %$ + + ~zod/try=> %dead-fish9 + %dead-fish9 + ~zod/try=> -:!>(%dead-fish9) + [%cube p=271.101.667.197.767.630.546.276 q=[%atom p=%tas]] + +------------------------------------------------------------------------ + +### ++tiki + + ++ tiki :: test case + $% [& p=(unit term) q=wing] :: simple wing + [| p=(unit term) q=twig] :: named wing + == :: + +XX move to `++ut` + +A `++wing` or `++twig`. + + ~zod/try=> (ream '=+ a=4 ?-(a @ ~)') + [ %tsls + p=[%ktts p=p=%a q=[%dtzy p=%ud q=4]] + q + [ %wthz + p=[%.y p=~ q=~[%a]] + q=~[[p=[%axil p=[%atom p=~.]] q=[%bczp p=%null]]] + ] + ] + ~zod/try=> (ream '=+ a=4 ?-(4 @ ~)') + [ %tsls + p=[%ktts p=p=%a q=[%dtzy p=%ud q=4]] + q + [ %wthz + p=[%.n p=~ q=[%dtzy p=%ud q=4]] + q=~[[p=[%axil p=[%atom p=~.]] q=[%bczp p=%null]]] + ] + ] + +------------------------------------------------------------------------ + +### ++tile + +See the Tile section of the Hoon Reference. + +------------------------------------------------------------------------ + +### ++toga + + ++ toga :: face control + $| p=term :: two togas + $% [0 ~] :: no toga + [1 p=term q=toga] :: deep toga + [2 p=toga q=toga] :: cell toga + == :: + +XX move to `++ut` and rune doc (for \^= examples) + +A face, or tree of faces. A `++toga` is applied to anything assigned +using `^=`. + + ~zod/try=> a=1 + a=1 + ~zod/try=> (ream 'a=1') + [%ktts p=p=%a q=[%dtzy p=%ud q=1]] + ~zod/try=> [a b]=[1 2 3] + [a=1 b=[2 3]] + ~zod/try=> (ream '[a b]=[1 2 3]') + [ %ktts + p=[%2 p=p=%a q=p=%b] + q=[%cltr p=~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]]] + ] + + ~zod/try=> [a ~]=[1 2 3] + [a=1 2 3] + ~zod/try=> (ream '[a ~]=[1 2 3]') + [ %ktts + p=[%2 p=p=%a q=[%0 ~]] + q=[%cltr p=~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]]] + ] + +------------------------------------------------------------------------ + +### ++trap + + ++ trap ,_|.(_*) :: makes perfect sense + +A trap is a core with one arm `++$`. + +See also: `|.` + + ~zod/try=> *trap + <1.mws 101.jzo 1.ypj %164> + ~zod/try=> (*trap) + 0 + ~zod/try=> (|.(42)) + 42 + +------------------------------------------------------------------------ + +### ++trel + + ++ trel |* [a=$+(* *) b=$+(* *) c=$+(* *)] :: just a triple + ,[p=a q=b r=c] :: + +Tile generator. `++trel` is a tuple of three of the types passed in. + + ~zod/try=> *(trel ,@ud ,@t ,@s) + [p=0 q='' r=--0] + +------------------------------------------------------------------------ + +### ++tuna + + ++ tuna :: tagflow + $% [%a p=twig] :: plain text + [%b p=twig] :: single tag + [%c p=twig] :: simple list + [%d p=twig] :: dynamic list + [%e p=twig q=(list tuna)] :: element + [%f p=(list tuna)] :: subflow + == :: + +An XML template tree. + +Leaf %a contains plain-text, %b an empty tag, %c a static list, %d a +dynamic list, %e a full node element containing a twig and a list of +tuna, and %f is a empty node. + +See also: `++sail` + +------------------------------------------------------------------------ + +### ++twig + +See Twig section of Hoon reference + +------------------------------------------------------------------------ + +### ++tine + + ++ tine (list ,[p=tile q=twig]) :: + +Switch statement cases. In `?-`, for example, your list of cases is a +`++tine`. + +See also: `++twig` + + ~zod/try=> (ream '?-(!! @ |, ^ &)') + [ %wthz + p=[%.n p=~ q=[%zpzp ~]] + q + ~[ + [p=[%axil p=[%atom p=~.]] q=[%dtzy p=%f q=1]] + [p=[%axil p=%cell] q=[%dtzy p=%f q=0]] + ] + ] + ~zod/try=> (tine |2:(ream '?-(!! @ |, ^ &)')) + ~[ + [p=[%axil p=[%atom p=~.]] q=[%dtzy p=%f q=1]] + [p=[%axil p=%cell] q=[%dtzy p=%f q=0]] + ] + +------------------------------------------------------------------------ + +### ++tusk + + ++ tusk (list twig) :: + +Variable-arity expression list. In `:*`, for example, your contents are +a `++tusk`. + +See also: `++twig` + + ~zod/try=> (ream '[1 2 3]') + [%cltr p=~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]]] + ~zod/try=> (tusk +:(ream '[1 2 3]')) + ~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]] + +------------------------------------------------------------------------ + +### ++tyre + + ++ tyre (list ,[p=term q=twig]) :: + +Associative list of term to twig, used in jet hint processing. + +See also: `++twig` + +------------------------------------------------------------------------ + +### ++tyke + + ++ tyke (list (unit twig)) :: + +List of twigs, or gaps left to be inferred, in path parsing. When you +use a path such as `/=main=/pub/src/doc` the path is in fact a `++tyke`, +where the `=` are inferred from your current path. + + ~zod/try=> (scan "/==as=" porc:vast) + [0 ~[~ ~ [~ [%dtzy p=%tas q=29.537]] ~]] + ~zod/try=> `tyke`+:(scan "/==as=" porc:vast) + ~[~ ~ [~ [%dtzy p=%tas q=29.537]] ~] + +------------------------------------------------------------------------ + +### ++tram + + ++ tram (list ,[p=wing q=twig]) :: + +List of changes by location in context. When using `%=`, for example, +the list of changes is a `++tram`. + +See also: `++twig` + + ~zod/try=> (ream '$(a 1, b 2)') + [ %cnts + p=~[%$] + q=~[[p=~[%a] q=[%dtzy p=%ud q=1]] [p=~[%b] q=[%dtzy p=%ud q=2]]] + ] + ~zod/try=> (tram +:(ream '$(a 1, b 2)')) + ~[[p=~ q=[% p=0]] [p=~[%a] q=[%dtzy p=%ud q=1]] [p=~[%b] q=[%dtzy p=%ud q=2]]] + +------------------------------------------------------------------------ + +### ++nock + + ++ nock $& [p=nock q=nock] :: autocons + $% [%0 p=@] :: axis select + [%1 p=*] :: constant + [%2 p=nock q=nock] :: compose + [%3 p=nock] :: cell test + [%4 p=nock] :: increment + [%5 p=nock q=nock] :: equality test + [%6 p=nock q=nock r=nock] :: if, then, else + [%7 p=nock q=nock] :: serial compose + [%8 p=nock q=nock] :: push onto subject + [%9 p=@ q=nock] :: select arm and fire + [%10 p=?(@ [p=@ q=nock]) q=nock] :: hint + [%11 p=nock] :: grab data from sky + == :: + +See Nock doc + + ~zod/try=> !=([+(.) 20 -<]) + [[4 0 1] [1 20] 0 4] + ~zod/try=> (nock !=([+(.) 20])) + [p=[%4 p=[%0 p=1]] q=[%1 p=20]] + +------------------------------------------------------------------------ + +### ++tone + + ++ tone $% [%0 p=*] :: success + [%1 p=(list)] :: blocks + [%2 p=(list ,[@ta *])] :: error ~_s + == :: + +Intermediate Nock computation result. Similar to `++toon`, but stack +trace is not yet rendered. + + ~zod/try=> (mink [[20 21] 0 3] ,~) + [%0 p=21] + + ~zod/try=> (mink [[0] !=(.^(cy//=main/1))] ,~) + [%1 p=~[[31.075 1.685.027.454 1.852.399.981 49 0]]] + ~zod/try=> (path [31.075 1.685.027.454 1.852.399.981 49 0]) + /cy/~zod/main/1 + + ~zod/try=> (mink [[1 2] !=(~|(%hi +(.)))] ,~) + [%2 p=~[[~.yelp 26.984]]] + ~zod/try=> (mink [[1 2] !=(!:(+(.)))] ,~) + [ %2 + p + ~[ + [ ~.spot + [ [ 1.685.027.454 + 7.959.156 + \/159.445.990.350.374.058.574.398.238.344.143.957.205.628.479.572.65\/ + 8.112.403.878.526 + \/ \/ + 0 + ] + [1 20] + 1 + 24 + ] + ] + ] + ] + +------------------------------------------------------------------------ + +### ++toon + + ++ toon $% [%0 p=*] :: success + [%1 p=(list)] :: blocks + [%2 p=(list tank)] :: stack trace + == :: + +Nock computation result. Either success (`%0`), a block with list of +requests blocked on (`%1`), or failure with stack trace (`%2`). + + ~zod/try=> (mock [[20 21] 0 3] ,~) + [%0 p=21] + + ~zod/try=> (mock [[0] !=(.^(cy//=main/1))] ,~) + [%1 p=~[[31.075 1.685.027.454 1.852.399.981 49 0]]] + ~zod/try=> (path [31.075 1.685.027.454 1.852.399.981 49 0]) + /cy/~zod/main/1 + + ~zod/try=> (mock [[1 2] !=(!:(+(.)))] ,~) + [%2 p=~[[%leaf p="/~zod/try/~2014.9.23..18.34.32..d3c5/:<[1 20].[1 24]>"]]] + +------------------------------------------------------------------------ + +### ++tune + + ++ tune $% [%0 p=vase] :: + [%1 p=(list)] :: + [%2 p=(list ,[@ta *])] :: + == :: + +XX Unused + +Probably typed `tone`? + +------------------------------------------------------------------------ + +### ++twin + + ++ twin ,[p=term q=wing r=axis s=type] :: alias info + +Aliasing. Used in `%bull` `++type` to typecheck aliased faces. + + ~zod/try=> (~(busk ut %cell %noun [%atom %ud]) %fal [%& 3]~) + [ %bull + p=[p=%fal q=~[[%.y p=3]] r=3 s=[%atom p=%ud]] + q=[%cell p=%noun q=[%atom p=%ud]] + ] + ~zod/try=> &2:(~(busk ut %cell %noun [%atom %ud]) %fal [%& 3]~) + p=[p=%fal q=~[[%.y p=3]] r=3 s=[%atom p=%ud]] + ~zod/try=> (twin &2:(~(busk ut %cell %noun [%atom %ud]) %fal [%& 3]~)) + [p=%fal q=~[[%.y p=3]] r=3 s=[%atom p=%ud]] + +------------------------------------------------------------------------ + +### ++type + +See Type section of Hoon reference + +------------------------------------------------------------------------ + +### ++typo + + ++ typo type :: old type + +Pointer for `++type`. `++typo` preserves the previous `++type` in your +context when upating. + +See also: `++seem`, `++vise`, `++type` + +------------------------------------------------------------------------ + +### ++udal + + ++ udal :: atomic change (%b) + $: p=@ud :: blockwidth + q=(list ,[p=@ud q=(unit ,[p=@ q=@])]) :: indels + == :: + +XX Unused + +------------------------------------------------------------------------ + +### ++udon + + ++ udon :: abstract delta + $: p=umph :: preprocessor + $= q :: patch + $% [%a p=* q=*] :: trivial replace + [%b p=udal] :: atomic indel + [%c p=(urge)] :: list indel + [%d p=upas q=upas] :: tree edit + == :: + == :: + +See `%clay` doc + +------------------------------------------------------------------------ + +### ++umph + + ++ umph :: change filter + $| $? %a :: no filter + %b :: jamfile + %c :: LF text + == :: + $% [%d p=@ud] :: blocklist + == :: + +See `%clay` doc + +------------------------------------------------------------------------ + +### ++unce + + ++ unce |* a=_,* :: change part + $% [%& p=@ud] :: skip[copy] + [%| p=(list a) q=(list a)] :: p -> q[chunk] + == :: + +See `%clay` doc + +------------------------------------------------------------------------ + +### ++unit + + ++ unit |* a=_,* :: maybe + $|(~ [~ u=a]) :: + +Tile generator. A `++unit` is either `~` or `[~ u=a]` where `a` is the +type that was passed in. + +See also: `++bind`, Section 2bA + + ~zod/try=> :type; *(unit time) + ~ + u(@da) + ~zod/try=> `(unit time)`[~ -<-] + [~ ~2014.9.24..19.25.10..7dd5] + +------------------------------------------------------------------------ + +### ++upas + + ++ upas :: tree change (%d) + $& [p=upas q=upas] :: cell + $% [%0 p=axis] :: copy old + [%1 p=*] :: insert new + [%2 p=axis q=udon] :: mutate! + == :: + +See `%clay` doc + +------------------------------------------------------------------------ + +### ++urge + + ++ urge |*(a=_,* (list (unce a))) :: list change + +See `%clay` doc + +------------------------------------------------------------------------ + +### ++vase + + ++ vase ,[p=type q=*] :: type-value pair + +Typed data. A `++vase` is used wherever typed data is explicitly worked +with. + +See `%arvo` doc + + ~zod/try=> `vase`!>(~) + [p=[%cube p=0 q=[%atom p=%n]] q=0] + +------------------------------------------------------------------------ + +### ++vise + + ++ vise ,[p=typo q=*] :: old vase + +Used to convert from previously-typed data during reboot. + +See `++typo`, `++seer` + +------------------------------------------------------------------------ + +### ++wall + + ++ wall (list tape) :: text lines (no \n) + +A list of lines. A `++wall` is used instead of a single `++tape` with +`\n`. + +See also: `++wash` + + ~zod/try=> `wall`(wash [0 20] leaf/<(bex 256)>) + << + "\/115.792.089.237.\/" + " 316.195.423.570." + " 985.008.687.907." + " 853.269.984.665." + " 640.564.039.457." + " 584.007.913.129." + " 639.936" + "\/ \/" + >> + +------------------------------------------------------------------------ + +### ++wain + + ++ wain (list cord) :: text lines (no \n) + +A list of lines. A `++wain` is used instead of a single `++cord` with +`\n`. + +See also: `++lore`, `++role` + + ~zod/try=> `wain`/som/del/rok + <|som del rok|> + ~zod/try=> `wain`(lore ^:@t/=main=/bin/tree/hoon) + <| + !: + :: /===/bin/tree/hoon + |= ^ + |= [pax=path fla=$|(~ [%full ~])] + =- ~[te/-]~ + =+ len=(lent pax) + =+ rend=?~(fla |=(a=path +:(spud (slag len a))) spud) + |- ^- wain + =+ ark=;;(arch .^(cy/pax)) + =- ?~ q.ark - + [(crip (rend pax)) -] + %- zing + %- turn :_ |=(a=@t ^$(pax (weld pax `path`/[a]))) + %- sort :_ aor + %- turn :_ |=([a=@t ~] a) + (~(tap by r.ark)) + |> + +------------------------------------------------------------------------ + +### ++wing + + ++ wing (list limb) :: + +Address in subject. A `++wing` is a path to a value in the subject. A +term alone is the trivial case of a `++wing`. + +See also: `++twig` + + ~zod/try=> (ream 'a.+.c') + [%cnzz p=~[%a [%.y p=3] %c]] + ~zod/try=> (wing +:(ream 'a.+.c')) + ~[%a [%.y p=3] %c] + +------------------------------------------------------------------------ + +### ++wine + + ++ wine $| ?(%noun %path %tank %void %wall %wool %yarn) + $% [%atom p=term] :: + [%core p=(list ,@ta) q=wine] :: + [%face p=term q=wine] :: + [%list p=term q=wine] :: + [%pear p=term q=@] :: + [%pick p=(list wine)] :: + [%plot p=(list wine)] :: + [%stop p=@ud] :: + [%tree p=term q=wine] :: + [%unit p=term q=wine] :: + == :: + +Printable type. `++wine` is used for pretty printing. + +See also: `++calf` + + ~zod/try=> ~(dole ut p:!>(*@tas)) + [p={} q=[%atom p=%tas]] + ~zod/try=> `wine`q:~(dole ut p:!>(*@tas)) + [%atom p=%tas] + + ~zod/try=> ~(dole ut p:!>(*path)) + [ p + { [ p=1 + q + [ %pick + p + ~[ + [%pear p=%n q=0] + [%plot p=~[[%face p=%i q=[%atom p=%ta]] [%face p=%t q=[%stop p=1]]]] + ] + ] + ] + } + q=%path + ] + ~zod/try=> `wine`q:~(dole ut p:!>(*path)) + %path + + ~zod/try=> ~(dole ut p:!>(*(map time cord))) + [ p + { [ p=1 + q + [ %pick + p + ~[ + [%pear p=%n q=0] + [ %plot + p + ~[ + [ %face + p=%n + q + [ %plot + p=~[[%face p=%p q=[%atom p=%da]] [%face p=%q q=[%atom p=%t]]] + ] + ] + [%face p=%l q=[%stop p=1]] + [%face p=%r q=[%stop p=1]] + ] + ] + ] + ] + ] + } + q + [ %tree + p=%nlr + q=[%plot p=~[[%face p=%p q=[%atom p=%da]] [%face p=%q q=[%atom p=%t]]]] + ] + ] + ~zod/try=> `wine`q:~(dole ut p:!>(*(map time cord))) + [ %tree + p=%nlr + q=[%plot p=~[[%face p=%p q=[%atom p=%da]] [%face p=%q q=[%atom p=%t]]]] + ] + +------------------------------------------------------------------------ + +### ++wonk + + ++ wonk |*(veq=edge ?~(q.veq !! p.u.q.veq)) :: + :: :: + :: :: + +XX Not a model? + + ++ wonk |*(veq=edge ?~(q.veq !! p.u.q.veq)) :: + +Pull result out of a `++edge`, or crash if there's no result. + +See also: `++edge`, Section 2eC + + ~zod/try=> (wide:vast [1 1] "(add 2 2)") + [ p=[p=1 q=10] + q + [ ~ + [ p=[%cnhp p=[%cnzz p=~[%add]] q=~[[%dtzy p=%ud q=2] [%dtzy p=%ud q=2]]] + q=[p=[p=1 q=10] q=""] + ] + ] + ] + ~zod/try=> (wonk (wide:vast [1 1] "(add 2 2)")) + [%cnhp p=[%cnzz p=~[%add]] q=~[[%dtzy p=%ud q=2] [%dtzy p=%ud q=2]]] + +------------------------------------------------------------------------ + +### ++map + + ++ map |* [a=_,* b=_,*] :: associative tree + $|(~ [n=[p=a q=b] l=(map a b) r=(map a b)]) :: + +Tile generator. A `++map` is a +[treap](http://en.wikipedia.org/wiki/Treap) of key, value pairs. + +See also: `++by` + + ~zod/try=> :type; *(map ,@t ,@u) + {} + nlr([p=@t q=@u]) + ~zod/try=> `(map ,@ta ,@ud)`(mo (limo a/1 b/2 ~)) + {[p=~.a q=1] [p=~.b q=2]} + +------------------------------------------------------------------------ + +### ++qeu + + ++ qeu |* a=_,* :: queue + $|(~ [n=a l=(qeu a) r=(qeu a)]) :: + +Tile generator. A `++qeu` is an ordered +[treap](http://en.wikipedia.org/wiki/Treap) of items. + +See also: `++to` + + ~zod/try=> (qeu time) + <1.qyo [* <1.sxx [a=<1.ebd [* <101.jzo 1.ypj %164>]> <101.jzo 1.ypj %164>]>]> + ~zod/try=> (~(gas to *(qeu time)) [~2014.1.1 ~2014.1.2 ~]) + {~2014.1.2 ~2014.1.1} + +------------------------------------------------------------------------ + +### ++set + + ++ set |* a=_,* :: set + $|(~ [n=a l=(set a) r=(set a)]) :: + +Tile generator. A `++set` is a +[treap](http://en.wikipedia.org/wiki/Treap) with unique values. + +See also: `++in` + + ~zod/try=> (sa "abc") + {~~a ~~c ~~b} + ~zod/try=> (~(put in (sa "abc")) %d) + {~~d ~~a ~~c ~~b} + ~zod/try=> (~(put in (sa "abc")) %a) + {~~a ~~c ~~b} + +------------------------------------------------------------------------ + +### ++jar + + ++ jar |*([a=_,* b=_,*] (map a (list b))) :: map of lists + +Tile generator. A `++jar` is a `++map` of `++list`. + +See also: `++ja`, `++by`, `++map`, `++list` + + ~zod/try=> =a (limo [1 2 ~]) + ~zod/try=> a + [i=1 t=[i=2 t=~]] + ~zod/try=> =b (limo [3 4 ~]) + ~zod/try=> b + [i=3 t=[i=4 t=~]] + ~zod/try=> =c (mo (limo [[%a a] [%b b] ~])) + ~zod/try=> c + {[p=%a q=[i=1 t=[i=2 t=~]]] [p=%b q=[i=3 t=[i=4 t=~]]]} + ~zod/try=> (~(get ja c) %a) + [i=1 t=[i=2 t=~]] + ~zod/try=> (~(get ja c) %c) + ~ + +------------------------------------------------------------------------ + +### ++jug + + ++ jug |*([a=_,* b=_,*] (map a (set b))) :: map of sets + +Tile generator. Similar to `++jar`, but with `++set`. A `++jug` is a +`++map` of `++set`. + +See also: `++ju`, `++by`, `++map`, `++set` + + ~zod/try=> =a (sa (limo [1 2 ~])) + ~zod/try=> a + {1 2} + ~zod/try=> =b (sa (limo [3 4 ~])) + ~zod/try=> b + {4 3} + ~zod/try=> =c (mo (limo [[%a a] [%b b] ~])) + ~zod/try=> c + {[p=%a q={1 2}] [p=%b q={4 3}]} + ~zod/try=> (~(get ju c) %b) + {4 3} + ~zod/try=> (~(put ju c) [%b 5]) + {[p=%a q={1 2}] [p=%b q={5 4 3}]} + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2a.md b/docs/pub/doc/hoon/library/2a.md new file mode 100644 index 0000000000..ec9bdd8596 --- /dev/null +++ b/docs/pub/doc/hoon/library/2a.md @@ -0,0 +1,450 @@ +chapter 2a, basic unsigned math +=============================== + +### ++add + +Add + + ++ add :: add + ~/ %add + |= [a=@ b=@] + ^- @ + ?: =(0 a) b + $(a (dec a), b +(b)) + :: + +Produces the sum of `a` and `b` as an atom. + +`a` is an [atom](). + +`b` is an [atom](). + + ~zod/try=> (add 2 2) + 4 + ~zod/try=> (add 1 1.000.000) + 1.000.001 + ~zod/try=> (add 1.333 (mul 2 2)) + 1.337 + +------------------------------------------------------------------------ + +### ++cap + +Tree head + + ++ cap :: tree head + ~/ %cap + |= a=@ + ^- ?(%2 %3) + ?- a + %2 %2 + %3 %3 + ?(%0 %1) !! + * $(a (div a 2)) + == + :: + +Tests whether an `a` is in the head or tail of a noun. Produces the +[cube]() `%2` if it is within the head, or the [cube]() `%3` if is is +within the tail. + +`a` is an [atom](). + + ~zod/try=> (cap 4) + %2 + ~zod/try=> (cap 6) + %3 + ~zod/try=> (cap (add 10 9)) + %2 + +------------------------------------------------------------------------ + +### ++dec + +Decrement + + ++ dec :: decrement + ~/ %dec + |= a=@ + ~| %decrement-underflow + ?< =(0 a) + =+ b=0 + |- ^- @ + ?: =(a +(b)) b + $(b +(b)) + :: + +Produces `a-1` as an atom. + +`a` is an [atom](). + + ~zod/try=> (dec 7) + 6 + ~zod/try=> (dec 0) + ! decrement-underflow + ! exit + +------------------------------------------------------------------------ + +### ++div + +Divide + + ++ div :: divide + ~/ %div + |= [a=@ b=@] + ^- @ + ~| 'div' + ?< =(0 b) + =+ c=0 + |- + ?: (lth a b) c + $(a (sub a b), c +(c)) + :: + +Computes `a` divided by `b`, producing an atom. + +`a` is an [atom](). + +`b` is an [atom](). + + ~zod/try=> (div 4 2) + 2 + ~zod/try=> (div 17 8) + 2 + ~zod/try=> (div 20 30) + 0 + +------------------------------------------------------------------------ + +### ++fac + +Factorial + + ++ fac :: factorial + ~/ %fac + |= a=@ + ^- @ + ?: =(0 a) 1 + (mul a $(a (dec a))) + :: + +Computes the factorial of `a`, producing an atom. + +`a` is an [atom](). + + ~zod/try=> (fac 3) + 6 + ~zod/try=> (fac 0) + 1 + ~zod/try=> (fac 11) + 39.916.800 + +------------------------------------------------------------------------ + +### ++gte + +Greater-than/equal + + ++ gte :: greater-equal + ~/ %gte + |= [a=@ b=@] + ^- ? + !(lth a b) + :: + +Tests whether `a` is greater than a number `b`, producing a loobean. + +`a` is an [atom](). + +`b` is an [atom](). + + ~zod/try=> (gte 100 10) + %.y + ~zod/try=> (gte 4 4) + %.y + ~zod/try=> (gte 3 4) + %.n + +------------------------------------------------------------------------ + +### ++gth + +Greater-than + + ++ gth :: greater-than + ~/ %gth + |= [a=@ b=@] + ^- ? + !(lte a b) + :: + +Tests whether `a` is greater than `b`, producing a loobean. + +`a` is an [atom](). + +`b` is an [atom](). + + ~zod/try=> (gth 'd' 'c') + %.y + ~zod/try=> (gth ~h1 ~m61) + %.n + +------------------------------------------------------------------------ + +### ++lte + +Less-than/equal + + ++ lte :: less-equal + ~/ %lte + |= [a=@ b=@] + |(=(a b) (lth a b)) + :: + +Tests whether `a` is less than or equal to `b`, producing a loobean. + +`a` is an [atom](). + +`b` is an [atom](). + + ~zod/try=> (lte 4 5) + %.y + ~zod/try=> (lte 5 4) + %.n + ~zod/try=> (lte 5 5) + %.y + ~zod/try=> (lte 0 0) + %.y + +------------------------------------------------------------------------ + +### ++lth + +Less-than + + ++ lth :: less-than + ~/ %lth + |= [a=@ b=@] + ^- ? + ?& !=(a b) + |- + ?| =(0 a) + ?& !=(0 b) + $(a (dec a), b (dec b)) + == == == + :: + +Tests whether `a` is less than `b`, producing a loobean. + +`a` is an [atom](). + +`b` is an [atom](). + + ~zod/try=> (lth 4 5) + %.y + ~zod/try=> (lth 5 4) + %.n + ~zod/try=> (lth 5 5) + %.n + ~zod/try=> (lth 5 0) + %.n + +------------------------------------------------------------------------ + +### ++mas + +Axis within head/tail + + ++ mas :: tree body + ~/ %mas + |= a=@ + ^- @ + ?- a + 1 !! + 2 1 + 3 1 + * (add (mod a 2) (mul $(a (div a 2)) 2)) + == + :: + +------------------------------------------------------------------------ + +Computes the axis of `a` within the head or the tail, producing an atom. + +`a` is an [atom](). + + ~zod/try=> (mas 3) + 1 + ~zod/try=> (mas 4) + 2 + ~zod/try=> (mas 5) + 3 + ~zod/try=> (mas 6) + 2 + ~zod/try=> (mas 0) + ! exit + ~zod/try=> (mas 1) + ! exit + +### ++max + +Maximum + + ++ max :: maximum + ~/ %max + |= [a=@ b=@] + ^- @ + ?: (gth a b) a + b + :: + +Computes the maximum of `a` and `b`, producing an atom. + +`a` is an [atom](). + +`b` is an [atom](). + + ~zod/try=> (max 10 100) + 100 + ~zod/try=> (max 10.443 9) + 10.443 + ~zod/try=> (max 0 1) + 1 + +------------------------------------------------------------------------ + +### ++min + +Minimum + + ++ min :: minimum + ~/ %min + |= [a=@ b=@] + ^- @ + ?: (lth a b) a + b + :: + +Computes the minimum of `a` and `b`, producing an atom. + +`a` is an [atom](). + +`b` is an [atom](). + + ~zod/try=> (min 10 100) + 10 + ~zod/try=> (min 10.443 9) + 9 + ~zod/try=> (min 0 1) + 0 + +------------------------------------------------------------------------ + +### ++mod + +Modulus + + ++ mod :: remainder + ~/ %mod + |= [a=@ b=@] + ^- @ + ?< =(0 b) + (sub a (mul b (div a b))) + :: + +Computes the remainder of dividing `a` by `b`, producing an atom. + +`a` is an [atom](). + +`b` is an [atom](). + +------------------------------------------------------------------------ + +### ++mul + +Multiply + + ++ mul :: multiply + ~/ %mul + |= [a=@ b=@] + ^- @ + =+ c=0 + |- + ?: =(0 a) c + $(a (dec a), c (add b c)) + :: + +Multiplies `a` by `b`, producing an atom. + +`a` is an [atom](). + +`b` is an [atom](). + + ~zod/try=> (mul 3 4) + 12 + ~zod/try=> (mul 0 1) + 0 + +------------------------------------------------------------------------ + +### ++peg + +Axis within axis + + ++ peg :: tree connect + ~/ %peg + |= [a=@ b=@] + ^- @ + ?- b + 1 a + 2 (mul a 2) + 3 +((mul a 2)) + * (add (mod b 2) (mul $(b (div b 2)) 2)) + == + :: + +Computes the axis of `b` within axis `a`, producing an atom. + +`a` is an [atom](). + +`b` is an [atom](). + + ~zod/try=> (peg 4 1) + 4 + ~zod/try=> (peg 4 2) + 8 + ~zod/try=> (peg 8 45) + 269 + +------------------------------------------------------------------------ + +### ++sub + +Subtract + + ++ sub :: subtract + ~/ %sub + |= [a=@ b=@] + ~| %subtract-underflow + ^- @ + ?: =(0 b) a + $(a (dec a), b (dec b)) + +Subtracts `b` from `a`, producing an atom. + +`a` is an [atom](). + +`b` is an [atom](). + + ~zod/try=> (sub 10 5) + 5 + ~zod/try=> (sub 243 44) + 199 + ~zod/try=> (sub 5 0) + 5 + ~zod/try=> (sub 0 5) + ! subtract-underflow + ! exit + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2b.md b/docs/pub/doc/hoon/library/2b.md new file mode 100644 index 0000000000..5e68f3d273 --- /dev/null +++ b/docs/pub/doc/hoon/library/2b.md @@ -0,0 +1,897 @@ +chapter 2b, basic containers +============================ + +Section 2bA, units +------------------ + +### ++biff + +Unit as argument + + ++ biff :: apply + |* [a=(unit) b=$+(* (unit))] + ?~ a ~ + (b u.a) + +Applies a gate that produces a unit, `b`, to the value (`u.a`) of a unit +`a`. If `a` is empty, `~` is produced. + +`a` is a [unit](). + +`b` is a [gate]() that accepts a noun and produces a unit. + + ~zod/try=> (biff (some 5) |=(a=@ (some (add a 2)))) + [~ u=7] + ~zod/try=> (biff ~ |=(a=@ (some (add a 2)))) + ~ + +------------------------------------------------------------------------ + +### ++bind + +Bind + + ++ bind :: argue + |* [a=(unit) b=gate] + ?~ a ~ + [~ u=(b u.a)] + +Applies a function `b` to the value (`u.a`) of a unit `a`, producing a +unit. + +`a` is a [unit]() + +`b` is a [gate](). + + ~zod/try=> (bind ((unit ,@) [~ 97]) ,@t) + [~ `a`] + ~zod/try=> =a |=(a=@ (add a 1)) + ~zod/try=> (bind ((unit ,@) [~ 2]) a) + [~ 3] + +------------------------------------------------------------------------ + +### ++bond + +Replace null + + ++ bond :: replace + |* a=trap + |* b=(unit) + ?~ b $:a + u.b + +Replaces an empty unit `b` with the product of a kicked trap `a`. If the +unit is not empty, then the original unit is produced. + +`a` is a [trap](). + +`b` is a [unit](). + + ~zod/try=> (bex 10) + 1.024 + ~zod/try=> ((bond |.((bex 10))) ~) + 1.024 + ~zod/try=> ((bond |.((bex 10))) (slaw %ud '123')) + 123 + +------------------------------------------------------------------------ + +### ++both + +Group unit values + + ++ both :: all the above + |* [a=(unit) b=(unit)] + ?~ a ~ + ?~ b ~ + [~ u=[u.a u.b]] + +Produces a unit whose value is a cell of the values of two input units +`a` and `b`. If either of the two units are empty, `~` is produced. + +`a` is a [unit](). + +`b` is a [unit](). + + ~zod/try=> (both (some 1) (some %b)) + [~ u=[1 %b]] + ~zod/try=> (both ~ (some %b)) + ~ + +------------------------------------------------------------------------ + +### ++clap + +Apply gate to two units + + ++ clap :: combine + |* [a=(unit) b=(unit) c=_|=(^ +<-)] + ?~ a b + ?~ b a + [~ u=(c u.a u.b)] + +Applies a binary operation `c` which produces a unit to the values of +two units `a` and `b`. + +`a` is a [unit](). + +`b` is a [unit](). + +`c` is a [gate]() that performs a binary operation. + + ~zod/try=> =u ((unit ,@t) [~ 'a']) + ~zod/try=> =v ((unit ,@t) [~ 'b']) + ~zod/try=> (clap u v |=([a=@t b=@t] (welp (trip a) (trip b)))) + [~ u="ab"] + ~zod/try=> =a ((unit ,@u) [~ 1]) + ~zod/try=> =b ((unit ,@u) [~ 2]) + ~zod/try=> =c |=([a=@ b=@] (add a b)) + ~zod/try=> (clap a b c) + [~ 3] + + +------------------------------------------------------------------------ + +### ++drop + +Unit list + + ++ drop :: enlist + |* a=(unit) + ?~ a ~ + [i=u.a t=~] + +Produces a [list]() of the value from a unit `a`. + +`a` is a [unit](). + + ~zod/try=> =a ((unit ,@) [~ 97]) + ~zod/try=> (drop a) + [i=97 t=~] + ~zod/try=> =a ((unit ,@) [~]) + ~zod/try=> (drop a) + ~ + +------------------------------------------------------------------------ + +### ++fall + +Default unit + + ++ fall :: default + |* [a=(unit) b=*] + ?~(a b u.a) + +Produces a default value `b` for a unit `a` in cases where the unit is +null. + +`a` is a [unit](). + +`b` is a [noun]() used as the default value. + + ~zod/try=> (fall ~ `a`) + `a` + ~zod/try=> (fall [~ u=0] `a`) + 0 + +------------------------------------------------------------------------ + +### ++lift + +Fmap + + ++ lift :: lift gate (fmap) + |* a=gate :: flipped + |* b=(unit) :: curried + (bind b a) :: bind + +Similar to `fmap` in Haskell: accepts a gate `a` that accepts and +produces an unwrapped value, passes it the value of a unit `b`, and then +produces a unit value. + +`a` is a [gate](). + +`b` is a [unit](). + + ~zod/try=> ((lift dec) `(unit ,@)`~) + ~ + ~zod/try=> ((lift dec) `(unit ,@)`[~ 20]) + [~ 19] + +------------------------------------------------------------------------ + +### ++mate + +Choose + + ++ mate :: choose + |* [a=(unit) b=(unit)] + ?~ b a + ?~ a b + ?.(=(u.a u.b) ~|('mate' !!) a) + +Accepts two units `a` and `b` whose values are expected to be +equivalent. If either is empty, then the value of the other is produced. +If neither are empty, it asserts that both values are the same and +produces that value. If the assertion fails, `++mate` crashes with +`'mate'` in the stack trace. + +`a` is a [unit](). + +`b` is a [unit](). + + ~zod/try=> =a ((unit ,@) [~ 97]) + ~zod/try=> =b ((unit ,@) [~ 97]) + ~zod/try=> (mate a b) + [~ 97] + ~zod/try=> =a ((unit ,@) [~ 97]) + ~zod/try=> =b ((unit ,@) [~]) + ~zod/try=> (mate a b) + [~ 97] + ~zod/try=> =a ((unit ,@) [~ 97]) + ~zod/try=> =b ((unit ,@) [~ 98]) + ~zod/try=> (mate a b) + ! 'mate' + ! exit + +------------------------------------------------------------------------ + +### ++need + +Unwrap + + ++ need :: demand + |* a=(unit) + ?~ a !! + u.a + +Retrieve the value from a unit and crash if the unit is null. + +`a` is a [unit](). + + ~zod/try=> =a ((unit ,[@t @t]) [~ ['a' 'b']]) + ~zod/try=> (need a) + ['a' 'b'] + ~zod/try=> =a ((unit ,@ud) [~ 17]) + ~zod/try=> (need a) + 17 + ~zod/try=> =a ((unit ,@) [~]) + ~zod/try=> (need a) + ! exit + +------------------------------------------------------------------------ + +### ++some + +Unify + + ++ some :: lift (pure) + |* a=* + [~ u=a] + +Takes any atom `a` and produces a unit with the value set to `a`. + +`a` is a [noun](). + + ~zod/try=> (some [`a` `b`]) + [~ u=[`a` `b`]] + ~zod/try=> (some &) + [~ u=%.y] + +------------------------------------------------------------------------ + +section 2bB, lists +------------------ + +Reverse + +### ++flop + + ++ flop :: reverse + ~/ %flop + |* a=(list) + => .(a (homo a)) + ^+ a + =+ b=`_a`~ + |- + ?~ a b + $(a t.a, b [i.a b]) + +Produces the list `a` in reverse order. + +`a` is a [list](). + + ~zod/try=> =a (limo [1 2 3 ~]) + ~zod/try=> (flop a) + ~[3 2 1] + +### ++homo + +Homogenize + + ++ homo :: homogenize + |* a=(list) + ^+ =< $ + |% +- $ ?:(_? ~ [i=(snag 0 a) t=$]) + -- + a + +Produces a list whose type is a fork of all the contained types in the +list `a`. + +`a` is a [list](). + + ~zod/try=> lyst + [i=1 t=[i=97 t=[i=2 t=[i=98 t=[i=[~ u=10] t=~]]]]] + ~zod/try=> (homo lyst) + ~[1 97 2 98 [~ u=10]] + ~zod/try=> =a (limo [1 2 3 ~]) + ~zod/try=> a + [i=1 t=[i=2 t=[i=3 t=~]]] + ~zod/try=> (homo a) + ~[1 2 3] + +### ++limo + +List Constructor + + ++ limo :: listify + |* a=* + ^+ =< $ + |% +- $ ?~(a ~ ?:(_? i=-.a t=$ $(a +.a))) + -- + a + +Turns a null-terminated tuple into a list. + +`a` is a null-terminated tuple. + + ~zod/try=> (limo [1 2 3 ~]) + [i=1 t=[i=2 t=[i=3 t=~]]] + +### ++lent + +List length + + ++ lent :: length + ~/ %lent + |= a=(list) + ^- @ + =+ b=0 + |- + ?~ a b + $(a t.a, b +(b)) + +Produces the length of any list `a` as an atom. + +`a` is a [list](). + + ~zod/try=> (lent (limo [1 2 3 4 ~])) + 4 + ~zod/try=> (lent (limo [1 'a' 2 'b' (some 10) ~])) + 5 + +------------------------------------------------------------------------ + +### ++levy + +"and" to list + + ++ levy + ~/ %levy :: all of + |* [a=(list) b=_|=(p=* .?(p))] + |- ^- ? + ?~ a & + ?. (b i.a) | + $(a t.a) + +Produces the Boolean "and" of the result of every element in list `a` +passed to gate `b`. + +`a` is a [list](). + +`b` is a [gate](). + + ~zod/try=> =a |=(a=@ (lte a 1)) + ~zod/try=> (levy (limo [0 1 2 1 ~]) a) + %.n + ~zod/try=> =a |=(a=@ (lte a 3)) + ~zod/try=> (levy (limo [0 1 2 1 ~]) a) + %.y + +------------------------------------------------------------------------ + +### ++lien + +"or" to list + + ++ lien :: some of + ~/ %lien + |* [a=(list) b=$+(* ?)] + |- ^- ? + ?~ a | + ?: (b i.a) & + $(a t.a) + +Produces the Boolean "or" of the result of every element in list `a` +passed to gate `b`. + +`a` is a [list](). + +`b` is a [gate](). + + ~zod/try=> =a |=(a=@ (gte a 1)) + ~zod/try=> (lien (limo [0 1 2 1 ~]) a) + %.y + ~zod/try=> =a |=(a=@ (gte a 3)) + ~zod/try=> (lien (limo [0 1 2 1 ~]) a) + %.n + +------------------------------------------------------------------------ + +### ++murn + +Maybe transform + + ++ murn :: maybe transform + |* [a=(list) b=$+(* (unit))] + |- + ?~ a ~ + =+ c=(b i.a) + ?~ c + $(a t.a) + [i=u.c t=$(a t.a)] + +Passes each member of list `a` to gate `b`, which must produce a unit. +Produces a new list with all the results that do not produce `~`. + +`a` is a [list](). + +`b` is a [gate]() that produces a [unit](). + + ~zod/try=> =a |=(a=@ ?.((gte a 2) ~ (some (add a 10)))) + ~zod/try=> (murn (limo [0 1 2 3 ~]) a) + [i=12 t=[i=13 t=~]] + +### ++reap + +Replicate + + ++ reap :: replicate + |* [a=@ b=*] + |- ^- (list ,_b) + ?~ a ~ + [b $(a (dec a))] + +Replicate: produces a list containing `a` copies of `b`. + +`a` is an [atom]() + +`b` is a [noun]() + + ~zod/try=> (reap 20 %a) + ~[%a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a] + ~zod/try=> (reap 5 ~s1) + ~[~s1 ~s1 ~s1 ~s1 ~s1] + ~zod/try=> `@dr`(roll (reap 5 ~s1) add) + ~s5 + +------------------------------------------------------------------------ + +### ++reel + +Right fold + + ++ reel :: right fold + ~/ %reel + |* [a=(list) b=_|=([* *] +<+)] + |- ^+ +<+.b + ?~ a + +<+.b + (b i.a $(a t.a)) + +Right fold: moves right to left across a list `a`, recursively slamming +a binary gate `b` with an element from `a` and an accumulator, producing +the final value of the accumulator. + +`a` is a [list](). + +`b` is a binary [gate](). + + ~zod/try=> =sum =|([p=@ q=@] |.((add p q))) + ~zod/try=> (reel (limo [1 2 3 4 5 ~]) sum) + 15 + ~zod/try=> =a =|([p=@ q=@] |.((sub p q))) + ~zod/try=> (reel (limo [6 3 1 ~]) a) + 4 + ~zod/try=> (reel (limo [3 6 1 ~]) a) + ! subtract-underflow + ! exit + +------------------------------------------------------------------------ + +### ++roll + +Left fold + + ++ roll :: left fold + ~/ %roll + |* [a=(list) b=_|=([* *] +<+)] + |- ^+ +<+.b + ?~ a + +<+.b + $(a t.a, b b(+<+ (b i.a +<+.b))) + +Left fold: moves left to right across a list `a`, recursively slamming a +binary gate `b` with an element from the list and an accumulator, +producing the final value of the accumulator. + +`a` is a [list](). + +`b` is a binary [gate](). + + ~zod/try=> =sum =|([p=@ q=@] |.((add p q))) + ~zod/try=> (roll (limo [1 2 3 4 5 ~]) sum) + q=15 + ~zod/try=> =a =|([p=@ q=@] |.((sub p q))) + ~zod/try=> (roll (limo [6 3 1 ~]) a) + ! subtract-underflow + ! exit + ~zod/try=> (roll (limo [1 3 6 ~]) a) + q=4 + +------------------------------------------------------------------------ + +### ++skid + +Separate + + ++ skid :: separate + |* [a=(list) b=$+(* ?)] + |- ^+ [p=a q=a] + ?~ a [~ ~] + =+ c=$(a t.a) + ?:((b i.a) [[i.a p.c] q.c] [p.c [i.a q.c]]) + +Seperates a list `a` into two lists - Those elements of `a` who produce +true when slammed to gate `b` and those who produce `%.n`. + +`a` is a [list](). + +`b` is a [gate]() that accepts one argument and produces a loobean. + + ~zod/try=> =a |=(a=@ (gth a 1)) + ~zod/try=> (skid (limo [0 1 2 3 ~]) a) + [p=[i=2 t=[i=3 t=~]] q=[i=0 t=[i=1 t=~]]] + +------------------------------------------------------------------------ + +### ++skim + +Suffix + + ++ skim :: only + ~/ %skim + |* [a=(list) b=_|=(p=* .?(p))] + |- + ^+ a + ?~ a ~ + ?:((b i.a) [i.a $(a t.a)] $(a t.a)) + +Cycles through the members of a list `a`, passing them to a gate `b` and +producing a list of all of the members that produce `%.y`. Inverse of +`++skip`. + +`a` is a [list](). + +`b` is a [gate]() that accepts one argument and produces a loobean. + + ~zod/try=> =a |=(a=@ (gth a 1)) + ~zod/try=> (skim (limo [0 1 2 3 ~]) a) + [i=2 t=[i=3 t=~]] + +------------------------------------------------------------------------ + +### ++skip + +Except + + ++ skip :: except + ~/ %skip + |* [a=(list) b=_|=(p=* .?(p))] + |- + ^+ a + ?~ a ~ + ?:((b i.a) $(a t.a) [i.a $(a t.a)]) + +Cycles through the members of a list `a`, passing them to a gate `b` and +producing a list of all of the members that produce `%.n`. Inverse of +`++skim`. + +`a` is a [list](). + +`b` is a [gate]() that accepts one argument and produces a loobean. + + ~zod/try=> =a |=(a=@ (gth a 1)) + ~zod/try=> (skip (limo [0 1 2 3 ~]) a) + [i=0 t=[i=1 t=~]] + +------------------------------------------------------------------------ + +### ++scag + +Prefix + + ++ scag :: prefix + ~/ %scag + |* [a=@ b=(list)] + |- ^+ b + ?: |(?=(~ b) =(0 a)) ~ + [i.b $(b t.b, a (dec a))] + +Accepts an atom `a` and list `b`, producing the first `a` elements of +the front of the list. + +`a` is an [atom](). + +`b` is a [list](). + + ~zod/try=> (scag 2 (limo [0 1 2 3 ~])) + [i=0 t=[i=1 t=~]] + ~zod/try=> (scag 10 (limo [1 2 3 4 ~])) + [i=1 t=[i=2 t=[i=3 t=[i=4 t=~]]]] + +------------------------------------------------------------------------ + +### ++slag + +Suffix + + ++ slag :: suffix + ~/ %slag + |* [a=@ b=(list)] + |- ^+ b + ?: =(0 a) b + ?~ b ~ + $(b t.b, a (dec a)) + +Accepts an atom `a` and list `b`, producing the remaining elements from +`b` starting at `a`. + +`a` is an [atom](). + +`b` is a [list](). + + ~zod/try=> (slag 2 (limo [1 2 3 4 ~])) + [i=3 t=[i=4 t=~]] + ~zod/try=> (slag 1 (limo [1 2 3 4 ~])) + [i=2 t=[i=3 t=[i=4 t=~]]] + +------------------------------------------------------------------------ + +### ++snag + +Index + + ++ snag :: index + ~/ %snag + |* [a=@ b=(list)] + |- + ?~ b + ~|('snag-fail' !!) + ?: =(0 a) i.b + $(b t.b, a (dec a)) + +Accepts an atom `a` and a list `b`, producing the element at the index +of `a`and failing if the list is null. Lists are 0-indexed. + +`a` is an [atom](). + +`b` is a [list](). + + ~zod/try=> (snag 2 "asdf") + ~~d + ~zod/try=> (snag 0 `(list ,@ud)`~[1 2 3 4]) + 1 + +------------------------------------------------------------------------ + +### ++sort + +Quicksort + + ++ sort :: quicksort + ~/ %sort + |* [a=(list) b=$+([* *] ?)] + => .(a ^.(homo a)) + |- ^+ a + ?~ a ~ + %+ weld + $(a (skim t.a |=(c=_i.a (b c i.a)))) + ^+ t.a + [i.a $(a (skim t.a |=(c=_i.a !(b c i.a))))] + +Quicksort: accepts a list `a` and a gate `b` which accepts two nouns and +produces a loobean. `++sort` then produces a list of the elements of `a` +sorted according to `b`. + +`a` is an [atom](). + +`b` is a [gate]() which accepts two nouns and produces a loobean. + + ~zod/try=> =a =|([p=@ q=@] |.((gth p q))) + ~zod/try=> (sort (limo [0 1 2 3 ~]) a) + ~[3 2 1 0] + +------------------------------------------------------------------------ + +### ++swag + +Infix + + ++ swag :: infix + |* [[a=@ b=@] c=(list)] + (scag b (slag a c)) + +Similar to `substr` in Javascript: extracts a string infix, beginning at +inclusive index `a`, producing `b` number of characters. + +`a` and `b` are [atom]()s. + +`c` is a [list](). + + ~zod/try=> (swag [2 5] "roly poly") + "ly po" + ~zod/try=> (swag [2 2] (limo [1 2 3 4 ~])) + [i=3 t=[i=4 t=~]] + +------------------------------------------------------------------------ + +### ++turn + +Gate to list + + ++ turn :: transform + ~/ %turn + |* [a=(list) b=_,*] + |- + ?~ a ~ + [i=(b i.a) t=$(a t.a)] + +Accepts a list `a` and a gate `b`. Produces a list with the gate applied +to each element of the original list. + +`a` is a [list](). + +`b` is a [gate](). + + ~zod/try=> (turn (limo [104 111 111 110 ~]) ,@t) + <|h o o n|> + ~zod/try=> =a |=(a=@ (add a 4)) + ~zod/try=> (turn (limo [1 2 3 4 ~]) a) + ~[5 6 7 8] + +------------------------------------------------------------------------ + +### ++weld + +Concatenate + + ++ weld :: concatenate + ~/ %weld + |* [a=(list) b=(list)] + => .(a ^.(homo a), b ^.(homo b)) + |- ^+ b + ?~ a b + [i.a $(a t.a)] + +Concatenate two lists `a` and `b`. + +`a` and `b` are [list]()s. + + ~zod/try=> (weld "urb" "it") + ~[~~u ~~r ~~b ~~i ~~t] + ~zod/try=> (weld (limo [1 2 ~]) (limo [3 4 ~])) + ~[1 2 3 4] + +------------------------------------------------------------------------ + +### ++welp + +Perfect weld + + ++ welp :: perfect weld + =| [* *] + |% + +- $ + ?~ +<- + +<-(. +<+) + +<-(+ $(+<- +<->)) + -- + +Concatenate two lists `a` and `b` without losing their type information +to homogenization. + +`a` and `b` are [list]()s. + + ~zod/try=> (welp "foo" "bar") + "foobar" + ~zod/arvo=/hoon/hoon> (welp ~[60 61 62] ~[%a %b %c]) + [60 61 62 %a %b %c ~] + ~zod/arvo=/hoon/hoon> :type; (welp ~[60 61 62] ~[%a %b %c]) + [60 61 62 %a %b %c ~] + [@ud @ud @ud %a %b %c %~] + ~zod/arvo=/hoon/hoon> (welp [sa/1 so/2 ~] si/3) + [[%sa 1] [%so 2] %si 3] + +------------------------------------------------------------------------ + +### ++wild + +XXDELETE + + ++ wild :: concatenate + |* [a=(list) b=(list)] + => .(a ^.(homo a), b ^.(homo b)) + |- + ?~ a b + [i=i.a $(a t.a)] + +Concatenates two lists `a` and `b`, homogenizing their types +individually. + +`a` and `b` are [list]()s. + + ~zod/try=> (wild (limo ~[1 2 3]) (limo [4]~)) + ~[1 2 3 4] + ~zod/try=> (wild (limo 60 61 62 ~) (limo %a %b %c ~)) + [i=60 [i=61 [i=62 ~[%a %b %c]]]] + ~zod/try=> (weld (limo 60 61 62 ~) (limo %a %b %c ~)) + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.000 15].[10.016 57]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.001 15].[10.016 57]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.002 15].[10.016 57]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.004 15].[10.016 57]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.006 15].[10.016 57]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.006 29].[10.006 44]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.056 3].[10.061 13]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.058 3].[10.061 13]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.059 3].[10.061 13]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[10.060 5].[10.060 47]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.826 7].[9.844 35]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.827 7].[9.844 35]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.827 11].[9.838 13]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.828 11].[9.838 13]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.829 13].[9.831 47]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.830 13].[9.831 47]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.706 7].[9.712 25]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.707 7].[9.712 25]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.708 7].[9.712 25]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.712 7].[9.712 25]> + ! /~zod/arvo/~2014.10.2..22.58.23..5af9/hoon/:<[9.712 8].[9.712 25]> + ! exit + +------------------------------------------------------------------------ + +### ++zing + +Cons + + ++ zing :: promote + =| * + |% + +- $ + ?~ +< + +< + (welp +<- $(+< +<+)) + -- + +Turns a list of lists into a single list by promoting the elements of +each sublist into the higher. + +Accepts a [list]() of lists. + + ~zod/try=> (zing (limo [(limo ['a' 'b' 'c' ~]) (limo ['e' 'f' 'g' ~]) (limo ['h' 'i' 'j' ~]) ~])) + ~['a' 'b' 'c' 'e' 'f' 'g' 'h' 'i' 'j'] + ~zod/try=> (zing (limo [(limo [1 'a' 2 'b' ~]) (limo [3 'c' 4 'd' ~]) ~])) + ~[1 97 2 98 3 99 4 100] diff --git a/docs/pub/doc/hoon/library/2c.md b/docs/pub/doc/hoon/library/2c.md new file mode 100644 index 0000000000..41e86be446 --- /dev/null +++ b/docs/pub/doc/hoon/library/2c.md @@ -0,0 +1,2128 @@ +chapter 2c, simple noun surgery +=============================== + +section 2cA, bit surgery +------------------------ + +### ++bex + +Binary exponent + + ++ bex :: binary exponent + ~/ %bex + |= a=@ + ^- @ + ?: =(0 a) 1 + (mul 2 $(a (dec a))) + +Computes the result of `2^a`, producing an atom. + +`a` is an [atom](atom). + + ~zod/try=> (bex 4) + 16 + ~zod/try=> (bex (add 19 1)) + 1.048.576 + ~zod/try=> (bex 0) + 1 + +------------------------------------------------------------------------ + +### ++xeb + +Binary logarithm + + ++ xeb :: binary logarithm + :: ~/ %xeb + |= a=@ + ^- @ + (met 0 a) + +Computes the base-2 logarithm of `a`, producing an atom. + +`a` is an [atom](atom). + + ~zod/try=> (xeb 31) + 5 + ~zod/try=> (xeb 32) + 6 + ~zod/try=> (xeb 49) + 6 + ~zod/try=> (xeb 0) + 0 + ~zod/try=> (xeb 1) + 1 + ~zod/try=> (xeb 2) + 2 + +------------------------------------------------------------------------ + +### ++can + +Assemble + + ++ can :: assemble + ~/ %can + |= [a=bloq b=(list ,[p=@ q=@])] + ^- @ + ?~ b 0 + (mix (end a p.i.b q.i.b) (lsh a p.i.b $(b t.b))) + +Produces an atom from a list `b` of length-value pairs `p` and `q`, +where `p` is the length in bloqs of size `a`, and `q` is an atomic +value. + +`a` is a block size (see [++bloq]()). + +`b` is a [list](list) of length value pairs, `p` and `q`. + + ~zod/try=> `@ub`(can 3 ~[[1 1]]) + 0b1 + ~zod/try=> `@ub`(can 0 ~[[1 255]]) + 0b1 + ~zod/try=> `@ux`(can 3 [3 0xc1] [1 0xa] ~) + 0xa00.00c1 + ~zod/try=> `@ux`(can 3 [3 0xc1] [1 0xa] [1 0x23] ~) + 0x23.0a00.00c1 + ~zod/try=> `@ux`(can 4 [3 0xc1] [1 0xa] [1 0x23] ~) + 0x23.000a.0000.0000.00c1 + ~zod/try=> `@ux`(can 3 ~[[1 'a'] [2 'bc']]) + 0x63.6261 + +------------------------------------------------------------------------ + +### ++cat + +Concatenate + + ++ cat :: concatenate + ~/ %cat + |= [a=bloq b=@ c=@] + (add (lsh a (met a b) c) b) + +Concatenates two atoms, `b` and `c`, using bloq size `a`, producing an +atom. + +`a` is a block size (see [++bloq]()). + +`b` is an [atom](). + +`c` is an [atom](). + + ~zod/try=> `@ub`(cat 3 1 0) + 0b1 + ~zod/try=> `@ub`(cat 0 1 1) + 0b11 + ~zod/try=> `@ub`(cat 0 2 1) + 0b110 + ~zod/try=> `@ub`(cat 2 1 1) + 0b1.0001 + ~zod/try=> `@ub`256 + 0b1.0000.0000 + ~zod/try=> `@ub`255 + 0b1111.1111 + ~zod/try=> `@ub`(cat 3 256 255) + 0b1111.1111.0000.0001.0000.0000 + ~zod/try=> `@ub`(cat 2 256 255) + 0b1111.1111.0001.0000.0000 + ~zod/try=> (cat 3 256 255) + 16.711.936 + +------------------------------------------------------------------------ + +### ++cut + +Slice + + ++ cut :: slice + ~/ %cut + |= [a=bloq [b=@ c=@] d=@] + (end a c (rsh a b d)) + +Slices `c` blocks of size `a` that are `b` blocks from the end of `d`. +Produces an atom. + +`a` is a block size (see [++bloq]()). + +`b` is an [atom](). + +`c` is an [atom](). + + ~zod/try=> (cut 0 [1 1] 2) + 1 + ~zod/try=> (cut 0 [2 1] 4) + 1 + ~zod/try=> `@t`(cut 3 [0 3] 'abcdefgh') + 'abc' + ~zod/try=> `@t`(cut 3 [1 3] 'abcdefgh') + 'bcd' + ~zod/try=> `@ub`(cut 0 [0 3] 0b1111.0000.1101) + 0b101 + ~zod/try=> `@ub`(cut 0 [0 6] 0b1111.0000.1101) + 0b1101 + ~zod/try=> `@ub`(cut 0 [4 6] 0b1111.0000.1101) + 0b11.0000 + ~zod/try=> `@ub`(cut 0 [3 6] 0b1111.0000.1101) + 0b10.0001 + +------------------------------------------------------------------------ + +### ++end + +Tail + + ++ end :: tail + ~/ %end + |= [a=bloq b=@ c=@] + (mod c (bex (mul (bex a) b))) + +Produces an atom by taking the last `b` blocks of size `a` from `c`. + +`a` is a block size (see [++bloq]()). + +`b` is an [atom](). + +`c` is an [atom](). + + ~zod/try=> `@ub`12 + 0b1100 + ~zod/try=> `@ub`(end 0 3 12) + 0b100 + ~zod/try=> (end 0 3 12) + 4 + ~zod/try=> `@ub`(end 1 3 12) + 0b1100 + ~zod/try=> (end 1 3 12) + 12 + ~zod/try=> `@ux`'abc' + 0x63.6261 + ~zod/try=> `@ux`(end 3 2 'abc') + 0x6261 + ~zod/try=> `@t`(end 3 2 'abc') + 'ab' + +------------------------------------------------------------------------ + +### ++fil + +Fill bloqstream + + ++ fil :: fill bloqstream + |= [a=bloq b=@ c=@] + =+ n=0 + =+ d=c + |- ^- @ + ?: =(n b) + (rsh a 1 d) + $(d (add c (lsh a 1 d)), n +(n)) + +Produces an atom by repeating `c` for `b` blocks of size `a`. + +`a` is a block size (see [++bloq]()). + +`b` is an [atom](). + +`c` is an [atom](). + + ~zod/try=> `@t`(fil 3 5 %a) + 'aaaaa' + ~zod/try=> `@t`(fil 5 10 %ceeb) + 'ceebceebceebceebceebceebceebceebceebceeb' + ~zod/try=> `@t`(fil 4 10 %eced) + 'ʇʇʇʇʇʇʇʇʇʇed' + ~zod/try=> `@tas`(fil 4 10 %bf) + %bfbfbfbfbfbfbfbfbfbf + +------------------------------------------------------------------------ + +### ++lsh + +Left-shift + + ++ lsh :: left-shift + ~/ %lsh + |= [a=bloq b=@ c=@] + (mul (bex (mul (bex a) b)) c) + +Produces an atom by left-shifting `c` by `b` blocks of size `a`. + +`a` is a block size (see [++bloq]()). + +`b` is an [atom](). + +`c` is an [atom](). + + ~zod/try=> `@ub`1 + 0b1 + ~zod/try=> `@ub`(lsh 0 1 1) + 0b10 + ~zod/try=> (lsh 0 1 1) + 2 + ~zod/try=> `@ub`255 + 0b1111.1111 + ~zod/try=> `@ub`(lsh 3 1 255) + 0b1111.1111.0000.0000 + ~zod/try=> (lsh 3 1 255) + 65.280 + +------------------------------------------------------------------------ + +### ++met + +Measure + + ++ met :: measure + ~/ %met + |= [a=bloq b=@] + ^- @ + =+ c=0 + |- + ?: =(0 b) c + $(b (rsh a 1 b), c +(c)) + +Computes the number of blocks of size `a` in `b`, producing an atom. + +`a` is a block size (see [++bloq]()). + +`b` is an [atom](). + + ~zod/try=> (met 0 1) + 1 + ~zod/try=> (met 0 2) + 2 + ~zod/try=> (met 3 255) + 1 + ~zod/try=> (met 3 256) + 2 + ~zod/try=> (met 3 'abcde') + 5 + +------------------------------------------------------------------------ + +### ++rap + +Assemble non-zero + + ++ rap :: assemble nonzero + ~/ %rap + |= [a=bloq b=(list ,@)] + ^- @ + ?~ b 0 + (cat a i.b $(b t.b)) + +Concatenate a list of atoms `b` using blocksize `a`, producing an atom. + +`a` is a block size (see [++bloq]()). + +`b` is a [list]() of [atoms](). + + ~zod/try=> `@ub`(rap 2 (limo [1 2 3 4 ~])) + 0b100.0011.0010.0001 + ~zod/try=> `@ub`(rap 1 (limo [1 2 3 4 ~])) + 0b1.0011.1001 + ~zod/try=> (rap 0 (limo [0 0 0 ~])) + 0 + ~zod/try=> (rap 0 (limo [1 0 1 ~])) + 3 + +------------------------------------------------------------------------ + +### ++rep + +Assemble single + + ++ rep :: assemble single + ~/ %rep + |= [a=bloq b=(list ,@)] + ^- @ + =+ c=0 + |- + ?~ b 0 + (con (lsh a c (end a 1 i.b)) $(c +(c), b t.b)) + +Produces an atom by assembling a list of atoms `b` using block size `a`. + +`a` is a block size (see [++bloq]()). + +`b` is a list of [atoms](). + + ~zod/try=> `@ub`(rep 2 (limo [1 2 3 4 ~])) + 0b100.0011.0010.0001 + ~zod/try=> (rep 0 (limo [0 0 1 ~])) + 4 + ~zod/try=> (rep 0 (limo [0 0 0 1 ~])) + 8 + ~zod/try=> (rep 0 (limo [0 1 0 0 ~])) + 2 + ~zod/try=> (rep 0 (limo [0 1 0 1 ~])) + 10 + ~zod/try=> (rep 0 (limo [0 1 0 1 0 1 ~])) + 42 + ~zod/try=> `@ub`42 + 0b10.1010 + +------------------------------------------------------------------------ + +### ++rip + +Disassemble + + ++ rip :: disassemble + ~/ %rip + |= [a=bloq b=@] + ^- (list ,@) + ?: =(0 b) ~ + [(end a 1 b) $(b (rsh a 1 b))] + +Produces a list of atoms from the bits of `b` using block size `a`. + +`a` is a block size (see [++bloq]()). + +`b` is an [atom](). + + ~zod/try=> `@ub`155 + 0b1001.1011 + ~zod/try=> (rip 0 155) + ~[1 1 0 1 1 0 0 1] + ~zod/try=> (rip 2 155) + ~[11 9] + ~zod/try=> (rip 1 155) + ~[3 2 1 2] + ~zod/try=> `@ub`256 + 0b1.0000.0000 + ~zod/try=> (rip 0 256) + ~[0 0 0 0 0 0 0 0 1] + ~zod/try=> (rip 2 256) + ~[0 0 1] + ~zod/try=> (rip 3 256) + ~[0 1] + +------------------------------------------------------------------------ + +### ++rsh + +Right-shift + + ++ rsh :: right-shift + ~/ %rsh + |= [a=bloq b=@ c=@] + (div c (bex (mul (bex a) b))) + +Right-shifts `c` by `b` blocks of size `a`, producing an atom. + +`a` is a block size (see [++bloq]()). + +`b` is an [atom](). + +`c` is an [atom](). + + ~zod/try=> `@ub`145 + 0b1001.0001 + ~zod/try=> `@ub`(rsh 1 1 145) + 0b10.0100 + ~zod/try=> (rsh 1 1 145) + 36 + ~zod/try=> `@ub`(rsh 2 1 145) + 0b1001 + ~zod/try=> (rsh 2 1 145) + 9 + ~zod/try=> `@ub`10 + 0b1010 + ~zod/try=> `@ub`(rsh 0 1 10) + 0b101 + ~zod/try=> (rsh 0 1 10) + 5 + ~zod/try=> `@ux`'abc' + 0x63.6261 + ~zod/try=> `@t`(rsh 3 1 'abc') + 'bc' + ~zod/try=> `@ux`(rsh 3 1 'abc') + 0x6362 + +------------------------------------------------------------------------ + +### ++swap + +Reverse block order + + ++ swap |=([a=bloq b=@] (rep a (flop (rip a b)))) :: reverse bloq order + +Switches little ending to big and vice versa: produces an atom by +reversing the block order of `b` using block size `a`. + +`a` is a block size (see [++bloq]()). + +`b` is an [atom]() + + ~zod/try=> `@ub`24 + 0b1.1000 + ~zod/try=> (swap 0 24) + 3 + ~zod/try=> `@ub`3 + 0b11 + ~zod/try=> (swap 0 0) + 0 + ~zod/try=> (swap 0 128) + 1 + +------------------------------------------------------------------------ + +section 2cB, bit logic +---------------------- + +### ++con + +Binary OR + + ++ con :: binary or + ~/ %con + |= [a=@ b=@] + =+ [c=0 d=0] + |- ^- @ + ?: ?&(=(0 a) =(0 b)) d + %= $ + a (rsh 0 1 a) + b (rsh 0 1 b) + c +(c) + d %+ add d + %^ lsh 0 c + ?& =(0 (end 0 1 a)) + =(0 (end 0 1 b)) + == + == + +Computes the bit-wise logical OR of two atoms, `a` and `b`, producing an +atom. + +`a` is an [atom]() + +`b` is an [atom]() + + ~zod/try=> (con 0b0 0b1) + 1 + ~zod/try=> (con 0 1) + 1 + ~zod/try=> (con 0 0) + 0 + ~zod/try=> `@ub`(con 0b1111.0000 0b1.0011) + 0b1111.0011 + ~zod/try=> (con 4 4) + 4 + ~zod/try=> (con 10.000 234) + 10.234 + +------------------------------------------------------------------------ + +### ++dis + +Binary AND + + ++ dis :: binary and + ~/ %dis + |= [a=@ b=@] + =| [c=@ d=@] + |- ^- @ + ?: ?|(=(0 a) =(0 b)) d + %= $ + a (rsh 0 1 a) + b (rsh 0 1 b) + c +(c) + d %+ add d + %^ lsh 0 c + ?| =(0 (end 0 1 a)) + =(0 (end 0 1 b)) + == + == + +Computes the bit-wise logical AND of two atoms `a` and `b`, producing an +atom. + +`a` is an [atom]() + +`b` is an [atom]() + + ~zod/try=> `@ub`9 + 0b1001 + ~zod/try=> `@ub`5 + 0b101 + ~zod/try=> `@ub`(dis 9 5) + 0b1 + ~zod/try=> (dis 9 5) + 1 + ~zod/try=> `@ub`534 + 0b10.0001.0110 + ~zod/try=> `@ub`987 + 0b11.1101.1011 + ~zod/try=> `@ub`(dis 534 987) + 0b10.0001.0010 + ~zod/try=> (dis 534 987) + 530 + +------------------------------------------------------------------------ + +### ++mix + +Binary XOR + + ++ mix :: binary xor + ~/ %mix + |= [a=@ b=@] + ^- @ + =+ [c=0 d=0] + |- + ?: ?&(=(0 a) =(0 b)) d + %= $ + a (rsh 0 1 a) + b (rsh 0 1 b) + c +(c) + d (add d (lsh 0 c =((end 0 1 a) (end 0 1 b)))) + == + +Produces the bit-wise logical XOR of `a` and `b`, producing an atom. + +`a` is an [atom]() + +`b` is an [atom]() + + ~zod/try=> `@ub`2 + 0b10 + ~zod/try=> `@ub`3 + 0b11 + ~zod/try=> `@ub`(mix 2 3) + 0b1 + ~zod/try=> (mix 2 3) + 1 + ~zod/try=> `@ub`(mix 2 2) + 0b0 + ~zod/try=> (mix 2 2) + 0 + +------------------------------------------------------------------------ + +### ++not + +Binary NOT + + ++ not |= [a=bloq b=@ c=@] :: binary not (sized) + (mix c (dec (bex (mul b (bex a))))) + +Computes the bit-wise logical NOT of the bottom `b` blocks of size `a` +of `c`. + +`a` is a block size (see [++bloq]()). + +`b` is an [atom](). + +`c` is an [atom](). + + ~zod/try=> `@ub`24 + 0b1.1000 + ~zod/try=> (not 0 5 24) + 7 + ~zod/try=> `@ub`7 + 0b111 + ~zod/try=> (not 2 5 24) + 1.048.551 + ~zod/try=> (not 2 5 1.048.551) + 24 + ~zod/try=> (not 1 1 (not 1 1 10)) + 10 + +------------------------------------------------------------------------ + +section 2cC, noun orders +------------------------ + +### ++aor + +Alphabetic order + + ++ aor :: alphabetic-order + ~/ %aor + |= [a=* b=*] + ^- ? + ?: =(a b) & + ?. ?=(@ a) + ?: ?=(@ b) | + ?: =(-.a -.b) + $(a +.a, b +.b) + $(a -.a, b -.b) + ?. ?=(@ b) & + |- + =+ [c=(end 3 1 a) d=(end 3 1 b)] + ?: =(c d) + $(a (rsh 3 1 a), b (rsh 3 1 b)) + (lth c d) + +Computes whether `a` and `b` are in alphabetical order, producing a +loobean. + +`a` is a [noun](). + +`b` is a [noun](). + + ~zod/try=> (aor 'a' 'b') + %.y + ~zod/try=> (aor 'b' 'a') + %.n + ~zod/try=> (aor "foo" "bar") + %.n + ~zod/try=> (aor "bar" "foo") + %.y + ~zod/try=> (aor "abcdefz" "abcdefa") + %.n + ~zod/try=> (aor "abcdefa" "abcdefz") + %.y + ~zod/try=> (aor 10.000 17.000) + %.y + ~zod/try=> (aor 10 9) + %.n + +------------------------------------------------------------------------ + +### ++dor + +Numeric order + + ++ dor :: d-order + ~/ %dor + |= [a=* b=*] + ^- ? + ?: =(a b) & + ?. ?=(@ a) + ?: ?=(@ b) | + ?: =(-.a -.b) + $(a +.a, b +.b) + $(a -.a, b -.b) + ?. ?=(@ b) & + (lth a b) + +Computes whether `a` and `b` are in ascending numeric order, producing a +loobean. + +`a` is a [noun](). + +`b` is a [noun](). + + ~zod/try=> (dor 1 2) + %.y + ~zod/try=> (dor 2 1) + %.n + ~zod/try=> (dor ~[1 2 3] ~[1 2 4]) + %.y + ~zod/try=> (dor ~[1 2 4] ~[1 2 3]) + %.n + ~zod/try=> (dor (limo ~[99 100 10.000]) ~[99 101 10.000]) + %.y + ~zod/try=> (dor ~[99 101 10.999] (limo ~[99 100 10.000])) + %.n + +------------------------------------------------------------------------ + +### ++gor + +Hash order + + ++ gor :: g-order + ~/ %gor + |= [a=* b=*] + ^- ? + =+ [c=(mug a) d=(mug b)] + ?: =(c d) + (dor a b) + (lth c d) + +XX revisit + + ~zod/try=> (gor 'd' 'c') + %.y + ~zod/try=> 'd' + 'd' + ~zod/try=> 'c' + ~zod/try=> `@ud`'d' + 100 + ~zod/try=> `@ud`'c' + 99 + ~zod/try=> (mug 'd') + 1.628.185.714 + ~zod/try=> (mug 'c') + 1.712.073.811 + ~zod/try=> (gor 'd' 'c') + %.y + ~zod/try=> (gor 'c' 'd') + %.n + ~zod/try=> (gor "foo" "bar") + %.n + ~zod/try=> (gor (some 10) (limo [1 2 3 ~])) + %.n + +------------------------------------------------------------------------ + +### ++hor + +Hash order + + ++ hor :: h-order + ~/ %hor + |= [a=* b=*] + ^- ? + ?: ?=(@ a) + ?. ?=(@ b) & + (gor a b) + ?: ?=(@ b) | + ?: =(-.a -.b) + (gor +.a +.b) + (gor -.a -.b) + +XX revisit + +Recursive hash comparator gate. + + ~zod/try=> (hor . 1) + %.n + ~zod/try=> (hor 1 2) + %.y + ~zod/try=> (hor "abc" "cba") + %.y + ~zod/try=> (hor 'c' 'd') + %.n + +------------------------------------------------------------------------ + +### ++vor + + ++ vor :: v-order + ~/ %vor + |= [a=* b=*] + ^- ? + =+ [c=(mug (mug a)) d=(mug (mug b))] + ?: =(c d) + (dor a b) + (lth c d) + +XX revisit + +Double hash comparator gate. + + ~zod/try=> (vor 'f' 'g') + %.y + ~zod/try=> (vor 'a' 'z') + %.n + ~zod/try=> (vor 43.326 41.106) + %.n + +section 2cD, insecure hashing +----------------------------- + +### ++fnv + + ++ fnv |=(a=@ (end 5 1 (mul 16.777.619 a))) :: FNV scrambler + +Hashes an atom with the 32-bit FNV non-cryptographic hash algorithm. +Multiplies `a` by the prime number 16,777,619 and then takes the block +of size 5 off the product's end, producing atom. + +`a` is an [atom](). + + ~zod/try=> (fnv 10.000) + 272.465.456 + ~zod/try=> (fnv 10.001) + 289.243.075 + ~zod/try=> (fnv 1) + 16.777.619 + +------------------------------------------------------------------------ + +### ++mum + + ++ mum :: mug with murmur3 + ~/ %mum + |= a=* + |^ (trim ?@(a a (mix $(a -.a) (mix 0x7fff.ffff $(a +.a))))) + ++ spec :: standard murmur3 + |= [syd=@ key=@] + ?> (lte (met 5 syd) 1) + =+ ^= row + |= [a=@ b=@] + (con (end 5 1 (lsh 0 a b)) (rsh 0 (sub 32 a) b)) + =+ mow=|=([a=@ b=@] (end 5 1 (mul a b))) + =+ len=(met 5 key) + =- =. goc (mix goc len) + =. goc (mix goc (rsh 4 1 goc)) + =. goc (mow goc 0x85eb.ca6b) + =. goc (mix goc (rsh 0 13 goc)) + =. goc (mow goc 0xc2b2.ae35) + (mix goc (rsh 4 1 goc)) + ^= goc + =+ [inx=0 goc=syd] + |- ^- @ + ?: =(inx len) goc + =+ kop=(cut 5 [inx 1] key) + =. kop (mow kop 0xcc9e.2d51) + =. kop (row 15 kop) + =. kop (mow kop 0x1b87.3593) + =. goc (mix kop goc) + =. goc (row 13 goc) + =. goc (end 5 1 (add 0xe654.6b64 (mul 5 goc))) + $(inx +(inx)) + :: + ++ trim :: 31-bit nonzero + |= key=@ + =+ syd=0xcafe.babe + |- ^- @ + =+ haz=(spec syd key) + =+ ham=(mix (rsh 0 31 haz) (end 0 31 haz)) + ?.(=(0 ham) ham $(syd +(syd))) + -- + :: + +XX document + + ~zod/try=> (mum 10.000) + 1.232.632.901 + ~zod/try=> (mum 10.001) + 658.093.079 + ~zod/try=> (mum 1) + 818.387.364 + ~zod/try=> (mum (some 10)) + 1.177.215.703 + ~zod/try=> (mum ~[1 2 3 4 5]) + 1.517.902.092 + +### ++mug + + ++ mug :: 31bit nonzero FNV1a + ~/ %mug + |= a=* + ?^ a + =+ b=[p=$(a -.a) q=$(a +.a)] + |- ^- @ + =+ c=(fnv (mix p.b (fnv q.b))) + =+ d=(mix (rsh 0 31 c) (end 0 31 c)) + ?. =(0 c) c + $(q.b +(q.b)) + =+ b=2.166.136.261 + |- ^- @ + =+ c=b + =+ [d=0 e=(met 3 a)] + |- ^- @ + ?: =(d e) + =+ f=(mix (rsh 0 31 c) (end 0 31 c)) + ?. =(0 f) f + ^$(b +(b)) + $(c (fnv (mix c (cut 3 [d 1] a))), d +(d)) + +Hashes `a` with the 31-bit nonzero FNV-1a non-cryptographic hash +algorithm, producing an atom. + + ~zod/try=> (mug 10.000) + 178.152.889 + ~zod/try=> (mug 10.001) + 714.838.017 + ~zod/try=> (mug 1) + 67.918.732 + ~zod/try=> (mug (some 10)) + 1.872.403.737 + ~zod/try=> (mug (limo [1 2 3 4 5 ~])) + 1.067.931.605 + +section 2cE, phonetic base +-------------------------- + +### ++po + + ++ po + ~/ %po + =+ :- ^= sis :: prefix syllables + 'dozmarbinwansamlitsighidfidlissogdirwacsabwissib\ + /rigsoldopmodfoglidhopdardorlorhodfolrintogsilmir\ + /holpaslacrovlivdalsatlibtabhanticpidtorbolfosdot\ + /losdilforpilramtirwintadbicdifrocwidbisdasmidlop\ + /rilnardapmolsanlocnovsitnidtipsicropwitnatpanmin\ + /ritpodmottamtolsavposnapnopsomfinfonbanporworsip\ + /ronnorbotwicsocwatdolmagpicdavbidbaltimtasmallig\ + /sivtagpadsaldivdactansidfabtarmonranniswolmispal\ + /lasdismaprabtobrollatlonnodnavfignomnibpagsopral\ + /bilhaddocridmocpacravripfaltodtiltinhapmicfanpat\ + /taclabmogsimsonpinlomrictapfirhasbosbatpochactid\ + /havsaplindibhosdabbitbarracparloddosbortochilmac\ + /tomdigfilfasmithobharmighinradmashalraglagfadtop\ + /mophabnilnosmilfopfamdatnoldinhatnacrisfotribhoc\ + /nimlarfitwalrapsarnalmoslandondanladdovrivbacpol\ + /laptalpitnambonrostonfodponsovnocsorlavmatmipfap' + ^= dex :: suffix syllables + 'zodnecbudwessevpersutletfulpensytdurwepserwylsun\ + /rypsyxdyrnuphebpeglupdepdysputlughecryttyvsydnex\ + /lunmeplutseppesdelsulpedtemledtulmetwenbynhexfeb\ + /pyldulhetmevruttylwydtepbesdexsefwycburderneppur\ + /rysrebdennutsubpetrulsynregtydsupsemwynrecmegnet\ + /secmulnymtevwebsummutnyxrextebfushepbenmuswyxsym\ + /selrucdecwexsyrwetdylmynmesdetbetbeltuxtugmyrpel\ + /syptermebsetdutdegtexsurfeltudnuxruxrenwytnubmed\ + /lytdusnebrumtynseglyxpunresredfunrevrefmectedrus\ + /bexlebduxrynnumpyxrygryxfeptyrtustyclegnemfermer\ + /tenlusnussyltecmexpubrymtucfyllepdebbermughuttun\ + /bylsudpemdevlurdefbusbeprunmelpexdytbyttyplevmyl\ + /wedducfurfexnulluclennerlexrupnedlecrydlydfenwel\ + /nydhusrelrudneshesfetdesretdunlernyrsebhulryllud\ + /remlysfynwerrycsugnysnyllyndyndemluxfedsedbecmun\ + /lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes' + |% + +Provides the phonetic syllables and name generators for the Urbit naming +system. The two faces, `sis` and `dex` are available to the arms +contained in this section. + +------------------------------------------------------------------------ + +### ++ind + +Parse prefix + + ++ ind ~/ %ind :: parse prefix + |= a=@ + =+ b=0 + |- ^- (unit ,@) + ?:(=(256 b) ~ ?:(=(a (tod b)) [~ b] $(b +(b)))) + +Produces the byte of the right-hand syllable `a`. + +`a` is an [atom](). + + ~zod/try=> (ind:po 'zod') + [~ 0] + ~zod/try=> (ind:po 'zam') + ~ + ~zod/try=> (ind:po 'del') + [~ 37] + +------------------------------------------------------------------------ + +### ++ins + +Parse suffix + + ++ ins ~/ %ins :: parse suffix + |= a=@ + =+ b=0 + |- ^- (unit ,@) + ?:(=(256 b) ~ ?:(=(a (tos b)) [~ b] $(b +(b)))) + +Produces the byte of the left-hand phonetic syllable `b`. + +`a` is an [atom](). + + ~zod/try=> (ins:po 'mar') + [~ 1] + ~zod/try=> (ins:po 'son') + [~ 164] + ~zod/try=> (ins:po 'pit') + [~ 242] + ~zod/try=> (ins:po 'pok') + ~ + +------------------------------------------------------------------------ + +### ++tod + +Fetch prefix + + ++ tod ~/ %tod :: fetch prefix + |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] dex))) + +Produces the phonetic prefix syllable from index `a` within `dex` as an +atom. + +`a` is an [atom]() + + ~zod/try=> `@t`(tod:po 1) + 'nec' + ~zod/try=> `@t`(tod:po 98) + 'dec' + ~zod/try=> `@t`(tod:po 0) + 'zod' + ~zod/try=> `@t`(tod:po 150) + 'ryg' + ~zod/try=> `@t`(tod:po 255) + 'fes' + ~zod/try=> `@t`(tod:po 256) + ! exit + +------------------------------------------------------------------------ + +### ++tos + +Fetch suffix + + ++ tos ~/ %tos :: fetch suffix + |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] sis))) + +Produces the phonetic prefix syllable from index `a` within `sis` as an +atom. + + ~zod/try=> `@t`(tos:po 0) + 'doz' + ~zod/try=> `@t`(tos:po 120) + 'fab' + ~zod/try=> `@t`(tos:po 43) + 'pid' + ~zod/try=> `@t`(tos:po 253) + 'mat' + +------------------------------------------------------------------------ + +section 2cF, signed and modular ints +------------------------------------ + +### ++si + + ++ si !: :: signed integer + |% + +Container for the signed integer functions. + +------------------------------------------------------------------------ + +### ++abs + + ++ abs |=(a=@s (add (end 0 1 a) (rsh 0 1 a))) :: absolute value + +Produces the absolute value of a signed integer. + +`a` is a signed integer, `@s`. + + ~zod/try=> (abs:si -2) + 2 + ~zod/try=> (abs:si -10.000) + 10.000 + ~zod/try=> (abs:si --2) + 2 + +------------------------------------------------------------------------ + +### ++dif + + ++ dif |= [a=@s b=@s] :: subtraction + (sum a (new !(syn b) (abs b))) + +Produces the difference between two signed integers `b` and `c`. + +`a` is a signed integer, `@s`. + +`b` is a signed integer, `@s`. + + ~zod/try=> (dif:si --10 -7) + --17 + ~zod/try=> (dif:si --10 --7) + --3 + ~zod/try=> (dif:si `@s`0 --7) + -7 + ~zod/try=> (dif:si `@s`0 `@s`7) + --4 + +------------------------------------------------------------------------ + +### ++dul + + ++ dul |= [a=@s b=@] :: modulus + =+(c=(old a) ?:(-.c (mod +.c b) (sub b +.c))) + +Produces the modulus of two signed integers. + +`a` is a signed integer, `@s`. + +`b` is an [atom](). + + ~zod/try=> (dul:si --9 3) + 0 + ~zod/try=> (dul:si --9 4) + 1 + ~zod/try=> (dul:si --9 5) + 4 + ~zod/try=> (dul:si --9 6) + 3 + ~zod/try=> (dul:si --90 --10) + 10 + +------------------------------------------------------------------------ + +### ++fra + + ++ fra |= [a=@s b=@s] :: divide + (new =(0 (mix (syn a) (syn b))) (div (abs a) (abs b))) + +Produces the quotient of two signed integers. + +`a` is a signed integer, `@s`. + +`b` is a signed integer, `@s`. + + ~zod/try=> (fra:si --10 -2) + -5 + ~zod/try=> (fra:si -20 -5) + --4 + +------------------------------------------------------------------------ + +### ++new + + ++ new |= [a=? b=@] :: [sign value] to @s + `@s`?:(a (mul 2 b) ?:(=(0 b) 0 +((mul 2 (dec b))))) + +Produces a signed integer from a loobean sign value `a` and an atom `b`. + +`a` is a loobean. + +`b` is an [atom](). + + ~zod/try=> (new:si [& 10]) + --10 + ~zod/try=> (new:si [| 10]) + -10 + ~zod/try=> (new:si [%.y 7]) + --7 + +------------------------------------------------------------------------ + +### ++old + + ++ old |=(a=@s [(syn a) (abs a)]) :: [sign value] + +Produces the cell `[sign value]` representations of a signed integer. + +`a` is a signed integer, `@s`. + + ~zod/try=> (old:si 7) + ! type-fail + ! exit + ~zod/try=> (old:si -7) + [%.n 7] + ~zod/try=> (old:si --7) + [%.y 7] + ~zod/try=> (old:si `@s`7) + [%.n 4] + ~zod/try=> (old:si -0) + [%.y 0] + +------------------------------------------------------------------------ + +### ++pro + + ++ pro |= [a=@s b=@s] :: multiplication + (new =(0 (mix (syn a) (syn b))) (mul (abs a) (abs b))) + +Produces the product of two signed integers. + +`a` is a signed integer, `@s`. + +`b` is a signed integer, `@s`. + + ~zod/try=> (pro:si -4 --2) + -8 + ~zod/try=> (pro:si -4 -2) + --8 + ~zod/try=> (pro:si --10.000.000 -10) + -100.000.000 + ~zod/try=> (pro:si -1.337 --0) + --0 + +------------------------------------------------------------------------ + +### ++rem + + ++ rem |=([a=@s b=@s] (dif a (pro b (fra a b)))) :: remainder + +Produces the remainder from a division of two signed integers. + +`a` is a signed integer, `@s`. + +`b` is a signed integer, `@s`. + + ~zod/try=> (rem:si -10 -4) + -2 + ~zod/try=> (rem:si --10 --4) + --2 + ~zod/try=> (rem:si --10 -4) + --2 + ~zod/try=> (rem:si --7 --3) + --1 + ~zod/try=> (rem:si --0 --10.000) + --0 + +------------------------------------------------------------------------ + +### ++sum + + ++ sum |= [a=@s b=@s] :: addition + ~| %si-sum + =+ [c=(old a) d=(old b)] + ?: -.c + ?: -.d + (new & (add +.c +.d)) + ?: (gte +.c +.d) + (new & (sub +.c +.d)) + (new | (sub +.d +.c)) + ?: -.d + ?: (gte +.c +.d) + (new | (sub +.c +.d)) + (new & (sub +.d +.c)) + (new | (add +.c +.d)) + +Sum two signed integers. + +`b` is a signed integer, `@s`. + +`c` is a signed integer, `@s`. + + ~zod/try=> (sum:si --10 --10) + --20 + ~zod/try=> (sum:si --10 -0) + --10 + ~zod/try=> (sum:si -10 -7) + -17 + ~zod/try=> (sum:si -10 --7) + -3 + +------------------------------------------------------------------------ + +### ++sun + + ++ sun |=(a=@u (mul 2 a)) :: @u to @s + +Produces a signed integer from an unsigned integer. + +Note that the result must be manually cast to some @s odor to be +inferred as an unsigned integer in the type system. + +`a` is an unsigned integer, `@u`. + + ~zod/try=> `@s`10 + --5 + ~zod/try=> (sun:si 10) + 20 + ~zod/try=> `@s`(sun:si 10) + --10 + ~zod/try=> `@sd`(sun:si 10) + --10 + ~zod/try=> `@sd`(sun:si 12.345) + --12.345 + +------------------------------------------------------------------------ + +### ++syn + + ++ syn |=(a=@s =(0 (end 0 1 a))) :: sign test + +Produce the sign of a signed integer, `&` being posiitve, `|` negative. + +`a` is a signed integer, `@s`. + + ~zod/try=> (syn:si -2) + %.n + ~zod/try=> (syn:si --2) + %.y + ~zod/try=> (syn:si -0) + %.y + +------------------------------------------------------------------------ + +### ++cmp + + ++ cmp |= [a=@s b=@s] :: compare + ^- @s + ?: =(a b) + --0 + ?: (syn a) + ?: (syn b) + ?: (gth a b) + --1 + -1 + --1 + ?: (syn b) + -1 + ?: (gth a b) + -1 + --1 + +Compare two signed integers. + +`b` is a signed integer, `@s`. + +`c` is a signed integer, `@s`. + + ~zod/try=> (cmp:si --10 --10) + --0 + ~zod/try=> (cmp:si --10 -0) + --1 + ~zod/try=> (cmp:si -10 -7) + -1 + ~zod/try=> (cmp:si -10 --7) + -1 + +### ++dif + + ++ dif |=([b=@ c=@] (sit (sub (add out (sit b)) (sit c)))) + +Produces the difference between two atoms in the modular basis +representation. + +`b` is an [atom](). + +`c` is an [atom](). + + ~zod/try=> (~(dif fe 3) 63 64) + 255 + ~zod/try=> (~(dif fe 3) 5 10) + 251 + ~zod/try=> (~(dif fe 3) 0 1) + 255 + ~zod/try=> (~(dif fe 0) 9 10) + 1 + ~zod/try=> (~(dif fe 0) 9 11) + 0 + ~zod/try=> (~(dif fe 0) 9 12) + 1 + ~zod/try=> (~(dif fe 2) 9 12) + 13 + ~zod/try=> (~(dif fe 2) 63 64) + 15 + +------------------------------------------------------------------------ + +### ++inv + + ++ inv |=(b=@ (sub (dec out) (sit b))) + +Inverts the order of the modular field. + +`b` is an [atom](). + + ~zod/try=> (~(inv fe 3) 255) + 0 + ~zod/try=> (~(inv fe 3) 256) + 255 + ~zod/try=> (~(inv fe 3) 0) + 255 + ~zod/try=> (~(inv fe 3) 1) + 254 + ~zod/try=> (~(inv fe 3) 2) + 253 + ~zod/try=> (~(inv fe 3) 55) + 200 + +------------------------------------------------------------------------ + +### ++net + + ++ net |= b=@ ^- @ + => .(b (sit b)) + ?: (lte a 3) + b + =+ c=(dec a) + %+ con + (lsh c 1 $(a c, b (cut c [0 1] b))) + $(a c, b (cut c [1 1] b)) + +Reverse bytes within block. + +`b` is an [atom](). + + ~zod/try=> (~(net fe 3) 64) + 64 + ~zod/try=> (~(net fe 3) 128) + 128 + ~zod/try=> (~(net fe 3) 255) + 255 + ~zod/try=> (~(net fe 3) 256) + 0 + ~zod/try=> (~(net fe 3) 257) + 1 + ~zod/try=> (~(net fe 3) 500) + 244 + ~zod/try=> (~(net fe 3) 511) + 255 + ~zod/try=> (~(net fe 3) 512) + 0 + ~zod/try=> (~(net fe 3) 513) + 1 + ~zod/try=> (~(net fe 3) 0) + 0 + ~zod/try=> (~(net fe 3) 1) + 1 + ~zod/try=> (~(net fe 0) 1) + 1 + ~zod/try=> (~(net fe 0) 2) + 0 + ~zod/try=> (~(net fe 0) 3) + 1 + ~zod/try=> (~(net fe 6) 1) + 72.057.594.037.927.936 + ~zod/try=> (~(net fe 6) 2) + 144.115.188.075.855.872 + ~zod/try=> (~(net fe 6) 3) + 216.172.782.113.783.808 + ~zod/try=> (~(net fe 6) 4) + 288.230.376.151.711.744 + ~zod/try=> (~(net fe 6) 5) + 360.287.970.189.639.680 + ~zod/try=> (~(net fe 6) 6) + 432.345.564.227.567.616 + ~zod/try=> (~(net fe 6) 7) + 504.403.158.265.495.552 + ~zod/try=> (~(net fe 6) 512) + 562.949.953.421.312 + ~zod/try=> (~(net fe 6) 513) + 72.620.543.991.349.248 + +------------------------------------------------------------------------ + +### ++out + + ++ out (bex (bex a)) + +The maximum integer value that the current block can store. + + ~zod/try=> ~(out fe 0) + 2 + ~zod/try=> ~(out fe 1) + 4 + ~zod/try=> ~(out fe 2) + 16 + ~zod/try=> ~(out fe 3) + 256 + ~zod/try=> ~(out fe 4) + 65.536 + ~zod/try=> ~(out fe 10) + \/179.769.313.486.231.590.772.930.519.078.902.473.361.797.697.894.230.657.\/ + 273.430.081.157.732.675.805.500.963.132.708.477.322.407.536.021.120.113. + 879.871.393.357.658.789.768.814.416.622.492.847.430.639.474.124.377.767. + 893.424.865.485.276.302.219.601.246.094.119.453.082.952.085.005.768.838. + 150.682.342.462.881.473.913.110.540.827.237.163.350.510.684.586.298.239. + 947.245.938.479.716.304.835.356.329.624.224.137.216 + \/ \/ + +------------------------------------------------------------------------ + +### ++rol + + ++ rol |= [b=bloq c=@ d=@] ^- @ :: roll left + =+ e=(sit d) + =+ f=(bex (sub a b)) + =+ g=(mod c f) + (sit (con (lsh b g e) (rsh b (sub f g) e))) + +Roll `d` to the left by `c` `b`-sized blocks. + +`b` is a block size (see [++bloq]()). + +`c` is an [atom](). + +`d` is an [atom](). + + ~zod/try=> `@ux`(~(rol fe 6) 4 3 0xabac.dedf.1213) + 0x1213.0000.abac.dedf + ~zod/try=> `@ux`(~(rol fe 6) 4 2 0xabac.dedf.1213) + 0xdedf.1213.0000.abac + ~zod/try=> `@t`(~(rol fe 5) 3 1 'dfgh') + 'hdfg' + ~zod/try=> `@t`(~(rol fe 5) 3 2 'dfgh') + 'ghdf' + ~zod/try=> `@t`(~(rol fe 5) 3 0 'dfgh') + 'dfgh' + +------------------------------------------------------------------------ + +### ++ror + + ++ ror |= [b=bloq c=@ d=@] ^- @ :: roll right + =+ e=(sit d) + =+ f=(bex (sub a b)) + =+ g=(mod c f) + (sit (con (rsh b g e) (lsh b (sub f g) e))) + +Roll `d` to the right by `c` `b`-sized blocks. + +`b` is a block size (see [++bloq]()). + +`c` is an [atom](). + +`d` is an [atom](). + + ~zod/try=> `@ux`(~(ror fe 6) 4 1 0xabac.dedf.1213) + 0x1213.0000.abac.dedf + ~zod/try=> `@ux`(~(ror fe 6) 3 5 0xabac.dedf.1213) + 0xacde.df12.1300.00ab + ~zod/try=> `@ux`(~(ror fe 6) 3 3 0xabac.dedf.1213) + 0xdf12.1300.00ab.acde + ~zod/try=> `@t`(~(rol fe 5) 3 0 'hijk') + 'hijk' + ~zod/try=> `@t`(~(rol fe 5) 3 1 'hijk') + 'khij' + ~zod/try=> `@t`(~(rol fe 5) 3 2 'hijk') + 'jkhi' + +------------------------------------------------------------------------ + +### ++sum + + ++ sum |=([b=@ c=@] (sit (add b c))) :: wrapping add + +Sum two numbers in this modular field. + +`b` is an [atom](). + +`c` is an [atom](). + + ~zod/try=> (~(sum fe 3) 10 250) + 4 + ~zod/try=> (~(sum fe 0) 0 1) + 1 + ~zod/try=> (~(sum fe 0) 0 2) + 0 + ~zod/try=> (~(sum fe 2) 14 2) + 0 + ~zod/try=> (~(sum fe 2) 14 3) + 1 + ~zod/try=> (~(sum fe 4) 10.000 256) + 10.256 + ~zod/try=> (~(sum fe 4) 10.000 100.000) + 44.464 + +### ++sit + + ++ sit |=(b=@ (end a 1 b)) :: enforce modulo + +Produce an atom in the current modular block representation. + +`b` is an [atom](). + + ~zod/try=> (~(sit fe 3) 255) + 255 + ~zod/try=> (~(sit fe 3) 256) + 0 + ~zod/try=> (~(sit fe 3) 257) + 1 + ~zod/try=> (~(sit fe 2) 257) + 1 + ~zod/try=> (~(sit fe 2) 10.000) + 0 + ~zod/try=> (~(sit fe 2) 100) + 4 + ~zod/try=> (~(sit fe 2) 19) + 3 + ~zod/try=> (~(sit fe 2) 17) + 1 + ~zod/try=> (~(sit fe 0) 17) + 1 + ~zod/try=> (~(sit fe 0) 0) + 0 + ~zod/try=> (~(sit fe 0) 1) + 1 + +------------------------------------------------------------------------ + +section 2cG, floating point +--------------------------- + +XX awaiting interface rewrite + +section 2cH, urbit time +----------------------- + +Note that entering '-\<-' in the shell produces the current time in @da +format. We use this for many of our examples. + + ~zod/try=> -<- + ~2014.8.4..19.39.59..9288 + +### ++year + + ++ year :: date to @d + |= det=date + ^- @d + =+ ^= yer + ?: a.det + (add 292.277.024.400 y.det) + (sub 292.277.024.400 (dec y.det)) + =+ day=(yawn yer m.det d.t.det) + (yule day h.t.det m.t.det s.t.det f.t.det) + +Accept a parsed date of form `[[a=? y=@ud] m=@ud t=tarp]` and produce +its `@d`representation. + +`det` is a [`++date`]() + + ~zod/try=> (year [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=4 s=57 f=~[0xd940]]]) + 0x8000000d227df4e9d940000000000000 + +------------------------------------------------------------------------ + +### ++yore + + ++ yore :: @d to date + |= now=@d + ^- date + =+ rip=(yell now) + =+ ger=(yall d.rip) + :- ?: (gth y.ger 292.277.024.400) + [a=& y=(sub y.ger 292.277.024.400)] + [a=| y=+((sub 292.277.024.400 y.ger))] + [m.ger d.ger h.rip m.rip s.rip f.rip] + +Produces a `++date` from a `@d` + +`now` is a `@d`. + + ~zod/try=> (yore -<-) + [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=17 s=1 f=~[0x700d]]] + ~zod/try=> (yore -<-) + [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=28 s=53 f=~[0x7b82]]] + +### ++yell + + ++ yell :: tarp from @d + |= now=@d + ^- tarp + =+ sec=(rsh 6 1 now) + =+ ^= fan + =+ [muc=4 raw=(end 6 1 now)] + |- ^- (list ,@ux) + ?: |(=(0 raw) =(0 muc)) + ~ + => .(muc (dec muc)) + [(cut 4 [muc 1] raw) $(raw (end 4 muc raw))] + =+ day=(div sec day:yo) + => .(sec (mod sec day:yo)) + =+ hor=(div sec hor:yo) + => .(sec (mod sec hor:yo)) + =+ mit=(div sec mit:yo) + => .(sec (mod sec mit:yo)) + [day hor mit sec fan] + +Produce a parsed daily time format from an atomic date. + +`now` is a `@d`. + + ~zod/try=> (yell ~2014.3.20..05.42.53..7456) + [d=106.751.991.820.094 h=5 m=42 s=53 f=~[0x7456]] + ~zod/try=> (yell ~2014.6.9..19.09.40..8b66) + [d=106.751.991.820.175 h=19 m=9 s=40 f=~[0x8b66]] + ~zod/try=> (yell ~1776.7.4) + [d=106.751.991.733.273 h=0 m=0 s=0 f=~] + +------------------------------------------------------------------------ + +### ++yule + + ++ yule :: time atom + |= rip=tarp + ^- @d + =+ ^= sec ;: add + (mul d.rip day:yo) + (mul h.rip hor:yo) + (mul m.rip mit:yo) + s.rip + == + =+ ^= fac =+ muc=4 + |- ^- @ + ?~ f.rip + 0 + => .(muc (dec muc)) + (add (lsh 4 muc i.f.rip) $(f.rip t.f.rip)) + (con (lsh 6 1 sec) fac) + +Accept a [`++tarp`](), a parsed daily time, and produces a time atom, +`@d`. + +`rip` is a [`++tarp`](). + + ~zod/try=> =murica (yell ~1776.7.4) + ~zod/try=> murica + [d=106.751.991.733.273 h=0 m=0 s=0 f=~] + ~zod/try=> (yule murica) + 0x8000000b62aaf5800000000000000000 + ~zod/try=> `@da`(yule murica) + ~1776.7.4 + ~zod/try=> `@da`(yule (yell ~2014.3.20..05.42.53..7456)) + ~2014.3.20..05.42.53..7456 + ~zod/try=> `tarp`[31 12 30 0 ~] + [d=31 h=12 m=30 s=0 f=~] + ~zod/try=> `@dr`(yule `tarp`[31 12 30 0 ~]) + ~d31.h12.m30 + +------------------------------------------------------------------------ + +### ++yall + + ++ yall :: day # to day of year + |= day=@ud + ^- [y=@ud m=@ud d=@ud] + =+ [era=0 cet=0 lep=_?] + => .(era (div day era:yo), day (mod day era:yo)) + => ^+ . + ?: (lth day +(cet:yo)) + .(lep &, cet 0) + => .(lep |, cet 1, day (sub day +(cet:yo))) + .(cet (add cet (div day cet:yo)), day (mod day cet:yo)) + =+ yer=(add (mul 400 era) (mul 100 cet)) + |- ^- [y=@ud m=@ud d=@ud] + =+ dis=?:(lep 366 365) + ?. (lth day dis) + =+ ner=+(yer) + $(yer ner, day (sub day dis), lep =(0 (end 0 2 ner))) + |- ^- [y=@ud m=@ud d=@ud] + =+ [mot=0 cah=?:(lep moy:yo moh:yo)] + |- ^- [y=@ud m=@ud d=@ud] + =+ zis=(snag mot cah) + ?: (lth day zis) + [yer +(mot) +(day)] + $(mot +(mot), day (sub day zis)) + +Produce the date tuple of `[y=@ud m=@ud d=@ud]` of the year, month, and +day from a number of days from the beginning of time. + +`day` is an unsigned decimal, `@ud`. + + ~zod/try=> (yall 198) + [y=0 m=7 d=17] + ~zod/try=> (yall 90.398) + [y=247 m=7 d=3] + ~zod/try=> (yall 0) + [y=0 m=1 d=1] + +------------------------------------------------------------------------ + +### ++yawn + + ++ yawn :: days since Jesus + |= [yer=@ud mot=@ud day=@ud] + ^- @ud + => .(mot (dec mot), day (dec day)) + => ^+ . + %= . + day + =+ cah=?:((yelp yer) moy:yo moh:yo) + |- ^- @ud + ?: =(0 mot) + day + $(mot (dec mot), cah (slag 1 cah), day (add day (snag 0 cah))) + == + |- ^- @ud + ?. =(0 (mod yer 4)) + =+ ney=(dec yer) + $(yer ney, day (add day ?:((yelp ney) 366 365))) + ?. =(0 (mod yer 100)) + =+ nef=(sub yer 4) + $(yer nef, day (add day ?:((yelp nef) 1.461 1.460))) + ?. =(0 (mod yer 400)) + =+ nec=(sub yer 100) + $(yer nec, day (add day ?:((yelp nec) 36.525 36.524))) + (add day (mul (div yer 400) (add 1 (mul 4 36.524)))) + +Inverse of `yall`, computes number of days A.D. from y/m/d date as the +tuple `[yer=@ud mot=@ud day=@ud]`. + +`yer` is an unsigned decimal, `@ud`. + +`mon` is an unsigned decimal, `@ud`. + +`day` is an unsigned decimal, `@ud`. + + ~zod/try=> (yawn 2.014 8 4) + 735.814 + ~zod/try=> (yawn 1.776 7 4) + 648.856 + ~zod/try=> (yawn 1.990 10 11) + 727.116 + +------------------------------------------------------------------------ + +### ++yelp + + ++ yelp :: leap year + |= yer=@ud ^- ? + &(=(0 (mod yer 4)) |(!=(0 (mod yer 100)) =(0 (mod yer 400)))) + +Determines whether a year contains an ISO 8601 leap week. Produces a +loobean. + +`yer` is an unsigned decimal, `@ud`. + + ~zod/try=> (yelp 2.014) + %.n + ~zod/try=> (yelp 2.008) + %.y + ~zod/try=> (yelp 0) + %.y + ~zod/try=> (yelp 14.011) + %.n + +------------------------------------------------------------------------ + +### ++yo + + ++ yo :: time constants + + +Useful constants for interacting with earth time. + +### ++cet + + |% ++ cet 36.524 :: (add 24 (mul 100 365)) + +Days in a century. Derived by multiplying the number of days in a year +(365) by the number of years in a century (100), then adding the number +days from leap years in a century (24). + + ~zod/try=> cet:yo + 36.524 + ~zod/try=> (add 365 cet:yo) + 36.889 + ~zod/try=> (sub (add 24 (mul 100 365)) cet:yo) + 0 + +------------------------------------------------------------------------ + +### ++day + + ++ day 86.400 :: (mul 24 hor) + +Number of seconds in a day. + + ~zod/try=> day:yo + 86.400 + ~zod/try=> (add 60 day:yo) + 86.460 + +------------------------------------------------------------------------ + +### ++era + + ++ era 146.097 :: (add 1 (mul 4 cet)) + +XX Revisit + +------------------------------------------------------------------------ + +### ++hor + + ++ hor 3.600 :: (mul 60 mit) + +The number of seconds in an hour. Derived by multiplying the number of +seconds in a minute by the minutes in an hour. + + ~zod/try=> hor:yo + 3.600 + ~zod/try=> (div hor:yo 60) + 60 + +------------------------------------------------------------------------ + +### ++jes + + ++ jes 106.751.991.084.417 :: (mul 730.692.561 era) + +XX Revisit + + ~zod/try=> jes:yo + 106.751.991.084.417 + +------------------------------------------------------------------------ + +### ++mit + + ++ mit 60 + +The number of seconds in a minute. + + ~zod/try=> mit:yo + 60 + +------------------------------------------------------------------------ + +### ++moh + + ++ moh `(list ,@ud)`[31 28 31 30 31 30 31 31 30 31 30 31 ~] + +The days in each month of the Gregorian common year. A list of unsigned +decimal atoms (Either 28, 30, or 31) denoting the number of days in the +month at the year at that index. + + ~zod/try=> moh:yo + ~[31 28 31 30 31 30 31 31 30 31 30 31] + ~zod/try=> (snag 4 moh:yo) + 31 + +------------------------------------------------------------------------ + +### ++moy + + ++ moy `(list ,@ud)`[31 29 31 30 31 30 31 31 30 31 30 31 ~] + +The days in each month of the Gregorian leap-year. A list of unsigned +decimal atoms (Either 29,30, or 31) denoting the number of days in the +month at the leap-year at that index. + + ~zod/try=> moy:yo + ~[31 29 31 30 31 30 31 31 30 31 30 31] + ~zod/try=> (snag 1 moy:yo) + 29 + +------------------------------------------------------------------------ + +### ++qad + + ++ qad 126.144.001 :: (add 1 (mul 4 yer)) + +The number of seconds in four years. Derived by adding one second to the +number of seconds in four years. + + ~zod/try=> qad:yo + 126.144.001 + +------------------------------------------------------------------------ + +### ++yer + + ++ yer 31.536.000 :: (mul 365 day) + +The number of seconds in a year. Derived by multiplying the number of +seconds in a day by 365. + + ~zod/try=> yer:yo + 31.536.000 + +------------------------------------------------------------------------ + +section 2cI, almost macros +-------------------------- + +### ++cury + + ++ cury + |* [a=_|=(^ _*) b=*] + |* c=_+<+.a + (a b c) + +Curry a gate, binding the head of its sample + +`a` is a [gate](). + +`b` is a noun. + + ~zod/try=> =mol (cury add 2) + ~zod/try=> (mol 4) + 6 + ~zod/try=> (mol 7) + 9 + +------------------------------------------------------------------------ + +### ++curr + + ++ curr + |* [a=_|=(^ _*) c=*] + |* b=_+<+.a + (a b c) + +Right curry a gate, binding the tail of its sample + +`a` is a gate. + +`c` is a noun. + + ~zod/try=> =tep (curr scan sym) + ~zod/try=> `@t`(tep "asd") + 'asd' + ~zod/try=> `@t`(tep "lek-om") + 'lek-om' + +------------------------------------------------------------------------ + +### ++cork + + ++ cork |*([a=_,* b=gate] (corl b a)) :: compose forward + +Build `f` such that `(f x) .= (b (a x))`. + +`a` is a noun. + +`b` is a gate. + + ~zod/try=> (:(cork dec dec dec) 20) + 17 + ~zod/try=> =mal (mo (limo a/15 b/23 ~)) + ~zod/try=> ((cork ~(got by mal) dec) %a) + 14 + ~zod/try=> ((cork ~(got by mal) dec) %b) + 22 + +------------------------------------------------------------------------ + +### ++corl + + ++ corl :: compose backwards + |* [a=gate b=_,*] + |= c=_+<.b + (a (b c)) + +Gate compose + +XX Revisit + +`a` is a gate. + +`b` is a noun. + + ~zod/try=> ((corl (lift bex) (slat %ud)) '2') + [~ 4] + +------------------------------------------------------------------------ + +### ++hard + + ++ hard + |* han=$+(* *) + |= fud=* ^- han + ~| %hard + =+ gol=(han fud) + ?>(=(gol fud) gol) + +Demands that a specific type be produced, crashing the program is it is +not. + + ~zod/try=> ((hard (list)) (limo [1 2 3 ~])) + ~[1 2 3] + ~zod/try=> ((hard ,@) (add 2 2)) + 4 + ~zod/try=> ((hard ,@t) (crip "Tape to cord, bro!")) + 'Tape to cord, bro' + ~zod/try=> ((hard tape) (crip "...Tape to cord, bro?...")) + ! hard + ! exit + +------------------------------------------------------------------------ + +### ++soft + + ++ soft + |* han=$+(* *) + |= fud=* ^- (unit han) + =+ gol=(han fud) + ?.(=(gol fud) ~ [~ gol]) + +Politely requests a specific type to be produced, producing null if it +is not. + + ~zod/try=> ((soft ,%4) (add 2 2)) + [~ %4] + ~zod/try=> ((soft ,@) (add 2 2)) + [~ 4] + ~zod/try=> ((soft ,%5) (add 2 2)) + ~ + ~zod/try=> ((soft ,@t) (crip "Tape to cord, Woohoo!")) + [~ 'Tape to cord, Woohoo!'] + ~zod/try=> ((soft ,@t) (trip 'Cmon man... Tape to cord? Please?!')) + ~ + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2da.md b/docs/pub/doc/hoon/library/2da.md new file mode 100644 index 0000000000..e094f63447 --- /dev/null +++ b/docs/pub/doc/hoon/library/2da.md @@ -0,0 +1,437 @@ +section 2dA, sets +================= + +### ++apt + +Set verification + + ++ apt :: set invariant + |= a=(tree) + ?~ a + & + ?& ?~(l.a & ?&((vor n.a n.l.a) (hor n.l.a n.a))) + ?~(r.a & ?&((vor n.a n.r.a) (hor n.a n.r.a))) + == + :: + +Produces a loobean indicating whether `a` is a set or not. + +`a` is a [tree](). + + ~zod/try=> =b (sa `(list ,@t)`['john' 'bonita' 'daniel' 'madeleine' ~]) + ~zod/try=> (apt b) + %.y + ~zod/try=> =m (mo `(list ,[@t *])`[['a' 1] ['b' [2 3]] ['c' 4] ['d' 5] ~]) + ~zod/try=> m + {[p='d' q=5] [p='a' q=1] [p='c' q=4] [p='b' q=[2 3]]} + ~zod/try=> (apt m) + %.y + +------------------------------------------------------------------------ + +### ++in + +Set operations + + ++ in :: set engine + ~/ %in + |/ a=(set) + +Input arm. + + ~zod/try=> ~(. in (sa "asd")) + <13.evb [nlr(^$1{@tD $1}) <414.fvk 101.jzo 1.ypj %164>]> + +`a` is a [set]() + +### +-all:in + +Logical AND + + +- all :: logical AND + ~/ %all + |* b=$+(* ?) + |- ^- ? + ?~ a + & + ?&((b n.a) $(a l.a) $(a r.a)) + :: + +Computes the logical AND on every element in `a` slammed with `b`, +producing a loobean. + +`a` is a [set](). + +`b` is a [wet gate]() that accepts a noun and produces a loobean. + + ~zod/try=> =b (sa `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) + ~zod/try=> (~(all in b) |=(a=* ?@(+.a & |))) + %.n + ~zod/try=> =b (sa `(list ,@t)`['john' 'bonita' 'daniel' 'madeleine' ~]) + ~zod/try=> (~(all in b) |=(a=@t (gte a 100))) + %.y + +------------------------------------------------------------------------ + +### +-any:in + +Logical OR + + +- any :: logical OR + ~/ %any + |* b=$+(* ?) + |- ^- ? + ?~ a + | + ?|((b n.a) $(a l.a) $(a r.a)) + :: + +Computes the logical OR on every element of `a` slammed with `b`. + +`a` is a [set](). + +`b` is a [gate]() that accepts a noun and produces a loobean. + + ~zod/try=> =b (sa `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) + ~zod/try=> (~(any in b) |=(a=* ?@(+.a & |))) + %.y + ~zod/try=> =b (sa `(list ,@t)`['john' 'bonita' 'daniel' 'madeleine' ~]) + ~zod/try=> (~(any in b) |=(a=@t (lte a 100))) + %.n + +------------------------------------------------------------------------ + +### +-del:in + +Remove noun + + +- del :: b without any a + ~/ %del + |* b=* + |- ^+ a + ?~ a + ~ + ?. =(b n.a) + ?: (hor b n.a) + [n.a $(a l.a) r.a] + [n.a l.a $(a r.a)] + |- ^- ?(~ _a) + ?~ l.a r.a + ?~ r.a l.a + ?: (vor n.l.a n.r.a) + [n.l.a l.l.a $(l.a r.l.a)] + [n.r.a $(r.a l.r.a) r.r.a] + :: + +Removes `b` from the set `a`. + +`a` is a [set](). + +`b` is a [noun](). + + ~zod/try=> =b (sa `(list ,@t)`['a' 'b' 'c' ~]) + ~zod/try=> (~(del in b) 'a') + {'c' 'b'} + ~zod/try=> =b (sa `(list ,@t)`['john' 'bonita' 'daniel' 'madeleine' ~]) + ~zod/try=> (~(del in b) 'john') + {'bonita' 'madeleine' 'daniel'} + ~zod/try=> (~(del in b) 'susan') + {'bonita' 'madeleine' 'daniel' 'john'} + +------------------------------------------------------------------------ + +### +-dig:in + +Axis a in b + + +- dig :: axis of a in b + |= b=* + =+ c=1 + |- ^- (unit ,@) + ?~ a ~ + ?: =(b n.a) [~ u=(peg c 2)] + ?: (gor b n.a) + $(a l.a, c (peg c 6)) + $(a r.a, c (peg c 7)) + :: + +Produce the axis of `b` within `a`. + +`a` is a [set](). + +`b` is a [noun](). + + ~zod/try=> =a (sa `(list ,@)`[1 2 3 4 5 6 7 ~]) + ~zod/try=> a + {5 4 7 6 1 3 2} + ~zod/try=> -.a + n=6 + ~zod/try=> (~(dig in a) 7) + [~ 12] + ~zod/try=> (~(dig in a) 2) + [~ 14] + ~zod/try=> (~(dig in a) 6) + [~ 2] + +------------------------------------------------------------------------ + +### +-gas:in + +Concatenate + + +- gas :: concatenate + ~/ %gas + |= b=(list ,_?>(?=(^ a) n.a)) + |- ^+ a + ?~ b + a + $(b t.b, a (put(+< a) i.b)) + :: + +Insert the elements of a list `b` into a set `a`. + +`a` is a [set](). + +`b` is a [list](). + + ~zod/try=> b + {'bonita' 'madeleine' 'rudolf' 'john'} + ~zod/try=> (~(gas in b) `(list ,@t)`['14' 'things' 'number' '1.337' ~]) + {'1.337' '14' 'number' 'things' 'bonita' 'madeleine' 'rudolf' 'john'} + ~zod/try=> (~(gas in s) `(list ,@t)`['1' '2' '3' ~]) + {'1' '3' '2' 'e' 'd' 'a' 'c' 'b'} + +------------------------------------------------------------------------ + +### +-has:in + +b in a? + + +- has :: b exists in a check + ~/ %has + |* b=* + |- ^- ? + ?~ a + | + ?: =(b n.a) + & + ?: (hor b n.a) + $(a l.a) + $(a r.a) + :: + +Checks if `b` is an element of `a`, producing a loobean. + +`a` is a [set](). + +`b` is a [noun](). + + ~zod/try=> =a (~(gas in `(set ,@t)`~) `(list ,@t)`[`a` `b` `c` ~]) + ~zod/try=> (~(has in a) `a`) + %.y + ~zod/try=> (~(has in a) 'z') + %.n + +------------------------------------------------------------------------ + +### +-int:in + +Intersection + + +- int :: intersection + ~/ %int + |* b=_a + |- ^+ a + ?~ b + ~ + ?~ a + ~ + ?. (vor n.a n.b) + $(a b, b a) + ?: =(n.b n.a) + [n.a $(a l.a, b l.b) $(a r.a, b r.b)] + ?: (hor n.b n.a) + %- uni(+< $(a l.a, b [n.b l.b ~])) $(b r.b) + %- uni(+< $(a r.a, b [n.b ~ r.b])) $(b l.b) + +Produces a set of the intersection between two sets of the same type, +`a` and `b`. + +`a` is a [set](). + +`b` is a [set](). + + ~zod/try=> (~(int in (sa "ac")) (sa "ha")) + {~~a} + ~zod/try=> (~(int in (sa "acmo")) ~) + {} + ~zod/try=> (~(int in (sa "acmo")) (sa "ham")) + {~~a ~~m} + ~zod/try=> (~(int in (sa "acmo")) (sa "lep")) + {} + +------------------------------------------------------------------------ + +### +-put:in + +Put b in a + + +- put :: puts b in a + ~/ %put + |* b=* + |- ^+ a + ?~ a + [b ~ ~] + ?: =(b n.a) + a + ?: (hor b n.a) + =+ c=$(a l.a) + ?> ?=(^ c) + ?: (vor n.a n.c) + [n.a c r.a] + [n.c l.c [n.a r.c r.a]] + =+ c=$(a r.a) + ?> ?=(^ c) + ?: (vor n.a n.c) + [n.a l.a c] + [n.c [n.a l.a l.c] r.c] + :: + +Add an element `b` to the set `a`. + +`a` is a [set](). + +`b` is a [noun](). + + ~zod/try=> =a (~(gas in `(set ,@t)`~) `(list ,@t)`[`a` `b` `c` ~]) + ~zod/try=> =b (~(put in a) `d`) + ~zod/try=> b + {`d` `a` `c` `b`} + ~zod/try=> -.l.+.b + n=`d` + +------------------------------------------------------------------------ + +### +-rep:in + +Accumulate + + +- rep :: replace by tile + |* [b=* c=_,*] + |- + ?~ a b + $(a r.a, b $(a l.a, b (c n.a b))) + :: + +Accumulate the elements of `a` using a gate `c` and an accumulator `b`. + +`a` is a [set](). + +`b` is a [noun]() that accepts a noun and produces a loobean. + +`c` is a [gate](). + + ~zod/try=> =a (~(gas in *(set ,@)) [1 2 3 ~]) + ~zod/try=> a + {1 3 2} + ~zod/try=> (~(rep in a) 0 |=([a=@ b=@] (add a b))) + 6 + +------------------------------------------------------------------------ + +### +-tap:in + +Set to list + + +- tap :: list tiles a set + ~/ %tap + |= b=(list ,_?>(?=(^ a) n.a)) + ^+ b + ?~ a + b + $(a r.a, b [n.a $(a l.a)]) + :: + +Flatten the set `a` into a list. + +`a` is an [set](). + +`a` is a [set](). + +`b` is a [list](). + + ~zod/try=> =s (sa `(list ,@t)`['a' 'b' 'c' 'd' 'e' ~]) + ~zod/try=> s + {'e' 'd' 'a' 'c' 'b'} + ~zod/try=> (~(tap in s) `(list ,@t)`['1' '2' '3' ~]) + ~['b' 'c' 'a' 'd' 'e' '1' '2' '3'] + ~zod/try=> b + {'bonita' 'madeleine' 'daniel' 'john'} + ~zod/try=> (~(tap in b) `(list ,@t)`['david' 'people' ~]) + ~['john' 'daniel' 'madeleine' 'bonita' 'david' 'people'] + +------------------------------------------------------------------------ + +### +-uni:in + +Union + + +- uni :: union + ~/ %uni + |* b=_a + |- ^+ a + ?~ b + a + ?~ a + b + ?: (vor n.a n.b) + ?: =(n.b n.a) + [n.b $(a l.a, b l.b) $(a r.a, b r.b)] + ?: (hor n.b n.a) + $(a [n.a $(a l.a, b [n.b l.b ~]) r.a], b r.b) + $(a [n.a l.a $(a r.a, b [n.b ~ r.b])], b l.b) + ?: =(n.a n.b) + [n.b $(b l.b, a l.a) $(b r.b, a r.a)] + ?: (hor n.a n.b) + $(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a) + $(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a) + +Produces a set of the union between two sets of the same type, `a` and +`b`. + +`a` is a [set](). + +`b` is a [set](). + + ~zod/try=> (~(uni in (sa "ac")) (sa "ha")) + {~~a ~~c ~~h} + ~zod/try=> (~(uni in (sa "acmo")) ~) + {~~a ~~c ~~m ~~o} + ~zod/try=> (~(uni in (sa "acmo")) (sa "ham")) + {~~a ~~c ~~m ~~o ~~h} + ~zod/try=> (~(uni in (sa "acmo")) (sa "lep")) + {~~e ~~a ~~c ~~m ~~l ~~o ~~p} + +------------------------------------------------------------------------ + +### +-wyt:in + +Set size + + +- wyt :: size of set + |- ^- @ + ?~(a 0 +((add $(a l.a) $(a r.a)))) + +Produce the number of elements in set `a` as an atom. + +`a` is an [set](). + + ~zod/try=> =a (~(put in (~(put in (sa)) 'a')) 'b') + ~zod/try=> ~(wyt in a) + 2 + ~zod/try=> b + {'bonita' 'madeleine' 'daniel' 'john'} + ~zod/try=> ~(wyt in b) + 4 + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2db.md b/docs/pub/doc/hoon/library/2db.md new file mode 100644 index 0000000000..189eb213f8 --- /dev/null +++ b/docs/pub/doc/hoon/library/2db.md @@ -0,0 +1,813 @@ +section 2dB, maps +================= + +### ++ept + +Map invariant. + + ++ ept :: map invariant + |= a=(tree ,[p=* q=*]) + ?~ a + & + ?& ?~(l.a & ?&((vor p.n.a p.n.l.a) (hor p.n.l.a p.n.a))) + ?~(r.a & ?&((vor p.n.a p.n.r.a) (hor p.n.a p.n.r.a))) + == + +Computes whether `a` is a [map](), producing a loobean. + +`a` is a [tree](). + + ~zod/try=> m + {[p='d' q=5] [p='a' q=1] [p='c' q=4] [p='b' q=[2 3]]} + ~zod/try=> (ept m) + %.y + ~zod/try=> b + {'bonita' 'madeleine' 'daniel' 'john'} + ~zod/try=> (ept b) + ! type-fail + ! exit + +------------------------------------------------------------------------ + +### ++ja + +Jar engine + + ++ ja :: jar engine + |/ a=(jar) + +A container arm for `++jar` operation arms. A `++jar` is a `++map` of +`++list`s. The contained arms inherit the [sample]() jar. + +`a` is a [jar](). + + ~zod/try=> ~(. ja (mo (limo a/"ho" b/"he" ~))) + <2.dgz [nlr([p={%a %b} q=""]) <414.fvk 101.jzo 1.ypj %164>]> + +------------------------------------------------------------------------ + +### +-get:ja + +Grab value by key + + +- get :: grab value by key + |* b=* + =+ c=(~(get by a) b) + ?~(c ~ u.c) + +Produces a list retrieved from jar `a` using the key `b`. + +`a` is a [`++jar`](). + +`b` is a key of the same type as the keys in `a`. + + ~zod/try=> =l (mo `(list ,[@t (list ,@)])`[['a' `(list ,@)`[1 2 3 ~]] ['b' `(list ,@)`[4 5 6 ~]] ~]) + ~zod/try=> l + {[p='a' q=~[1 2 3]] [p='b' q=~[4 5 6]]} + ~zod/try=> (~(get ja l) 'a') + ~[1 2 3] + ~zod/try=> (~(get ja l) 'b') + ~[4 5 6] + ~zod/try=> (~(get ja l) 'c') + ~ + +------------------------------------------------------------------------ + +### +-add:ja + +Prepend to list + + +- add :: adds key-list pair + |* [b=* c=*] + =+ d=(get(+< a) b) + (~(put by a) b [c d]) + +Produces jar `a` with value `c` prepended to the list located at key +`b`. + +`a` is a [jar](). + +`b` is a key of the same type as the keys in `a`. + +`c` is a value of the same type as the values in `a`. + + ~zod/try=> =l (mo `(list ,[@t (list ,@)])`[['a' `(list ,@)`[1 2 3 ~]] ['b' `(list ,@)`[4 5 6 ~]] ~]) + ~zod/try=> l + {[p='a' q=~[1 2 3]] [p='b' q=~[4 5 6]]} + ~zod/try=> (~(add ja l) 'b' 7) + {[p='a' q=~[1 2 3]] [p='b' q=~[7 4 5 6]]} + ~zod/try=> (~(add ja l) 'a' 100) + {[p='a' q=~[100 1 2 3]] [p='b' q=~[4 5 6]]} + ~zod/try=> (~(add ja l) 'c' 7) + {[p='a' q=~[1 2 3]] [p='c' q=~[7]] [p='b' q=~[4 5 6]]} + ~zod/try=> (~(add ja l) 'c' `(list ,@)`[7 8 9 ~]) + ! type-fail + ! exit + +------------------------------------------------------------------------ + +### ++ju + +Jug operations + + ++ ju :: jug engine + |/ a=(jug) + +Container arm for jug operation arms. A `++jug` is a `++map` of +`++sets`. The contained arms inherit its [sample]() jug, `a`. + +`a` is a [jug](). + + ~zod/try=> ~(. ju (mo (limo a/(sa "ho") b/(sa "he") ~))) + <2.dgz [nlr([p={%a %b} q={nlr(^$1{@tD $1}) nlr(^$3{@tD $3})}]) <414.fvk 101.jzo 1.ypj %164>]> + +### +-del:ju + +Remove + + +- del :: delete at key b + |* [b=* c=*] + ^+ a + =+ d=(get(+< a) b) + =+ e=(~(del in d) c) + ?~ e + (~(del by a) b) + (~(put by a) b e) + +Produces jug `a` with value `c` removed from set located at key `b`. + +`a` is a [jug](). + +`b` is a key of the same type as the keys in `a`. + +`c` is the value of the same type of the keys in `a` that is to be +removed. + + ~zod/try=> s + {[p='a' q={1 3 2}] [p='b' q={5 4 6}]} + ~zod/try=> (~(del ju s) 'a' 1) + {[p='a' q={3 2}] [p='b' q={5 4 6}]} + ~zod/try=> (~(del ju s) 'c' 7) + {[p='a' q={1 3 2}] [p='b' q={5 4 6}]} + +------------------------------------------------------------------------ + +### +-get:ju + +Retrieve set + + +- get :: gets set by key + |* b=* + =+ c=(~(get by a) b) + ?~(c ~ u.c) + +Produces a set retrieved from jar `a` using key `b`. + +`a` is a [jar](). + +`b` is a key of the same type as the keys in `a`. + + ~zod/try=> s + {[p='a' q={1 3 2}] [p='b' q={5 4 6}]} + ~zod/try=> (~(get ju s) 'a') + {1 3 2} + ~zod/try=> (~(get ju s) 'b') + {5 4 6} + ~zod/try=> (~(get ju s) 'c') + ~ + +------------------------------------------------------------------------ + +### +-has:ju + +Check contents + + +- has :: existence check + |* [b=* c=*] + ^- ? + (~(has in (get(+< a) b)) c) + +Computes whether a value `c` exists within the set located at key `b` +with jar `a`. Produces a loobean. + +`a` is a [set](). + +`b` is a key as a [noun](). + +`c` is a value as a [noun](). + + ~zod/try=> s + {[p='a' q={1 3 2}] [p='b' q={5 4 6}]} + ~zod/try=> (~(has ju s) 'a' 3) + %.y + ~zod/try=> (~(has ju s) 'b' 6) + %.y + ~zod/try=> (~(has ju s) 'a' 7) + %.n + ~zod/try=> (~(has jus s) 'c' 7) + ! -find-limb.jus + ! find-none + ! exit + ~zod/try=> (~(has ju s) 'c' 7) + %.n + +------------------------------------------------------------------------ + +### +-put:ju + +Add key-set pair + + +- put :: adds key-element pair + |* [b=* c=*] + ^+ a + =+ d=(get(+< a) b) + (~(put by a) b (~(put in d) c)) + +Produces jar `a` with `c` added to the set value located at key `b`. + +`a` is a [set](). + +`b` is a key as a [noun](). + +`c` is a [value](). + + ~zod/try=> s + {[p='a' q={1 3 2}] [p='b' q={5 4 6}]} + ~zod/try=> (~(put ju s) 'a' 7) + {[p='a' q={7 1 3 2}] [p='b' q={5 4 6}]} + ~zod/try=> (~(put ju s) 'a' 1) + {[p='a' q={1 3 2}] [p='b' q={5 4 6}]} + ~zod/try=> (~(put ju s) 'c' 7) + {[p='a' q={1 3 2}] [p='c' q={7}] [p='b' q={5 4 6}]} + +------------------------------------------------------------------------ + +### ++by + +Map operations + + ++ by :: map engine + ~/ %by + |/ a=(map) + +Container arm for map operation arms. A map is a set of key, value +pairs. The contained arms inherit it's [sample]() [map](), `a`. + +`a` is a [map](). + + ~zod/try=> ~(. by (mo (limo [%a 1] [%b 2] ~))) + <19.irb [nlr([p={%a %b} q=@ud]) <414.rvm 101.jzo 1.ypj %164>]> + +------------------------------------------------------------------------ + +### +-all:by + +Logical AND + + +- all :: logical AND + ~/ %all + |* b=$+(* ?) + |- ^- ? + ?~ a + & + ?&((b q.n.a) $(a l.a) $(a r.a)) + +Computes the logical AND on the results of slamming every element in map +`a` with gate `b`. Produces a loobean. + +`a` is a [map](). + +`b` is a [wet gate](). + + ~zod/try=> =b (mo `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) + ~zod/try=> (~(all by b) |=(a=* ?@(a & |))) + %.n + ~zod/try=> =a (mo `(list ,[@t @u])`[['a' 1] ['b' 2] ['c' 3] ['d' 4] ['e' 5] ~]) + ~zod/try=> (~(all by a) |=(a=@ (lte a 6))) + %.y + ~zod/try=> (~(all by a) |=(a=@ (lte a 4))) + %.n + +------------------------------------------------------------------------ + +### +-any:by + +Logical OR + + +- any :: logical OR + ~/ %any + |* b=$+(* ?) + |- ^- ? + ?~ a + | + ?|((b q.n.a) $(a l.a) $(a r.a)) + +Computes the logical OR on the results of slamming every element with +gate `b`. Produces a loobean. + +`a` is a [map](). + +`b` is a [wet gate](). + + ~zod/try=> =b (mo `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) + ~zod/try=> (~(all by b) |=(a=* ?@(a & |))) + %.y + ~zod/try=> =a (mo `(list ,[@t @u])`[['a' 1] ['b' 2] ['c' 3] ['d' 4] ['e' 5] ~]) + ~zod/try=> (~(any by a) |=(a=@ (lte a 4))) + %.y + +------------------------------------------------------------------------ + +### +-del:by + +Delete + + +- del :: delete at key b + ~/ %del + |* b=* + |- ^+ a + ?~ a + ~ + ?. =(b p.n.a) + ?: (gor b p.n.a) + [n.a $(a l.a) r.a] + [n.a l.a $(a r.a)] + |- ^- ?(~ _a) + ?~ l.a r.a + ?~ r.a l.a + ?: (vor p.n.l.a p.n.r.a) + [n.l.a l.l.a $(l.a r.l.a)] + [n.r.a $(r.a l.r.a) r.r.a] + +Produces map `a` with the element located at key `b` removed. + +`a` is a [map](). + +`b` is a key as a [noun](). + + ~zod/try=> =b (mo `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) + ~zod/try=> (~(del by b) `a`) + {[p=`b` q=[2 3]]} + +------------------------------------------------------------------------ + +### +-dig:by + +Axis of key + + +- dig :: axis of key + |= b=* + =+ c=1 + |- ^- (unit ,@) + ?~ a ~ + ?: =(b p.n.a) [~ u=(peg c 2)] + ?: (gor b p.n.a) + $(a l.a, c (peg c 6)) + $(a r.a, c (peg c 7)) + +Produce the axis of key `b` within map `a`. + +`a` is a [map](). + +`b` is a key as a [noun](). + + ~zod/try=> =b (mo `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) + ~zod/try=> (~(dig by b) `b`) + [~ 2] + +------------------------------------------------------------------------ + +### +-gas:by + +Concatenate + + +- gas :: concatenate + ~/ %gas + |* b=(list ,[p=* q=*]) + => .(b `(list ,_?>(?=(^ a) n.a))`b) + |- ^+ a + ?~ b + a + $(b t.b, a (put(+< a) p.i.b q.i.b)) + +Insert a list of key-value pairs `b` into map `a`. + +`a` is a [map](). + +`b` is a [list]() of [cells]() of key-value nouns `p` and `q`. + + ~zod/try=> =a (mo `(list ,[@t *])`[[`a` 1] [`b` 2] ~]) + ~zod/try=> =b `(list ,[@t *])`[[`c` 3] [`d` 4] ~] + ~zod/try=> (~(gas by a) b) + {[p=`d` q=4] [p=`a` q=1] [p=`c` q=3] [p=`b` q=2]} + +------------------------------------------------------------------------ + +### +-get:by + +Grab unit value + + +- get :: unit value by key + ~/ %get + |* b=* + |- ^- ?(~ [~ u=_?>(?=(^ a) q.n.a)]) + ?~ a + ~ + ?: =(b p.n.a) + [~ u=q.n.a] + ?: (gor b p.n.a) + $(a l.a) + $(a r.a) + +Produce the unit value of the value located at key `b` within map `a`. + +`a` is a [map]() + +`b` is a [key]() as a [noun]() + + ~zod/try=> =b (mo `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) + ~zod/try=> (~(get by b) `b`) + [~ [2 3]] + +------------------------------------------------------------------------ + +### +-got:by + +Assert + + +- got + |* b=* + %- need + %- get(+< a) b + +Produce the value located at key `b` within map `a`. Crash if key `b` +does not exist. + +`a` is a [map](). + +`b` is a [key](). + + ~zod/try=> =m (mo `(list ,[@t *])`[['a' 1] ['b' 2] ~]) + ~zod/try=> m + {[p='a' q=1] [p='b' q=2]} + ~zod/try=> (~(get by m) 'a') + [~ 1] + ~zod/try=> (~(got by m) 'a') + 1 + ~zod/try=> (~(got by m) 'c') + ! exit + +------------------------------------------------------------------------ + +### +-has:by + +Key existence check + + +- has :: key existence check + ~/ %has + |* b=* + !=(~ (get(+< a) b)) + +Checks whether map `a` contains an element with key `b`, producing a +loobean. + +`a` is a [map](). + +`b` is a key as a [noun](). + + ~zod/try=> =b (mo `(list ,[@t *])`[['a' 1] ['b' [2 3]] ~]) + ~zod/try=> (~(has by b) `b`) + %.y + ~zod/try=> (~(has by b) `c`) + %.n + +------------------------------------------------------------------------ + +### +-int:by + +Intersection + + +- int :: intersection + ~/ %int + |* b=_a + |- ^+ a + ?~ b + ~ + ?~ a + ~ + ?: (vor p.n.a p.n.b) + ?: =(p.n.b p.n.a) + [n.b $(a l.a, b l.b) $(a r.a, b r.b)] + ?: (hor p.n.b p.n.a) + %- uni(+< $(a l.a, b [n.b l.b ~])) $(b r.b) + %- uni(+< $(a r.a, b [n.b ~ r.b])) $(b l.b) + ?: =(p.n.a p.n.b) + [n.b $(b l.b, a l.a) $(b r.b, a r.a)] + ?: (hor p.n.a p.n.b) + %- uni(+< $(b l.b, a [n.a l.a ~])) $(a r.a) + %- uni(+< $(b r.b, a [n.a ~ r.a])) $(a l.a) + +Produces a map of the (key) intersection between two maps of the same +type, `a` and `b`. If both maps have an identical key that point to +different values, the element from map `b` is used. + +`a` is a [map](). + +`b` is a [map](). + + ~zod/try=> =n (mo `(list ,[@t *])`[['a' 1] ['c' 3] ~]) + ~zod/try=> n + {[p='a' q=1] [p='c' q=3]} + ~zod/try=> m + {[p='a' q=1] [p='b' q=2]} + ~zod/try=> (~(int by m) n) + {[p='a' q=1]} + ~ravpel-holber/try=> =p (mo `(list ,[@t *])`[['a' 2] ['b' 2] ~]) + ~zod/try=> p + {[p='a' q=2] [p='b' q=2]} + ~zod/try=> (~(int by p) n) + {[p='a' q=2]} + ~zod/try=> =q (mo `(list ,[@t *])`[['a' 2] ['c' 2] ~]) + ~zod/try=> q + {[p='a' q=2] [p='b' q=2]} + ~zod/try=> (~(int by p) q) + {[p='a' q=2] [p='b' q=2]} + ~zod/try=> =o (mo `(list ,[@t *])`[['c' 3] ['d' 4] ~]) + ~zod/try=> (~(int by m) o) + {} + + +------------------------------------------------------------------------ + +### +-mar:by + +Assert and Add + + +- mar :: add with validation + |* [b=_?>(?=(^ a) p.n.a) c=(unit ,_?>(?=(^ a) q.n.a))] + ?~ c + (del b) + (put b u.c) + +Produces map `a` with the addition of a key-value pair, where the value +is a nonempty unit. + +Accept a noun and a unit of a noun of the type of the map's keys and +values, respectively. Validate that the value is not null and put the +pair in the map. If the value is null, delete the key. + +XX This arm is broken, asana task 15186618346453 + + ~zod/try=> m + {[p='a' q=1] [p='b' q=2]} + ~zod/try=> (~(mar by m) 'c' (some 3)) + ! -find-limb.n + ! find-none + ! exit + ~zod/try=> (~(mar by m) 'c' ~) + ! -find-limb.n + ! find-none + ! exit + ~zod/try=> (~(mar by m) 'b' ~) + ! -find-limb.n + ! find-none + ! exit + +------------------------------------------------------------------------ + +### +-put:by + +Add key-value pair + + +- put :: adds key-value pair + ~/ %put + |* [b=* c=*] + |- ^+ a + ?~ a + [[b c] ~ ~] + ?: =(b p.n.a) + ?: =(c q.n.a) + a + [[b c] l.a r.a] + ?: (gor b p.n.a) + =+ d=$(a l.a) + ?> ?=(^ d) + ?: (vor p.n.a p.n.d) + [n.a d r.a] + [n.d l.d [n.a r.d r.a]] + =+ d=$(a r.a) + ?> ?=(^ d) + ?: (vor p.n.a p.n.d) + [n.a l.a d] + [n.d [n.a l.a l.d] r.d] + +Produces `a` with the addition of the key-value pair of `b` and `c`. + +`a` is a [map](). + +`b` is a key of the same type as the keys in `a`. + +`c` is a value of the same type of the values in `a`. + + ~zod/try=> m + {[p='a' q=1] [p='b' q=2]} + ~zod/try=> (~(put by m) 'c' 3) + {[p='a' q=1] [p='c' q=3] [p='b' q=2]} + ~zod/try=> (~(put by m) "zod" 26) + ! type-fail + ! exit + ~zod/try=> (~(put by m) 'a' 2) + {[p='a' q=2] [p='b' q=2]} + +------------------------------------------------------------------------ + +### +-rep:by + + +- rep :: replace by product + |* [b=* c=_,*] + |- + ?~ a b + $(a r.a, b $(a l.a, b (c q.n.a b))) + +Accumulate using gate from values in map + +XX interface changing. + +------------------------------------------------------------------------ + +### +-rib:by + + +- rib :: transform + product + |* [b=* c=_,*] + |- ^+ [b a] + ?~ a [b ~] + =+ d=(c n.a b) + =. n.a +.d + =+ e=$(a l.a, b -.d) + =+ f=$(a r.a, b -.e) + [-.f [n.a +.e +.f]] + +Replace values with accumulator + +XX interface changing, possibly disappearing + +------------------------------------------------------------------------ + +### +-run:by + +Transform values + + +- run :: turns to tuples + |* b=_,* + |- + ?~ a a + a(n (b q.n.a), l $(a l.a), r $(a r.a)) + +Iterates over every value in set `a` using gate `b`. Produces a map. + +`a` is a [map](). + +`b` is a [wet gate](). + + ~zod/try=> m + {[p='a' q=1] [p='b' q=2]} + ~zod/try=> ^+(m (~(run by m) dec)) + {[p='a' q=0] [p='b' q=1]} + ~zod/try=> `(map ,@tas ,@t)`(~(run by m) (cury scot %ux)) + {[p=%a q='0x1'] [p=%b q='0x2']} + +------------------------------------------------------------------------ + +### +-tap:by + +Listify pairs + + +- tap :: listify pairs + ~/ %tap + |= b=(list ,_?>(?=(^ a) n.a)) + ^+ b + ?~ a + b + $(a r.a, b [n.a $(a l.a)]) + +Produces the list of all elements in map `a` that is prepended to list +`b`, which is empty by default. + +`a` is a [map](). + +`b` is a [list](). + + {[p='a' q=1] [p='b' q=2]} + ~zod/try=> `*`m + [[98 2] [[97 1] 0 0] 0] + ~zod/try=> (~(tap by m)) + ~[[p='b' q=2] [p='a' q=1]] + ~zod/try=> `*`(~(tap by m)) + [[98 2] [97 1] 0] + +------------------------------------------------------------------------ + +### +-uni:by + +Union + + +- uni :: union, merge + ~/ %uni + |* b=_a + |- ^+ a + ?~ b + a + ?~ a + b + ?: (vor p.n.a p.n.b) + ?: =(p.n.b p.n.a) + [n.b $(a l.a, b l.b) $(a r.a, b r.b)] + ?: (hor p.n.b p.n.a) + $(a [n.a $(a l.a, b [n.b l.b ~]) r.a], b r.b) + $(a [n.a l.a $(a r.a, b [n.b ~ r.b])], b l.b) + ?: =(p.n.a p.n.b) + [n.b $(b l.b, a l.a) $(b r.b, a r.a)] + ?: (hor p.n.a p.n.b) + $(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a) + $(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a) + +Produces a map of the union between the keys of `a` and `b`. If `b` +shares a key with `a`, the tuple from `a` is preserved. + +`a` is a [map](). + +`b` is a [map](). + + ~zod/try=> m + {[p='a' q=1] [p='b' q=2]} + ~zod/try=> o + {[p='d' q=4] [p='c' q=3]} + ~zod/try=> (~(uni by m) o) + {[p='d' q=4] [p='a' q=1] [p='c' q=3] [p='b' q=2]} + ~zod/try=> (~(uni by m) ~) + {[p='a' q=1] [p='b' q=2]} + ~zod/try=> n + {[p='a' q=1] [p='c' q=9]} + ~zod/try=> (~(uni by o) n) + {[p='d' q=4] [p='a' q=1] [p='c' q=3]} + ~zod/try=> =n (mo `(list ,[@t *])`[['a' 1] ['c' 9] ~]) + ~zod/try=> n + {[p='a' q=1] [p='c' q=9]} + ~zod/try=> (~(uni by o) n) + {[p='d' q=4] [p='a' q=1] [p='c' q=9]} + +------------------------------------------------------------------------ + +### +-urn:by + +Turn (with key) + + +- urn :: turn + |* b=$+([* *] *) + |- + ?~ a ~ + [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)] + +Iterates over every value in map `a` using gate `b`, which accepts both +the key and the value of each element as its sample. + +`a` is a [map](). + +`b` is a [wet gate]() that accepts two nouns (a key and a value) and +produces a noun (the new value). + + ~zod/try=> m + {[p='a' q=1] [p='b' q=2]} + ~zod/try=> (~(urn by m) |=(a=[p=* q=*] q.a)) + {[p='a' q=1] [p='b' q=2]} + ~zod/try=> (~(urn by m) |=(a=[p=* q=*] 7)) + {[p='a' q=7] [p='b' q=7]} + ~zod/try=> (~(urn by m) |=(a=[p=* q=*] p.a)) + {[p='a' q=97] [p='b' q=98]} + +------------------------------------------------------------------------ + +### +-wyt:by + +Depth + + +- wyt :: depth of map + |- ^- @ + ?~(a 0 +((add $(a l.a) $(a r.a)))) + +Produce the depth of the tree map `a`. + +`a` is a [map](). + + ~zod/try=> m + {[p='a' q=1] [p='b' q=2]} + ~zod/try=> o + {[p='d' q=4] [p='c' q=3]} + ~zod/try=> ~(wyt by m) + 2 + ~zod/try=> ~(wyt by o) + 2 + ~zod/try=> ~(wyt by (~(uni by m) o)) + 4 + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2dc.md b/docs/pub/doc/hoon/library/2dc.md new file mode 100644 index 0000000000..78f3f64f88 --- /dev/null +++ b/docs/pub/doc/hoon/library/2dc.md @@ -0,0 +1,221 @@ +section 2dC, queues +=================== + +### ++to + +Queue engine + + ++ to :: queue engine + |/ a=(qeu) + +Container arm for queue operation arms. The contained arms inherit its +[sample]() `++qeu` `a`. + +`a` is a queue, [++qeu](). + +### +-bal:to + +Balance + + +- bal + |- ^+ a + ?~ a ~ + ?. |(?=(~ l.a) (vor n.a n.l.a)) + $(a [n.l.a l.l.a $(a [n.a r.l.a r.a])]) + ?. |(?=(~ r.a) (vor n.a n.r.a)) + $(a [n.r.a $(a [n.a l.a l.r.a]) r.r.a]) + a + :: + +Vertically rebalances queue `a`. + +`a` is a [queue](). + + ~zod/try=> `(qeu tape)`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~] + {"a" "b" "c" "d" "e" "f" "g"} + ~zod/try=> `*`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~] + [[97 0] 0 [98 0] 0 [99 0] 0 [100 0] 0 [101 0] 0 [102 0] 0 [103 0] 0 0] + ~zod/try=> ~(bal to `(qeu tape)`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~]) + {"a" "b" "c" "d" "e" "f" "g"} + ~zod/try=> `*`~(bal to `(qeu tape)`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~]) + [[100 0] [[99 0] [[98 0] [[97 0] 0 0] 0] 0] [101 0] 0 [102 0] 0 [103 0] 0 0] + +------------------------------------------------------------------------ + +### +-dep:to + +Maximum Depth + + +- dep :: max depth of queue + |- ^- @ + ?~ a 0 + +((max $(a l.a) $(a r.a))) + :: + +Produces the maximum depth of leaves (r.a and l.a) in queue `a`. + +`a` is a [queue](). + + ~zod/try=> =a (~(gas to `(qeu ,@)`~) `(list ,@)`[1 2 3 4 5 6 7 ~]) + ~zod/try=> ~(dep to a) + 4 + ~zod/try=> =a (~(gas to `(qeu ,@)`~) `(list ,@)`[1 2 3 4 ~]) + ~zod/try=> ~(dep to a) + 3 + ~zod/try=> =a (~(gas to `(qeu ,@)`~) `(list ,@)`[1 2 ~]) + ~zod/try=> ~(dep to a) + 2 + ~zod/try=> ~(dep to `(qeu tape)`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~]) + 7 + ~zod/try=> ~(dep to ~(bal to `(qeu tape)`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~])) + 4 + +------------------------------------------------------------------------ + +### +-gas + +Push list + + +- gas :: insert list to queue + |= b=(list ,_?>(?=(^ a) n.a)) + |- ^+ a + ?~(b a $(b t.b, a (put(+< a) i.b))) + :: + +Push all elements of list `b` into the queue. + +`a` is a [queue](). + +`b` is a list. + + ~zod/try=> (~(gas to `(qeu ,@)`~) `(list ,@)`[1 2 3 ~]) + {3 2 1} + ~zod/try=> =a (~(gas to `(qeu ,@)`~) `(list ,@)`[1 2 3 ~]) + ~zod/try=> =b `(list ,@)`[4 5 6 ~] + ~zod/try=> (~(gas to a) b) + {6 5 4 3 2 1} + +------------------------------------------------------------------------ + +### +-get:to + +Pop + + +- get :: head-tail pair + |- ^+ [p=?>(?=(^ a) n.a) q=a] + ?~ a + !! + ?~ r.a + [n.a l.a] + =+ b=$(a r.a) + :- p.b + ?: |(?=(~ q.b) (vor n.a n.q.b)) + [n.a l.a q.b] + [n.q.b [n.a l.a l.q.b] r.q.b] + :: + +Produces the head and tail queue of `a`. + +`a` is a [queue](). + + ~zod/try=> =s (~(gas to *(qeu ,@)) `(list ,@)`~[1 2 3]) + ~zod/try=> ~(get to s) + [p=1 q={3 2}] + ~zod/try=> ~(get to ~) + ! exit + +------------------------------------------------------------------------ + +### +-nap:to + +Remove last in + + +- nap :: removes head + ?> ?=(^ a) + ?: =(~ l.a) r.a + =+ b=get(+< l.a) + bal(+< ^+(a [p.b q.b r.a])) + :: + +Removes the head of queue `a`, producing the resulting queue. + +`a` is a [queue](). + + ~zod/try=> =a (~(gas to `(qeu ,@)`~) `(list ,@)`[1 2 3 4 5 6 ~]) + ~zod/try=> -.a + n=6 + ~zod/try=> =b ~(nap to a) + ~zod/try=> -.b + n=2 + ~zod/try=> b + {5 4 3 2 1} + ~zod/try=> a + {6 5 4 3 2 1} + +------------------------------------------------------------------------ + +### +-put:to + +Insert + + +- put :: insert new tail + |* b=* + |- ^+ a + ?~ a + [b ~ ~] + bal(+< a(l $(a l.a))) + :: + +Accept any noun `b` and adds to queue `a` as the head, producing the +resulting queue. + +`a` is a [queue](). + +`b` is any noun. + + ~zod/try=> (~(gas to `(qeu ,@)`~) `(list ,@)`[3 1 2 4 5 6 ~]) + ~zod/try=> (~(put to a) 7) + {7 6 5 4 2 1 3} + +------------------------------------------------------------------------ + +### +-tap:to + +Queue to list + + +- tap :: queue to list + |= b=(list ,_?>(?=(^ a) n.a)) + ^+ b + ?~ a + b + $(a r.a, b [n.a $(a l.a)]) + :: + +Produces queue `a` as a list from front to back. + +`a` is a [queue](). + + ~zod/try=> =a (~(gas to `(qeu ,@)`~) `(list ,@)`[3 1 2 4 5 6 ~]) + ~zod/try=> `*`a + [6 0 2 [4 [5 0 0] 0] 1 0 3 0 0] + ~zod/try=> (~(tap to a) `(list ,@)`[99 100 101 ~]) + ~[3 1 2 4 5 6 99 100 101] + +------------------------------------------------------------------------ + +### +-top:to + + +- top :: produces head + |- ^- (unit ,_?>(?=(^ a) n.a)) + ?~ a ~ + ?~(r.a [~ n.a] $(a r.a)) + +Produces the head of queue `a` as a unit (an empty queue has no head). + +`a` is a [queue](). + + ~zod/try=> =a (~(gas to `(qeu ,@)`~) `(list ,@)`[1 2 3 4 5 6 ~]) + ~zod/try=> ~(top to a) + [~ 1] + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2dd.md b/docs/pub/doc/hoon/library/2dd.md new file mode 100644 index 0000000000..e60f84c2c4 --- /dev/null +++ b/docs/pub/doc/hoon/library/2dd.md @@ -0,0 +1,69 @@ +section 2dD, casual containers +============================== + +### ++mo + +Map from list + + ++ mo :: map from list + |* a=(list) + => .(a `_(homo a)`a) + => .(a `(list ,[p=_-<.a q=_->.a])`a) + =+ b=*(map ,_?>(?=(^ a) p.i.a) ,_?>(?=(^ a) q.i.a)) + (~(gas by b) a) + :: + +Produces a map of key-value pairs from the left-right cell pairs of list +`a`. + +`a` is a [list](). + + ~zod/try=> (mo `(list ,[@t *])`[[`a` 1] [`b` 2] ~]) + {[p=`a` q=1] [p=`b` q=2]} + +------------------------------------------------------------------------ + +### ++sa + +Set from list + + ++ sa :: set from list + |* a=(list) + => .(a `_(homo a)`a) + =+ b=*(set ,_?>(?=(^ a) i.a)) + (~(gas in b) a) + :: + +Produces a set of the elements in list `a`. + +`a` is a [list](). + + ~zod/try=> (sa `(list ,@)`[1 2 3 4 5 ~]) + {5 4 1 3 2} + ~zod/try=> (sa `(list ,[@t *])`[[`a` 1] [`b` 2] ~]) + {[`a` 1] [`b` 2]} + +------------------------------------------------------------------------ + +### ++qu + +Queue from list + + ++ qu :: queue from list + |* a=(list) + => .(a `_(homo a)`a) + =+ b=*(qeu ,_?>(?=(^ a) i.a)) + (~(gas to b) a) + +Produces a queue from list `a`. + +`a` is a [list](). + + ~zod/try=> (qu `(list ,@ud)`~[1 2 3 5]) + {5 3 2 1} + ~zod/try=> (qu "sada") + {'a' 'd' 'a' 's'} + ~zod/try=> ~(top to (qu "sada")) + [~ 's'] + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2ea.md b/docs/pub/doc/hoon/library/2ea.md new file mode 100644 index 0000000000..31fd555df3 --- /dev/null +++ b/docs/pub/doc/hoon/library/2ea.md @@ -0,0 +1,162 @@ +section 2eA, packing +==================== + +### ++cue + +Unpack atom to noun + + ++ cue :: unpack atom to noun + ~/ %cue + |= a=@ + ^- * + =+ b=0 + =+ m=`(map ,@ ,*)`~ + =< q + |- ^- [p=@ q=* r=_m] + ?: =(0 (cut 0 [b 1] a)) + =+ c=(rub +(b) a) + [+(p.c) q.c (~(put by m) b q.c)] + =+ c=(add 2 b) + ?: =(0 (cut 0 [+(b) 1] a)) + =+ u=$(b c) + =+ v=$(b (add p.u c), m r.u) + =+ w=[q.u q.v] + [(add 2 (add p.u p.v)) w (~(put by r.v) b w)] + =+ d=(rub c a) + [(add 2 p.d) (need (~(get by m) q.d)) m] + :: + +Produces a noun unpacked from atom `a`. The inverse of jam. + +`a` is an [atom](). + + ~zod/try=> (cue 12) + 1 + ~zod/try=> (cue 817) + [1 1] + ~zod/try=> (cue 4.657) + [1 2] + ~zod/try=> (cue 39.689) + [0 19] + +------------------------------------------------------------------------ + +### ++jam + + ++ jam :: pack + ~/ %jam + |= a=* + ^- @ + =+ b=0 + =+ m=`(map ,* ,@)`~ + =< q + |- ^- [p=@ q=@ r=_m] + =+ c=(~(get by m) a) + ?~ c + => .(m (~(put by m) a b)) + ?: ?=(@ a) + =+ d=(mat a) + [(add 1 p.d) (lsh 0 1 q.d) m] + => .(b (add 2 b)) + =+ d=$(a -.a) + =+ e=$(a +.a, b (add b p.d), m r.d) + [(add 2 (add p.d p.e)) (mix 1 (lsh 0 2 (cat 0 q.d q.e))) r.e] + ?: ?&(?=(@ a) (lte (met 0 a) (met 0 u.c))) + =+ d=(mat a) + [(add 1 p.d) (lsh 0 1 q.d) m] + =+ d=(mat u.c) + [(add 2 p.d) (mix 3 (lsh 0 2 q.d)) m] + :: + +Produces an atom unpacked from noun `a`. The inverse of cue. + +`a` is a [noun](). + + ~zod/try=> (jam 1) + 12 + ~zod/try=> (jam [1 1]) + 817 + ~zod/try=> (jam [1 2]) + 4.657 + ~zod/try=> (jam [~ u=19]) + 39.689 + +------------------------------------------------------------------------ + +### ++mat + +Length-encode + + ++ mat :: length-encode + ~/ %mat + |= a=@ + ^- [p=@ q=@] + ?: =(0 a) + [1 1] + =+ b=(met 0 a) + =+ c=(met 0 b) + :- (add (add c c) b) + (cat 0 (bex c) (mix (end 0 (dec c) b) (lsh 0 (dec c) a))) + +Produces a cell whose tail `q` is atom `a` with a bit representation of +its length prepended to it (as the least significant bits). The head `p` +is the length of `q` in bits. + +`a` is an atom. + + ~zod/try=> (mat 0xaaa) + [p=20 q=699.024] + ~zod/try=> (met 0 q:(mat 0xaaa)) + 20 + ~zod/try=> `@ub`q:(mat 0xaaa) + 0b1010.1010.1010.1001.0000 + ~zod/try=> =a =-(~&(- -) `@ub`0xaaa) + 0b1010.1010.1010 + ~zod/try=> =b =-(~&(- -) `@ub`(xeb a)) + 0b1100 + ~zod/try=> =b =-(~&(- -) `@ub`(met 0 a)) + 0b1100 + ~zod/try=> =c =-(~&(- -) (xeb b)) + 4 + ~zod/try=> [`@ub`a `@ub`(end 0 (dec c) b) `@ub`(bex c)] + [0b1010.1010.1010 0b100 0b1.0000] + +------------------------------------------------------------------------ + +### ++rub + +Length-decode + + ++ rub :: length-decode + ~/ %rub + |= [a=@ b=@] + ^- [p=@ q=@] + =+ ^= c + =+ [c=0 m=(met 0 b)] + |- ?< (gth c m) + ?. =(0 (cut 0 [(add a c) 1] b)) + c + $(c +(c)) + ?: =(0 c) + [1 0] + =+ d=(add a +(c)) + =+ e=(add (bex (dec c)) (cut 0 [d (dec c)] b)) + [(add (add c c) e) (cut 0 [(add d (dec c)) e] b)] + +The inverse of `++mat`. Accepts a cell of index `a` and a bitstring `b` +and produces the cell whose tail `q` is the decoded atom at index `a` +and whose head is the length of the encoded atom `q`, by which the +offset `a` is advanced. Only used internally as a helper cue. + +`a` is an atom. + +`b` is a bitstring as an atom. + + ~zod/try=> `@ub`(jam 0xaaa) + 0b1.0101.0101.0101.0010.0000 + ~zod/try=> (rub 1 0b1.0101.0101.0101.0010.0000) + [p=20 q=2.730] + ~zod/try=> `@ux`q:(rub 1 0b1.0101.0101.0101.0010.0000) + 0xaaa + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2eb.md b/docs/pub/doc/hoon/library/2eb.md new file mode 100644 index 0000000000..67609aa372 --- /dev/null +++ b/docs/pub/doc/hoon/library/2eb.md @@ -0,0 +1,63 @@ +section 2eB, parsing (tracing) +============================== + +### ++last + +Farther trace + + ++ last |= [zyc=hair naz=hair] :: farther trace + ^- hair + ?: =(p.zyc p.naz) + ?:((gth q.zyc q.naz) zyc naz) + ?:((gth p.zyc p.naz) zyc naz) + :: + +Compares two line-column pairs, `zyc` and `naz`, and produces whichever +[hair]() is farther along. + +`zyc` is a [hair](). + +`naz` is a [hair](). + + ~zod/try=> (last [1 1] [1 2]) + [p=1 q=2] + ~zod/try=> (last [2 1] [1 2]) + [p=2 q=1] + ~zod/try=> (last [0 0] [99 0]) + [p=99 q=0] + ~zod/try=> (last [7 7] [7 7]) + [p=7 q=7] + +------------------------------------------------------------------------ + +### ++lust + +Detect newline + + ++ lust |= [weq=char naz=hair] :: detect newline + ^- hair + ?:(=(10 weq) [+(p.naz) 1] [p.naz +(q.naz)]) + +Advances the hair `naz` by a row if the char `weq` is a newline, or by a +column if `weq` is any other character. + +`weq` is a [char](). + +`naz` is a [hair](). + + ~zod/try=> (lust `a` [1 1]) + [p=1 q=2] + ~zod/try=> (lust `@t`10 [1 1]) + [p=2 q=1] + ~zod/try=> (lust '9' [10 10]) + [p=10 q=11] + /~zod/try=> (roll "maze" [.(+<+ [1 1])]:lust) + [1 5] + /~zod/try=> %- roll :_ [.(+<+ [1 1])]:lust + """ + Sam + lokes + """ + [2 6] + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2ec.md b/docs/pub/doc/hoon/library/2ec.md new file mode 100644 index 0000000000..aed4f419ae --- /dev/null +++ b/docs/pub/doc/hoon/library/2ec.md @@ -0,0 +1,652 @@ +section 2eC, parsing (custom rules) +=================================== + +### ++cold + +Replace with constant + + ++ cold :: replace w/ constant + ~/ %cold + |* [cus=* sef=_rule] + ~/ %fun + |= tub=nail + =+ vex=(sef tub) + ?~ q.vex + vex + [p=p.vex q=[~ u=[p=cus q=q.u.q.vex]]] + :: + +Parser modifier. Accepts a rule `sef` and produces a parser that +produces a constant `cus`, if `sef` is successful. + +`cus` is a constant [noun](). + +`sef` is a [`++rule`](). + + ~zod/try=> ((cold %foo (just 'a')) [[1 1] "abc"]) + [p=[p=1 q=2] q=[~ u=[p=%foo q=[p=[p=1 q=2] q="bc"]]]] + ~zod/try=> ((cold %foo (just 'a')) [[1 1] "bc"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++cook + +Apply gate + + ++ cook :: apply gate + ~/ %cook + |* [poq=_,* sef=_rule] + ~/ %fun + |= tub=nail + =+ vex=(sef tub) + ?~ q.vex + vex + [p=p.vex q=[~ u=[p=(poq p.u.q.vex) q=q.u.q.vex]]] + :: + +Parser modifier. Produces a parser that takes a (successful) result of a +rule `sef` and slams it through `poq`. + +`poq` is a [gate](). + +`sef` is a [`++rule`](). + + ~zod/try=> ((cook ,@ud (just 'a')) [[1 1] "abc"]) + [p=[p=1 q=2] q=[~ u=[p=97 q=[p=[p=1 q=2] q="bc"]]]] + ~zod/try=> ((cook ,@tas (just 'a')) [[1 1] "abc"]) + [p=[p=1 q=2] q=[~ u=[p=%a q=[p=[p=1 q=2] q="bc"]]]] + ~zod/try=> ((cook |=(a=@ +(a)) (just 'a')) [[1 1] "abc"]) + [p=[p=1 q=2] q=[~ u=[p=98 q=[p=[p=1 q=2] q="bc"]]]] + ~zod/try=> ((cook |=(a=@ `@t`+(a)) (just 'a')) [[1 1] "abc"]) + [p=[p=1 q=2] q=[~ u=[p='b' q=[p=[p=1 q=2] q="bc"]]]] + +------------------------------------------------------------------------ + +### ++easy + +Always parse + + ++ easy :: always parse + ~/ %easy + |* huf=* + ~/ %fun + |= tub=nail + ^- (like ,_huf) + [p=p.tub q=[~ u=[p=huf q=tub]]] + :: + +Parser generator. Produces a parser that succeeds with given noun `huf` +without consuming any text. + + ~zod/try=> ((easy %foo) [[1 1] "abc"]) + [p=[p=1 q=1] q=[~ [p=%foo q=[p=[p=1 q=1] q="abc"]]]] + ~zod/try=> ((easy %foo) [[1 1] "bc"]) + [p=[p=1 q=1] q=[~ [p=%foo q=[p=[p=1 q=1] q="bc"]]]] + ~zod/try=> ((easy 'a') [[1 1] "bc"]) + [p=[p=1 q=1] q=[~ [p='a' q=[p=[p=1 q=1] q="bc"]]]] + +------------------------------------------------------------------------ + +### ++fail + +Never parse + + ++ fail |=(tub=nail [p=p.tub q=~]) :: never parse + +Produces an [edge]() at the same text position ([hair]()) with a failing +result (`q=~`). + +`tub` is a [`++nail`](). + + ~zod/try=> (fail [[1 1] "abc"]) + [p=[p=1 q=1] q=~] + ~zod/try=> (fail [[p=1.337 q=70] "Parse me, please?"]) + [p=[p=1.337 q=70] q=~] + +------------------------------------------------------------------------ + +### ++full + +Parse to end + + ++ full :: parse to end + |* sef=_rule + |= tub=nail + =+ vex=(sef tub) + ?~(q.vex vex ?:(=(~ q.q.u.q.vex) vex [p=p.vex q=~])) + :: + +Accepts a [`++nail`](), `tub`, and produces a parser that succeeds only +when a `tub` success consumes the remainder of the [tape](). + +`sef` is a [`++rule`](). + + ~zod/try=> ((full (just 'a')) [[1 1] "ab"]) + [p=[p=1 q=2] q=~] + ~zod/try=> ((full (jest 'ab')) [[1 1] "ab"]) + [p=[p=1 q=3] q=[~ u=[p='ab' q=[p=[p=1 q=3] q=""]]]] + ~zod/try=> ((full ;~(plug (just 'a') (just 'b'))) [[1 1] "ab"]) + [p=[p=1 q=3] q=[~ u=[p=[~~a ~~b] q=[p=[p=1 q=3] q=""]]]] + +------------------------------------------------------------------------ + +### ++funk + +Add to tape + + ++ funk :: add to tape first + |* [pre=tape sef=_rule] + |= tub=nail + (sef p.tub (weld pre q.tub)) + :: + +Parser modifier: prepend text to tape before applying parser. + +`pre` is a [`++tape`]() + +`sef` is a [`++rule`]() + + ~zod/try=> ((funk "abc prefix-" (jest 'abc')) [[1 1] "to be parsed"]) + [p=[p=1 q=4] q=[~ [p='abc' q=[p=[p=1 q=4] q=" prefix-to be parsed"]]]] + ~zod/try=> ((funk "parse" (just 'a')) [[1 4] " me"]) + [p=[p=1 q=4] q=~] + +------------------------------------------------------------------------ + +### ++here + +Place-based apply + + ++ here :: place-based apply + ~/ %here + |* [hez=_|=([a=pint b=*] [a b]) sef=_rule] + ~/ %fun + |= tub=nail + =+ vex=(sef tub) + ?~ q.vex + vex + [p=p.vex q=[~ u=[p=(hez [p.tub p.q.u.q.vex] p.u.q.vex) q=q.u.q.vex]]] + :: + +Parser modifier. Similar to [`++cook`](), produces a parser that takes a +(successful) result of `sef` and slams it through `hez`. `hez` accepts a +[`++pint`]() `a` and a noun `b`, which is what the parser parsed. + +`hez` is a [gate](). + +`sef` is a [`++rule`]() + + ~zod/try=> (scan "abc" (star alf)) + "abc" + ~zod/try=> (scan "abc" (here |*(^ +<) (star alf))) + [[[p=1 q=1] p=1 q=4] "abc"] + ~zod/try=> (scan "abc" (star (here |*(^ +<) alf))) + ~[[[[p=1 q=1] p=1 q=2] ~~a] [[[p=1 q=2] p=1 q=3] ~~b] [[[p=1 q=3] p=1 q=4] ~~c]] + +------------------------------------------------------------------------ + +### ++inde + +Indentation block + + ++ inde |* sef=_rule :: indentation block + |= nail ^+ (sef) + =+ [har tap]=[p q]:+< + =+ lev=(fil 3 (dec q.har) ' ') + =+ eol=(just `@t`10) + =+ =- roq=((star ;~(pose prn ;~(sfix eol (jest lev)) -)) har tap) + ;~(simu ;~(plug eol eol) eol) + ?~ q.roq roq + =+ vex=(sef har(q 1) p.u.q.roq) + =+ fur=p.vex(q (add (dec q.har) q.p.vex)) + ?~ q.vex vex(p fur) + =- vex(p fur, u.q -) + :+ &3.vex + &4.vex(q.p (add (dec q.har) q.p.&4.vex)) + =+ res=|4.vex + |- ?~ res |4.roq + ?. =(10 -.res) [-.res $(res +.res)] + (welp [`@t`10 (trip lev)] $(res +.res)) + :: + +Apply rule to indented block starting at current column number, omitting +the leading whitespace. + +`sef` is a [`++rule`]() + + ~zod/try=> (scan "abc" (inde (star ;~(pose prn (just `@`10))))) + "abc" + ~zod/try=> (scan "abc" (star ;~(pose prn (just `@`10)))) + "abc" + ~zod/try=> (scan " abc\0ade" ;~(pfix ace ace (star ;~(pose prn (just `@`10))))) + "abc + de" + ~zod/try=> (scan " abc\0ade" ;~(pfix ace ace (inde (star ;~(pose prn (just `@`10)))))) + ! {1 6} + ! exit + ~zod/try=> (scan " abc\0a de" ;~(pfix ace ace (inde (star ;~(pose prn (just `@`10)))))) + "abc + de" + +------------------------------------------------------------------------ + +### ++jest + +Match a cord + + ++ jest :: match a cord + |= daf=@t + |= tub=nail + =+ fad=daf + |- ^- (like ,@t) + ?: =(0 daf) + [p=p.tub q=[~ u=[p=fad q=tub]]] + ?: |(?=(~ q.tub) !=((end 3 1 daf) i.q.tub)) + (fail tub) + $(p.tub (lust i.q.tub p.tub), q.tub t.q.tub, daf (rsh 3 1 daf)) + :: + +Match and consume a cord. + +`daf` is a `@t` + + ~zod/try=> ((jest 'abc') [[1 1] "abc"]) + [p=[p=1 q=4] q=[~ [p='abc' q=[p=[p=1 q=4] q=""]]]] + ~zod/try=> (scan "abc" (jest 'abc')) + 'abc' + ~zod/try=> (scan "abc" (jest 'acb')) + ! {1 2} + ! 'syntax-error' + ! exit + ~zod/try=> ((jest 'john doe') [[1 1] "john smith"]) + [p=[p=1 q=6] q=~] + ~zod/try=> ((jest 'john doe') [[1 1] "john doe"]) + [p=[p=1 q=9] q=[~ [p='john doe' q=[p=[p=1 q=9] q=""]]]] + +------------------------------------------------------------------------ + +### ++just + +Match a char + + ++ just :: XX redundant, jest + ~/ %just :: match a char + |= daf=char + ~/ %fun + |= tub=nail + ^- (like char) + ?~ q.tub + (fail tub) + ?. =(daf i.q.tub) + (fail tub) + (next tub) + :: + +Match and consume a single character. + +`daf` is a [`++char`]() + + ~zod/try=> ((just 'a') [[1 1] "abc"]) + [p=[p=1 q=2] q=[~ [p=~~a q=[p=[p=1 q=2] q="bc"]]]] + ~zod/try=> (scan "abc" (just 'a')) + ! {1 2} + ! 'syntax-error' + ! exit + ~zod/try=> (scan "a" (just 'a')) + ~~a + ~zod/try=> (scan "%" (just '%')) + ~~~25. + +------------------------------------------------------------------------ + +### ++knee + +Recursive parsers + + ++ knee :: callbacks + |* [gar=* sef=_|.(rule)] + |= tub=nail + ^- (like ,_gar) + ((sef) tub) + :: + +Used for recursive parsers, which would otherwise be infinite when +compiled. + +`gar` is a noun. + +`sef` is a [gate]() that accepts a [`++rule`]() + + ~zod/try=> |-(;~(plug prn ;~(pose $ (easy ~)))) + ! rest-loop + ! exit + ~zod/try=> |-(;~(plug prn ;~(pose (knee *tape |.(^$)) (easy ~)))) + < 1.obo + [ c=c=tub=[p=[p=@ud q=@ud] q=""] + b + < 1.bes + [ c=tub=[p=[p=@ud q=@ud] q=""] + b=<1.tnv [tub=[p=[p=@ud q=@ud] q=""] <1.ktu [daf=@tD <414.fvk 101.jzo 1.ypj %164>]>]> + a=<1.fvg [tub=[p=[p=@ud q=@ud] q=""] <1.khu [[les=@ mos=@] <414.fvk 101.jzo 1.ypj %164>]>]> + v=<414.fvk 101.jzo 1.ypj %164> + ] + > + a + ... 450 lines omitted ... + ] + > + ~zod/try=> (scan "abcd" |-(;~(plug prn ;~(pose (knee *tape |.(^$)) (easy ~))))) + [~~a "bcd"] + +------------------------------------------------------------------------ + +### ++mask + +Match char + + ++ mask :: match char in set + ~/ %mask + |= bud=(list char) + ~/ %fun + |= tub=nail + ^- (like char) + ?~ q.tub + (fail tub) + ?. (lien bud |=(a=char =(i.q.tub a))) + (fail tub) + (next tub) + :: + +Parser generator. Matches the next character if it is in a list of +characters. + +`bud` is a list of [`++char`]() + + ~zod/try=> (scan "a" (mask "cba")) + ~~a + ~zod/try=> ((mask "abc") [[1 1] "abc"]) + [p=[p=1 q=2] q=[~ [p=~~a q=[p=[p=1 q=2] q="bc"]]]] + ~zod/try=> ((mask "abc") [[1 1] "bbc"]) + [p=[p=1 q=2] q=[~ [p=~~b q=[p=[p=1 q=2] q="bc"]]]] + ~zod/try=> ((mask "abc") [[1 1] "dbc"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++next + +Consume char + + ++ next :: consume a char + |= tub=nail + ^- (like char) + ?~ q.tub + (fail tub) + =+ zac=(lust i.q.tub p.tub) + [zac [~ i.q.tub [zac t.q.tub]]] + :: + +Consume any character, producing it as a result. + +`tub` is a [`++nail`]() + + ~zod/try=> (next [[1 1] "ebc"]) + [p=[p=1 q=2] q=[~ [p=~~e q=[p=[p=1 q=2] q="bc"]]]] + ~zod/try=> (next [[1 1] "john jumps jones"]) + [p=[p=1 q=2] q=[~ [p=~~j q=[p=[p=1 q=2] q="ohn jumps jones"]]]] + +------------------------------------------------------------------------ + +### ++sear + +Conditional `++cook` + + ++ sear :: conditional cook + |* [pyq=_|=(* *(unit)) sef=_rule] + |= tub=nail + =+ vex=(sef tub) + ?~ q.vex + vex + =+ gey=(pyq p.u.q.vex) + ?~ gey + [p=p.vex q=~] + [p=p.vex q=[~ u=[p=u.gey q=q.u.q.vex]]] + :: + +Conditional [`++cook`](). Slams the result through a gate that produces +a unit; if that unit is empty, fail. + +`tub` is a [`++nail`]() + + ~zod/try=> ((sear |=(a=* ?@(a (some a) ~)) (just `a`)) [[1 1] "abc"]) + [p=[p=1 q=2] q=[~ u=[p=97 q=[p=[p=1 q=2] q="bc"]]]] + ~zod/try=> ((sear |=(* ~) (just 'a')) [[1 1] "abc"]) + [p=[p=1 q=2] q=~] + +------------------------------------------------------------------------ + +### ++shim + +Char in range + + ++ shim :: match char in range + ~/ %shim + |= [les=@ mos=@] + ~/ %fun + |= tub=nail + ^- (like char) + ?~ q.tub + (fail tub) + ?. ?&((gte i.q.tub les) (lte i.q.tub mos)) + (fail tub) + (next tub) + :: + +Match characters within a range. + +`les` and `mos` are atoms, `@`. + + ~zod/try=> ((shim 'a' 'z') [[1 1] "abc"]) + [p=[p=1 q=2] q=[~ [p=~~a q=[p=[p=1 q=2] q="bc"]]]] + ~zod/try=> ((shim 'a' 'Z') [[1 1] "abc"]) + [p=[p=1 q=1] q=~] + ~zod/try=> ((shim 'a' 'Z') [[1 1] "Abc"]) + [p=[p=1 q=2] q=[~ [p=~~~41. q=[p=[p=1 q=2] q="bc"]]]] + +------------------------------------------------------------------------ + +### ++stag + +Add label + + ++ stag :: add a label + ~/ %stag + |* [gob=* sef=_rule] + ~/ %fun + |= tub=nail + =+ vex=(sef tub) + ?~ q.vex + vex + [p=p.vex q=[~ u=[p=[gob p.u.q.vex] q=q.u.q.vex]]] + :: + +Add a label to an edge parsed by a rule. + +`gob` is a noun. + +`sef` is a rule. + + ~zod/try=> ((stag %foo (just 'a')) [[1 1] "abc"]) + [p=[p=1 q=2] q=[~ u=[p=[%foo ~~a] q=[p=[p=1 q=2] q="bc"]]]] + ~zod/try=> ((stag "xyz" (jest 'abc')) [[1 1] "abc"]) + [p=[p=1 q=4] q=[~ u=[p=["xyz" 'abc'] q=[p=[p=1 q=4] q=""]]]] + ~zod/try=> ((stag 10.000 (shim 0 100)) [[1 1] "abc"]) + [p=[p=1 q=2] q=[~ u=[p=[10.000 ~~a] q=[p=[p=1 q=2] q="bc"]]]] + +------------------------------------------------------------------------ + +### ++stet + +Add faces + + ++ stet + |* leh=(list ,[?(@ [@ @]) _rule]) + |- + ?~ leh + ~ + [i=[p=-.i.leh q=+.i.leh] t=$(leh t.leh)] + :: + +Add `[p q]` faces to range-parser pairs in a list. + +`leh` is a list of range-parsers. + + ~zod/try=> (stet (limo [[5 (just 'a')] [1 (jest 'abc')] [[1 1] (shim 0 200)] + [[1 10] (cold %foo (just 'a'))]~])) + ~[ + [p=5 q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>] + [p=1 q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>] + [p=[1 1] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>] + [p=[1 10] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>] + ] + ~zod/try=> [[[1 1] (just 'a')] [[2 1] (shim 0 200)] ~] + [ [[1 1] <1.tnv [tub=[p=[p=@ud q=@ud] q=""] <1.ktu [daf=@tD <414.fvk 101.jzo 1.ypj %164>]>]>] + [[2 1] <1.fvg [tub=[p=[p=@ud q=@ud] q=""] <1.khu [[les=@ mos=@] <414.fvk 101.jzo 1.ypj %164>]>]>] + ~ + ] + ~zod/try=> (stet (limo [[[1 1] (just 'a')] [[2 1] (shim 0 200)] ~])) + ~[ + [p=[1 1] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>] + [p=[2 1] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>] + ] + +------------------------------------------------------------------------ + +### ++stew + +Switch by first + + ++ stew :: switch by first char + ~/ %stew + |* leh=(list ,[p=?(@ [@ @]) q=_rule]) :: char/range keys + =+ ^= wor :: range complete lth + |= [ort=?(@ [@ @]) wan=?(@ [@ @])] + ?@ ort + ?@(wan (lth ort wan) (lth ort -.wan)) + ?@(wan (lth +.ort wan) (lth +.ort -.wan)) + =+ ^= hel :: build parser map + =+ hel=`(tree $_(?>(?=(^ leh) i.leh)))`~ + |- ^+ hel + ?~ leh + ~ + =+ yal=$(leh t.leh) + |- ^+ hel + ?~ yal + [i.leh ~ ~] + ?: (wor p.i.leh p.n.yal) + =+ nuc=$(yal l.yal) + ?> ?=(^ nuc) + ?: (vor p.n.yal p.n.nuc) + [n.yal nuc r.yal] + [n.nuc l.nuc [n.yal r.nuc r.yal]] + =+ nuc=$(yal r.yal) + ?> ?=(^ nuc) + ?: (vor p.n.yal p.n.nuc) + [n.yal l.yal nuc] + [n.nuc [n.yal l.yal l.nuc] r.nuc] + ~% %fun ..^$ ~ + |= tub=nail + ?~ q.tub + (fail tub) + |- + ?~ hel + (fail tub) + ?: ?@ p.n.hel + =(p.n.hel i.q.tub) + ?&((gte i.q.tub -.p.n.hel) (lte i.q.tub +.p.n.hel)) + :: (q.n.hel [(lust i.q.tub p.tub) t.q.tub]) + (q.n.hel tub) + ?: (wor i.q.tub p.n.hel) + $(hel l.hel) + $(hel r.hel) + :: + +Parser generator. From an associative list of characters or character +ranges to rules, construct a map, and parse tapes only with rules +associated with a range the tape's first character falls in. + +------------------------------------------------------------------------ + +### ++stir + +Parse repeatedly + + ++ stir :: parse repeatedly + ~/ %stir + |* [rud=* raq=_|*([a=* b=*] [a b]) fel=_rule] + ~/ %fun + |= tub=nail + ^- (like ,_rud) + =+ vex=(fel tub) + ?~ q.vex + [p.vex [~ rud tub]] + =+ wag=$(tub q.u.q.vex) + ?> ?=(^ q.wag) + [(last p.vex p.wag) [~ (raq p.u.q.vex p.u.q.wag) q.u.q.wag]] + :: + +Parse with rule as many times as possible, and fold over results with a +binary gate. + +`rud` is a noun. + +`raq` is a gate that takes two nouns and produces a cell. + +`fel` is a rule. + + ~zod/try=> (scan "abc" (stir *@ add prn)) + 294 + ~zod/try=> (roll "abc" add) + b=294 + +------------------------------------------------------------------------ + +### ++stun + +Parse several times + + ++ stun :: parse several times + |* [[les=@ mos=@] fel=_rule] + |= tub=nail + ^- (like (list ,_(wonk (fel)))) + ?: =(0 mos) + [p.tub [~ ~ tub]] + =+ vex=(fel tub) + ?~ q.vex + ?: =(0 les) + [p.vex [~ ~ tub]] + vex + =+ ^= wag %= $ + les ?:(=(0 les) 0 (dec les)) + mos ?:(=(0 mos) 0 (dec mos)) + tub q.u.q.vex + == + ?~ q.wag + wag + [p.wag [~ [p.u.q.vex p.u.q.wag] q.u.q.wag]] + +Parse bounded number of times. + +`[les=@ mos=@]` is a cell of atoms indicating the bounds. + +`fel` is a rule. + + ~zod/try=> ((stun [5 10] prn) [1 1] "aquickbrownfoxran") + [p=[p=1 q=11] q=[~ [p="aquickbrow" q=[p=[p=1 q=11] q="nfoxran"]]]] + ~zod/try=> ((stun [5 10] prn) [1 1] "aquickbro") + [p=[p=1 q=10] q=[~ [p="aquickbro" q=[p=[p=1 q=10] q=""]]]] + ~zod/try=> ((stun [5 10] prn) [1 1] "aqui") + [p=[p=1 q=5] q=~] + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2ed.md b/docs/pub/doc/hoon/library/2ed.md new file mode 100644 index 0000000000..c31280f241 --- /dev/null +++ b/docs/pub/doc/hoon/library/2ed.md @@ -0,0 +1,289 @@ +section 2eD +=========== + +### ++bend + +Conditional composer + + ++ bend :: conditional comp + ~/ %bend + |* raq=_|*([a=* b=*] [~ u=[a b]]) + ~/ %fun + |* [vex=edge sab=_rule] + ?~ q.vex + vex + =+ yit=(sab q.u.q.vex) + =+ yur=(last p.vex p.yit) + ?~ q.yit + [p=yur q=q.vex] + =+ vux=(raq p.u.q.vex p.u.q.yit) + ?~ vux + [p=yur q=q.vex] + [p=yur q=[~ u=[p=u.vux q=q.u.q.yit]]] + :: + +Parsing composer: connects the edge `vex` with the subsequent rule `sab` +as an optional suffix, using the gate `raq` to compose or reject its +result. If there is no suffix, or if the suffix fails to be composed +with the current result, the current result is produced. Used to map a +group of rules to a specified output. + +`raq` is a [gate](). + +`sab` is a [rule](). + +`vex` is an [edge](). + + ~zod/try=> (;~((bend |=([a=char b=char] ?.(=(a b) ~ (some +(a))))) prn prn) [1 1] "qs") + [p=[p=1 q=3] q=[~ u=[p=~~q q=[p=[p=1 q=2] q="s"]]]] + ~zod/try=> (;~((bend |=([a=char b=char] ?.(=(a b) ~ (some +(a))))) prn prn) [1 1] "qqq") + [p=[p=1 q=3] q=[~ u=[p=~~r q=[p=[p=1 q=3] q="q"]]]] + ~zod/try=> (scan "aa" ;~((bend |=([a=char b=char] ?.(=(a b) ~ (some +(a))))) prn prn)) + ~~b + ~zod/try=> (scan "ba" ;~((bend |=([a=char b=char] ?.(=(a b) ~ (some +(a))))) prn prn)) + ! {1 3} + ! exit + ~zod/try=> `(unit ,@tas)`(scan "" ;~((bend) (easy ~) sym)) + ~ + ~zod/try=> `(unit ,@tas)`(scan "sep" ;~((bend) (easy ~) sym)) + [~ %sep] + +------------------------------------------------------------------------ + +### ++comp + +Arbitrary compose + + ++ comp + ~/ %comp + |* raq=_|*([a=* b=*] [a b]) :: arbitrary compose + ~/ %fun + |* [vex=edge sab=_rule] + ?~ q.vex + vex + =+ yit=(sab q.u.q.vex) + =+ yur=(last p.vex p.yit) + ?~ q.yit + [p=yur q=q.yit] + [p=yur q=[~ u=[p=(raq p.u.q.vex p.u.q.yit) q=q.u.q.yit]]] + :: + +Parsing composer: connects the edge `vex` with a following rule `sab`, +combining the contents of `vex` with the result of `sab` using a binary +gate `raq`. Used to fold over the results of several rules. + +`raq` is a [gate]() that accepts a cell of two nouns, `a` and `b`, and +produces a cell of two nouns. + +`sab` is a [rule](). + +`vex` is an [edge](). + + ~zod/try=> (scan "123" ;~((comp |=([a=@u b=@u] (add a b))) dit dit dit)) + 6 + ~zod/try=> (scan "12" ;~((comp |=([a=@u b=@u] (add a b))) dit dit dit)) + ! {1 3} + ! exit + +------------------------------------------------------------------------ + +### ++glue + +Skip delimiter + + ++ glue :: add rule + ~/ %glue + |* bus=_rule + ~/ %fun + |* [vex=edge sab=_rule] + (plug vex ;~(pfix bus sab)) + :: + +Parsing composer: connects an edge `vex` with a following rule `sab` by +parsing the rule `bus` (the delimiting symbol) and throwing out the +result. + +`bus` is a [rule](). + +`sab` is a [rule](). + +`vex` is an [edge](). + + ~zod/try=> (scan "200|mal|bon" ;~((glue bar) dem sym sym)) + [q=200 7.102.829 7.237.474] + ~zod/try=> `[@u @tas @tas]`(scan "200|mal|bon" ;~((glue bar) dem sym sym)) + [200 %mal %bon] + ~zod/try=> (scan "200|;|bon" ;~((glue bar) dem sem sym)) + [q=200 ~~~3b. 7.237.474] + ~zod/try=> (scan "200.;.bon" ;~((glue dot) dem sem sym)) + [q=200 ~~~3b. 7.237.474] + +------------------------------------------------------------------------ + +### ++less + +Parse unless + + ++ less :: no first and second + |* [vex=edge sab=_rule] + ?~ q.vex + =+ roq=(sab) + [p=(last p.vex p.roq) q=q.roq] + vex(q ~) + :: + +Parsing composer: if an edge `vex` reflects a success, fail. Otherwise, +connect `vex` with the following rule. + +`sab` is a [rule](). + +`vex` is an [edge](). + + ~zod/try=> (scan "sas-/lo" (star ;~(less lus bar prn))) + "sas-/lo" + ~zod/try=> (scan "sas-/l+o" (star ;~(less lus bar prn))) + ! {1 8} + ! exit + ~zod/try=> (scan "sas|-/lo" (star ;~(less lus bar prn))) + ! {1 5} + ! exit + +------------------------------------------------------------------------ + +### ++pfix + +Discard first rule + + ++ pfix :: discard first rule + ~/ %pfix + (comp |*([a=* b=*] b)) + :: + +Parsing composer: connects an [edge]() `vex` with two subsequent rules, +ignoring the result of the first and producing the result of the second. + +`vex` is an [edge](). + + ~zod/try=> `@t`(scan "%him" ;~(pfix cen sym)) + 'him' + ~zod/try=> (scan "+++10" ;~(pfix (star lus) dem)) + q=10 + +------------------------------------------------------------------------ + +### ++plug + +Parse to tuple + + ++ plug :: first then second + ~/ %plug + |* [vex=edge sab=_rule] + ?~ q.vex + vex + =+ yit=(sab q.u.q.vex) + =+ yur=(last p.vex p.yit) + ?~ q.yit + [p=yur q=q.yit] + [p=yur q=[~ u=[p=[p.u.q.vex p.u.q.yit] q=q.u.q.yit]]] + :: + +Parsing composer: connects `vex` with a following rule `sab`, producing +a cell of both the results. See also: the monad applicator [;\~]() for a +more detailed explanation. + +`sab` is a [rule](). + +`vex` is an [edge](). + + ~zod/try=> (scan "1..20" ;~(plug dem dot dot dem)) + [q=1 ~~~. ~~~. q=20] + ~zod/try=> (scan "moke/~2014.1.1" ;~(plug sym fas nuck:so)) + [1.701.539.693 ~~~2f. [% p=[p=~.da q=170.141.184.500.766.106.671.844.917.172.921.958.400]]] + ~zod/try=> ;;(,[@tas @t ~ %da @da] (scan "moke/~2014.1.1" ;~(plug sym fas nuck:so))) + [%moke '/' ~ %da ~2014.1.1] + +------------------------------------------------------------------------ + +### ++pose + +Parse options + + ++ pose :: first or second + ~/ %pose + |* [vex=edge sab=_rule] + ?~ q.vex + =+ roq=(sab) + [p=(last p.vex p.roq) q=q.roq] + vex + +Parsing composer: if `vex` reflects a failure, connect it with the +following rule `sab`. See also: the monad applicator [;\~]() + +`sab` is a [rule](). + +`vex` is an [edge](). + + ~zod/try=> `@t`(scan "+" ;~(pose lus tar cen)) + '+' + ~zod/try=> `@t`(scan "*" ;~(pose lus tar cen)) + '*' + ~zod/try=> `@t`(scan "%" ;~(pose lus tar cen)) + '%' + ~zod/try=> `@t`(scan "-" ;~(pose lus tar cen)) + ! {1 1} + ! exit + +------------------------------------------------------------------------ + +### ++simu + +First and second + + ++ simu :: first and second + |* [vex=edge sab=_rule] + ?~ q.vex + vex + =+ roq=(sab) + roq + :: + +Parsing composer: if an edge `vex` reflects a failure, fail. Otherwise, +connect `vex` with the following rule. + +`sab` is a [rule](). + +`vex` is an [edge](). + + ~zod/try=> (scan "~zod" scat:vast) + [%dtzy p=%p q=0] + ~zod/try=> (scan "%zod" scat:vast) + [%dtzz p=%tas q=6.582.138] + ~zod/try=> (scan "%zod" ;~(simu cen scat:vast)) + [%dtzz p=%tas q=6.582.138] + ~zod/try=> (scan "~zod" ;~(simu cen scat:vast)) + ! {1 1} + ! exit + +------------------------------------------------------------------------ + +### ++sfix + +Discard second rule + + ++ sfix :: discard second rule + ~/ %sfix + (comp |*([a=* b=*] a)) + +Parsing composer: connects `vex` with two subsequent rules returning the +result of the first and discarding the result of the second. + +`a` is the result of parsing the first [rule](). + +`b` is the result of of parsing the second [rule](). + + ~zod/try=> `@t`(scan "him%" ;~(sfix sym cen)) + 'him' + ~zod/try=> (scan "10+++" ;~(sfix dem (star lus))) + q=10 + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2ee.md b/docs/pub/doc/hoon/library/2ee.md new file mode 100644 index 0000000000..9ad9697831 --- /dev/null +++ b/docs/pub/doc/hoon/library/2ee.md @@ -0,0 +1,195 @@ +section 2eE, parsing (composers) +================================ + +### ++bass + + ++ bass + |* [wuc=@ tyd=_rule] + %+ cook + |= waq=(list ,@) + %+ roll + waq + =|([p=@ q=@] |.((add p (mul wuc q)))) + tyd + :: + +Parser modifier: +[LSB](http://en.wikipedia.org/wiki/Least_significant_bit) ordered list +as atom of a base. + +`wuc` is an [atom](). + +`tyd` is a [rule](). + + ~zod/try=> (scan "123" (bass 10 (star dit))) + q=123 + ~zod/try=> (scan "123" (bass 8 (star dit))) + q=83 + ~zod/try=> `@ub`(scan "123" (bass 8 (star dit))) + 0b101.0011 + +------------------------------------------------------------------------ + +### ++boss + + ++ boss + |* [wuc=@ tyd=_rule] + %+ cook + |= waq=(list ,@) + %+ reel + waq + =|([p=@ q=@] |.((add p (mul wuc q)))) + tyd + :: + +Parser modifier: +[LSB](http://en.wikipedia.org/wiki/Least_significant_bit) ordered list +as atom of a base. + +`wuc` is an [atom](). + +`tyd` is a [rule](). + + ~zod/try=> (scan "123" (boss 10 (star dit))) + q=321 + ~zod/try=> `@t`(scan "bam" (boss 256 (star alp))) + 'bam' + ~zod/try=> `@ux`(scan "bam" (boss 256 (star alp))) + 0x6d.6162 + +------------------------------------------------------------------------ + +### ++ifix + + ++ ifix + |* [fel=[p=_rule q=_rule] hof=_rule] + ;~(pfix p.fel ;~(sfix hof q.fel)) + :: + +Parser modifier: surround with pair of rules, output of which is +discarded. + +`fel` is a pair of [rule]()s. + +`hof` is a [rule](). + + ~zod/try=> (scan "-40-" (ifix [hep hep] dem)) + q=40 + ~zod/try=> (scan "4my4" (ifix [dit dit] (star alf))) + "my" + +------------------------------------------------------------------------ + +### ++more + + ++ more + |* [bus=_rule fel=_rule] + ;~(pose (most bus fel) (easy ~)) + :: + +Parser modifier: using a delimiter rule, parse a list of matches. + +`bus` is a [rule](). + +`fel` is a [rule](). + + ~zod/try=> (scan "" (more ace dem)) + ~ + ~zod/try=> (scan "40 20" (more ace dem)) + [q=40 ~[q=20]] + ~zod/try=> (scan "40 20 60 1 5" (more ace dem)) + [q=40 ~[q=20 q=60 q=1 q=5]] + +------------------------------------------------------------------------ + +### ++most + + ++ most + |* [bus=_rule fel=_rule] + ;~(plug fel (star ;~(pfix bus fel))) + :: + +Parser modifier: using a delimiter rule, parse a list of at least one +match. + +`bus` is a [rule](). + +`fel` is a [rule](). + + ~zod/try=> (scan "40 20" (most ace dem)) + [q=40 ~[q=20]] + ~zod/try=> (scan "40 20 60 1 5" (most ace dem)) + [q=40 ~[q=20 q=60 q=1 q=5]] + ~zod/try=> (scan "" (most ace dem)) + ! {1 1} + ! exit + +------------------------------------------------------------------------ + +### ++plus + + ++ plus |*(fel=_rule ;~(plug fel (star fel))) + +Parser modifier: parse list of at least one match + +`fel` is a [rule](). + + ~zod/try=> (scan ">>>>" (cook lent (plus gar))) + 4 + ~zod/try=> (scan "- - " (plus ;~(pose ace hep))) + [~~- " - "] + ~zod/try=> `tape`(scan "- - " (plus ;~(pose ace hep))) + "- - " + ~zod/try=> `(pole ,@t)`(scan "- - " (plus ;~(pose ace hep))) + ['-' [' ' [' ' ['-' [' ' ~]]]]] + +------------------------------------------------------------------------ + +### ++slug + + ++ slug + |* raq=_|*([a=* b=*] [a b]) + |* [bus=_rule fel=_rule] + ;~((comp raq) fel (stir rud raq ;~(pfix bus fel))) + :: + +Parser modifier: By composing with a gate, parse a delimited list of +matches. + +`bus` is a [rule](). + +`fel` is a [rule](). + + ~zod/try=> (scan "20+5+110" ((slug add) lus dem)) + 135 + ~zod/try=> `@t`(scan "a b c" ((slug |=(a=[@ @t] (cat 3 a))) ace alp)) + 'abc' + +------------------------------------------------------------------------ + +### ++star + + ++ star :: 0 or more times + |* fel=_rule + (stir `(list ,_(wonk *fel))`~ |*([a=* b=*] [a b]) fel) + +Parser modifier: parse list of matches. + +`fel` is a [rule](). + + ~zod/try=> (scan "aaaaa" (just 'a')) + ! {1 2} + ! 'syntax-error' + ! exit + ~zod/try=> (scan "aaaaa" (star (just 'a'))) + "aaaaa" + ~zod/try=> (scan "abcdef" (star (just 'a'))) + ! {1 2} + ! 'syntax-error' + ! exit + ~zod/try=> (scan "abcabc" (star (jest 'abc'))) + <|abc abc|> + ~zod/try=> (scan "john smith" (star (shim 0 200))) + "john smith" + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2ef.md b/docs/pub/doc/hoon/library/2ef.md new file mode 100644 index 0000000000..f0f1bef945 --- /dev/null +++ b/docs/pub/doc/hoon/library/2ef.md @@ -0,0 +1,648 @@ +section 2eF, parsing (ascii) +============================ + +### ++ace + +Parse space + + ++ ace (just ' ') + +Parses ASCII character 32, space. + + ~zod/try=> (scan " " ace) + ~~. + ~zod/try=> `cord`(scan " " ace) + ' ' + ~zod/try=> (ace [[1 1] " "]) + [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (ace [[1 1] " abc "]) + [p=[p=1 q=2] q=[~ [p=~~. q=[p=[p=1 q=2] q="abc "]]]] + +------------------------------------------------------------------------ + +### ++bar + +Parse vertical bar + + ++ bar (just '|') + +Parses ASCII character 124, the vertical bar. + + ~zod/try=> (scan "|" bar) + ~~~7c. + ~zod/try=> `cord`(scan "|" bar) + '|' + ~zod/try=> (bar [[1 1] "|"]) + [p=[p=1 q=2] q=[~ [p=~~~7c. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (bar [[1 1] "|="]) + [p=[p=1 q=2] q=[~ [p=~~~7c. q=[p=[p=1 q=2] q="="]]]] + +------------------------------------------------------------------------ + +### ++bas + +Parse backslash + + ++ bas (just '\\') + +Parses ASCII character 92, the backslash. Note the extra `\` in the slam +of `bas` with [`++just`]() is to escape the escape character, `\`. + + ~zod/try=> (scan "\\" bas) + ~~~5c. + ~zod/try=> `cord`(scan "\\" bas) + '\' + ~zod/try=> (bas [[1 1] "\"]) + ~ + ~zod/try=> (bas [[1 1] "\\"]) + [p=[p=1 q=2] q=[~ [p=~~~5c. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (bas [[1 1] "\""]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++buc + +Parse dollar sign + + ++ buc (just '$') + +Parses ASCII character 36, the dollar sign. + + ~zod/try=> (scan "$" buc) + ~~~24. + ~zod/try=> `cord`(scan "$" buc) + '$' + ~zod/try=> (buc [[1 1] "$"]) + [p=[p=1 q=2] q=[~ [p=~~~24. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (buc [[1 1] "$%"]) + [p=[p=1 q=2] q=[~ [p=~~~24. q=[p=[p=1 q=2] q="%"]]]] + +------------------------------------------------------------------------ + +### ++cab + +Parse underscore + + ++ cab (just '_') + +Parses ASCII character 95, the underscore. + + ~zod/try=> (scan "_" cab) + ~~~5f. + ~zod/try=> `cord`(scan "_" cab) + '_' + ~zod/try=> (cab [[1 1] "_"]) + [p=[p=1 q=2] q=[~ [p=~~~5f. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (cab [[1 1] "|_"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++cen + +Parses percent sign + + ++ cen (just '%') + +Parses ASCII character 37, the percent sign. + + ~zod/try=> (scan "%" cen) + ~~~25. + ~zod/try=> `cord`(scan "%" cen) + '%' + ~zod/try=> (cen [[1 1] "%"]) + [p=[p=1 q=2] q=[~ [p=~~~25. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (cen [[1 1] "%^"]) + [p=[p=1 q=2] q=[~ [p=~~~25. q=[p=[p=1 q=2] q="^"]]]] + +------------------------------------------------------------------------ + +### ++col + +Parse colon + + ++ col (just ':') + +Parses ASCII character 58, the colon + + ~zod/try=> (scan ":" col) + ~~~3a. + ~zod/try=> `cord`(scan ":" col) + ':' + ~zod/try=> (col [[1 1] ":"]) + [p=[p=1 q=2] q=[~ [p=~~~3a. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (col [[1 1] ":-"]) + [p=[p=1 q=2] q=[~ [p=~~~3a. q=[p=[p=1 q=2] q="-"]]]] + +------------------------------------------------------------------------ + +### ++com + +Parse comma + + ++ com (just ',') + +Parses ASCII character 44, the comma. + + ~zod/try=> (scan "," com) + ~~~2c. + ~zod/try=> `cord`(scan "," com) + ',' + ~zod/try=> (com [[1 1] ","]) + [p=[p=1 q=2] q=[~ [p=~~~2c. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (com [[1 1] "not com"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++doq + +Parse double quote + + ++ doq (just '"') + +Parses ASCII character 34, the double quote. + + ~tadbyl-hilbel/try=> (scan "\"" doq) + ~~~22. + ~tadbyl-hilbel/try=> `cord`(scan "\"" doq) + '"' + ~tadbyl-hilbel/try=> (doq [[1 1] "\""]) + [p=[p=1 q=2] q=[~ [p=~~~22. q=[p=[p=1 q=2] q=""]]]] + ~tadbyl-hilbel/try=> (doq [[1 1] "not successfully parsed"]) + [p=[p=1 q=1] q=~] + ~tadbyl-hilbel/try=> (scan "see?" doq) + ! {1 1} + ! 'syntax-error' + ! exit + +------------------------------------------------------------------------ + +### ++dot + +Parse period + + ++ dot (just '.') + +Parses ASCII character 46, the period. + + ~zod/try=> (scan "." dot) + ~~~. + ~zod/try=> `cord`(scan "." dot) + '.' + ~zod/try=> (dot [[1 1] "."]) + [p=[p=1 q=2] q=[~ [p=~~~. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (dot [[1 1] ".^"]) + [p=[p=1 q=2] q=[~ [p=~~~. q=[p=[p=1 q=2] q="^"]]]] + +------------------------------------------------------------------------ + +### ++fas + +Parse forward slash + + ++ fas (just '/') + +Parses ASCII character 47, the forward slash. + + ~zod/try=> (scan "/" fas) + ~~~2f. + ~zod/try=> `cord`(scan "/" fas) + '/' + ~zod/try=> (fas [[1 1] "/"]) + [p=[p=1 q=2] q=[~ [p=~~~2f. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (fas [[1 1] "|/"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++gal + +Parse less-than sign + + ++ gal (just '<') + +Parses ASCII character 60, the less-than sign. + + ~zod/try=> (scan "<" gal) + ~~~3c. + ~zod/try=> `cord`(scan "<" gal) + '<' + ~zod/try=> (gal [[1 1] "<"]) + [p=[p=1 q=2] q=[~ [p=~~~3c. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (gal [[1 1] "<+"]) + [p=[p=1 q=2] q=[~ [p=~~~3c. q=[p=[p=1 q=2] q="+"]]]] + ~zod/try=> (gal [[1 1] "+<"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++gar + +Parse greater-than sign + + ++ gar (just '>') + +Parses ASCII character 62, the greater-than sign. + + ~zod/try=> (scan ">" gar) + ~~~3e. + ~zod/try=> `cord`(scan ">" gar) + '>' + ~zod/try=> (gar [[1 1] ">"]) + [p=[p=1 q=2] q=[~ [p=~~~3e. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (gar [[1 1] "=>"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++hax + +Parse number sign + + ++ hax (just '#') + +Parses ASCII character 35, the number sign. + + ~zod/try=> (scan "#" hax) + ~~~23. + ~zod/try=> `cord`(scan "#" hax) + '#' + ~zod/try=> (hax [[1 1] "#"]) + [p=[p=1 q=2] q=[~ [p=~~~23. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (hax [[1 1] "#!"]) + [p=[p=1 q=2] q=[~ [p=~~~23. q=[p=[p=1 q=2] q="!"]]]] + +------------------------------------------------------------------------ + +### ++kel + +Parse left curley bracket + + ++ kel (just '{') + +Parses ASCII character 123, the left curly bracket. Note that `{` +(`kel`) and `}` (`ker`) open and close a Hoon expression for Hoon string +interpolation. To parse either of them, they must be escaped. + + ~zod/try=> (scan "\{" kel) + ~~~7b. + ~zod/try=> `cord`(scan "\{" kel) + '{' + ~zod/try=> (kel [[1 1] "\{"]) + [p=[p=1 q=2] q=[~ [p=~~~7b. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (kel [[1 1] " \{"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++ker + +Parse right curley bracket + + ++ ker (just '}') + +Parses ASCII character 125, the right curly bracket. Note that `{` +(`kel`) and `}` (`ker`) open and close a Hoon expression for Hoon string +interpolation. To parse either of them, they must be escaped. + + ~zod/try=> (scan "}" ker) + ~~~7d. + ~zod/try=> `cord`(scan "}" ker) + '}' + ~zod/try=> (ker [[1 1] "}"]) + [p=[p=1 q=2] q=[~ [p=~~~7d. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (ker [[1 1] "\{}"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++ket + +Parse caret + + ++ ket (just '^') + +Parses ASCII character 94, the caret. + + ~zod/try=> (scan "^" ket) + ~~~5e. + ~zod/try=> `cord`(scan "^" ket) + '^' + ~zod/try=> (ket [[1 1] "^"]) + [p=[p=1 q=2] q=[~ [p=~~~5e. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (ket [[1 1] ".^"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++lus + +Parse plus sign + + ++ lus (just '+') + +Parses ASCII character 43, the plus sign. + + ~zod/try=> (scan "+" lus) + ~~~2b. + ~zod/try=> `cord`(scan "+" lus) + '+' + ~zod/try=> (lus [[1 1] "+"]) + [p=[p=1 q=2] q=[~ [p=~~~2b. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (lus [[1 1] ".+"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++hep + +Parse hyphen + + ++ hep (just '-') + +Parses ASCII character 45, the hyphen. + + ~zod/try=> (scan "-" hep) + ~~- + ~zod/try=> `cord`(scan "-" hep) + '-' + ~zod/try=> (hep [[1 1] "-"]) + [p=[p=1 q=2] q=[~ [p=~~- q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (hep [[1 1] ":-"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++pel + +Parse left parenthesis + + ++ pel (just '(') + +Parses ASCII character 40, the left parenthesis. + + ~zod/try=> (scan "(" pel) + ~~~28. + ~zod/try=> `cord`(scan "(" pel) + '(' + ~zod/try=> (pel [[1 1] "("]) + [p=[p=1 q=2] q=[~ [p=~~~28. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (pel [[1 1] ";("]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++pam + +Parse ampersand + + ++ pam (just '&') + +Parses ASCII character 38, the ampersand. + + ~zod/try=> (scan "&" pam) + ~~~26. + ~zod/try=> `cord`(scan "&" pam) + '&' + ~zod/try=> (pam [[1 1] "&"]) + [p=[p=1 q=2] q=[~ [p=~~~26. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (pam [[1 1] "?&"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++per + +Parse right parenthesis + + ++ per (just ')') + +Parses ASCII character 41, the right parenthesis. + + ~zod/try=> (scan ")" per) + ~~~29. + ~zod/try=> `cord`(scan ")" per) + ')' + ~zod/try=> (per [[1 1] ")"]) + [p=[p=1 q=2] q=[~ [p=~~~29. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (per [[1 1] " )"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++pat + +Parse "at" sign + + ++ pat (just '@') + +Parses ASCII character 64, the "at" sign. + + ~zod/try=> (scan "@" pat) + ~~~4. + ~zod/try=> `cord`(scan "@" pat) + '@' + ~zod/try=> (pat [[1 1] "@"]) + [p=[p=1 q=2] q=[~ [p=~~~4. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (pat [[1 1] "?@"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++sel + +Parse left square bracket + +Left square bracket + + ++ sel (just '[') + +Parses ASCII character 91, the left square bracket. + + ~zod/try=> (scan "[" sel) + ~~~5b. + ~zod/try=> `cord`(scan "[" sel) + '[' + ~zod/try=> (sel [[1 1] "["]) + [p=[p=1 q=2] q=[~ [p=~~~5b. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (sel [[1 1] "-["]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++sem + +Parse semicolon + + ++ sem (just ';') + +Parses ASCII character 59, the semicolon. + +### Examples + + ~zod/try=> (scan ";" sem) + ~~~3b. + ~zod/try=> `cord`(scan ";" sem) + ';' + ~zod/try=> (sem [[1 1] ";"]) + [p=[p=1 q=2] q=[~ [p=~~~3b. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (sem [[1 1] " ;"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++ser + +Parse right square bracket + + ++ ser (just ']') + +Parses ASCII character 93, the right square bracket. + + ~zod/try=> (scan "]" ser) + ~~~5d. + ~zod/try=> `cord`(scan "]" ser) + ']' + ~zod/try=> (ser [[1 1] "]"]) + [p=[p=1 q=2] q=[~ [p=~~~5d. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (ser [[1 1] "[ ]"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++sig + +Parse tilde + + ++ sig (just '~') + +Parses ASCII character 126, the tilde. + + ~zod/try=> (scan "~" sig) + ~~~~ + ~zod/try=> `cord`(scan "~" sig) + '~' + ~zod/try=> (sig [[1 1] "~"]) + [p=[p=1 q=2] q=[~ [p=~~~~ q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (sig [[1 1] "?~"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++soq + +Parse single quote + + ++ soq (just '\'') + +Parses ASCII character 39, soq. Note the extra '' is to escape the first +`soq` because soq delimits a cord. + + ~zod/try=> (scan "'" soq) + ~~~27. + ~zod/try=> `cord`(scan "'" soq) + ''' + ~zod/try=> (soq [[1 1] "'"]) + [p=[p=1 q=2] q=[~ [p=~~~27. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (soq [[1 1] ">'"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++tar + +Parse asterisk + + ++ tar (just '*') + +Parses ASCII character 42, the asterisk. + + ~zod/try=> (scan "*" tar) + ~~~2a. + ~zod/try=> `cord`(scan "*" tar) + '*' + ~zod/try=> (tar [[1 1] "*"]) + [p=[p=1 q=2] q=[~ [p=~~~2a. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (tar [[1 1] ".*"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++tec + +Parse backtick + + ++ tec (just '`') :: backTiCk + +Parses ASCII character 96, the backtick (also known as the "grave +accent". + + ~zod/try=> (scan "`" tec) + ~~~6. + ~zod/try=> `cord`(scan "`" tec) + '`' + ~zod/try=> (tec [[1 1] "`"]) + [p=[p=1 q=2] q=[~ [p=~~~6. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (tec [[1 1] " `"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++tis + +Parse equals sign + + ++ tis (just '=') + +Parses ASCII character 61, the equals sign. + + ~zod/try=> (scan "=" tis) + ~~~3d. + ~zod/try=> `cord`(scan "=" tis) + '=' + ~zod/try=> (tis [[1 1] "="]) + [p=[p=1 q=2] q=[~ [p=~~~3d. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (tis [[1 1] "|="]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++wut + +Parses question mark + + ++ wut (just '?') + +Parses ASCII character 63, wut. + + ~zod/try=> (scan "?" wut) + ~~~3f. + ~zod/try=> `cord`(scan "?" wut) + '?' + ~zod/try=> (wut [[1 1] "?"]) + [p=[p=1 q=2] q=[~ [p=~~~3f. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (wut [[1 1] ".?"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ + +### ++zap + +Exclamation point + + ++ zap (just '!') + +Parses ASCII character 33, the exclamation point zap. + + ~zod/try=> (scan "!" zap) + ~~~21. + ~zod/try=> `cord`(scan "!" zap) + '!' + ~zod/try=> (zap [[1 1] "!"]) + [p=[p=1 q=2] q=[~ [p=~~~21. q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (zap [[1 1] "?!"]) + [p=[p=1 q=1] q=~] + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2eg.md b/docs/pub/doc/hoon/library/2eg.md new file mode 100644 index 0000000000..73289c668c --- /dev/null +++ b/docs/pub/doc/hoon/library/2eg.md @@ -0,0 +1,160 @@ +section 2eG, parsing (whitespace) +================================= + +### ++dog + +`.` optional gap + + ++ dog ;~(plug dot gay) :: + +Dot followed by an optional gap, used in numbers. + + /~zod/try=> 1.234. + 703 + 1.234.703 + ~zod/try=> (scan "a. " ;~(pfix alf dog)) + [~~~. ~] + +------------------------------------------------------------------------ + +### ++doh + +`@p` separator + + ++ doh ;~(plug ;~(plug hep hep) gay) :: + +Phonetic base phrase separator + + /~zod/try=> ~nopfel-botduc-nilnev-dolfyn--haspub-natlun-lodmur-holtyd + ~nopfel-botduc-nilnev-dolfyn--haspub-natlun-lodmur-holtyd + /~zod/try=> ~nopfel-botduc-nilnev-dolfyn-- + haspub-natlun-lodmur-holtyd + ~nopfel-botduc-nilnev-dolfyn--haspub-natlun-lodmur-holtyd + ~zod/try=> (scan "--" doh) + [[~~- ~~-] ~] + ~zod/try=> (scan "-- " doh) + [[~~- ~~-] ~] + +------------------------------------------------------------------------ + +### ++dun + +`--` to `~` + + ++ dun (cold ~ ;~(plug hep hep)) :: -- (phep) to ~ + +Parse phep, `--`, to null, `~`. + + ~zod/try=> (scan "--" dun) + ~ + ~zod/try=> (dun [[1 1] "--"]) + [p=[p=1 q=3] q=[~ u=[p=~ q=[p=[p=1 q=3] q=""]]]] + +------------------------------------------------------------------------ + +### ++duz + +`==` to `~` + + ++ duz (cold ~ ;~(plug tis tis)) :: == (stet) to ~ + +Parse stet, `==`, to null `~`. + + ~zod/try=> (scan "==" duz) + ~ + ~zod/try=> (duz [[1 1] "== |=..."]) + [p=[p=1 q=3] q=[~ u=[p=~ q=[p=[p=1 q=3] q=" |=..."]]]] + +------------------------------------------------------------------------ + +### ++gah + +Newline or ' ' + + ++ gah (mask [`@`10 ' ' ~]) :: newline or ace + +Whitespace component, either newline or space. + + /~zod/try=> ^- * :: show spaces + """ + - + - + - + """ + [32 32 32 45 10 32 45 10 32 32 45 0] + /~zod/try=> ^- * + """ + + """ + [32 32 32 10 32 10 32 32 0] + /~zod/try=> ^- (list ,@) + %- scan :_ (star gah) + """ + + """ + ~[32 32 32 10 32 10 32 32] + +------------------------------------------------------------------------ + +### ++gap + +Plural whitespace + + ++ gap (cold ~ ;~(plug gaq (star ;~(pose vul gah)))) :: plural whitespace + +Separates tall runes + +------------------------------------------------------------------------ + +### ++gaq + +End of line + + ++ gaq ;~ pose :: end of line + (just `@`10) + ;~(plug gah ;~(pose gah vul)) + vul + == + +Two spaces, a newline, or comment. + +------------------------------------------------------------------------ + +### ++gaw + +Classic whitespace + + ++ gaw (cold ~ (star ;~(pose vul gah))) :: classic white + +Terran whitespace + +------------------------------------------------------------------------ + +### ++gay + +Optional gap. + + ++ gay ;~(pose gap (easy ~)) :: + +Optional gap. + +------------------------------------------------------------------------ + +### ++vul + + ++ vul %- cold :- ~ :: comments + ;~ plug col col + (star prn) + (just `@`10) + == + +Parse comments and produce a null. Note that a comment must be ended +with a newline character. + + ~zod/try=> (scan "::this is a comment \0a" vul) + ~ + ~zod/try=> (scan "::this is a comment " vul) + ! {1 21} + ! exit + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2eh.md b/docs/pub/doc/hoon/library/2eh.md new file mode 100644 index 0000000000..3fff19596a --- /dev/null +++ b/docs/pub/doc/hoon/library/2eh.md @@ -0,0 +1,531 @@ +section 2eH, parsing (idioms) +============================= + +### ++alf + +Alphabetic characters + + ++ alf ;~(pose low hig) :: alphabetic + +Parse alphabetic characters, both upper and lowercase. + + ~zod/try=> (scan "a" alf) + ~~a + ~zod/try=> (scan "A" alf) + ~~~41. + ~zod/try=> (scan "AaBbCc" (star alf)) + "AaBbCc" + +------------------------------------------------------------------------ + +### ++aln + +Alphanumeric characters + + ++ aln ;~(pose low hig nud) :: alphanumeric + +Parse alphanumeric characters - both alphabetic characters and numbers. + + ~zod/try=> (scan "0" aln) + ~~0 + ~zod/try=> (scan "alf42" (star aln)) + "alf42" + ~zod/try=> (scan "0123456789abcdef" (star aln)) + "0123456789abcdef" + +------------------------------------------------------------------------ + +### ++alp + +Alphanumeric and `-` + + ++ alp ;~(pose low hig nud hep) :: alphanumeric and - + +Parse alphanumeric strings and hep, "-". + + ~zod/try=> (scan "7" alp) + ~~7 + ~zod/try=> (scan "s" alp) + ~~s + ~zod/try=> (scan "123abc-" (star alp)) + "123abc-" + +------------------------------------------------------------------------ + +### ++bet + +Axis syntax `-`, `+` + + ++ bet ;~(pose (cold 2 hep) (cold 3 lus)) :: axis syntax - + + +Parse the hep and lus axis syntax. + + ~zod/try=> (scan "-" bet) + 2 + ~zod/try=> (scan "+" bet) + 3 + +------------------------------------------------------------------------ + +### ++bin + +Binary to atom + + ++ bin (bass 2 (most gon but)) :: binary to atom + +Parse a tape of binary (0s and 1s) and produce its atomic +representation. + + ~zod/try=> (scan "0000" bin) + 0 + ~zod/try=> (scan "0001" bin) + 1 + ~zod/try=> (scan "0010" bin) + 2 + ~zod/try=> (scan "100000001111" bin) + 2.063 + +------------------------------------------------------------------------ + +### ++but + +Binary digit + + ++ but (cook |=(a=@ (sub a '0')) (shim '0' '1')) :: binary digit + +Parse a single binary digit. + + ~zod/try=> (scan "0" but) + 0 + ~zod/try=> (scan "1" but) + 1 + ~zod/try=> (scan "01" but) + ! {1 2} + ! 'syntax-error' + ! exit + ~zod/try=> (scan "01" (star but)) + ~[0 1] + +------------------------------------------------------------------------ + +### ++cit + +Octal digit + + ++ cit (cook |=(a=@ (sub a '0')) (shim '0' '7')) :: octal digit + +Parse a single octal digit. + + ~zod/try=> (scan "1" cit) + 1 + ~zod/try=> (scan "7" cit) + 7 + ~zod/try=> (scan "8" cit) + ! {1 1} + ! 'syntax-error' + ! exit + ~zod/try=> (scan "60" (star cit)) + ~[6 0] + +------------------------------------------------------------------------ + +### ++dem + +Decimal to atom + + ++ dem (bass 10 (most gon dit)) :: decimal to atom + +Parse a decimal number to an atom. + + ~zod/try=> (scan "7" dem) + 7 + ~zod/try=> (scan "42" dem) + 42 + ~zod/try=> (scan "150000000" dem) + 150.000.000 + ~zod/try=> (scan "12456" dem) + 12.456 + +------------------------------------------------------------------------ + +### ++dit + +Decimal digit + + ++ dit (cook |=(a=@ (sub a '0')) (shim '0' '9')) :: decimal digit + +Parse a single decimal digit. + + ~zod/try=> (scan "7" dit) + 7 + ~zod/try=> (scan "42" (star dit)) + ~[4 2] + ~zod/try=> (scan "26000" (star dit)) + ~[2 6 0 0 0] + +------------------------------------------------------------------------ + +### ++gul + +Axis syntax `<` or `>` + + ++ gul ;~(pose (cold 2 gal) (cold 3 gar)) :: axis syntax < > + +Parse the axis gal and gar axis syntax. + + ~zod/try=> (scan "<" gul) + 2 + ~zod/try=> (scan ">" gul) + 3 + +------------------------------------------------------------------------ + +### ++gon + +Long numbers + + ++ gon ;~(pose ;~(plug bas gay fas) (easy ~)) :: long numbers \ / + +Parse long numbers - Numbers which wrap around the shell with the line +break characters bas and fas. + + ~zod/try=> (scan "\\/" gon) + [~~~5c. ~ ~~~2f.] + ~zod/try=> (gon [[1 1] "\\/"]) + [p=[p=1 q=3] q=[~ u=[p=[~~~5c. ~ ~~~2f.] q=[p=[p=1 q=3] q=""]]]] + +------------------------------------------------------------------------ + +### ++hex + +Hex to atom + + ++ hex (bass 16 (most gon hit)) :: hex to atom + +Parse any hexadecimal number to an atom. + + ~zod/try=> (scan "a" hex) + 10 + ~zod/try=> (scan "A" hex) + 10 + ~zod/try=> (scan "2A" hex) + 42 + ~zod/try=> (scan "1ee7" hex) + 7.911 + ~zod/try=> (scan "1EE7" hex) + 7.911 + ~zod/try=> (scan "1EE7F7" hex) + 2.025.463 + ~zod/try=> `@ux`(scan "1EE7F7" hex) + 0x1e.e7f7 + +------------------------------------------------------------------------ + +### ++hig + +Uppercase + + ++ hig (shim 'A' 'Z') :: uppercase + +Parse a single uppercase letter. + + ~zod/try=> (scan "G" hig) + ~~~47. + ~zod/try=> `cord`(scan "G" hig) + 'G' + ~zod/try=> (scan "ABCDEFGHIJKLMNOPQRSTUVWXYZ" (star hig)) + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + ~zod/try=> (hig [[1 1] "G"]) + [p=[p=1 q=2] q=[~ [p=~~~47. q=[p=[p=1 q=2] q=""]]]] + +------------------------------------------------------------------------ + +### ++hit + +Hex digits + + ++ hit ;~ pose :: hex digits + dit + (cook |=(a=char (sub a 87)) (shim 'a' 'f')) + (cook |=(a=char (sub a 55)) (shim 'A' 'F')) + == + +Parse a single hexadecimal digit. + + ~zod/try=> (scan "a" hit) + 10 + ~zod/try=> (scan "A" hit) + 10 + ~zod/try=> (hit [[1 1] "a"]) + [p=[p=1 q=2] q=[~ [p=10 q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (scan "2A" (star hit)) + ~[2 10] + +------------------------------------------------------------------------ + +### ++low + +Lowercase + + ++ low (shim 'a' 'z') :: lowercase + +Parse a single lowercase letter. + + ~zod/try=> (scan "g" low) + ~~g + ~zod/try=> `cord`(scan "g" low) + 'g' + ~zod/try=> (scan "abcdefghijklmnopqrstuvwxyz" (star low)) + "abcdefghijklmnopqrstuvwxyz" + ~zod/try=> (low [[1 1] "g"]) + [p=[p=1 q=2] q=[~ [p=~~g q=[p=[p=1 q=2] q=""]]]] + +------------------------------------------------------------------------ + +### ++mes + +Hexbyte + + ++ mes %+ cook :: hexbyte + |=([a=@ b=@] (add (mul 16 a) b)) + ;~(plug hit hit) + +Parse a hexbyte. + + ~zod/try=> (scan "2A" mes) + 42 + ~zod/try=> (mes [[1 1] "2A"]) + [p=[p=1 q=3] q=[~ u=[p=42 q=[p=[p=1 q=3] q=""]]]] + ~zod/try=> (scan "42" mes) + 66 + +------------------------------------------------------------------------ + +### ++nix + +Letters, `-`, and `_` + + ++ nix (boss 256 (star ;~(pose aln cab))) :: + +Letters, `-`, and `_` + + ~zod/try=> (scan "as_me" nix) + q=435.626.668.897 + ~zod/try=> `@t`(scan "as_me" nix) + 'as_me' + +------------------------------------------------------------------------ + +### ++nud + +Numeric + + ++ nud (shim '0' '9') :: numeric + +Parse a numeric character - A number. + + ~zod/try=> (scan "0" nud) + ~~0 + ~zod/try=> (scan "7" nud) + ~~7 + ~zod/try=> (nud [[1 1] "1"]) + [p=[p=1 q=2] q=[~ [p=~~1 q=[p=[p=1 q=2] q=""]]]] + ~zod/try=> (scan "0123456789" (star nud)) + "0123456789" + +------------------------------------------------------------------------ + +### ++prn + +Printable character + + ++ prn ;~(less (just `@`127) (shim 32 256)) + +Parse any printable character + + ~zod/try=> (scan "h" prn) + ~~h + ~zod/try=> (scan "!" prn) + ~~~21. + ~zod/try=> (scan "\01" prn) + ! {1 1} + ! exit + +------------------------------------------------------------------------ + +### ++qat + +Chars in blockcord + + ++ qat ;~ pose :: chars in blockcord + prn + ;~(less ;~(plug (just `@`10) soqs) (just `@`10)) + == + +Parse character in cord block. + + ~zod/try=> (scan "h" qat) + ~~h + ~zod/try=> (scan "!" qat) + ~~~21. + ~zod/try=> (scan "\0a" qat) + ~~~a. + ~zod/try=> (scan "\00" qat) + ! {1 1} + ! exit + +------------------------------------------------------------------------ + +### ++qit + +Chars in cord + + ++ qit ;~ pose :: chars in a cord + ;~(less bas soq prn) + ;~(pfix bas ;~(pose bas soq mes)) :: escape chars + == + +Parse an individual character to its cord atom representation. + + ~zod/try=> (scan "%" qit) + 37 + ~zod/try=> `@t`(scan "%" qit) + '%' + ~zod/try=> (scan "0" qit) + 48 + ~zod/try=> (scan "E" qit) + 69 + ~zod/try=> (scan "a" qit) + 97 + ~zod/try=> (scan "\\0a" qit) + 10 + ~zod/try=> `@ux`(scan "\\0a" qit) + 0xa + ~zod/try=> (scan "cord" (star qit)) + ~[99 111 114 100] + +------------------------------------------------------------------------ + +### ++qut + +Cord + + ++ qut ;~ pose :: cord + ;~ less soqs + (ifix [soq soq] (boss 256 (more gon qit))) + == + %- inde %+ ifix + :- ;~ plug soqs + ;~(pose ;~(plug (plus ace) vul) (just '\0a')) + == + ;~(plug (just '\0a') soqs) + (boss 256 (star qat)) + == + :: + +Parse single-soq cord with `\{gap}/` anywhere in the middle, or +triple-soq cord which must be in an indented block. + + ~zod/try=> (scan "'cord'" qut) + q=1.685.221.219 + ~zod/try=> 'cord' + 'cord' + ~zod/try=> `@ud`'cord' + 1.685.221.219 + /~zod/try=> ''' + Heredoc isn't prohibited from containing quotes + ''' + 'Heredoc isn't prohibited from containing quotes' + +------------------------------------------------------------------------ + +### ++soqs + +Delimiting `'''` + + ++ soqs ;~(plug soq soq soq) :: delimiting ''' + +Triple single quote + + ~zod/try=> (scan "'''" soqs) + [~~~27. ~~~27. ~~~27.] + ~zod/try=> (rash '"""' soqs) + ! {1 1} + ! exit + +------------------------------------------------------------------------ + +### ++sym + +Term + + ++ sym + %+ cook + |=(a=tape (rap 3 ^-((list ,@) a))) + ;~(plug low (star ;~(pose nud low hep))) + :: + +A term: a letter(lowercase), followed by letters, numbers, or `-`. + + ~zod/try=> (scan "sam-2" sym) + 215.510.507.891 + ~zod/try=> `@t`(scan "sam-2" sym) + 'sam-2' + ~zod/try=> (scan "sym" sym) + 7.174.515 + +------------------------------------------------------------------------ + +### ++ven + +`+>-` axis syntax + + ++ ven ;~ (comp |=([a=@ b=@] (peg a b))) :: +>- axis syntax + bet + =+ hom=`?`| + |= tub=nail + ^- (like axis) + =+ vex=?:(hom (bet tub) (gul tub)) + ?~ q.vex + [p.tub [~ 1 tub]] + =+ wag=$(p.tub p.vex, hom !hom, tub q.u.q.vex) + ?> ?=(^ q.wag) + [p.wag [~ (peg p.u.q.vex p.u.q.wag) q.u.q.wag]] + == + +Axis syntax parser + + ~zod/arvo=/hoon/hoon> (scan "->+" ven) + 11 + ~zod/arvo=/hoon/hoon> `@ub`(scan "->+" ven) + 0b1011 + ~zod/arvo=/hoon/hoon> (peg (scan "->" ven) (scan "+" ven)) + 11 + ~zod/arvo=/hoon/hoon> ->+:[[1 2 [3 4]] 5] + [3 4] + +------------------------------------------------------------------------ + +### ++vit + +Base64 digit + + ++ vit :: base64 digit + ;~ pose + (cook |=(a=@ (sub a 65)) (shim 'A' 'Z')) + (cook |=(a=@ (sub a 71)) (shim 'a' 'z')) + (cook |=(a=@ (add a 4)) (shim '0' '9')) + (cold 62 (just '-')) + (cold 63 (just '+')) + == + +Terran base64 + + ~zod/arvo=/hoon/hoon> (scan "C" vit) + 2 + ~zod/arvo=/hoon/hoon> (scan "c" vit) + 28 + ~zod/arvo=/hoon/hoon> (scan "2" vit) + 54 + ~zod/arvo=/hoon/hoon> (scan "-" vit) + 62 diff --git a/docs/pub/doc/hoon/library/2ei.md b/docs/pub/doc/hoon/library/2ei.md new file mode 100644 index 0000000000..c5c304c5b2 --- /dev/null +++ b/docs/pub/doc/hoon/library/2ei.md @@ -0,0 +1,107 @@ +section 2eI, parsing (external) +=============================== + +### ++rash + +Parse or crash + + ++ rash |*([naf=@ sab=_rule] (scan (trip naf) sab)) :: + +Parse a cord with a given rule and crash if the cord isn't entirely +parsed. + +`naf` is an [atom](). + +`sab` is a [rule](). + + ~zod/try=> (rash 'I was the world in which I walked, and what I saw' (star (shim 0 200))) + "I was the world in which I walked, and what I saw" + ~zod/try=> (rash 'abc' (just 'a')) + ! {1 2} + ! 'syntax-error' + ! exit + ~zod/try=> (rash 'abc' (jest 'abc')) + 'abc' + `~zod/try=> (rash 'abc' (jest 'ab')) + ! {1 3} + ! 'syntax-error' + ! exit + +------------------------------------------------------------------------ + +### ++rush + +Parse or null + + ++ rush |*([naf=@ sab=_rule] (rust (trip naf) sab)) + +Parse a given with a given rule and produce null if the cord isn't +entirely parsed. + +`naf` is an [atom](). + +`sab` is a [rule](). + + ~zod/try=> (rush 'I was the world in which I walked, and what I saw' (star (shim 0 200))) + [~ "I was the world in which I walked, and what I saw"] + ~zod/try=> (rush 'abc' (just 'a')) + ~ + ~zod/try=> (rush 'abc' (jest 'abc')) + [~ 'abc'] + ~zod/try=> (rush 'abc' (jest 'ac')) + ~ + ~zod/try=> (rush 'abc' (jest 'ab')) + ~ + +------------------------------------------------------------------------ + +### ++rust + +Parse tape or null + + ++ rust |* [los=tape sab=_rule] + =+ vex=((full sab) [[1 1] los]) + ?~(q.vex ~ [~ u=p.u.q.vex]) + +Parse a tape with a given rule and produce null if the tape isn't +entirely parsed. + +`los` is a [tape](). + +`sab` is a [rule](). + + ~zod/try=> (rust "I was the world in which I walked, and what I saw" (star (shim 0 200))) + [~ "I was the world in which I walked, and what I saw"] + ~zod/try=> (rust "Or heard or felt came not but from myself;" (star (shim 0 200))) + [~ "Or heard or felt came not but from myself;"] + ~zod/try=> (rust "And there I found myself more truly and more strange." (jest 'And there I')) + ~ + +------------------------------------------------------------------------ + +### ++scan + +Parse tape or crash + + ++ scan |* [los=tape sab=_rule] + =+ vex=((full sab) [[1 1] los]) + ?~ q.vex + ~_ (show [%m '{%d %d}'] p.p.vex q.p.vex ~) + ~|('syntax-error' !!) + p.u.q.vex + +Parse a tape with a given rule and crash if the tape isn't entirely +parsed. + +`los` is a [tape](). + +`sab` is a [rule](). + + ~zod/try=> (scan "I was the world in which I walked, and what I saw" (star (shim 0 200))) + "I was the world in which I walked, and what I saw" + ~zod/try=> (scan "Or heard or felt came not but from myself;" (star (shim 0 200))) + "Or heard or felt came not but from myself;" + ~zod/try=> (scan "And there I found myself more truly and more strange." (jest 'And there I')) + ! {1 12} + ! 'syntax-error' + ! exit diff --git a/docs/pub/doc/hoon/library/2ej.md b/docs/pub/doc/hoon/library/2ej.md new file mode 100644 index 0000000000..a445efefce --- /dev/null +++ b/docs/pub/doc/hoon/library/2ej.md @@ -0,0 +1,561 @@ +section 2eJ, formatting (basic text) +==================================== + +### ++cass + +To lowercase + + ++ cass :: lowercase + |= vib=tape + %+ rap 3 + (turn vib |=(a=@ ?.(&((gte a 'A') (lte a 'Z')) a (add 32 a)))) + :: + +Produce the case insensitive (all lowercase) cord of a tape. + +`vib` is a [tape](). + + ~zod/try=> (cass "john doe") + 7.309.170.810.699.673.450 + ~zod/try=> `cord`(cass "john doe") + 'john doe' + ~zod/try=> (cass "abc, 123, !@#") + 2.792.832.775.110.938.439.066.079.945.313 + ~zod/try=> `cord`(cass "abc, 123, !@#") + 'abc, 123, !@#' + +------------------------------------------------------------------------ + +### ++cuss + +To uppercase + + ++ cuss :: uppercase + |= vib=tape + ^- @t + %+ rap 3 + (turn vib |=(a=@ ?.(&((gte a 'a') (lte a 'z')) a (sub a 32)))) + :: + +Turn all occurances of lowercase letters in any tape into uppercase +letters, as a cord. + +`vib` is a [tape](). + + ~zod/try=> (cuss "john doe") + 'JOHN DOE' + ~zod/try=> (cuss "abc ABC 123 !@#") + 'ABC ABC 123 !@#' + ~zod/try=> `@ud`(cuss "abc") + 4.407.873 + ~zod/try=> (cuss "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsQqRrVvWwXxYyZz") + 'AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSQQRRVVWWXXYYZZ' + +------------------------------------------------------------------------ + +### ++crip + +Tape to cord + + ++ crip |=(a=tape `@t`(rap 3 a)) :: tape to cord + +Produce cord from a tape. + +`a` is a [tape](). + + ~zod/try=> (crip "john doe") + 'john doe' + ~zod/try=> (crip "abc 123 !@#") + 'abc 123 !@#' + ~zod/try=> `@ud`(crip "abc") + 6.513.249 + +------------------------------------------------------------------------ + +### ++mesc + +Escape special chars + + ++ mesc :: ctrl code escape + |= vib=tape + ^- tape + ?~ vib + ~ + ?: =('\\' i.vib) + ['\\' '\\' $(vib t.vib)] + ?: ?|((gth i.vib 126) (lth i.vib 32) =(39 i.vib)) + ['\\' (welp ~(rux at i.vib) '/' $(vib t.vib))] + [i.vib $(vib t.vib)] + :: + +Escape special characters, used in [`++show`]() + +`vib` is a [tape](). + + /~zod/try=> (mesc "ham lus") + "ham lus" + /~zod/try=> (mesc "bas\\hur") + "bas\\\\hur" + /~zod/try=> (mesc "as'saß") + "as\0x27/sa\0xc3/\0x9f/" + +------------------------------------------------------------------------ + +### ++runt + +Prepend `n` times + + ++ runt :: prepend repeatedly + |= [[a=@ b=@] c=tape] + ^- tape + ?: =(0 a) + c + [b $(a (dec a))] + :: + +Add `a` repetitions of character `b` to the head of `c` + +`a` and `b` are [atom]()s. + +`c` is a [tape](). + + /~zod/try=> (runt [2 '/'] "ham") + "//ham" + /~zod/try=> (runt [10 'a'] "") + "aaaaaaaaaa" + +------------------------------------------------------------------------ + +### ++sand + +Soft-cast by odor + + ++ sand :: atom sanity + |= a=@ta + |= b=@ ^- (unit ,@) + ?.(((sane a) b) ~ [~ b]) + :: + +Soft-cast validity by odor. + +`a` is a [`@ta`](). + +`b` is an [atom](). + + /~zod/try=> `(unit ,@ta)`((sand %ta) 'sym-som') + [~ ~.sym-som] + /~zod/try=> `(unit ,@ta)`((sand %ta) 'err!') + ~ + +------------------------------------------------------------------------ + +### ++sane + +Check odor validity + + ++ sane :: atom sanity + |= a=@ta + |= b=@ ^- ? + ?. =(%t (end 3 1 a)) + ~|(%sane-stub !!) + =+ [inx=0 len=(met 3 b)] + ?: =(%tas a) + |- ^- ? + ?: =(inx len) & + =+ cur=(cut 3 [inx 1] b) + ?& ?| &((gte cur 'a') (lte cur 'z')) + &(=('-' cur) !=(0 inx) !=(len inx)) + &(&((gte cur '0') (lte cur '9')) !=(0 inx)) + == + $(inx +(inx)) + == + ?: =(%ta a) + |- ^- ? + ?: =(inx len) & + =+ cur=(cut 3 [inx 1] b) + ?& ?| &((gte cur 'a') (lte cur 'z')) + &((gte cur '0') (lte cur '9')) + |(=('-' cur) =('~' cur) =('_' cur) =('.' cur)) + == + $(inx +(inx)) + == + |- ^- ? + ?: =(0 b) & + =+ cur=(end 3 1 b) + ?: &((lth cur 32) !=(10 cur)) | + =+ len=(teff cur) + ?& |(=(1 len) =+(i=1 |-(|(=(i len) &((gte (cut 3 [i 1] b) 128) $(i +(i))))))) + $(b (rsh 3 len b)) + == + :: + +Check validity by odor. Produces a gate. + +`a` is a [`@ta`](). + +`b` is an [atom](). + + /~zod/try=> ((sane %tas) %mol) + %.y + /~zod/try=> ((sane %tas) 'lam') + %.y + /~zod/try=> ((sane %tas) 'more ace') + %.n + +------------------------------------------------------------------------ + +### ++trim + +Tape split + + ++ trim :: tape split + |= [a=@ b=tape] + ^- [p=tape q=tape] + ?~ b + [~ ~] + ?: =(0 a) + [~ b] + =+ c=$(a (dec a), b t.b) + [[i.b p.c] q.c] + :: + +Split first `a` characters off tape. + +`a` is an [atom](). + +`b` is a [tape](). + + /~zod/try=> (trim 5 "lasok termun") + [p="lasok" q=" termun"] + /~zod/try=> (trim 5 "zam") + [p="zam" q=""] + +------------------------------------------------------------------------ + +### ++trip + +Cord to tape + + ++ trip :: cord to tape + ~/ %trip + |= a=@ ^- tape + ?: =(0 (met 3 a)) + ~ + [^-(@ta (end 3 1 a)) $(a (rsh 3 1 a))] + :: + +Produce tape from cord. + +`a` is an [atom](). + + /~zod/try=> (trip 'john doe') + "john doe" + /~zod/try=> (trip 'abc 123 !@#') + "abc 123 !@#" + /~zod/try=> (trip 'abc') + "abc" + +------------------------------------------------------------------------ + +### ++teff + +UTF8 Length + + ++ teff :: length utf8 + |= a=@t ^- @ + =+ b=(end 3 1 a) + ?: =(0 b) + ?>(=(0 a) 0) + ?> |((gte b 32) =(10 b)) + ?:((lte b 127) 1 ?:((lte b 223) 2 ?:((lte b 239) 3 4))) + :: + +Number of utf8 bytes. + +`a` is a [`@t`](). + + /~zod/try=> (teff 'a') + 1 + /~zod/try=> (teff 'ß') + 2 + +------------------------------------------------------------------------ + +### ++turf + +UTF8 to UTF32 cord + + ++ turf :: utf8 to utf32 + |= a=@t + ^- @c + %+ rap 5 + |- ^- (list ,@c) + =+ b=(teff a) + ?: =(0 b) ~ + :- %+ can 0 + %+ turn + ^- (list ,[p=@ q=@]) + ?+ b !! + 1 [[0 7] ~] + 2 [[8 6] [0 5] ~] + 3 [[16 6] [8 6] [0 4] ~] + 4 [[24 6] [16 6] [8 6] [0 3] ~] + == + |=([p=@ q=@] [q (cut 0 [p q] a)]) + $(a (rsh 3 b a)) + :: + +Convert utf8 ([cord]()) to utf32 codepoints. + +`a` is a [`@t`](). + + /~zod/try=> (turf 'my ßam') + ~-my.~df.am + /~zod/try=> 'я тут' + 'я тут' + /~zod/try=> (turf 'я тут') + ~-~44f..~442.~443.~442. + /~zod/try=> `@ux`'я тут' + 0x82.d183.d182.d120.8fd1 + /~zod/try=> `@ux`(turf 'я тут') + 0x442.0000.0443.0000.0442.0000.0020.0000.044f + +------------------------------------------------------------------------ + +### ++tuba + +UTF8 to UTF32 tape + + ++ tuba :: utf8 to utf32 tape + |= a=tape + ^- (list ,@c) + (rip 5 (turf (rap 3 a))) :: XX horrible + :: + +Convert tape to list of codepoints. + +`a` is a [tape]() + + /~zod/try=> (tuba "я тут") + ~[~-~44f. ~-. ~-~442. ~-~443. ~-~442.] + /~zod/try=> (tuba "chars") + ~[~-c ~-h ~-a ~-r ~-s] + +------------------------------------------------------------------------ + +### ++tufa + +UTF32 to UTF8 tape + + ++ tufa :: utf32 to utf8 tape + |= a=(list ,@c) + ^- tape + ?~ a "" + (weld (rip 3 (tuft i.a)) $(a t.a)) + :: + +Wrap list of utf32 codepoints to utf8 [tape](). + +`a` is a [list]() of [`@c`](). + + /~zod/try=> (tufa ~[~-~44f. ~-. ~-~442. ~-~443. ~-~442.]) + "я тут" + /~zod/try=> (tufa ((list ,@c) ~[%a %b 0xb1 %c])) + "ab±c" + +------------------------------------------------------------------------ + +### ++tuft + +UTF32 to UTF8 text + + ++ tuft :: utf32 to utf8 text + |= a=@c + ^- @t + %+ rap 3 + |- ^- (list ,@) + ?: =(0 a) + ~ + =+ b=(end 5 1 a) + =+ c=$(a (rsh 5 1 a)) + ?: (lth b 0x7f) + [b c] + ?: (lth b 0x7ff) + :* (mix 0b1100.0000 (cut 0 [6 5] b)) + (mix 0b1000.0000 (end 0 6 b)) + c + == + ?: (lth b 0xffff) + :* (mix 0b1110.0000 (cut 0 [12 4] b)) + (mix 0b1000.0000 (cut 0 [6 6] b)) + (mix 0b1000.0000 (end 0 6 b)) + c + == + :* (mix 0b1111.0000 (cut 0 [18 3] b)) + (mix 0b1000.0000 (cut 0 [12 6] b)) + (mix 0b1000.0000 (cut 0 [6 6] b)) + (mix 0b1000.0000 (end 0 6 b)) + c + == + :: + +Convert utf32 glyph to +[LSB](http://en.wikipedia.org/wiki/Least_significant_bit) utf8 cord. + +`a` is a [`@c`](). + + /~zod/try=> (tuft `@c`%a) + 'a' + /~zod/try=> (tuft `@c`0xb6) + '¶' + +------------------------------------------------------------------------ + +### ++wack + +Coin format encode + + ++ wack :: coin format + |= a=@ta + ^- @ta + =+ b=(rip 3 a) + %+ rap 3 + |- ^- tape + ?~ b + ~ + ?: =('~' i.b) ['~' '~' $(b t.b)] + ?: =('_' i.b) ['~' '-' $(b t.b)] + [i.b $(b t.b)] + :: + +Escape span `~` as `~~` and `_` as `~-`. Used for printing. + +`a` is a [`@ta`](). + + /~zod/try=> (wack '~20_sam~') + ~.~~20~-sam~~ + /~zod/try=> `@t`(wack '~20_sam~') + '~~20~-sam~~' + ~zod/try=> ~(rend co %many ~[`ud/5 `ta/'~20_sam']) + "._5_~~.~~20~-sam__" + ~zod/try=> ._5_~~.~~20~-sam__ + [5 ~.~20_sam] + +------------------------------------------------------------------------ + +### ++wick + +Coin format decode + + ++ wick :: coin format + |= a=@ + ^- @ta + =+ b=(rip 3 a) + %+ rap 3 + |- ^- tape + ?~ b + ~ + ?: =('~' i.b) + ?~ t.b !! + [?:(=('~' i.t.b) '~' ?>(=('-' i.t.b) '_')) $(b t.t.b)] + [i.b $(b t.b)] + :: + +Unescape span `~~` as `~` and `~-` as `_`. + +`a` is a an [atom](). + + /~zod/try=> `@t`(wick '~-ams~~lop') + '_ams~lop' + /~zod/try=> `@t`(wick (wack '~20_sam~')) + '~20_sam~' + +------------------------------------------------------------------------ + +### ++woad + +Unescape cord + + ++ woad :: cord format + |= a=@ta + ^- @t + %+ rap 3 + |- ^- (list ,@) + ?: =(0 a) + ~ + =+ b=(end 3 1 a) + =+ c=(rsh 3 1 a) + ?: =('.' b) + [' ' $(a c)] + ?. =('~' b) + [b $(a c)] + => .(b (end 3 1 c), c (rsh 3 1 c)) + ?+ b =- (weld (rip 3 (tuft p.d)) $(a q.d)) + ^= d + =+ d=0 + |- ^- [p=@ q=@] + ?: =('.' b) + [d c] + ?< =(0 c) + %= $ + b (end 3 1 c) + c (rsh 3 1 c) + d %+ add (mul 16 d) + %+ sub b + ?: &((gte b '0') (lte b '9')) 48 + ?>(&((gte b 'a') (lte b 'z')) 87) + == + %'.' ['.' $(a c)] + %'~' ['~' $(a c)] + == + :: + +Unescape cord codepoints. + +`a` is a [`@ta`](). + + /~zod/try=> (woad ~.~b6.20.as) + '¶20 as' + +------------------------------------------------------------------------ + +### ++wood + +Escape cord + + ++ wood :: cord format + |= a=@t + ^- @ta + %+ rap 3 + |- ^- (list ,@) + ?: =(0 a) + ~ + =+ b=(teff a) + =+ c=(turf (end 3 b a)) + =+ d=$(a (rsh 3 b a)) + ?: ?| &((gte c 'a') (lte c 'z')) + &((gte c '0') (lte c '9')) + =('-' c) + == + [c d] + ?+ c + :- '~' + =+ e=(met 2 c) + |- ^- tape + ?: =(0 c) + ['.' d] + =. e (dec e) + =+ f=(rsh 2 e c) + [(add ?:((lte f 9) 48 87) f) $(c (end 2 e c))] + :: + %' ' ['.' d] + %'.' ['~' '.' d] + %'~' ['~' '~' d] + == + +Escape cord codepoints. + +`a` is a [`@ta`](). + + /~zod/try=> (wood 'my ßam') + ~.my.~df.am diff --git a/docs/pub/doc/hoon/library/2ek.md b/docs/pub/doc/hoon/library/2ek.md new file mode 100644 index 0000000000..a0d4372f7d --- /dev/null +++ b/docs/pub/doc/hoon/library/2ek.md @@ -0,0 +1,162 @@ +section 2eK, formatting (layout) +================================ + +### ++re + +Pretty-printing engine + + ++ re + |_ tac=tank + +Pretty-printing engine. + +`tac` is a [`++tank`](). + + /~zod/try=> ~(. re leaf/"ham") + <2.ghl [[%leaf ""] <414.gly 100.xkc 1.ypj %164>]> + +### ++ram + +Flatten to tape + + ++ ram + ^- tape + ?- -.tac + %leaf p.tac + %palm ram(tac [%rose [p.p.tac (weld q.p.tac r.p.tac) s.p.tac] q.tac]) + %rose + %+ weld + q.p.tac + |- ^- tape + ?~ q.tac + r.p.tac + =+ voz=$(q.tac t.q.tac) + (weld ram(tac i.q.tac) ?~(t.q.tac voz (weld p.p.tac voz))) + == + :: + +Flatten tank out into a tape. + + /~zod/try=> ~(ram re leaf/"foo") + "foo" + /~zod/try=> ~(ram re rose/["." "(" ")"]^~[leaf/"bar" leaf/"baz" leaf/"bam"]) + "(bar.baz.bam)" + +### ++win + +Render at indent + + ++ win + |= [tab=@ edg=@] + =+ lug=`wall`~ + |^ |- ^- wall + ?- -.tac + %leaf (rig p.tac) + %palm + ?: fit + (rig ram) + ?~ q.tac + (rig q.p.tac) + ?~ t.q.tac + (rig(tab (add 2 tab), lug $(tac i.q.tac)) q.p.tac) + => .(q.tac `(list tank)`q.tac) + =+ lyn=(mul 2 (lent q.tac)) + =+ ^= qyr + |- ^- wall + ?~ q.tac + lug + %= ^$ + tac i.q.tac + tab (add tab (sub lyn 2)) + lug $(q.tac t.q.tac, lyn (sub lyn 2)) + == + (wig(lug qyr) q.p.tac) + :: + %rose + ?: fit + (rig ram) + =+ ^= gyl + |- ^- wall + ?~ q.tac + ?:(=(%$ r.p.tac) lug (rig r.p.tac)) + ^$(tac i.q.tac, lug $(q.tac t.q.tac), tab din) + ?: =(%$ q.p.tac) + gyl + (wig(lug gyl) q.p.tac) + == + :: + +Render at indent level `tab` and width `edg`. + +`tab` and `edg` are [atom]()s. + + /~zod/try=> (~(win re leaf/"samoltekon-lapdok") 0 20) + <<"samoltekon-lapdok">> + /~zod/try=> (~(win re leaf/"samoltekon-lapdok") 0 10) + <<"\/samolt\/" " ekon-l" " apdok" "\/ \/">> + /~zod/try=> (~(win re rose/["--" "[" "]"]^~[leaf/"1423" leaf/"2316"]) 0 20) + <<"[1423--2316]">> + /~zod/try=> (~(win re rose/["--" "[" "]"]^~[leaf/"1423" leaf/"2316"]) 0 10) + <<"[ 1423" " 2316" "]">> + +### ++din + + ++ din (mod (add 2 tab) (mul 2 (div edg 3))) + +XX document + +### ++fit + +Fit on one line test + + ++ fit (lte (lent ram) (sub edg tab)) + +Determine whether `tac` fits on one line. Internal to `++win` + +### ++rig + +Wrap in `\/` + + ++ rig + |= hom=tape + ^- wall + ?: (lte (lent hom) (sub edg tab)) + [(runt [tab ' '] hom) lug] + => .(tab (add tab 2), edg (sub edg 2)) + =+ mut=(trim (sub edg tab) hom) + :- (runt [(sub tab 2) ' '] ['\\' '/' (weld p.mut `_hom`['\\' '/' ~])]) + => .(hom q.mut) + |- + ?~ hom + :- %+ runt + [(sub tab 2) ' '] + ['\\' '/' (runt [(sub edg tab) ' '] ['\\' '/' ~])] + lug + => .(mut (trim (sub edg tab) hom)) + [(runt [tab ' '] p.mut) $(hom q.mut)] + :: + +Wrap tape in `\/` if it doesn't fit at current indentation. Internal to +`++win` + +### ++wig + +`++win` render tape + + ++ wig + |= hom=tape + ^- wall + ?~ lug + (rig hom) + =+ lin=(lent hom) + =+ wug=:(add 1 tab lin) + ?. =+ mir=i.lug + |- ?~ mir + | + ?|(=(0 wug) ?&(=(' ' i.mir) $(mir t.mir, wug (dec wug)))) + (rig hom) :: ^ XX regular form? + [(runt [tab ' '] (weld hom `tape`[' ' (slag wug i.lug)])) t.lug] + -- + -- + +Render tape. Internal to `++win`. diff --git a/docs/pub/doc/hoon/library/2el.md b/docs/pub/doc/hoon/library/2el.md new file mode 100644 index 0000000000..2438891273 --- /dev/null +++ b/docs/pub/doc/hoon/library/2el.md @@ -0,0 +1,1871 @@ +section 2eL, formatting (path) +============================== + +### ++ab + +Primitive parser engine + + ++ ab + |% + +A core containing numeric parser primitives. + + ~zod/try=> ab + <36.ecc 414.gly 100.xkc 1.ypj %164> + +------------------------------------------------------------------------ + +### ++bix + +Parse hex pair + + ++ bix (bass 16 (stun [2 2] six)) + +Parsing rule. Parses a pair of base-16 digits. Used in escapes. + + ~zod/try=> (scan "07" bix:ab) + q=7 + ~zod/try=> (scan "51" bix:ab) + q=81 + ~zod/try=> (scan "a3" bix:ab) + q=163 + +------------------------------------------------------------------------ + +### ++hif + +Parse phonetic pair + + ++ hif (boss 256 ;~(plug tip tiq (easy ~))) + +Parsing rule. Parses an atom of odor [`@pE`](), a phrase of two bytes +encoded phonetically. + + ~zod/try=> (scan "doznec" hif:ab) + q=256 + ~zod/try=> (scan "pittyp" hif:ab) + q=48.626 + +------------------------------------------------------------------------ + +### ++huf + +Parse two phonetic pairs + + ++ huf %+ cook + |=([a=@ b=@] (wred:un ~(zug mu ~(zag mu [a b])))) + ;~(plug hif ;~(pfix hep hif)) + +Parsing rule. Parses and unscrambles an atom of odor [@pF](), a phrase +of two two-byte pairs that are encoded (and scrambled) phonetically. + + ~zod/try=> (scan "pittyp-pittyp" huf:ab) + 328.203.557 + ~zod/try=> (scan "tasfyn-partyv" huf:ab) + 65.792 + ~zod/try=> `@ux`(scan "tasfyn-partyv" huf:ab) + 0x1.0100 + +------------------------------------------------------------------------ + +### ++hyf + +Parse 8 phonetic bytes + + ++ hyf (bass 0x1.0000.0000 ;~(plug huf ;~(pfix hep huf) (easy ~))) + +Parsing rule. Parses an atom of odor [@pG](), a phrase of eight of +phonetic bytes. + + ~zod/try=> (scan "sondel-forsut-tillyn-nillyt" hyf:ab) + q=365.637.097.828.335.095 + ~zod/try=> `@u`~sondel-forsut-tillyn-nillyt + 365.637.097.828.335.095 + +------------------------------------------------------------------------ + +### ++pev + +Parse \<= 5 base-32 + + ++ pev (bass 32 ;~(plug sev (stun [0 4] siv))) + +Parsing rule. Parses up to five base-32 digits without a leading zero. + + ~zod/try=> (scan "a" pev:ab) + q=10 + ~zod/try=> (scan "290j" pev:ab) + q=74.771 + ~zod/try=> (scan "123456" pev:ab) + ! {1 6} + ! exit + ~zod/try=> (scan "090j" pev:ab) + ~ + +------------------------------------------------------------------------ + +### ++pew + +Parse \<= 5 base-64 + + ++ pew (bass 64 ;~(plug sew (stun [0 4] siw))) + +Parsing rule. Parses up to five base-64 digits without a leading zero. + + ~zod/try=> (scan "Q" pew:ab) + q=52 + ~zod/try=> (scan "aQ~9" pew:ab) + q=2.838.473 + ~zod/try=> `@`0waQ~9 + 2.838.473 + ~zod/try=> (scan "123456" pew:ab) + ! {1 6} + ! exit + ~zod/try=> (scan "012345" pew:ab) + ! {1 1} + ! exit + +------------------------------------------------------------------------ + +### ++piv + +Parse 5 base-32 + + ++ piv (bass 32 (stun [5 5] siv)) + +Parsing rule. Parses exactly five base-32 digits. + + ~zod/try=> (scan "10b3l" piv:ab) + q=1.059.957 + ~zod/try=> (scan "1" piv:ab) + ! {1 2} + ! exit + +------------------------------------------------------------------------ + +### ++piw + +Parse 5 base-64 + + ++ piw (bass 64 (stun [5 5] siw)) + +Parsing rule. Parses exactly five base-64 digits. + + ~zod/try=> (scan "2C-pZ" piw:ab) + q=43.771.517 + ~zod/try=> (scan "2" piv:ab) + ! {1 2} + ! exit + +------------------------------------------------------------------------ + +### ++qeb + +Parse \<= 4 binary + + ++ qeb (bass 2 ;~(plug seb (stun [0 3] sib))) + +Parsing rule. Parses a binary number of up to 4 digits in length without +a leading zero. + + ~zod/try=> (scan "1" qeb:ab) + q=1 + ~zod/try=> (scan "101" qeb:ab) + q=5 + ~zod/try=> (scan "1111" qeb:ab) + q=15 + ~zod/try=> (scan "11111" qeb:ab) + ! {1 5} + ! exit + ~zod/try=> (scan "01" qeb:ab) + ! {1 1} + ! exit + +------------------------------------------------------------------------ + +### ++qex + +Parse \<= 4 hex + + ++ qex (bass 16 ;~(plug sex (stun [0 3] hit))) + +Parsing rule. Parses a hexadecimal number of up to 4 digits in length +without a leading zero. + + ~zod/try=> (scan "ca" qex:ab) + q=202 + ~zod/try=> (scan "18ac" qex:ab) + q=6.316 + ~zod/try=> (scan "18acc" qex:ab) + ! {1 5} + ! exit + ~zod/try=> (scan "08ac" qex:ab) + ! {1 1} + ! exit + +------------------------------------------------------------------------ + +### ++qib + +Parse 4 binary + + ++ qib (bass 2 (stun [4 4] sib)) + +Parsing rule. Parses exactly four binary digits. + + ~zod/try=> (scan "0001" qib:ab) + q=1 + ~zod/try=> (scan "0100" qib:ab) + q=4 + ~zod/try=> (scan "110" qib:ab) + ! {1 4} + ! exit + +------------------------------------------------------------------------ + +### ++qix + +Parse 4 hex + + ++ qix (bass 16 (stun [4 4] six)) + +Parsing rule. Parses exactly four hexadecimal digits. + + ~zod/try=> (scan "0100" qix:ab) + q=256 + ~zod/try=> (scan "10ff" qix:ab) + q=4.351 + ~zod/try=> (scan "0" qix:ab) + ! {1 2} + ! exit + +------------------------------------------------------------------------ + +### ++seb + +Parse 1 + + ++ seb (cold 1 (just '1')) + +Parsing rule. Parses the number 1. + + ~zod/try=> (scan "1" seb:ab) + 1 + ~zod/try=> (scan "0" seb:ab) + ! ~zod/try/~2014.10.23..22.34.21..bfdd/:<[1 1].[1 18]> + ! {1 1} + ~zod/try=> (scan "2" seb:ab) + ! ~zod/try/~2014.10.23..22.34.29..d399/:<[1 1].[1 18]> + ! {1 1} + +------------------------------------------------------------------------ + +### ++sed + +Parse decimal + + ++ sed (cook |=(a=@ (sub a '0')) (shim '1' '9')) + +Parsing rule. Parses a nonzero decimal digit. + + ~zod/try=> (scan "5" sed:ab) + 5 + ~zod/try=> (scan "0" sed:ab) + ! {1 1} + ! exit + +------------------------------------------------------------------------ + +### ++sev + +Parse base-32 + + ++ sev ;~(pose sed sov) + +Parsing rule. Parses a nonzero base-32 digit + + ~zod/try=> (scan "c" sev:ab) + 12 + ~zod/socialnet=> (scan "0" sev:ab) + ! {1 1} + ! exit + +------------------------------------------------------------------------ + +### ++sew + +Parse base-64 + + ++ sew ;~(pose sed sow) + +Parsing rule. Parses a nonzero base-64 digit + + ~zod/try=> (scan "M" sew:ab) + 48 + ~zod/try=> (scan "0" sew:ab) + ! {1 1} + ! exit + +------------------------------------------------------------------------ + +### ++sex + +Parse hex + + ++ sex ;~(pose sed sox) + +Parsing rule. Parses a nonzero hexadecimal digit. + + ~zod/try=> (scan "e" sex:ab) + 14 + ~zod/try=> (scan "0" sex:ab) + ! {1 1} + ! exit + +------------------------------------------------------------------------ + +### ++sib + +Parse binary + + ++ sib (cook |=(a=@ (sub a '0')) (shim '0' '1')) + +Parsing rule. Parses a binary digit. + + ~zod/try=> (scan "1" sib:ab) + 1 + ~zod/socialnet=> (scan "0" sib:ab) + 0 + +------------------------------------------------------------------------ + +### ++sid + +Parse decimal + + ++ sid (cook |=(a=@ (sub a '0')) (shim '0' '9')) + +Parsing rule. Parses a decimal digit. + + ~zod/try=> (scan "5" sid:ab) + 5 + +------------------------------------------------------------------------ + +### ++siv + +Parse base-32 + + ++ siv ;~(pose sid sov) + +Parsing rule. Parses a base-32 digit. + + ~zod/try=> (scan "c" siv:ab) + 12 + +------------------------------------------------------------------------ + +### ++siw + +Parse base-64 + + ++ siw ;~(pose sid sow) + +Parsing rule. Parses a base-64 digit. + + ~zod/try=> (scan "M" siw:ab) + 48 + +------------------------------------------------------------------------ + +### ++six + +Parse hex + + ++ six ;~(pose sid sox) + +Parsing rule. Parses a hexadecimal digit. + + ~zod/try=> (scan "e" six:ab) + 14 + +------------------------------------------------------------------------ + +### ++sov + +Parse base-32 + + ++ sov (cook |=(a=@ (sub a 87)) (shim 'a' 'v')) + +Parsing rule. Parses a base-32 letter. + + ~zod/try=> (scan "c" sov:ab) + 12 + +------------------------------------------------------------------------ + +### ++sow + +Parse base-64 + + ++ sow ;~ pose + (cook |=(a=@ (sub a 87)) (shim 'a' 'z')) + (cook |=(a=@ (sub a 29)) (shim 'A' 'Z')) + (cold 62 (just '-')) + (cold 63 (just '~')) + == + +Parsing rule. Parses a base-64 letter/symbol. + + ~zod/try=> (scan "M" sow:ab) + 48 + +------------------------------------------------------------------------ + +### ++sox + +Parse hex letter + + ++ sox (cook |=(a=@ (sub a 87)) (shim 'a' 'f')) + +Parsing rule. Parses a hexadecimal letter. + + ~zod/try=> (scan "e" sox:ab) + 14 + +------------------------------------------------------------------------ + +### ++ted + +Parse \<= 3 decimal + + ++ ted (bass 10 ;~(plug sed (stun [0 2] sid))) + +Parsing rule. Parses a decimal number of up to 3 digits without a +leading zero. + + ~zod/try=> (scan "21" ted:ab) + q=21 + ~zod/try=> (scan "214" ted:ab) + q=214 + ~zod/try=> (scan "2140" ted:ab) + {1 4} + ~zod/try=> (scan "0" ted:ab) + ! {1 1} + ! exit + +------------------------------------------------------------------------ + +### ++tip + +Leading phonetic byte + + ++ tip (sear |=(a=@ (ins:po a)) til) + +Parsing rule. Parses the leading phonetic byte, which represents a +syllable. + + ~zod/try=> (scan "doz" tip:ab) + 0 + ~zod/try=> (scan "pit" tip:ab) + 242 + +------------------------------------------------------------------------ + +### ++tiq + +Trailing phonetic syllable + + ++ tiq (sear |=(a=@ (ind:po a)) til) + +Parsing rule. Parses the trailing phonetic byte, which represents a +syllable. + + ~zod/try=> (scan "zod" tiq:ab) + 0 + ~zod/try=> (scan "nec" tiq:ab) + 1 + +------------------------------------------------------------------------ + +### ++tid + +Parse 3 decimal digits + + ++ tid (bass 10 (stun [3 3] sid)) + +Parsing rule. Parses exactly three decimal digits. + + ~zod/try=> (scan "013" tid:ab) + q=13 + ~zod/try=> (scan "01" tid:ab) + ! {1 3} + ! exit + +------------------------------------------------------------------------ + +### ++til + +Parse 3 lowercase + + ++ til (boss 256 (stun [3 3] low)) + +Parsing rule. Parses exactly three lowercase letters. + + ~zod/try=> (scan "mer" til:ab) + q=7.497.069 + ~zod/try=> `@t`(scan "mer" til:ab) + 'mer' + ~zod/try=> (scan "me" til:ab) + ! {1 3} + ! exit + +------------------------------------------------------------------------ + +### ++urs + +Parse span characters + + ++ urs %+ cook + |=(a=tape (rap 3 ^-((list ,@) a))) + (star ;~(pose nud low hep dot sig cab)) + +Parsing rule. Parses characters from an atom of the span odor [`@ta`](). + + ~zod/try=> `@ta`(scan "asa-lom_tak" urs:ab) + ~.asa-lom_tak + ~zod/try=> `@t`(scan "asa-lom_tak" urs:ab) + 'asa-lom_tak' + +------------------------------------------------------------------------ + +### ++urt + +Parse non-`_` span + + ++ urt %+ cook + |=(a=tape (rap 3 ^-((list ,@) a))) + (star ;~(pose nud low hep dot sig)) + +Parsing rule. Parses all characters of the span odor [`@ta`]() except +for cab, `_`. + + ~zod/try=> `@t`(scan "asa-lom.t0k" urt:ab) + 'asa-lom.t0k' + +------------------------------------------------------------------------ + +### ++voy + +Parse bas, soq, or bix + + ++ voy ;~(pfix bas ;~(pose bas soq bix)) + +Parsing rule. Parses an escaped backslash, single quote, or hex pair +byte. + + ~zod/try=> (scan "\\0a" voy:ab) + q=10 + ~zod/try=> (scan "\\'" voy:ab) + q=39 + +------------------------------------------------------------------------ + +### ++ag + +Top-level atom parser engine + + ++ ag + |% + +A core containing top-level atom parsers. + + ~zod/try=> ag + <14.vpu 414.mof 100.xkc 1.ypj %164> + +------------------------------------------------------------------------ + +### ++ape + +Parse 0 or rule + + ++ ape |*(fel=_rule ;~(pose (cold 0 (just '0')) fel)) + +Parser modifier. Parses 0 or the sample rule `fel`. + +`fel` is a [`rule`](). + + ~zod/try=> (scan "202" (star (ape:ag (cold 2 (just '2'))))) + ~[2 0 2] + +------------------------------------------------------------------------ + +### ++bay + +Parses binary number + + ++ bay (ape (bass 16 ;~(plug qeb:ab (star ;~(pfix dog qib:ab))))) + +Parsing rule. Parses a binary number without a leading zero. + + ~zod/try=> (scan "10.0110" bay:ag) + q=38 + +------------------------------------------------------------------------ + +### ++bip + +Parse IPv6 + + ++ bip =+ tod=(ape qex:ab) + (bass 0x1.0000 ;~(plug tod (stun [7 7] ;~(pfix dog tod)))) + +Parsing rule. Parses a [`@is`](), an IPv6 address. + + ~zod/try=> (scan "0.0.ea.3e6c.0.0.0.0" bip:ag) + q=283.183.420.760.121.105.516.068.864 + ~zod/try=> `@is`(scan "0.0.ea.3e6c.0.0.0.0" bip:ag) + .0.0.ea.3e6c.0.0.0.0 + +------------------------------------------------------------------------ + +### ++dem + +Parse decimal with dots + + ++ dem (ape (bass 1.000 ;~(plug ted:ab (star ;~(pfix dog tid:ab))))) + +Parsing rule. Parses a decimal number that includes dot separators. + + ~zod/try=> (scan "52" dem:ag) + q=52 + ~zod/try=> (scan "13.507" dem:ag) + q=13.507 + +------------------------------------------------------------------------ + +### ++dim + +Parse decimal number + + ++ dim (ape (bass 10 ;~(plug sed:ab (star sid:ab)))) + +Parsing rule. Parses a decimal number without a leading zero. + + ~zod/try=> (scan "52" dim:ag) + q=52 + ~zod/try=> (scan "013507" dim:ag) + ! {1 2} + ! exit + +------------------------------------------------------------------------ + +### ++dum + +Parse decimal with leading `0` + + ++ dum (bass 10 (plus sid:ab)) + +Parsing rule. Parses a decmial number with leading zeroes. + + ~zod/try=> (scan "52" dum:ag) + q=52 + ~zod/try=> (scan "0000052" dum:ag) + q=52 + ~zod/try=> (scan "13507" dim:ag) + q=13.507 + +------------------------------------------------------------------------ + +### ++fed + +Parse phonetic base + + ++ fed ;~ pose + (bass 0x1.0000.0000.0000.0000 (most doh hyf:ab)) + huf:ab + hif:ab + tiq:ab + == + +Parsing rule. Parses an atom of odor [`@p`](), the phonetic base. + + ~zod/try=> (scan "zod" fed:ag) + 0 + ~zod/try=> (scan "nec" fed:ag) + 1 + ~zod/try=> (scan "sondel" fed:ag) + 9.636 + ~zod/try=> ~tillyn-nillyt + ~tillyn-nillyt + ~zod/try=> (scan "tillyn-nillyt" fed:ag) + 3.569.565.175 + ~zod/try=> (scan "tillyn-nillyt-tasfyn-partyv" fed:ag) + 15.331.165.687.565.582.592 + ~zod/try=> (scan "tillyn-nillyt-tasfyn-partyv--novweb-talrud-talmud-sonfyr" fed:ag) + 282.810.089.790.159.633.869.501.053.313.363.681.181 + +------------------------------------------------------------------------ + +### ++hex + +Parse hex + + ++ hex (ape (bass 0x1.0000 ;~(plug qex:ab (star ;~(pfix dog qix:ab))))) + +Parsing rule. Parses a hexadecimal number + + ~zod/try=> (scan "4" hex:ag) + q=4 + ~zod/try=> (scan "1a" hex:ag) + q=26 + ~zod/try=> (scan "3.ac8d" hex:ag) + q=240.781 + ~zod/try=> `@ux`(scan "3.ac8d" hex:ag) + 0x3.ac8d + +------------------------------------------------------------------------ + +### ++lip + +Parse IPv4 address + + ++ lip =+ tod=(ape ted:ab) + (bass 256 ;~(plug tod (stun [3 3] ;~(pfix dog tod)))) + +Parsing rule. Parses an IPv4 address. + + ~zod/try=> (scan "127.0.0.1" lip:ag) + q=2.130.706.433 + ~zod/try=> `@if`(scan "127.0.0.1" lip:ag) + .127.0.0.1 + ~zod/try=> `@if`(scan "8.8.8.8" lip:ag) + .8.8.8.8 + +------------------------------------------------------------------------ + +### ++viz + +Parse Base-32 with dots + + ++ viz (ape (bass 0x200.0000 ;~(plug pev:ab (star ;~(pfix dog piv:ab))))) + +Parsing rule. Parses a Base-32 number with dot separators. + + ~zod/try=> (scan "e2.ol4pm" viz:ag) + q=15.125.353.270 + +------------------------------------------------------------------------ + +### ++vum + +Parse base-32 string + + ++ vum (bass 32 (plus siv:ab)) + +Parsing rule. Parses a raw base-32 string. + + ~zod/try=> (scan "e2ol4pm" vum:ag) + q=15.125.353.270 + +------------------------------------------------------------------------ + +### ++wiz + +Parse base-64 + + ++ wiz (ape (bass 0x4000.0000 ;~(plug pew:ab (star ;~(pfix dog piw:ab))))) + -- + :: + +Parsing rule. Parses a base-64 number. + + ~zod/try=> (scan "e2O.l4Xpm" wiz:ag) + q=61.764.130.813.526 + +------------------------------------------------------------------------ + +### ++co + +Literal rendering engine + + ++ co + =< |_ lot=coin + +A [door]() that contains arms that operate on the sample coin `lot`. + +`lot` is a [`++coin`](). + + ~zod/try=> ~(. co many/~[`ta/'mo' `ud/5]) + < 3.dhd + [ [ %many + [%~ %ta @t] + [%~ %ud @ud] + %~ + ] + <10.utz 3.zid [rex="" <414.hmb 100.xkc 1.ypj %164>]> + ] + > + +------------------------------------------------------------------------ + +### ++rear + +Prepend & render as tape + + ++ rear |=(rom=tape =>(.(rex rom) rend)) + +Renders a coin `lot` as a [tape]() prepended to the sample tape `rom`. + +`rom` is a [`pe`]() + +`lot` is a [`++coin`](). + + ~zod/try=> (~(rear co %$ %ux 200) "--ha") + "0xc8--ha" + +------------------------------------------------------------------------ + +### ++rent + +Render as span + + ++ rent `@ta`(rap 3 rend) + +Renders a coin `lot` as a span. + +`lot` is a [`++coin`](). + + ~zod/try=> ~(rent co %$ %ux 200) + ~.0xc8 + ~zod/try=> `@t`~(rent co %$ %ux 200) + '0xc8' + +------------------------------------------------------------------------ + +### ++rend + +Render as tape + + ++ rend + ^- tape + ?: ?=(%blob -.lot) + ['~' '0' ((v-co 1) (jam p.lot))] + ?: ?=(%many -.lot) + :- '.' + |- ^- tape + ?~ p.lot + ['_' '_' rex] + ['_' (weld (trip (wack rent(lot i.p.lot))) $(p.lot t.p.lot))] + =+ [yed=(end 3 1 p.p.lot) hay=(cut 3 [1 1] p.p.lot)] + |- ^- tape + ?+ yed (z-co q.p.lot) + %c ['~' '-' (weld (rip 3 (wood (tuft q.p.lot))) rex)] + %d + ?+ hay (z-co q.p.lot) + %a + =+ yod=(yore q.p.lot) + => ^+(. .(rex ?~(f.t.yod rex ['.' (s-co f.t.yod)]))) + => ^+ . + %= . + rex + ?: &(=(~ f.t.yod) =(0 h.t.yod) =(0 m.t.yod) =(0 s.t.yod)) + rex + => .(rex ['.' (y-co s.t.yod)]) + => .(rex ['.' (y-co m.t.yod)]) + ['.' '.' (y-co h.t.yod)] + == + => .(rex ['.' (a-co d.t.yod)]) + => .(rex ['.' (a-co m.yod)]) + => .(rex ?:(a.yod rex ['-' rex])) + ['~' (a-co y.yod)] + :: + %r + =+ yug=(yell q.p.lot) + => ^+(. .(rex ?~(f.yug rex ['.' (s-co f.yug)]))) + :- '~' + ?: &(=(0 d.yug) =(0 m.yug) =(0 h.yug) =(0 s.yug)) + ['.' 's' '0' rex] + => ^+(. ?:(=(0 s.yug) . .(rex ['.' 's' (a-co s.yug)]))) + => ^+(. ?:(=(0 m.yug) . .(rex ['.' 'm' (a-co m.yug)]))) + => ^+(. ?:(=(0 h.yug) . .(rex ['.' 'h' (a-co h.yug)]))) + => ^+(. ?:(=(0 d.yug) . .(rex ['.' 'd' (a-co d.yug)]))) + +.rex + == + :: + %f + ?: =(& q.p.lot) + ['.' 'y' rex] + ?:(=(| q.p.lot) ['.' 'n' rex] (z-co q.p.lot)) + :: + %n ['~' rex] + %i + ?+ hay (z-co q.p.lot) + %f ((ro-co [3 10 4] |=(a=@ ~(d ne a))) q.p.lot) + %s ((ro-co [4 16 8] |=(a=@ ~(x ne a))) q.p.lot) + == + :: + %p + =+ dyx=(met 3 q.p.lot) + :- '~' + ?: (lte dyx 1) + (weld (trip (tod:po q.p.lot)) rex) + ?: =(2 dyx) + ;: weld + (trip (tos:po (end 3 1 q.p.lot))) + (trip (tod:po (rsh 3 1 q.p.lot))) + rex + == + =+ [dyz=(met 5 q.p.lot) fin=|] + |- ^- tape + ?: =(0 dyz) + rex + %= $ + fin & + dyz (dec dyz) + q.p.lot (rsh 5 1 q.p.lot) + rex + =+ syb=(wren:un (end 5 1 q.p.lot)) + =+ cog=~(zig mu [(rsh 4 1 syb) (end 4 1 syb)]) + ;: weld + (trip (tos:po (end 3 1 p.cog))) + (trip (tod:po (rsh 3 1 p.cog))) + `tape`['-' ~] + (trip (tos:po (end 3 1 q.cog))) + (trip (tod:po (rsh 3 1 q.cog))) + `tape`?:(fin ['-' ?:(=(1 (end 0 1 dyz)) ~ ['-' ~])] ~) + rex + == + == + :: + %r + ?+ hay (z-co q.p.lot) + %d + =+ r=(rlyd q.p.lot) + ?~ e.r + ['.' '~' (r-co r)] + ['.' '~' u.e.r] + %h ['.' '~' '~' (r-co (rlyh q.p.lot))] + %q ['.' '~' '~' '~' (r-co (rlyq q.p.lot))] + %s ['.' (r-co (rlys q.p.lot))] + == + :: + %u + =- (weld p.gam ?:(=(0 q.p.lot) `tape`['0' ~] q.gam)) + ^= gam ^- [p=tape q=tape] + ?+ hay [~ ((ox-co [10 3] |=(a=@ ~(d ne a))) q.p.lot)] + %b [['0' 'b' ~] ((ox-co [2 4] |=(a=@ ~(d ne a))) q.p.lot)] + %i [['0' 'i' ~] ((d-co 1) q.p.lot)] + %x [['0' 'x' ~] ((ox-co [16 4] |=(a=@ ~(x ne a))) q.p.lot)] + %v [['0' 'v' ~] ((ox-co [32 5] |=(a=@ ~(x ne a))) q.p.lot)] + %w [['0' 'w' ~] ((ox-co [64 5] |=(a=@ ~(w ne a))) q.p.lot)] + == + :: + %s + %+ weld + ?:((syn:si q.p.lot) "--" "-") + $(yed 'u', q.p.lot (abs:si q.p.lot)) + :: + %t + ?: =('a' hay) + ?: =('s' (cut 3 [2 1] p.p.lot)) + + (weld (rip 3 q.p.lot) rex) + ['~' '.' (weld (rip 3 q.p.lot) rex)] + ['~' '~' (weld (rip 3 (wood q.p.lot)) rex)] + == + -- + =+ rex=*tape + =< |% + ++ a-co |=(dat=@ ((d-co 1) dat)) + ++ d-co |=(min=@ (em-co [10 min] |=([? b=@ c=tape] [~(d ne b) c]))) + ++ r-co + |= [syn=? nub=@ der=@ ign=(unit tape) ne=?] + => .(rex ['.' (t-co ((d-co 1) der) ne)]) + => .(rex ((d-co 1) nub)) + ?:(syn rex ['-' rex]) + ++ t-co |= [a=tape n=?] ^- tape + ?: n a + ?~ a ~|(%empty-frac !!) t.a + :: + ++ s-co + |= esc=(list ,@) ^- tape + ~| [%so-co esc] + ?~ esc + rex + :- '.' + =>(.(rex $(esc t.esc)) ((x-co 4) i.esc)) + + :: + ++ v-co |=(min=@ (em-co [32 min] |=([? b=@ c=tape] [~(v ne b) c]))) + ++ w-co |=(min=@ (em-co [64 min] |=([? b=@ c=tape] [~(w ne b) c]))) + ++ x-co |=(min=@ (em-co [16 min] |=([? b=@ c=tape] [~(x ne b) c]))) + ++ y-co |=(dat=@ ((d-co 2) dat)) + ++ z-co |=(dat=@ `tape`['0' 'x' ((x-co 1) dat)]) + -- + ~% %co +> ~ + |% + ++ em-co + ~/ %emco + |= [[bas=@ min=@] [par=$+([? @ tape] tape)]] + |= hol=@ + ^- tape + ?: &(=(0 hol) =(0 min)) + rex + =+ [rad=(mod hol bas) dar=(div hol bas)] + %= $ + min ?:(=(0 min) 0 (dec min)) + hol dar + rex (par =(0 dar) rad rex) + == + :: + ++ ox-co + ~/ %oxco + |= [[bas=@ gop=@] dug=$+(@ @)] + %+ em-co + [|-(?:(=(0 gop) 1 (mul bas $(gop (dec gop))))) 0] + |= [top=? seg=@ res=tape] + %+ weld + ?:(top ~ `tape`['.' ~]) + %. seg + %+ em-co(rex res) + [bas ?:(top 0 gop)] + |=([? b=@ c=tape] [(dug b) c]) + :: + ++ ro-co + ~/ %roco + |= [[buz=@ bas=@ dop=@] dug=$+(@ @)] + |= hol=@ + ^- tape + ?: =(0 dop) + rex + => .(rex $(dop (dec dop))) + :- '.' + %- (em-co [bas 1] |=([? b=@ c=tape] [(dug b) c])) + [(cut buz [(dec dop) 1] hol)] + -- + :: + +Renders a coin `lot` as a tape. + +`lot` is a [`++coin`](). + + ~zod/try=> ~(rend co ~ %ux 200) + "0xc8" + ~zod/try=> ~(rend co %many ~[[%$ ux/200] [%$ p/40]]) + "._0xc8_~~tem__" + ~zod/try=> ~(rend co ~ %p 32.819) + "~pillyt" + ~zod/try=> ~(rend co ~ %ux 18) + "0x12" + ~zod/try=> ~(rend co [~ p=[p=%if q=0x7f00.0001]]) + ".127.0.0.1" + ~zod/try=> `@ux`.127.0.0.1 + 2.130.706.433 + ~zod/try=> ~(rend co %many ~[[~ %ud 20] [~ %uw 133] [~ %tas 'sam']]) + "._20_0w25_sam__" + ~zod/try=> ~(rend co %blob [1 1]) + "~0ph" + ~zod/try=> ~0ph + [1 1] + ~zod/try=> `@uv`(jam [1 1]) + 0vph + +------------------------------------------------------------------------ + +### ++ne + +Digit rendering engine + + ++ ne + |_ tig=@ + +A [door]() containing arms that render digits at bases 10, 16, 32, and +64. + +`tig` is an [`atom`](). + + ~zod/try=> ~(. ne 20) + <4.gut [@ud <414.hhh 100.xkc 1.ypj %164>]> + +------------------------------------------------------------------------ + +### ++d + +Render decimal + + ++ d (add tig '0') + +Renders a decimal digit as an atom of an ACII byte value. + +`tig` is an [`atom`](). + + ~zod/try=> `@t`~(d ne 7) + '7' + +------------------------------------------------------------------------ + +### ++x + +Render hex + + ++ x ?:((gte tig 10) (add tig 87) d) + +Renders a hexadecimal digit as an atom of an ASCII byte value. + +`tig` is an [`atom`](). + + ~zod/try=> `@t`~(x ne 7) + '7' + ~zod/try=> `@t`~(x ne 14) + 'e' + +------------------------------------------------------------------------ + +### ++v + +Render base-32 + + ++ v ?:((gte tig 10) (add tig 87) d) + +Renders a base-32 digit as an atom of an ASCII byte value. + + ~zod/try=> `@t`~(v ne 7) + '7' + ~zod/try=> `@t`~(v ne 14) + 'e' + ~zod/try=> `@t`~(v ne 25) + 'p' + +------------------------------------------------------------------------ + +### ++w + +Render base-64 + + ++ w ?:(=(tig 63) '~' ?:(=(tig 62) '-' ?:((gte tig 36) (add tig 29) x))) + -- + :: + +Renders a base-64 digit as an atom of an ASCII byte value. + +`tig` is an [`atom`](). + + ~zod/try=> `@t`~(w ne 7) + '7' + ~zod/try=> `@t`~(w ne 14) + 'e' + ~zod/try=> `@t`~(w ne 25) + 'p' + ~zod/try=> `@t`~(w ne 52) + 'Q' + ~zod/try=> `@t`~(w ne 61) + 'Z' + ~zod/try=> `@t`~(w ne 63) + '~' + ~zod/try=> `@t`~(w ne 62) + '-' + +------------------------------------------------------------------------ + +### ++mu + +Core used to scramble 16-bit atoms + + ++ mu + |_ [top=@ bot=@] + +A [door]() that contains arms that are used to scramble two atoms, `top` +and `bot`. Used especially in the phonetic base to disguise the +relationship between a destroyer and its cruiser. + +`bot` is an [atom](). + +`top` is an [atom](). + + ~zod/try=> ~(. mu 0x20e5 0x5901) + <3.sjm [[@ux @ux] <414.hhh 100.xkc 1.ypj %164>]> + +------------------------------------------------------------------------ + +### ++zag + +Add bottom into top + + ++ zag [p=(end 4 1 (add top bot)) q=bot] + +Produces the cell of `top` and `bot` with `top` scrambled to the result +of adding `bot` to `top` modulo 16. Used to scramble the name of a +destroyer. + +`bot` is an [atom](). + +`top` is an [atom](). + + ~zod/try=> `[@ux @ux]`~(zag mu 0x20e0 0x201) + [0x22e1 0x201] + +------------------------------------------------------------------------ + +### ++zig + +Subtract bottom from top + + ++ zig [p=(end 4 1 (add top (sub 0x1.0000 bot))) q=bot] + +The inverse of [`++zag`](). Produces the cell of `top` and `bot` with +`top` unscrambled. The unscrambled `top` is the sum of the sample `top` +and the 16-bit complement of `bot`. Used to unscramble the name of the +destroyer. + +`bot` is an [atom](). + +`top` is an [atom](). + + ~zod/try=> `[@ux @ux]`~(zig mu 0x2f46 0x1042) + [0x1f04 0x1042] + +------------------------------------------------------------------------ + +### ++zug + +Concatenate into atom + + ++ zug (mix (lsh 4 1 top) bot) + +Produces the concatenation of `top` and `bot`. Used to assemble a +destroyer name. + +`bot` is an [atom](). + +`top` is an [atom](). + + ~zod/try=> `@ux`~(zug mu 0x10e1 0xfa) + 0x10e1.00fa + +------------------------------------------------------------------------ + +### ++so + +Coin parser engine + + ++ so + |% + +Core containing arms that parse [`++coin`]s. + + ~zod/try=> so + <10.mkn 414.hhh 100.xkc 1.ypj %164> + +------------------------------------------------------------------------ + +### ++bisk + +Parse odor-atom pair + + ++ bisk + ;~ pose + ;~ pfix (just '0') + ;~ pose + (stag %ub ;~(pfix (just 'b') bay:ag)) + (stag %ui ;~(pfix (just 'i') dim:ag)) + (stag %ux ;~(pfix (just 'x') hex:ag)) + (stag %uv ;~(pfix (just 'v') viz:ag)) + (stag %uw ;~(pfix (just 'w') wiz:ag)) + == + == + (stag %ud dem:ag) + == + +Parsing rule. Parses an unsigned integer of any permitted base, +producing a [`++dime`](). + + ~zod/try=> (scan "25" bisk:so) + [%ud q=25] + ~zod/try=> (scan "0x12.6401" bisk:so) + [%ux q=1.205.249] + +------------------------------------------------------------------------ + +### ++crub + +Parse `@da`, `@dr`, `@p`, `@t` + + ++ crub + ;~ pose + %+ cook + |=(det=date `dime`[%da (year det)]) + ;~ plug + %+ cook + |=([a=@ b=?] [b a]) + ;~(plug dim:ag ;~(pose (cold | hep) (easy &))) + ;~(pfix dot dim:ag) :: month + ;~(pfix dot dim:ag) :: day + ;~ pose + ;~ pfix + ;~(plug dot dot) + ;~ plug + dum:ag + ;~(pfix dot dum:ag) + ;~(pfix dot dum:ag) + ;~(pose ;~(pfix ;~(plug dot dot) (most dot qix:ab)) (easy ~)) + == + == + (easy [0 0 0 ~]) + == + == + :: + %+ cook + |= [a=(list ,[p=?(%d %h %m %s) q=@]) b=(list ,@)] + =+ rop=`tarp`[0 0 0 0 b] + |- ^- dime + ?~ a + [%dr (yule rop)] + ?- p.i.a + %d $(a t.a, d.rop (add q.i.a d.rop)) + %h $(a t.a, h.rop (add q.i.a h.rop)) + %m $(a t.a, m.rop (add q.i.a m.rop)) + %s $(a t.a, s.rop (add q.i.a s.rop)) + == + ;~ plug + %+ most + dot + ;~ pose + ;~(pfix (just 'd') (stag %d dim:ag)) + ;~(pfix (just 'h') (stag %h dim:ag)) + ;~(pfix (just 'm') (stag %m dim:ag)) + ;~(pfix (just 's') (stag %s dim:ag)) + == + ;~(pose ;~(pfix ;~(plug dot dot) (most dot qix:ab)) (easy ~)) + == + :: + (stag %p fed:ag) + ;~(pfix dot (stag %ta urs:ab)) + ;~(pfix sig (stag %t (cook woad urs:ab))) + ;~(pfix hep (stag %c (cook turf (cook woad urs:ab)))) + == + +Parsing rule. Parses any atom of any of the following odors after a +leading sig, `~` into a [`++dime`](): [`@da`](), [`@dr`](), [`@p`](), +and [`@t`](), producing a [`++dime`](). + + ~zod/try=> (scan "1926.5.12" crub:so) + [p=~.da q=170.141.184.449.747.016.871.285.095.307.149.312.000] + ~zod/try=> (,[%da @da] (scan "1926.5.12" crub:so)) + [%da ~1926.5.12] + ~zod/try=> (scan "s10" crub:so) + [p=~.dr q=184.467.440.737.095.516.160] + ~zod/try=> (,[%dr @dr] (scan "s10" crub:so)) + [%dr ~s10] + ~zod/try=> (scan "doznec" crub:so) + [%p 256] + ~zod/try=> (scan ".mas" crub:so) + [%ta 7.561.581] + +------------------------------------------------------------------------ + +### ++nuck + +Top-level coin parser + + ++ nuck + %+ knee *coin |. ~+ + %- stew + ^. stet ^. limo + :~ :- ['a' 'z'] (cook |=(a=@ta [~ %tas a]) sym) + :- ['0' '9'] (stag ~ bisk) + :- '-' (stag ~ tash) + :- '.' ;~(pfix dot perd) + :- '~' ;~(pfix sig ;~(pose twid (easy [~ %n 0]))) + == + +Parsing rule. Switches on the first character and applies the +corresponding [`++coin`]() parser. + + ~zod/try=> (scan "~pillyt" nuck:so) + [% p=[p=~.p q=32.819]] + ~zod/try=> (scan "0x12" nuck:so) + [% p=[p=~.ux q=18]] + ~zod/try=> (scan ".127.0.0.1" nuck:so) + [% p=[p=~.if q=2.130.706.433]] + ~zod/try=> `@ud`.127.0.0.1 + 2.130.706.433 + ~zod/try=> (scan "._20_0w25_sam__" nuck:so) + [ %many + p + ~[[% p=[p=~.ud q=20]] [% p=[p=~.uw q=133]] [% p=[p=~.tas q=7.168.371]]] + ] + ~zod/try=> `@`%sam + 7.168.371 + ~zod/try=> (scan "~0ph" nuck:so) + [%blob p=[1 1]] + ~zod/try=> ~0ph + [1 1] + ~zod/try=> `@uv`(jam [1 1]) + 0vph + +------------------------------------------------------------------------ + +### ++nusk + +Parse coin literal with escapes + + ++ nusk + (sear |=(a=@ta (rush (wick a) nuck)) urt:ab) + +Parsing rule. Parses a coin literal with escapes. (See also: xx tuple +formatting). + + ~zod/try=> ~.asd_a + ~.asd_a + ~zod/try=> ._1_~~.asd~-a__ + [1 ~.asd_a] + ~zod/try=> (scan "~~.asd~-a" nusk:so) + [% p=[p=~.ta q=418.212.246.369]] + ~zod/try=> (,[~ %ta @ta] (scan "~~.asd~-a" nusk:so)) + [~ %ta ~.asd_a] + +------------------------------------------------------------------------ + +### ++perd + +Parsing rule. + + ++ perd + ;~ pose + (stag ~ zust) + (stag %many (ifix [cab ;~(plug cab cab)] (more cab nusk))) + == + +Parsing rule. Parses a dime or tuple without their respective standard +prefixes. + + ~zod/try=> (scan "y" perd:so) + [~ [%f %.y]] + ~zod/try=> (scan "n" perd:so) + [~ [%f %.n]] + ~zod/try=> | + %.n + ~zod/try=> (scan "_20_x__" perd:so) + [%many [[% p=[p=~.ud q=20]] ~[[% p=[p=~.tas q=120]]]]] + +------------------------------------------------------------------------ + +### ++royl + +Parse dime float + + ++ royl + =+ ^= zer + (cook lent (star (just '0'))) + =+ ^= voy + %+ cook royl-cell + ;~ plug + ;~(pose (cold | hep) (easy &)) + ;~(plug dim:ag ;~(pose ;~(pfix dot ;~(plug zer dim:ag)) (easy [0 0]))) + ;~ pose + ;~ pfix + (just 'e') + (cook some ;~(plug ;~(pose (cold | hep) (easy &)) dim:ag)) + == + (easy ~) + == + == + ;~ pose + (stag %rh (cook rylh ;~(pfix ;~(plug sig sig) voy))) + (stag %rq (cook rylq ;~(pfix ;~(plug sig sig sig) voy))) + (stag %rd (cook ryld ;~(pfix sig voy))) + (stag %rs (cook ryls voy) + == + +Parsing rule. Parses a number into a [`++dime`]() float. + + ~zod/try=> (scan "~3.14" royl:so) + [%rd .~3.13999999999999] + ~zod/try=> .~3.14 + .~3.13999999999999 + +------------------------------------------------------------------------ + +### ++royl-cell + +XX still not fully functional + + ++ royl-cell + |= [a=? b=[c=@ d=@ e=@] f=(unit ,[h=? i=@])] + ^- [? @ @ @ (unit ,@s)] + ?~ f + [a c.b d.b e.b ~] + ?: h.u.f + [a c.b d.b e.b [~ (mul i.u.f 2)]] + [a c.b d.b e.b [~ (dec (mul i.u.f 2))]] + +Intermediate parsed float convereter + +------------------------------------------------------------------------ + +### ++tash + +Parse signed dime + + ++ tash + =+ ^= neg + |= [syn=? mol=dime] ^- dime + ?> =('u' (end 3 1 p.mol)) + [(cat 3 's' (rsh 3 1 p.mol)) (new:si syn q.mol)] + ;~ pfix hep + ;~ pose + (cook |=(a=dime (neg | a)) bisk) + ;~(pfix hep (cook |=(a=dime (neg & a)) bisk)) + == + == + +Parsing rule. Parses a signed number into a [`++dime`](). + + ~zod/try=> (scan "-20" tash:so) + [p=~.sd q=39] + ~zod/try=> (,[%sd @sd] (scan "-20" tash:so)) + [%sd -20] + ~zod/try=> (,[%sd @sd] (scan "--20" tash:so)) + [%sd --20] + ~zod/try=> (,[%sx @sx] (scan "--0x2e" tash:so)) + [%sx --0x2e] + +------------------------------------------------------------------------ + +### ++twid + +Parse coins without `~` prefix + + ++ twid + ;~ pose + (cook |=(a=@ [%blob (cue a)]) ;~(pfix (just '0') vum:ag)) + (stag ~ crub) + == + :: + +Parsing rule. Parses coins after a leading sig, `~`. + + ~zod/try=> (scan "zod" twid:so) + [~ [%p 0]] + ~zod/try=> (scan ".sam" twid:so) + [~ [%ta 7.168.371]] + ~zod/try=> `@ud`~.sam + 7.168.371 + ~zod/try=> `@t`~.sam + 'sam' + ~zod/try=> (scan "0ph" twid:so) + [%blob [1 1]] + +------------------------------------------------------------------------ + +### ++zust + +Parse prefixed dimes from `@if`, `@f`, `@rd` + + ++ zust + ;~ pose + (stag %is bip:ag) + (stag %if lip:ag) + (stag %f ;~(pose (cold & (just 'y')) (cold | (just 'n')))) + royl + == + -- + +Parsing rule. Parses an atom of either [`@if`]() (IP address), [`@f`]() +(loobean), or [`rf`]()(floating point) into a [`++dime`](). + + ~zod/try=> (scan "127.0.0.1" zust:so) + [%if q=2.130.706.433] + ~zod/try=> (scan "af.0.0.0.0.e7a5.30d2.7" zust:so) + [%is q=908.651.950.243.594.834.993.091.554.288.205.831] + ~zod/try=> (,[%is @is] (scan "af.0.0.0.0.e7a5.30d2.7" zust:so)) + [%is .af.0.0.0.0.e7a5.30d2.7] + ~zod/try=> (,[%is @ux] (scan "af.0.0.0.0.e7a5.30d2.7" zust:so)) + [%is 0xaf.0000.0000.0000.0000.e7a5.30d2.0007] + ~zod/try=> (scan "y" zust:so) + [%f %.y] + ~zod/try=> (scan "12.09" zust:so) + [%rd .~12.00999999999999] + +------------------------------------------------------------------------ + +### ++scot + +Render dime as cord + + ++ scot |=(mol=dime ~(rent co %$ mol)) + +Renders a dime `mol` as a cord. + +`mol` is a [`++dime`](). + + ~zod/try=> (scot %p ~pillyt) + ~.~pillyt + ~zod/try=> `@t`(scot %p ~pillyt) + '~pillyt' + ~zod/try=> (scot %ux 0x12) + ~.0x12 + ~zod/try=> `@t`(scot %ux 0x12) + '0x12' + ~zod/try=> (scot %if .127.0.0.1) + ~..127.0.0.1 + ~zod/try=> `@t`(scot %if .127.0.0.1) + '.127.0.0.1' + ~zod/try=> (scot %ta ~.asd_a) + ~.~.asd_a + ~zod/try=> `@t`(scot %ta ~.asd_a) + '~.asd_a' + +------------------------------------------------------------------------ + +### ++scow + +Render dime as tape + + ++ scow |=(mol=dime ~(rend co %$ mol)) + +Renders `mol` as a tape. + +`mol` is a [`++dime`](). + + ~zod/try=> (scow %p ~pillyt) + "~pillyt" + ~zod/try=> (scow %ux 0x12) + "0x12" + ~zod/try=> (scow %if .127.0.0.1) + ".127.0.0.1" + ~zod/try=> (scow %ta ~.asd_a) + "~.asd_a" + +------------------------------------------------------------------------ + +### ++slat + +Curried slaw + + ++ slat |=(mod=@tas |=(txt=@ta (slaw mod txt))) + +Produces a [`gate`]() that parses a [`term`]() `txt` to an atom of the +odor specified by `mod`. + +`mod` is a term, an atom of odor [`@tas`](). + +`txt` is a span, an atom of odor [`@ta`](). + + ~zod/try=> `(unit ,@p)`((slat %p) '~pillyt') + [~ ~pillyt] + ~zod/try=> `(unit ,@ux)`((slat %ux) '0x12') + [~ 0x12] + ~zod/try=> `(unit ,@if)`((slat %if) '.127.0.0.1') + [~ .127.0.0.1] + ~zod/try=> `(unit ,@ta)`((slat %ta) '~.asd_a') + [~ ~.asd_a + +------------------------------------------------------------------------ + +### ++slav + +Demand: parse span with input odor + + ++ slav |=([mod=@tas txt=@ta] (need (slaw mod txt))) + +Parses a span `txt` to an atom of the odor specificed by `mod`. Crashes +if it failes to parse. + +`mod` is a term, an atom of odor [`@tas`](). + +`txt` is a span, an atom of odor [`@ta`](). + + ~zod/try=> `@p`(slav %p '~pillyt') + ~pillyt + ~zod/try=> `@p`(slav %p '~pillam') + ! exit + ~zod/try=> `@ux`(slav %ux '0x12') + 0x12 + ~zod/try=> `@ux`(slav %ux '0b10') + ! exit + ~zod/try=> `@if`(slav %if '.127.0.0.1') + .127.0.0.1 + ~zod/try=> `@if`(slav %if '.fe80.0.0.202') + ! exit + ~zod/try=> `@ta`(slav %ta '~.asd_a') + ~.asd_a + ~zod/try=> `@ta`(slav %ta '~~asd-a') + ! exit + +------------------------------------------------------------------------ + +### ++slaw + +Parse span to input odor + + ++ slaw + |= [mod=@tas txt=@ta] + ^- (unit ,@) + =+ con=(slay txt) + ?.(&(?=([~ %$ @ @] con) =(p.p.u.con mod)) ~ [~ q.p.u.con]) + :: + +Parses a span `txt` to an atom of the odor specified by `mod`. + +`mod` is a term, an atom of odor [`@tas`](). + +`txt` is a span, an atom of odor [`@ta`](). + + ~zod/try=> `(unit ,@p)`(slaw %p '~pillyt') + [~ ~pillyt] + ~zod/try=> `(unit ,@p)`(slaw %p '~pillam') + ~ + ~zod/try=> `(unit ,@ux)`(slaw %ux '0x12') + [~ 0x12] + ~zod/try=> `(unit ,@ux)`(slaw %ux '0b10') + ~ + ~zod/try=> `(unit ,@if)`(slaw %if '.127.0.0.1') + [~ .127.0.0.1] + ~zod/try=> `(unit ,@if)`(slaw %if '.fe80.0.0.202') + ~ + ~zod/try=> `(unit ,@ta)`(slaw %ta '~.asd_a') + [~ ~.asd_a] + ~zod/try=> `(unit ,@ta)`(slaw %ta '~~asd-a') + ~ + +------------------------------------------------------------------------ + +### ++slay + +Parse span to coin + + ++ slay + |= txt=@ta ^- (unit coin) + =+ vex=((full nuck:so) [[1 1] (trip txt)]) + ?~ q.vex + ~ + [~ p.u.q.vex] + :: + +Parses a span `txt` to the unit of a [`++coin`](). + +`txt` is a [`@ta`](). + + ~zod/try=> (slay '~pillyt') + [~ [% p=[p=~.p q=32.819]]] + ~zod/try=> (slay '0x12') + [~ [% p=[p=~.ux q=18]]] + ~zod/try=> (slay '.127.0.0.1') + [~ [% p=[p=~.if q=2.130.706.433]]] + ~zod/try=> `@ud`.127.0.0.1 + 2.130.706.433 + ~zod/try=> (slay '._20_0w25_sam__') + [ ~ + [ %many + p=~[[% p=[p=~.ud q=20]] [% p=[p=~.uw q=133]] [% p=[p=~.tas q=7.168.371]]] + ] + ] + ~zod/try=> `@`%sam + 7.168.371 + ~zod/try=> (slay '~0ph') + [~ [%blob p=[1 1]]] + ~zod/try=> 0ph + ~ + ~zod/try=> ~0ph + [1 1] + ~zod/try=> `@uv`(jam [1 1]) + 0vph + +------------------------------------------------------------------------ + +------------------------------------------------------------------------ + +### ++smyt + +Render path as tank + + ++ smyt + |= bon=path ^- tank + :+ %rose [['/' ~] ['/' ~] ['/' ~]] + |- ^- (list tank) + (turn bon |=(a=@ [%leaf (rip 3 a)])) + +Renders the path `bon` as a [`tank`](), which is used for +pretty-printing. + +`bon` is a [`++path`](). + + ~zod/try=> (smyt %) + [ %rose + p=[p="/" q="/" r="/"] + q + ~[ [%leaf p="~zod"] + [%leaf p="try"] + [%leaf p="~2014.10.28..18.36.58..a280"] + ] + ] + ~zod/try=> (smyt /as/les/top) + [ %rose + p=[p="/" q="/" r="/"] + q=~[[%leaf p="as"] [%leaf p="les"] [%leaf p="top"]] + ] + +------------------------------------------------------------------------ + +### ++spat + +Render path as cord + + ++ spat |=(pax=path (crip (spud pax))) :: path to cord + +Renders a path `pax` as cord. + +`pax` is a [`path`](). + + ~zod/try=> (spat %) + '~zod/try/~2014.10.28..18.40.20..4287' + ~zod/try=> (spat %/bin) + '~zod/try/~2014.10.28..18.41.12..3bcd/bin' + ~zod/try=> (spat /as/les/top) + '/as/les/top' + +------------------------------------------------------------------------ + +### ++spud + +Render path as tape + + ++ spud |=(pax=path ~(ram re (smyt pax))) :: path to tape + +Renders a path `pax` as [tape](). + +`pax` is a [`path`](). + + ~zod/try=> (spud %) + "~zod/try/~2014.10.28..18.40.46..e951" + ~zod/try=> (spud %/bin) + "~zod/try/~2014.10.28..18.41.05..16f2/bin" + ~zod/try=> (spud /as/les/top) + "/as/les/top" + +------------------------------------------------------------------------ + +### ++stab + +Parse span to path + + ++ stab :: parse span to path + |= zep=@ta ^- path + (rash zep ;~(pfix fas ;~(sfix (more fas urs:ab) fas))) + +Parsing rule. Parses a span `zep` to a static [`++path`](). + + ~zod/try=> (stab '/as/lek/tor') + /as/lek/tor + ~zod/try=> `(pole ,@ta)`(stab '/as/lek/tor') + [~.as [~.lek [~.tor ~]]] + ~zod/try=> (stab '~zod/arvo/~2014.10.28..18.48.41..335f/zuse') + ~zod/arvo/~2014.10.28..18.48.41..335f/zuse + ~zod/try=> `(pole ,@ta)`(stab '~zod/arvo/~2014.10.28..18.48.41..335f/zuse') + [~.~zod [~.arvo [~.~2014.10.28..18.48.41..335f [~.zuse ~]]]] + ~zod/try=> (stab '/a/~pillyt/pals/1') + /a/~pillyt/pals/1 + ~zod/try=> `(pole ,@ta)`(stab '/a/~pillyt/pals/1') + [~.a [~.~pillyt [~.pals [~.1 ~]]]] diff --git a/docs/pub/doc/hoon/library/2em.md b/docs/pub/doc/hoon/library/2em.md new file mode 100644 index 0000000000..caec667ac6 --- /dev/null +++ b/docs/pub/doc/hoon/library/2em.md @@ -0,0 +1,758 @@ +section 2eM, regular-expressions +================================ + +### ++pars + + ++ pars + |= [a=tape] :: parse tape to rege + ^- (unit rege) + =+ foo=((full apex:rags) [[1 1] a]) + ?~ q.foo + ~ + [~ p.u.q.foo] + :: + +Parse regular expression + + ~zod/try=> (pars "samo") + [ ~ + [ %pair + p=[%lite p=~~s] + q=[%pair p=[%lite p=~~a] q=[%pair p=[%lite p=~~m] q=[%lite p=~~o]]] + ] + ] + ~zod/try=> (pars "so[,.0-9]") + [ ~ + [ %pair + p=[%lite p=~~s] + q=[%pair p=[%lite p=~~o] q=[%brac p=288.036.862.105.223.168]] + ] + ] + ~zod/try=> `@ub`288.036.862.105.223.168 + 0b11.1111.1111.0101.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000 + ~zod/try=> `@ub`(lsh 0 `@`'9' 1) + 0b10.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000 + ~zod/try=> `@ub`(roll (turn ",.0123456789" |=(a=@ (lsh 0 a 1))) con) + 0b11.1111.1111.0101.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000.0000 + ~zod/try=> (pars "sop.*") + [ ~ + [ %pair + p=[%lite p=~~s] + q=[%pair p=[%lite p=~~o] q=[%pair p=[%lite p=~~p] q=[%mant p=%dote]]] + ] + ] + ~zod/try=> (pars "(hel)?") + [ ~ + [ %eith + p + [ %capt + p=[%pair p=[%lite p=~~h] q=[%pair p=[%lite p=~~e] q=[%lite p=~~l]]] + q=0 + ] + q=%empt + ] + ] + ~zod/try=> (pars "(hel)??") + [ ~ + [ %eith + p=%empt + q + [ %capt + p=[%pair p=[%lite p=~~h] q=[%pair p=[%lite p=~~e] q=[%lite p=~~l]]] + q=0 + ] + ] + ] + ~zod/try=> (pars "a\{1,20}") + [~ [%betw p=[%lite p=~~a] q=1 r=20]] + +### ++rags + + ++ rags :: rege parsers + => |% + +Regex parser arms + +### ++nor + + ++ nor ;~(less (mask "^$()|*?+.[\\") (shim 1 127)) :: non-control char + +XX document + +### ++les + + ++ les ;~(less bas asp) :: not backslash + +XX document + +### ++lep + + ++ lep ;~(less (mask "^[]\\") asp) :: charset non-control + +XX document + +### ++asp + + ++ asp (shim 32 126) :: printable ascii + +XX document + +### ++alb + + ++ alb ;~(less ser asp) :: charset literal char + +XX document + +### ++mis + + ++ mis ;~(less aln asp) :: non alphanumeric + -- + |% + +XX document + +### ++apex + + ++ apex :: top level + %+ knee *rege |. ~+ + ;~ pose + ;~((bend |=(a=[rege rege] (some [%eith a]))) mall ;~(pfix bar apex)) + (stag %eith ;~(plug (easy %empt) ;~(pfix bar apex))) + (easy %empt) + == + :: + +XX document + +### ++mall + + ++ mall + %+ knee *rege |. ~+ + ;~((bend |=(a=[rege rege] (some [%pair a]))) bets mall) + :: + +XX document + +### ++bets + + ++ bets + %+ knee *rege |. ~+ + |= tub=nail + =+ vex=(chun tub) + ?~ q.vex + vex + =+ a=p.u.q.vex + %- ;~ pose + (cold [%eith %empt a] (jest '??')) + (cold [%manl a] (jest '*?')) + (cold [%plll a] (jest '+?')) + (cold [%eith a %empt] wut) + (cold [%mant a] tar) + (cold [%plls a] lus) + (stag %betl ;~(plug (easy a) ;~(sfix rang wut))) + (stag %betw ;~(plug (easy a) rang)) + (stag %binl ;~(plug (easy a) (ifix [kel (jest ',}?')] dim:ag))) + (stag %bant ;~(plug (easy a) (ifix [kel (jest '}?')] dim:ag))) + (stag %bant ;~(plug (easy a) (ifix [kel ker] dim:ag))) + (stag %bint ;~(plug (easy a) (ifix [kel (jest ',}')] dim:ag))) + (easy a) + == + q.u.q.vex + :: + +XX document + +### ++ranc + + ++ ranc + |= [a=@ b=@] + ^- @ + ?:((gth a b) 0 (con (bex a) $(a +(a)))) + :: + +XX document + +### ++flap + + ++ flap |=(a=@ (mix a (dec (bex 256)))) + :: + +XX document + +### ++rang + + ++ rang + %+ sear |=([a=@ b=@] ?:((lte a b) (some [a b]) ~)) + (ifix [kel ker] ;~(plug dim:ag ;~(pfix com dim:ag))) + :: + +XX document + +### ++chun + + ++ chun + %+ knee *rege |. ~+ + ;~ pose + (cold %ende buc) + (cold %sart ket) + (cold %dote dot) + %+ cook |=(a=(list char) (reel a |=([p=char q=rege] [%pair [%lite p] q]))) + ;~(pfix (jest '\\Q') cape) + |= tub=nail + =+ foo=;~(plug kel dim:ag ;~(pose ker (jest ',}') ;~(plug com dim:ag ker))) + =+ bar=(foo tub) + ?~(q.bar (chad tub) (fail tub)) + (cook |=([a=rege] [%capt a 0]) (ifix [pel per] apex)) + %+ cook |=([a=rege] [%capt a 0]) + (ifix [;~(plug (jest '(?P<') (plus aln) gar) per] apex) + (ifix [(jest '(?:') per] apex) + (stag %brac ;~(pfix sel seac)) + == + :: + +XX document + +### ++seac + + ++ seac + |= tub=nail + ?~ q.tub + (fail tub) + ?: =(i.q.tub '^') + (;~(pfix ket (cook flap sead)) tub) + (sead tub) + :: + +XX document + +### ++sead + + ++ sead + %+ knee *@ |. ~+ + ;~ pose + |= tub=nail + ?~ q.tub + (fail tub) + ?. =(i.q.tub ']') + (fail tub) + ?~ t.q.tub + (fail tub) + ?: =(i.t.q.tub '-') + ?~ t.t.q.tub + (fail tub) + ?: =(i.t.t.q.tub ']') + (;~(pfix ser (cook |=(a=@ (con (bex ']') a)) sade)) tub) + (fail tub) + (;~(pfix ser (cook |=(a=@ (con (bex ']') a)) sade)) tub) + |= tub=nail + ?~ q.tub + (fail tub) + ?. =(i.q.tub '-') + (fail tub) + ?~ t.q.tub + (fail tub) + ?: =(i.t.q.tub '-') + ?~ t.t.q.tub + (fail tub) + ?: =(i.t.t.q.tub ']') + (;~(pfix hep (cook |=(a=@ (con (bex '-') a)) sade)) tub) + (fail tub) + (;~(pfix hep (cook |=(a=@ (con (bex '-') a)) sade)) tub) + (cook |=(a=[@ @] (con a)) ;~(plug seap sade)) + == + :: + +XX document + +### ++sade + + ++ sade + %+ knee *@ |. ~+ + ;~ pose + (cold (bex '-') (jest '-]')) + (cold 0 ser) + (cook |=([p=@ q=@] `@`(con p q)) ;~(plug seap sade)) + == + :: + +XX document + +### ++seap + + ++ seap + %+ knee *@ |. ~+ + ;~ pose + unid + %+ ifix (jest '[:')^(jest ':]') + ;~(pose ;~(pfix ket (cook flap chas)) chas) + %+ sear |=([a=@ b=@] ?:((gth a b) ~ (some (ranc a b)))) + ;~(plug asp ;~(pfix hep alb)) + |= tub=nail + ?~ q.tub + (fail tub) + ?~ t.q.tub + ((cook bex les) tub) + ?: =(i.t.q.tub '-') + ?~ t.t.q.tub + ((cook bex les) tub) + ?: =(i.t.t.q.tub ']') + ((cook bex les) tub) + (fail tub) + ((cook bex les) tub) + ;~(pfix bas escd) + == + :: + +XX document + +### ++cape + + ++ cape + %+ knee *tape |. ~+ + ;~ pose + (cold ~ (jest '\\E')) + ;~(plug next cape) + (cook |=(a=char (tape [a ~])) next) + (full (easy ~)) + == + +XX document + +### ++chas + + ++ chas :: ascii character set + =- (sear ~(get by -) sym) + %- mo ^- (list ,[@tas @I]) + :~ alnum/alnum alpha/alpha ascii/ascii blank/blank cntrl/cntrl + digit/digit graph/graph lower/lower print/print punct/punct + space/space upper/upper word/wordc xdigit/xdigit + == + :: Character sets + +++ alnum :(con lower upper digit) + + + XX document + + ###++alpha + +++ alpha :(con lower upper) + + + XX document + + ###++ascii + +++ ascii (ranc 0 127) + + + ++ blank (con (bex 32) (bex 9)) + +XX document + +### ++cntrl + + ++ cntrl :(con (ranc 0 31) (bex 127)) + +XX document + +### ++digit + + ++ digit (ranc '0' '9') + +XX document + +### ++graph + + ++ graph (ranc 33 126) + +XX document + +### ++lower + + ++ lower (ranc 'a' 'z') + +XX document + +### ++print + + ++ print (ranc 32 126) + +XX document + +### ++punct + + ++ punct ;: con + (ranc '!' '/') + (ranc ':' '@') + (ranc '[' '`') + (ranc '{' '~') + == + +XX document + +### ++space + + ++ space :(con (ranc 9 13) (bex ' ')) + +XX document + +### ++upper + + ++ upper (ranc 'A' 'Z') + +XX document + +### ++white + + ++ white :(con (bex ' ') (ranc 9 10) (ranc 12 13)) + +XX document + +### ++wordc + + ++ wordc :(con digit lower upper (bex '_')) + +XX document + +### ++xdigit + + ++ xdigit :(con (ranc 'a' 'f') (ranc 'A' 'F') digit) + :: + +XX document + +### ++chad + + ++ chad + %+ knee *rege |. ~+ + ;~(pose (stag %lite nor) (stag %brac unid) ;~(pfix bas escp)) + :: + +XX document + +### ++escd + + ++ escd + %+ knee *@ |. ~+ + ;~ pose + (cold (bex 7) (just 'a')) + (cold (bex 9) (just 't')) + (cold (bex 10) (just 'n')) + (cold (bex 11) (just 'v')) + (cold (bex 12) (just 'f')) + (cold (bex 13) (just 'r')) + (cold (bex 0) (just '0')) + (sear |=(a=@ ?:((lth a 256) (some (bex a)) ~)) (bass 8 (stun [2 3] cit))) + (cook bex ;~(pfix (just 'x') (bass 16 (stun [2 2] hit)))) + (cook bex (ifix [(jest 'x{') ker] (bass 16 (stun [2 2] hit)))) + (cook bex mis) + == + :: + +XX document + +### ++escp + + ++ escp + %+ knee *rege |. ~+ + ;~ pose + (cold %empt (just 'Q')) + (cold [%lite `@tD`0] (just '0')) + (cold [%lite `@tD`7] (just 'a')) + (cold [%lite `@tD`9] (just 't')) + (cold [%lite `@tD`10] (just 'n')) + (cold [%lite `@tD`11] (just 'v')) + (cold [%lite `@tD`12] (just 'f')) + (cold [%lite `@tD`13] (just 'r')) + (sear |=(a=@ ?:((lth a 256) (some [%lite a]) ~)) (bass 8 (stun [2 3] cit))) + (stag %lite ;~(pfix (just 'x') (bass 16 (stun [2 2] hit)))) + (stag %lite (ifix [(jest 'x{') ker] (bass 16 (stun [2 2] hit)))) + (cold %dote (just 'C')) + (cold %sart (just 'A')) + (cold %ende (just 'z')) + (cold %boun (just 'b')) + (cold %bout (just 'B')) + (stag %brac (cold wordc (just 'w'))) + (stag %brac (cold (flap wordc) (just 'W'))) + (stag %lite mis) + == + :: + +XX document + +### ++unid + + ++ unid + %+ knee *@ |. ~+ + ;~ pose + (cold digit (jest '\\d')) + (cold (flap digit) (jest '\\D')) + (cold white (jest '\\s')) + (cold (flap white) (jest '\\S')) + (cold wordc (jest '\\w')) + (cold (flap wordc) (jest '\\W')) + == + -- + :: + +XX document + +### ++ra + + ++ ra :: regex engine + |_ a=rege + +XX document + +### ++proc + + ++ proc :: capture numbering + |= b=@ + =- -(+ +>.$(a a)) + ^- [p=@ a=rege] + ?- a + [%capt *] =+ foo=$(a p.a, b +(b)) + [p.foo [%capt a.foo b]] + [%eith *] =+ foo=$(a p.a) + =+ bar=$(a q.a, b p.foo) + [p.bar [%eith a.foo a.bar]] + [%pair *] =+ foo=$(a p.a) + =+ bar=$(a q.a, b p.foo) + [p.bar [%pair a.foo a.bar]] + [%manl *] =+ foo=$(a p.a) + [p.foo [%manl a.foo]] + [%plll *] =+ foo=$(a p.a) + [p.foo [%plll a.foo]] + [%binl *] =+ foo=$(a p.a) + [p.foo [%binl a.foo q.a]] + [%betl *] =+ foo=$(a p.a) + [p.foo [%betl a.foo q.a r.a]] + [%mant *] =+ foo=$(a p.a) + [p.foo [%mant a.foo]] + [%plls *] =+ foo=$(a p.a) + [p.foo [%plls a.foo]] + [%bant *] =+ foo=$(a p.a) + [p.foo [%bant a.foo q.a]] + [%bint *] =+ foo=$(a p.a) + [p.foo [%bint a.foo q.a]] + [%betw *] =+ foo=$(a p.a) + [p.foo [%betw a.foo q.a r.a]] + * [b a] + == + :: + +XX document + +### ++cont + + ++ cont + |= [a=(map ,@u tape) b=(map ,@u tape)] + (~(gas by _(map ,@u tape)) (weld (~(tap by a)) (~(tap by b)))) + :: + +XX document + +### ++abor + + ++ abor + |= [a=char b=(unit ,[tape (map ,@u tape)])] + ^- (unit ,[tape (map ,@u tape)]) + ?~ b + b + [~ [[a -.u.b] +.u.b]] + :: + +XX document + +### ++matc + + ++ matc + |= [b=tape c=tape] + ^- (unit (map ,@u tape)) + =+ foo=`(unit ,[tape (map ,@u tape)])`(deep b %empt c) + (bind foo |*(a=^ (~(put by +.a) 0 -.a))) + :: + +XX document + +### ++chet + + ++ chet + |= [b=(unit ,[tape (map ,@u tape)]) c=tape d=tape] + ^- (unit ,[tape (map ,@u tape)]) + ?~ b + b + ?~ -.u.b + b + =+ bar=(deep (slag (lent -.u.b) c) %empt d) + ?~ bar + bar + b + +XX document + +### ++blak + + ++ blak (some ["" _(map ,@u tape)]) + +XX document + +### ++word + + ++ word |=(a=char =((dis wordc:rags (bex a)) 0)) + +XX document + +### ++deep + + ++ deep + |= [b=tape c=rege d=tape] + ^- (unit ,[tape (map ,@u tape)]) + ?- a + %dote ?~(b ~ (some [[i.b ~] _(map ,@u tape)])) + %ende ?~(b blak ~) + %sart ?:(=(b d) blak ~) + %empt blak + %boun =+ ^= luc + ?: =(b d) + & + =+ foo=(slag (dec (sub (lent d) (lent b))) d) + (word -.foo) + =+ cuc=?~(b & (word -.b)) + ?:(!=(luc cuc) blak ~) + %bout =+ ^= luc + ?: =(b d) + & + =+ foo=(slag (dec (sub (lent d) (lent b))) d) + (word -.foo) + =+ cuc=?~(b & (word -.b)) + ?:(=(luc cuc) blak ~) + [%capt *] =+ foo=$(a p.a) + ?~ foo + foo + =+ ft=u.foo + =+ bar=$(a c, b (slag (lent -.ft) b), c %empt) + ?~ bar + bar + [~ [-.ft (~(put by +.ft) q.a -.ft)]] + [%lite *] ?~(b ~ ?:(=(i.b p.a) (some [[i.b ~] _(map ,@u tape)]) ~)) + [%brac *] ?~ b + ~ + ?. =((dis (bex `@`i.b) p.a) 0) + (some [[i.b ~] _(map ,@u tape)]) + ~ + [%eith *] =+ foo=(chet(a c) $(a p.a) b d) + =+ bar=(chet(a c) $(a q.a) b d) + ?~ foo + bar + ?~ bar + foo + =+ ft=u.foo + =+ bt=u.bar + ?: (gte (lent -.ft) (lent -.bt)) + foo + bar + [%pair *] =+ foo=$(a p.a, c [%pair q.a c]) + ?~ foo + foo + =+ ft=u.foo + =+ bar=$(a q.a, b (slag (lent -.ft) b)) + ?~ bar + bar + =+ bt=u.bar + [~ [(weld -.ft -.bt) (cont +.ft +.bt)]] + [%manl *] =+ foo=$(a p.a) + ?~ foo + blak + ?~ -.u.foo + blak + $(a [%eith %empt [%pair p.a [%eith %empt a]]]) + [%mant *] =+ foo=$(a p.a) + ?~ foo + blak + =+ ft=u.foo + ?~ -.ft + blak + $(a [%eith [%pair p.a [%eith a %empt]] %empt]) + [%plls *] $(a [%pair p.a [%mant p.a]]) + [%plll *] $(a [%pair p.a [%manl p.a]]) + [%binl *] =+ min=?:(=(q.a 0) 0 (dec q.a)) + ?: =(q.a 0) + $(a [%manl p.a]) + $(a [%pair p.a [%binl p.a min]]) + [%bant *] ?: =(0 q.a) + blak + $(a [%pair p.a [%bant p.a (dec q.a)]]) + [%bint *] =+ min=?:(=(q.a 0) 0 (dec q.a)) + ?: =(q.a 0) + $(a [%mant p.a]) + $(a [%pair p.a [%bint p.a min]]) + [%betw *] ?: =(0 r.a) + blak + ?: =(q.a 0) + $(a [%eith [%pair p.a [%betw p.a 0 (dec r.a)]] %empt]) + $(a [%pair p.a [%betw p.a (dec q.a) (dec r.a)]]) + [%betl *] ?: =(0 r.a) + blak + ?: =(q.a 0) + $(a [%eith %empt [%pair p.a [%betl p.a 0 (dec r.a)]]]) + $(a [%pair p.a [%betl p.a (dec q.a) (dec r.a)]]) + == + -- + :: + +XX document + +### ++rexp + + ++ rexp :: Regex match + ~/ %rexp + |= [a=tape b=tape] + ^- (unit (unit (map ,@u tape))) + =+ ^= bar + |= [a=@ b=(map ,@u tape)] + ?: =(a 0) + b + =+ c=(~(get by b) a) + ?~ c + $(a (dec a), b (~(put by b) a "")) + $(a (dec a)) + =+ par=(pars a) + ?~ par ~ + =+ poc=(~(proc ra u.par) 1) + =+ c=b + |- + =+ foo=(matc:poc c b) + ?~ foo + ?~ c + [~ ~] + $(c t.c) + [~ [~ (bar (dec p.poc) u.foo)]] + :: + +XX document + +### ++repg + + ++ repg :: Global regex replace + ~/ %repg + |= [a=tape b=tape c=tape] + ^- (unit tape) + =+ par=(pars a) + ?~ par ~ + =+ poc=(~(proc ra u.par) 1) + =+ d=b + :- ~ + |- + ^- tape + =+ foo=(matc:poc d b) + ?~ foo + ?~ d + ~ + [i.d $(d t.d)] + =+ ft=(need (~(get by u.foo) 0)) + ?~ d + c + (weld c $(d `tape`(slag (lent ft) `tape`d))) + :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/docs/pub/doc/hoon/library/2en.md b/docs/pub/doc/hoon/library/2en.md new file mode 100644 index 0000000000..c9c9445ac5 --- /dev/null +++ b/docs/pub/doc/hoon/library/2en.md @@ -0,0 +1,257 @@ +section 2eN, pseudo-cryptography +================================ + +### ++un + +Reversible scrambling core + + ++ un :: =(x (wred (wren x))) + |% + +A core that contains arms that perform reversible scrambling operations. +Used in the `@p` phonetic base. + +------------------------------------------------------------------------ + +### ++wren + +Conceal structure + + ++ wren :: conceal structure + |= pyn=@ ^- @ + =+ len=(met 3 pyn) + ?: =(0 len) + 0 + => .(len (dec len)) + =+ mig=(zaft (xafo len (cut 3 [len 1] pyn))) + %+ can 3 + %- flop ^- (list ,[@ @]) + :- [1 mig] + |- ^- (list ,[@ @]) + ?: =(0 len) + ~ + => .(len (dec len)) + =+ mog=(zyft :(mix mig (end 3 1 len) (cut 3 [len 1] pyn))) + [[1 mog] $(mig mog)] + :: + +Scrambles a bytestring `pyn` by adding the current position to each +byte, looking it up in an s-box, and then performing the XOR operation +on the result, pushing it forward. Produces an atom. + +`pyn` is an [atom](). + + ~zod/try=> `@ux`(wren:un 'testing') + 0x30.bf6a.b9fe.7d8f + ~zod/try=> `@ux`'testing' + 0x67.6e69.7473.6574 + ~zod/try=> `@da`(wred:un (wren:un ~2001.2.5)) + ~2001.2.5 + +------------------------------------------------------------------------ + +### ++wred + +Restore structure + + ++ wred :: restore structure + |= cry=@ ^- @ + =+ len=(met 3 cry) + ?: =(0 len) + 0 + => .(len (dec len)) + =+ mig=(cut 3 [len 1] cry) + %+ can 3 + %- flop ^- (list ,[@ @]) + :- [1 (xaro len (zart mig))] + |- ^- (list ,[@ @]) + ?: =(0 len) + ~ + => .(len (dec len)) + =+ mog=(cut 3 [len 1] cry) + [[1 :(mix mig (end 3 1 len) (zyrt mog))] $(mig mog)] + :: + +Unscrambles a bytestring `cry` by subtracting the current position from +each byte, looking it up in an s-box, and performing the XOR operation +on the result, pushing it forward. Produces an atom. + +`cry` is an [atom](). + + ~zod/try=> (wred:un 0x30.bf6a.b9fe.7d8f) + 29.113.321.805.538.676 + ~zod/try=> `@t`(wred:un 0x30.bf6a.b9fe.7d8f) + 'testing' + ~zod/try=> (wred:un (wren:un 200.038.426)) + 200.038.426 + +------------------------------------------------------------------------ + +### ++xafo + +Add modulo 255 + + ++ xafo |=([a=@ b=@] +((mod (add (dec b) a) 255))) + +Produces the sum of two atoms modulo 255, encoded as a nonzero byte. + + ~zod/try=> (xafo:un 5 6) + 11 + ~zod/try=> (xafo:un 256 20) + 21 + +------------------------------------------------------------------------ + +### ++xaro + +Subtract modulo 255 + + ++ xaro |=([a=@ b=@] +((mod (add (dec b) (sub 255 (mod a 255))) 255))) + +Produces the difference between two atoms modulo 255, encoded as a +nonzero byte. + + ~zod/try=> (xaro:un 17 57) + 40 + ~zod/try=> (xaro:un 265 12) + 2 + +------------------------------------------------------------------------ + +### ++zaft + +Look up in 255 sub box + + ++ zaft :: forward 255-sbox + |= a=@D + =+ ^= b + 0xcc.75bc.86c8.2fb1.9a42.f0b3.79a0.92ca.21f6.1e41.cde5.fcc0. + 7e85.51ae.1005.c72d.1246.07e8.7c64.a914.8d69.d9f4.59c2.8038. + 1f4a.dca2.6fdf.66f9.f561.a12e.5a16.f7b0.a39f.364e.cb70.7318. + 1de1.ad31.63d1.abd4.db68.6a33.134d.a760.edee.5434.493a.e323. + 930d.8f3d.3562.bb81.0b24.43cf.bea5.a6eb.52b4.0229.06b2.6704. + 78c9.45ec.d75e.58af.c577.b7b9.c40e.017d.90c3.87f8.96fa.1153. + 0372.7f30.1c32.ac83.ff17.c6e4.d36d.6b55.e2ce.8c71.8a5b.b6f3. + 9d4b.eab5.8b3c.e7f2.a8fe.9574.5de0.bf20.3f15.9784.9939.5f9c. + e609.564f.d8a4.b825.9819.94aa.2c08.8e4c.9b22.477a.2840.3ed6. + 3750.6ef1.44dd.89ef.6576.d00a.fbda.9ed2.3b6c.7b0c.bde9.2ade. + 5c88.c182.481a.1b0f.2bfd.d591.2726.57ba + (cut 3 [(dec a) 1] b) + :: + +The inverse of [`++zaft](). Looks up a nonzero byte`a\` in a substiution +box with 255 values, producing a unique nonzero byte. + +`a` is an [atom]() of one byte in length. + + ~zod/try=> (zaft:un 0x12) + 42 + ~zod/try=> (zaft:un 0xff) + 204 + ~zod/try=> (zaft:un 0x0) + ! decrement-underflow + ! exit + +------------------------------------------------------------------------ + +### ++zart + +Reverse look up in 255 sub box + + ++ zart :: reverse 255-sbox + |= a=@D + =+ ^= b + 0x68.4f07.ea1c.73c9.75c2.efc8.d559.5125.f621.a7a8.8591.5613. + dd52.40eb.65a2.60b7.4bcb.1123.ceb0.1bd6.3c84.2906.b164.19b3. + 1e95.5fec.ffbc.f187.fbe2.6680.7c77.d30e.e94a.9414.fd9a.017d. + 3a7e.5a55.8ff5.8bf9.c181.e5b6.6ab2.35da.50aa.9293.3bc0.cdc6. + f3bf.1a58.4130.f844.3846.744e.36a0.f205.789e.32d8.5e54.5c22. + 0f76.fce7.4569.0d99.d26e.e879.dc16.2df4.887f.1ffe.4dba.6f5d. + bbcc.2663.1762.aed7.af8a.ca20.dbb4.9bc7.a942.834c.105b.c4d4. + 8202.3e61.a671.90e6.273d.bdab.3157.cfa4.0c2e.df86.2496.f7ed. + 2b48.2a9d.5318.a343.d128.be9c.a5ad.6bb5.6dfa.c5e1.3408.128d. + 2c04.0339.97a1.2ff0.49d0.eeb8.6c0a.0b37.b967.c347.d9ac.e072. + e409.7b9f.1598.1d3f.33de.8ce3.8970.8e7a + (cut 3 [(dec a) 1] b) + :: + +The inverse of [`++zaft`](). Looks up the index of a nonzero byte `a` in +the substitution box with 255 values, producing a unique nonzero byte. + +`a` is an [atom]() of one byte in length. + + ~zod/try=> `@ux`(zart:un 204) + 0xff + ~zod/try=> `@ux`(zart:un 42) + 0x12 + +------------------------------------------------------------------------ + +### ++zyft + +Lookup byte in 256 sub box + + ++ zyft :: forward 256-sbox + |= a=@D + =+ ^= b + 0xbb49.b71f.b881.b402.17e4.6b86.69b5.1647.115f.dddb.7ca5. + 8371.4bd5.19a9.b092.605d.0d9b.e030.a0cc.78ba.5706.4d2d. + 986a.768c.f8e8.c4c7.2f1c.effe.3cae.01c0.253e.65d3.3872. + ce0e.7a74.8ac6.daac.7e5c.6479.44ec.4143.3d20.4af0.ee6c. + c828.deca.0377.249f.ffcd.7b4f.eb7d.66f2.8951.042e.595a. + 8e13.f9c3.a79a.f788.6199.9391.7fab.6200.4ce5.0758.e2f1. + 7594.c945.d218.4248.afa1.e61a.54fb.1482.bea4.96a2.3473. + 63c2.e7cb.155b.120a.4ed7.bfd8.b31b.4008.f329.fca3.5380. + 9556.0cb2.8722.2bea.e96e.3ac5.d1bc.10e3.2c52.a62a.b1d6. + 35aa.d05e.f6a8.0f3b.31ed.559d.09ad.f585.6d21.fd1d.8d67. + 370b.26f4.70c1.b923.4684.6fbd.cf8b.5036.0539.9cdc.d93f. + 9068.1edf.8f33.b632.d427.97fa.9ee1 + (cut 3 [a 1] b) + :: + +The inverse of [`++zyrt`](). Looks up a byte `a` in a substituion box +with 256 values, producing a byte. + +`a` is an [atom]() of one byte in length. + + ~zod/try=> (zyft:un 0x12) + 57 + ~zod/try=> (zyft:un 0x0) + 225 + ~zod/try=> (zyft:un 0xff) + 187 + +------------------------------------------------------------------------ + +### ++zyrt + +Reverse lookup byte in 256 sub box + + ++ zyrt :: reverse 256-sbox + |= a=@D + =+ ^= b + 0x9fc8.2753.6e02.8fcf.8b35.2b20.5598.7caa.c9a9.30b0.9b48. + 47ce.6371.80f6.407d.00dd.0aa5.ed10.ecb7.0f5a.5c3a.e605. + c077.4337.17bd.9eda.62a4.79a7.ccb8.44cd.8e64.1ec4.5b6b. + 1842.ffd8.1dfb.fd07.f2f9.594c.3be3.73c6.2cb6.8438.e434. + 8d3d.ea6a.5268.72db.a001.2e11.de8c.88d3.0369.4f7a.87e2. + 860d.0991.25d0.16b9.978a.4bf4.2a1a.e96c.fa50.85b5.9aeb. + 9dbb.b2d9.a2d1.7bba.66be.e81f.1946.29a8.f5d2.f30c.2499. + c1b3.6583.89e1.ee36.e0b4.6092.937e.d74e.2f6f.513e.9615. + 9c5d.d581.e7ab.fe74.f01b.78b1.ae75.af57.0ec2.adc7.3245. + 12bf.2314.3967.0806.31dc.cb94.d43f.493c.54a6.0421.c3a1. + 1c4a.28ac.fc0b.26ca.5870.e576.f7f1.616d.905f.ef41.33bc. + df4d.225e.2d56.7fd6.1395.a3f8.c582 + (cut 3 [a 1] b) + +The inverse of [`++zyft`](). Looks up a byte `a` in a substituion box +with 256 values, producing a byte. + +`a` is an [atom]() of one byte in length. + + ~zod/try=> `@ux`(zyrt:un 57) + 0x12 + ~zod/try=> `@ux`(zyrt:un 225) + 0x0 + ~zod/try=> `@ux`(zyrt:un 187) + 0xff diff --git a/docs/pub/doc/hoon/library/2eo.md b/docs/pub/doc/hoon/library/2eo.md new file mode 100644 index 0000000000..ca9a54f459 --- /dev/null +++ b/docs/pub/doc/hoon/library/2eo.md @@ -0,0 +1,453 @@ +section 2eO, virtualization +=========================== + +### ++mack + +Nock subject to unit + + ++ mack + |= [sub=* fol=*] + ^- (unit) + =+ ton=(mink [sub fol] |=(* ~)) + ?.(?=([0 *] ton) ~ [~ p.ton]) + :: + +Accepts a nock subject-formula cell and wraps it into a [`++unit`](). +`fol` is pure nock, meaning that nock `11` operations result in a block, +producing a `~`. + +`sub` is a subject [noun](). + +`fol` is a formula [noun](), which is generally a `++nock`. + + ~zod/try=> (mack [[1 2 3] [0 1]]) + [~ [1 2 3]] + ~zod/try=> (mack [41 4 0 1]) + [~ 42] + ~zod/try=> (mack [4 0 4]) + ~ + ~zod/try=> (mack [[[0 2] [1 3]] 4 4 4 4 0 5]) + [~ 6] + ~zod/try=> ;;((unit ,@tas) (mack [[1 %yes %no] 6 [0 2] [0 6] 0 7])) + [~ %no] + +------------------------------------------------------------------------ + +### ++mink + +Mock interpreter + + ++ mink + ~/ %mink + |= [[sub=* fol=*] sky=$+(* (unit))] + =+ tax=*(list ,[@ta *]) + |- ^- tone + ?@ fol + [%2 tax] + ?: ?=(^ -.fol) + =+ hed=$(fol -.fol) + ?: ?=(%2 -.hed) + hed + =+ tal=$(fol +.fol) + ?- -.tal + %0 ?-(-.hed %0 [%0 p.hed p.tal], %1 hed) + %1 ?-(-.hed %0 tal, %1 [%1 (weld p.hed p.tal)]) + %2 tal + == + ?+ fol + [%2 tax] + :: + [0 b=@] + ?: =(0 b.fol) [%2 tax] + ?: =(1 b.fol) [%0 sub] + ?: ?=(@ sub) [%2 tax] + =+ [now=(cap b.fol) lat=(mas b.fol)] + $(b.fol lat, sub ?:(=(2 now) -.sub +.sub)) + :: + [1 b=*] + [%0 b.fol] + :: + [2 b=[^ *]] + =+ ben=$(fol b.fol) + ?. ?=(%0 -.ben) ben + ?>(?=(^ p.ben) $(sub -.p.ben, fol +.p.ben)) + ::?>(?=(^ p.ben) $([sub fol] p.ben) + :: + [3 b=*] + =+ ben=$(fol b.fol) + ?. ?=(%0 -.ben) ben + [%0 .?(p.ben)] + :: + [4 b=*] + =+ ben=$(fol b.fol) + ?. ?=(%0 -.ben) ben + ?. ?=(@ p.ben) [%2 tax] + [%0 .+(p.ben)] + :: + [5 b=*] + =+ ben=$(fol b.fol) + ?. ?=(%0 -.ben) ben + ?. ?=(^ p.ben) [%2 tax] + [%0 =(-.p.ben +.p.ben)] + :: + [6 b=* c=* d=*] + $(fol =>(fol [2 [0 1] 2 [1 c d] [1 0] 2 [1 2 3] [1 0] 4 4 b])) + :: + [7 b=* c=*] $(fol =>(fol [2 b 1 c])) + [8 b=* c=*] $(fol =>(fol [7 [[0 1] b] c])) + [9 b=* c=*] $(fol =>(fol [7 c 0 b])) + [10 @ c=*] $(fol c.fol) + [10 [b=* c=*] d=*] + =+ ben=$(fol c.fol) + ?. ?=(%0 -.ben) ben + ?: ?=(?(%hunk %lose %mean %spot) b.fol) + $(fol d.fol, tax [[b.fol p.ben] tax]) + $(fol d.fol) + :: + [11 b=*] + =+ ben=$(fol b.fol) + ?. ?=(%0 -.ben) ben + =+ val=(sky p.ben) + ?~(val [%1 p.ben ~] [%0 u.val]) + :: + == + :: + +Bottom-level [mock]() (virtual nock) interpreter. Produces a +[`++tone`](), a nock computation result. If nock 11 is invoked, `sky` +computes on the subject and produces a [`++unit`]() result. An empty +result becomes a `%1` `++tone`, indicating a block. + +`sub` is the subject as a [noun](). + +`fol` is the formula as a [noun](). + +`sky` is an [`%iron`]() gate invoked with [nock operator 11](). + + ~zod/try=> (mink [20 [4 0 1]] ,~) + [%0 p=21] + ~zod/try=> (mink [[90 5 3] [0 3]] ,~) + [%0 p=[5 3]] + ~zod/try=> (mink 20^[4 0 1] ,~) + [%0 p=21] + ~zod/try=> (mink [90 5 3]^[0 3] ,~) + [%0 p=[5 3]] + ~zod/try=> (mink [0]^[11 1 20] ,~) + [%1 p=~[20]] + ~zod/try=> (mink [0]^[11 1 20] |=(a=* `[40 a])) + [%0 p=[40 20]] + ~zod/try=> (mink [5]^[0 2] ,~) + [%2 p=~] + ~zod/try=> (mink [5]^[10 yelp/[0 1] 0 0] ,~) + [%2 p=~[[~.yelp 5]]] + +------------------------------------------------------------------------ + +### ++mock + +Compute formula on subject with hint + + ++ mock + |= [[sub=* fol=*] sky=$+(* (unit))] + (mook (mink [sub fol] sky)) + :: + +Produces a [`++toon`](), which is either a sucessful, blocked, or +crashed result. If nock 11 is invoked, `sky` computes on the subject and +produces a [`++unit`]() result. An empty result becomes a `%1` `++tune`, +indicating a block. + +`sub` is the subject as a [noun](). + +`fol` is the formula as a [noun](). + +`sky` is an [%iron]() gate invoked with [nock operator 11](). + + ~zod/try=> (mock [5 4 0 1] ,~) + [%0 p=6] + ~zod/try=> (mock [~ 11 1 0] |=(* `999)) + [%0 p=999] + ~zod/try=> (mock [~ 0 1.337] ,~) + [%2 p=~] + ~zod/try=> (mock [~ 11 1 1.337] ,~) + [%1 p=~[1.337]] + ~zod/try=> (mock [[[4 4 4 4 0 3] 10] 11 9 2 0 1] |=(* `[+<])) + [%0 p=14] + ~zod/try=> (mock [[[4 4 4 4 0 3] 10] 11 9 2 0 1] |=(* `[<+<>])) + [%0 p=[49 52 0]] + ~zod/try=> ;;(tape +:(mock [[[4 4 4 4 0 3] 10] 11 9 2 0 1] |=(* `[<+<>]))) + "14" + +------------------------------------------------------------------------ + +### ++mook + +Intelligently render crash annotation + + ++ mook + |= ton=tone + ^- toon + ?. ?=([2 *] ton) ton + :- %2 + =+ yel=(lent p.ton) + =. p.ton + ?. (gth yel 256) p.ton + %+ weld + (scag 128 p.ton) + ^- (list ,[@ta *]) + :_ (slag (sub yel 128) p.ton) + :- %lose + %+ rap 3 + ;: weld + "[skipped " + ~(rend co %$ %ud (sub yel 256)) + " frames]" + == + |- ^- (list tank) + ?~ p.ton ~ + =+ rex=$(p.ton t.p.ton) + ?+ -.i.p.ton rex + %hunk [(tank +.i.p.ton) rex] + %lose [[%leaf (rip 3 (,@ +.i.p.ton))] rex] + %mean :_ rex + ?@ +.i.p.ton [%leaf (rip 3 (,@ +.i.p.ton))] + =+ mac=(mack +.i.p.ton +<.i.p.ton) + ?~(mac [%leaf "####"] (tank u.mac)) + %spot :_ rex + =+ sot=(spot +.i.p.ton) + :- %leaf + ;: weld + ~(ram re (smyt p.sot)) + ":<[" + ~(rend co ~ %ud p.p.q.sot) + " " + ~(rend co ~ %ud q.p.q.sot) + "].[" + ~(rend co ~ %ud p.q.q.sot) + " " + ~(rend co ~ %ud q.q.q.sot) + "]>" + == + == + :: + +Converts a `%2` `++tone` nock stack trace to a list of [`++tank`](). +Each may be a tank, cord, [`++spot`](), or trapped tank. Produces a +[`++toon`](). + +`ton` is a [`++tone`](). + + ~zod/try=> (mook [%0 5 4 5 1]) + [%0 p=[5 4 5 1]] + ~zod/try=> (mook [%2 ~[[%hunk %rose ["<" "," ">"] ~[[%leaf "err"]]]]]) + [%2 p=~[[%rose p=[p="<" q="," r=">"] q=[i=[%leaf p="err"] t=~]]]] + ~zod/try=> (mook [%2 ~[[%malformed %elem] [%lose 'do print']]]) + [%2 p=~[[%leaf p="do print"]]] + ~zod/try=> (mook [%2 ~[[%mean |.(>(add 5 6)<)]]]) + [%2 p=~[[%leaf p="11"]]] + ~zod/try=> (mook [%2 ~[[%spot /b/repl [1 1]^[1 2]] [%mean |.(!!)]]]) + [%2 p=~[[%leaf p="/b/repl/:<[1 1].[1 2]>"] [%leaf p="####"]]] + +------------------------------------------------------------------------ + +### ++mang + +Unit: Slam gate with sample + + ++ mang + |= [[gat=* sam=*] sky=$+(* (unit))] + ^- (unit) + =+ ton=(mong [[gat sam] sky]) + ?.(?=([0 *] ton) ~ [~ p.ton]) + :: + +Produces a [`++unit`]() computation result from slamming `gat` with +`sam`, using `sky` to compute or block on nock 11 when applicable. +Similar to [`++mong`](). + +`gat` is a [noun]() that is generally a [`gate`](). + +`sam` is a [`sample`]() noun. + +`sky` is an [%iron]() gate invoked with [nock operator 11](). + + ~zod/try=> (mang [|=(@ 20) ~] ,~) + [~ 20] + ~zod/try=> (mang [|=(@ !!) ~] ,~) + ~ + ~zod/try=> (mang [|=(a=@ (add 20 a)) ~] ,~) + [~ 20] + ~zod/try=> (mang [|=(a=[@ @] (add 20 -.a)) ~] ,~) + ~ + ~zod/try=> (mang [|=(a=[@ @] (add 20 -.a)) [4 6]] ,~) + [~ 24] + ~zod/try=> (mang [|=(a=@ .^(a)) ~] ,~) + ~ + ~zod/try=> (mang [|=(a=@ .^(a)) ~] ,[~ %42]) + [~ 42] + ~zod/try=> (mang [|=(a=@ .^(a)) ~] |=(a=* [~ a 6])) + [~ [0 6]] + ~zod/try=> (mang [|=(a=@ .^(a)) 8] |=(a=* [~ a 6])) + [~ [8 6]] + +------------------------------------------------------------------------ + +### ++mong + +Slam gate with sample + + ++ mong + |= [[gat=* sam=*] sky=$+(* (unit))] + ^- toon + ?. &(?=(^ gat) ?=(^ +.gat)) + [%2 ~] + (mock [[-.gat [sam +>.gat]] -.gat] sky) + :: + +Produces a [`++toon`]() computation result from slamming `gat` with +`sam`, using `sky` to compute or block on nock 11 when applicable. + +`gat` is a [noun]() that is generally a [`gate`](). + +`sam` is a [`sample`]() noun. + +`sky` is an [%iron]() gate invoked with [nock operator 11](). + + ~zod/try=> (mong [|=(@ 20) ~] ,~) + [%0 p=20] + ~zod/try=> (mong [|=(@ !!) ~] ,~) + [%2 p=~] + ~zod/try=> (mong [|=(a=@ (add 20 a)) ~] ,~) + [%0 p=20] + ~zod/try=> (mong [|=(a=[@ @] (add 20 -.a)) ~] ,~) + [%2 p=~] + ~zod/try=> (mong [|=(a=[@ @] (add 20 -.a)) [4 6]] ,~) + [%0 p=24] + ~zod/try=> (mong [|=(a=@ .^(a)) ~] ,~) + [%1 p=~[0]] + ~zod/try=> (mong [|=(a=@ .^(a)) ~] ,[~ %42]) + [%0 p=42] + ~zod/try=> (mong [|=(a=@ .^(a)) ~] |=(a=* [~ a 6])) + [%0 p=[0 6]] + ~zod/try=> (mong [|=(a=@ .^(a)) 8] |=(a=* [~ a 6])) + [%0 p=[8 6]] + +------------------------------------------------------------------------ + +### ++mung + +Virtualize slamming gate + + ++ mung + |= [[gat=* sam=*] sky=$+(* (unit))] + ^- tone + ?. &(?=(^ gat) ?=(^ +.gat)) + [%2 ~] + (mink [[-.gat [sam +>.gat]] -.gat] sky) + :: + +Produces a [`++tone`]() computation result from slamming `gat` with +`sam`, using `sky` to compute or block on nock 11 when applicable. + +`gat` is a [noun]() that is generally a [`gate`](). + +`sam` is a [`sample`]() noun. + +`sky` is an [%iron]() gate invoked with [nock operator 11](). + + ~zod/try=> (mung [|=(@ 20) ~] ,~) + [%0 p=20] + ~zod/try=> (mung [|=(@ !!) ~] ,~) + [%2 p=~] + ~zod/try=> (mung [|=(a=@ (add 20 a)) ~] ,~) + [%0 p=20] + ~zod/try=> (mung [|=(a=[@ @] (add 20 -.a)) ~] ,~) + [%2 p=~] + ~zod/try=> (mung [|=(a=[@ @] (add 20 -.a)) [4 6]] ,~) + [%0 p=24] + ~zod/try=> (mung [|=(a=@ .^(a)) ~] ,~) + [%1 p=~[0]] + ~zod/try=> (mung [|=(a=@ .^(a)) ~] ,[~ %42]) + [%0 p=42] + ~zod/try=> (mung [|=(a=@ .^(a)) ~] |=(a=* [~ a 6])) + [%0 p=[0 6]] + ~zod/try=> (mung [|=(a=@ .^(a)) 8] |=(a=* [~ a 6])) + [%0 p=[8 6]] + +------------------------------------------------------------------------ + +### ++mule + +Typed virtual + + ++ mule :: typed virtual + ~/ %mule + |* taq=_|.(_*) + =+ mud=(mute taq) + ?- -.mud + & [%& p=$:taq] + | [%| p=p.mud] + == + :: + +Kicks a `++trap`, producing its results or any errors that occur along +the way. Used to lazily compute stack traces. + +`taq` is a [`++trap`](), generally producing a list of [`++tank`]()s. + + ~zod/try=> (mule |.(leaf/"hello")) + [%.y p=[%leaf "hello"]] + ~zod/try=> (mule |.(!!)) + [%.n p=~] + ~zod/try=> (mule |.(.^(a//=pals/1))) + [ %.n + p + ~[ + [ %rose + p=[p="/" q="/" r="/"] + q + [ i=[%leaf p="a"] + t=[i=[%leaf p="~zod"] t=[i=[%leaf p="pals"] t=[i=[%leaf p="1"] t=~]]] + ] + ] + ] + ] + +------------------------------------------------------------------------ + +### ++mute + +Untyped virtual + + ++ mute :: untyped virtual + |= taq=_^?(|.(_*)) + ^- (each ,* (list tank)) + =+ ton=(mock [taq 9 2 0 1] |=(* ~)) + ?- -.ton + %0 [%& p.ton] + %1 [%| (turn p.ton |=(a=* (smyt (path a))))] + %2 [%| p.ton] + == + +Kicks a `++trap`, producing its result as a noun or the tanks of any +error that occurs. Similar to [`++mule`](), but preserves no type +information. + +`taq` is a [`++trap`](). + + ~zod/try=> (mute |.(leaf/"hello")) + [%.y p=[1.717.658.988 104 101 108 108 111 0]] + ~zod/try=> (mute |.(!!)) + [%.n p=~] + ~zod/try=> (mute |.(.^(a//=pals/1))) + [ %.n + p + ~[ + [ %rose + p=[p="/" q="/" r="/"] + q=[i=[%leaf p="a"] t=[i=[%leaf p="~zod"] t=[i=[%leaf p="pals"] t=[i=[%leaf p="1"] t=~]]]] + ] + ] + ] + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2ep.md b/docs/pub/doc/hoon/library/2ep.md new file mode 100644 index 0000000000..c1c2e491bb --- /dev/null +++ b/docs/pub/doc/hoon/library/2ep.md @@ -0,0 +1,586 @@ +section 2eP, diff +================= + +A- more or less low priority and/or currently in the wrong section +anyway. + +------------------------------------------------------------------------ + +------------------------------------------------------------------------ + +### ++berk + +Invert diff patches + + ++ berk :: invert diff patch + |* bur=(urge) + |- ^+ bur + ?~ bur ~ + :_ $(bur t.bur) + ?- -.i.bur + & i.bur + | [%| q.i.bur p.i.bur] + == + :: + +Inverts a list of changes `bur`. Skips stay constant and replaces are +swapped. Produces a `bur`. + +`bur` is a [`++urge`](). + + ~zod/try=> (berk `(urge)`~[`10 %|^[~[2] ~[3 4]] `5]) + ~[[%.y p=10] [%.n p=~[3 4] q=~[2]] [%.y p=5]] + ~zod/try=> (lurk "somes" `(urge char)`~[`1 [%| "o" "a"] `3]) + "sames" + ~zod/try=> (berk `(urge char)`~[`1 [%| "o" "a"] `3]) + ~[[%.y p=1] [%.n p="a" q="o"] [%.y p=3]] + ~zod/try=> (lurk "sames" (berk `(urge char)`~[`1 [%| "o" "a"] `3])) + "somes" + +------------------------------------------------------------------------ + +### ++diff + +Generate patch + + ++ diff :: generate patch + |= pum=umph + |= [old=* new=*] ^- udon + :- pum + ?+ pum ~|(%unsupported !!) + %a [%d (nude old new)] + %b =+ [hel=(cue ((hard ,@) old)) hev=(cue ((hard ,@) new))] + [%d (nude hel hev)] + %c =+ [hel=(lore ((hard ,@) old)) hev=(lore ((hard ,@) new))] + [%c (lusk hel hev (loss hel hev))] + == + :: + +Produces a patch between two nouns, by change type + +`pum` is an [`++umph`](). + + ~zod/try=> ((diff %a) 20 21) + [p=%a q=[%d p=[%1 p=21] q=[%1 p=20]]] + ~zod/try=> ((diff %a) [1 2 3] [1 2 4]) + [ p=%a + q + [ %d + p=[p=[%0 p=2] q=[p=[%0 p=6] q=[%1 p=4]]] + q=[p=[%0 p=2] q=[p=[%0 p=6] q=[%1 p=3]]] + ] + ] + ~zod/try=> ~04hh + [1 2] + ~zod/try=> ~0ph + [1 1] + ~zod/try=> ((diff %b) 0v4hh 0vph) + [p=%b q=[%d p=[p=[%0 p=2] q=[%0 p=2]] q=[p=[%0 p=3] q=[%1 p=2]]]] + ~zod/try=> ((diff %c) (role 'sam' 'les' 'les' 'kor' ~) (role 'sam' 'mor' 'kor' ~)) + [p=%c q=[%c p=~[[%.y p=1] [%.n p=~[7.562.604 7.562.604] q=~[7.499.629]] [%.y p=1]]]] + ~[[%.y p=0] [%.y p=0] [%.y p=1] [%.n p=<|les les|> q=<|mor|>] [%.y p=1]] + ~zod/try=> (,[%c %c (urge cord)] ((diff %c) (role 'sam' 'les' 'les' 'kor' ~) (role 'sam' 'mor' 'kor' ~))) + [%c %c ~[[%.y p=1] [%.n p=<|les les|> q=<|mor|>] [%.y p=1]]] + +------------------------------------------------------------------------ + +### ++loss + +Longest subsequence + + ++ loss :: longest subsequence + ~/ %loss + |* [hel=(list) hev=(list)] + |- ^+ hev + =+ ^= sev + =+ [inx=0 sev=*(map ,@t (list ,@ud))] + |- ^+ sev + ?~ hev sev + =+ guy=(~(get by sev) i.hev) + $(hev t.hev, inx +(inx), sev (~(put by sev) i.hev [inx ?~(guy ~ u.guy)])) + =| gox=[p=@ud q=(map ,@ud ,[p=@ud q=_hev])] + =< abet + =< main + |% + ++ abet =.(q.rag ?:(=([& 0] p.rag) q.rag [p.rag q.rag]) (flop q.rag)) + ++ hink :: extend fits top + |= [inx=@ud goy=@ud] ^- ? + |(=(p.gox inx) (lth goy p:(need (~(get by q.gox) inx)))) + :: + ++ lonk :: extend fits bottom + |= [inx=@ud goy=@ud] ^- ? + |(=(0 inx) (gth goy p:(need (~(get by q.gox) (dec inx))))) + :: + ++ lune :: extend + |= [inx=@ud goy=@ud] + ^+ +> + %_ +>.$ + gox + :- ?:(=(inx p.gox) +(p.gox) p.gox) + %+ ~(put by q.gox) inx + [goy (snag goy hev) ?:(=(0 inx) ~ q:(need (~(get by q.gox) (dec inx))))] + == + :: + ++ merg :: merge all matches + |= gay=(list ,@ud) + ^+ +> + =+ ^= zes + =+ [inx=0 zes=*(list ,[p=@ud q=@ud])] + |- ^+ zes + ?: |(?=(~ gay) (gth inx p.gox)) zes + ?. (lonk inx i.gay) $(gay t.gay) + ?. (hink inx i.gay) $(inx +(inx)) + $(inx +(inx), gay t.gay, zes [[inx i.gay] zes]) + |- ^+ +>.^$ + ?~(zes +>.^$ $(zes t.zes, +>.^$ (lune i.zes))) + :: + ++ main + |- ^+ + + ?~ hel + ?~ hev + ?>(?=(~ lcs) +) + $(hev t.hev, rag (done %| ~ [i.hev ~])) + ?~ hev + $(hel t.hel, rag (done %| [i.hel ~] ~)) + ?~ lcs + +(rag (done %| (flop hel) (flop hev))) + ?: =(i.hel i.lcs) + ?: =(i.hev i.lcs) + $(lcs t.lcs, hel t.hel, hev t.hev, rag (done %& 1)) + $(hev t.hev, rag (done %| ~ [i.hev ~])) + ?: =(i.hev i.lcs) + $(hel t.hel, rag (done %| [i.hel ~] ~)) + $(hel t.hel, hev t.hev, rag (done %| [i.hel ~] [i.hev ~])) + -- + +Finds a subsequence of repeated elements within two [`++list`]()s, using +several internal helper arms. Produces a [`++tape`](). + +`hel` is a [`++list`]() of characters. + +`hev` is a [++list\`]() of characters. + + ~zod/try=> (loss "sam" "sem") + "sm" + ~zod/try=> (loss "samo" "semo") + "smo" + ~zod/try=> (loss "sakmo" "semo") + "smo" + ~zod/try=> (loss "ferdinham" "ferdilapos + ~ + ~zod/try=> (loss "ferdinham" "ferdilapos") + "ferdia" + +------------------------------------------------------------------------ + +### ++locz + +Find common + + ++ locz :: trivial algorithm + |= [hel=tape hev=tape] + ^- tape + =+ [leh=(lent hel) veh=(lent hev)] + =- (flop q.yun) + ^= yun + |- ^- [p=@ud q=tape] + ~+ + ?: |(=(0 leh) =(0 veh)) [0 ~] + =+ [dis=(snag (dec leh) hel) dat=(snag (dec veh) hev)] + ?: =(dis dat) + =+ say=$(leh (dec leh), veh (dec veh)) + [+(p.say) [dis q.say]] + =+ [lef=$(leh (dec leh)) rig=$(veh (dec veh))] + ?:((gth p.lef p.rig) lef rig) + :: + +Finds a subsequence of repeated elements within two [`++list`]()s, +producing a [\`++tape](). + + ~zod/try=> (locz "samukot" "semelkot") + "smkot" + ~zod/try=> (locz "samukot" "samelkot") + "samkot" + +------------------------------------------------------------------------ + +### ++lore + +Split on `\n` + + ++ lore :: atom to line list + ~/ %lore + |= lub=@ + =| tez=(list ,@t) + |- ^+ tez + ?: =(0 lub) (flop tez) + =+ ^= meg + =+ meg=0 + |- ^- @ud + =+ gam=(cut 3 [meg 1] lub) + ?:(|(=(10 gam) =(0 gam)) meg $(meg +(meg))) + =+ res=(rsh 3 +(meg) lub) + ?: &(=(0 (cut 3 [meg 1] lub)) !=(0 res)) + !! + $(lub res, tez [(end 3 meg lub) tez]) + :: + +Split on newlines, ascii `10` + + ~zod/try=> (lore 'soke\0alas\0amep') + <|soke las mep|> + ~zod/try=> (lore '|= a=@\0a=+ b=(add a 5)\0a(mix b a)') + <||= a=@ =+ b=(add a 5) (mix b a)|> + ~zod/try=> `wain`[(fil 3 80 ' ') (lore '|= a=@\0a=+ b=(add a 5)\0a(mix b a)')] + <| + |= a=@ + =+ b=(add a 5) + (mix b a) + |> + +------------------------------------------------------------------------ + +### ++role + +Join with `\n` + + ++ role :: line list to atom + |= tez=(list ,@t) + (rap 3 (turn tez |=(a=@t (cat 3 a 10)))) + :: + +Join line list with newlines. + + ~zod/try=> (role 'sep' 'tek' 'lap' ~) + 3.230.709.852.558.292.782.985.274.739 + ~zod/try=> `@t`(role 'sep' 'tek' 'lap' ~) + ''' + sep + tek + lap + ''' + +------------------------------------------------------------------------ + +### ++lump + +Change with `++udon` + + ++ lump :: apply patch + |= [don=udon src=*] + ^- * + ?+ p.don ~|(%unsupported !!) + %a + ?+ -.q.don ~|(%unsupported !!) + %a q.q.don + %c (lurk ((hard (list)) src) p.q.don) + %d (lure src p.q.don) + == + :: + %c + =+ dst=(lore ((hard ,@) src)) + %- role + ?+ -.q.don ~|(%unsupported !!) + %a ((hard (list ,@t)) q.q.don) + %c (lurk dst p.q.don) + == + == + :: + +Use udon to change noun + + ~zod/try=> (lump [%a %a 20 25] 20) + 25 + ~zod/try=> (lump [%a %d [[%0 1] [%0 1]] [%0 2]] 20) + [20 20] + ~zod/try=> (lump [%c %a ~['sa' 'le'] ~['sa' 'lo']] 'sa\0ale') + 11.473.670.267.251 + ~zod/try=> (,@t (lump [%c %a ~['sa' 'le'] ~['sa' 'lo']] 'sa\0ale')) + ''' + sa + lo + ''' + ~zod/try=> (,@t (lump [%c %c `1 [%| ~['le'] ~['lo' 'ma']] ~] 'sa\0ale')) + ''' + sa + ma + lo + ''' + +------------------------------------------------------------------------ + +### ++lure + +Patch `a` + + ++ lure :: apply tree diff + |= [a=* b=upas] + ^- * + ?^ -.b + [$(b -.b) $(b +.b)] + ?+ -.b ~|(%unsupported !!) + %0 .*(a [0 p.b]) + %1 .*(a [1 p.b]) + == + +Patch a by references to axis and literal. + + ~zod/try=> (lure ~[1 2] [[%0 2] [%1 3] [%0 7]]) + [1 3 0] + ~zod/try=> (lure ~[1 2 4] [[%0 2] [%1 3] [%0 7]]) + [1 3 4 0] + +------------------------------------------------------------------------ + +### ++limp + +Reverse patch + + ++ limp :: invert patch + |= don=udon ^- udon + :- p.don + ?+ -.q.don ~|(%unsupported !!) + %a [%a q.q.don p.q.don] + %c [%c (berk p.q.don)] + %d [%d q.q.don p.q.don] + == + :: + +Reverse a patch (preprocessor unchanged) + + ~zod/try=> (limp [%a %a 20 40]) + [p=%a q=[%a p=40 q=20]] + ~zod/try=> (limp [%c %c ~[`20 [%| ~[52 53] ~[51]] `6]]) + [p=%c q=[%c p=~[[%.y p=20] [%.n p=~[51] q=~[52 53]] [%.y p=6]]]] + ~zod/try=> (limp [%a %d [[%0 1] [%0 1]] [%0 2]]) + [p=%a q=[%d p=[%0 p=2] q=[p=[%0 p=1] q=[%0 p=1]]]] + +------------------------------------------------------------------------ + +### ++hump + +Prep for diff + + ++ hump :: general prepatch + |= [pum=umph src=*] ^- * + ?+ pum ~|(%unsupported !!) + %a src + %b (cue ((hard ,@) src)) + %c (lore ((hard ,@) src)) + == + :: + +Prep atom for diff: leave alone, cue, or split by newlines. + + ~zod/try=> (hump %a ~) + 0 + ~zod/try=> (hump %a 40) + 40 + ~zod/try=> (hump %c 40) + [40 0] + ~zod/try=> (hump %c 'as') + [29.537 0] + ~zod/try=> (hump %c 'as\0alok') + [29.537 7.040.876 0] + ~zod/try=> (hump %b 0vph) + [1 1] + +------------------------------------------------------------------------ + +### ++husk + +Atomize post diff + + ++ husk :: unprepatch + |= [pum=umph dst=*] ^- * + ?+ pum ~|(%unsupported !!) + %a dst + %b (jam dst) + %c (role ((hard (list ,@)) dst)) + == + :: + +Re-atomize after diff: leave alone, jam, or join with newlines. + + ~zod/try=> (husk %a 0) + 0 + ~zod/try=> (husk %a 40) + 40 + ~zod/try=> (husk %c [40 0]) + 2.600 + ~zod/try=> (rip 3 (,@ (husk %c [40 0]))) + ~[40 10] + ~zod/try=> (husk %c [%as 0]) + 684.897 + ~zod/try=> (husk %c [%as 0]) + 684.897 + ~zod/try=> (,@t (husk %c [%as 0])) + ''' + as + ''' + ~zod/try=> (husk %c [%as %lok 0]) + 2.932.876.065.272.673 + ~zod/try=> (,@t (husk %c [%as %lok 0])) + ''' + as + lok + ''' + ~zod/try=> (husk %b [1 1]) + 817 + ~zod/try=> (,@uv (husk %b [1 1])) + 0vph + ~zod/try=> ~0ph + [1 1] + +------------------------------------------------------------------------ + +### ++lurk + +Apply list patch + + ++ lurk :: apply list patch + |* [hel=(list) rug=(urge)] + ^+ hel + =+ war=`_hel`~ + |- ^+ hel + ?~ rug (flop war) + ?- -.i.rug + & + %= $ + rug t.rug + hel (slag p.i.rug hel) + war (weld (flop (scag p.i.rug hel)) war) + == + :: + | + %= $ + rug t.rug + hel =+ gur=(flop p.i.rug) + |- ^+ hel + ?~ gur hel + ?>(&(?=(^ hel) =(i.gur i.hel)) $(hel t.hel, gur t.gur)) + war (weld q.i.rug war) + == + == + :: + +Amend list using an urge: list of `[%& {number skipped}]` and +`[%| old new]` + + ~zod/try=> (lurk "hema" `(urge char)`~[`1 [%| "e" "ru"] `2]) + "hurma" + ~zod/try=> (lurk "koltep" `(urge char)`~[`3 [%| "et" ""] `1]) + "kolp" + +------------------------------------------------------------------------ + +### ++lusk + +`lcs` to list patch + + ++ lusk :: lcs to list patch + |* [hel=(list) hev=(list) lcs=(list)] + =+ ^= rag + ^- $% [& p=@ud] + [| p=_lcs q=_lcs] + == + [%& 0] + => .(rag [p=rag q=*(list ,_rag)]) + =< abet =< main + |% + ++ abet =.(q.rag ?:(=([& 0] p.rag) q.rag [p.rag q.rag]) (flop q.rag)) + ++ done + |= new=_p.rag + ^+ rag + ?- -.p.rag + | ?- -.new + | [[%| (weld p.new p.p.rag) (weld q.new q.p.rag)] q.rag] + & [new [p.rag q.rag]] + == + & ?- -.new + | [new ?:(=(0 p.p.rag) q.rag [p.rag q.rag])] + & [[%& (add p.p.rag p.new)] q.rag] + == + == + :: + ++ main + |- ^+ + + ?~ hel + ?~ hev + ?>(?=(~ lcs) +) + $(hev t.hev, rag (done %| ~ [i.hev ~])) + ?~ hev + $(hel t.hel, rag (done %| [i.hel ~] ~)) + ?~ lcs + +(rag (done %| (flop hel) (flop hev))) + ?: =(i.hel i.lcs) + ?: =(i.hev i.lcs) + $(lcs t.lcs, hel t.hel, hev t.hev, rag (done %& 1)) + $(hev t.hev, rag (done %| ~ [i.hev ~])) + ?: =(i.hev i.lcs) + $(hel t.hel, rag (done %| [i.hel ~] ~)) + $(hel t.hel, hev t.hev, rag (done %| [i.hel ~] [i.hev ~])) + -- + +Using a common sequence, generate urge from two lists + + ~zod/try=> (lusk "hamok" "hasok" "haok") + ~[[%.y p=2] [%.n p="m" q="s"] [%.y p=2]] + ~zod/try=> (lusk "hamok" "hasok" "hak") + ~[[%.y p=2] [%.n p="om" q="os"] [%.y p=1]] + ~zod/try=> (lusk "telroga" "tesomga" "teoga") + ~[[%.y p=2] [%.n p="rl" q="s"] [%.y p=1] [%.n p="" q="m"] [%.y p=2]] + ~zod/try=> (lurk "telroga" `(urge char)`~[[%.y p=2] [%.n p="rl" q="s"] [%.y p=1] [%.n p="" q="m"] [%.y p=2]]) + "tesomga" + +------------------------------------------------------------------------ + +### ++nude + +Tree change + + ++ nude :: tree change + |= [a=* b=*] + ^- [p=upas q=upas] + =< [p=(tred a b) q=(tred b a)] + |% + ++ axes :: locs of nouns + |= [a=@ b=*] ^- (map ,* axis) + =+ c=*(map ,* axis) + |- ^- (map ,* axis) + => .(c (~(put by c) b a)) + ?@ b + c + %- ~(uni by c) + %- ~(uni by $(a (mul 2 a), b -.b)) + $(a +((mul 2 a)), b +.b) + :: + ++ tred :: diff a->b + |= [a=* b=*] ^- upas + =| c=(unit ,*) + =+ d=(axes 1 a) + |- ^- upas + => .(c (~(get by d) b)) + ?~ c + ?@ b + [%1 b] + =+ e=^-(upas [$(b -.b) $(b +.b)]) + ?- e + [[%1 *] [%1 *]] [%1 [p.p.e p.q.e]] + * e + == + [%0 u.c] + -- + +Generate tree diff from two nouns. + + ~zod/try=> (nude 40 20) + [p=[%1 p=20] q=[%1 p=40]] + ~zod/try=> (nude [5 5] 5) + [p=[%0 p=3] q=[p=[%0 p=1] q=[%0 p=1]]] + ~zod/try=> (nude "sam" "sal") + [ p=[p=[%1 p=115] q=[p=[%1 p=97] q=[p=[%1 p=108] q=[%0 p=15]]]] + q=[p=[%1 p=115] q=[p=[%1 p=97] q=[p=[%1 p=109] q=[%0 p=15]]]] + ] + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2ew.md b/docs/pub/doc/hoon/library/2ew.md new file mode 100644 index 0000000000..7440b76363 --- /dev/null +++ b/docs/pub/doc/hoon/library/2ew.md @@ -0,0 +1,439 @@ +section 2eW, lite number theory +=============================== + +### ++egcd + +GCD + + ++ egcd :: schneier's egcd + |= [a=@ b=@] + =+ si + =+ [c=(sun a) d=(sun b)] + =+ [u=[c=(sun 1) d=--0] v=[c=--0 d=(sun 1)]] + |- ^- [d=@ u=@ v=@] + ?: =(--0 c) + [(abs d) d.u d.v] + :: ?> ?& =(c (sum (pro (sun a) c.u) (pro (sun b) c.v))) + :: =(d (sum (pro (sun a) d.u) (pro (sun b) d.v))) + :: == + =+ q=(fra d c) + %= $ + c (dif d (pro q c)) + d c + u [(dif d.u (pro q c.u)) c.u] + v [(dif d.v (pro q c.v)) c.v] + == + :: + +Greatest common denominator + + ~zod/try=> (egcd 20 15) + [d=5 u=2 v=1] + ~zod/try=> (egcd 24 16) + [d=8 u=2 v=1] + ~zod/try=> (egcd 7 5) + [d=1 u=3 v=6] + ~zod/try=> (egcd (shaf ~ %ham) (shaf ~ %sam)) + [ d=1 + u=59.983.396.314.566.203.239.184.568.129.921.874.787 + v=38.716.650.351.034.402.960.165.718.823.532.275.722 + ] + +------------------------------------------------------------------------ + +### ++pram + +Probable prime + + ++ pram :: rabin-miller + |= a=@ ^- ? + ?: ?| =(0 (end 0 1 a)) + =(1 a) + =+ b=1 + |- ^- ? + ?: =(512 b) + | + ?|(=+(c=+((mul 2 b)) &(!=(a c) =(a (mul c (div a c))))) $(b +(b))) + == + | + =+ ^= b + =+ [s=(dec a) t=0] + |- ^- [s=@ t=@] + ?: =(0 (end 0 1 s)) + $(s (rsh 0 1 s), t +(t)) + [s t] + ?> =((mul s.b (bex t.b)) (dec a)) + =+ c=0 + |- ^- ? + ?: =(c 64) + & + =+ d=(~(raw og (add c a)) (met 0 a)) + =+ e=(~(exp fo a) s.b d) + ?& ?| =(1 e) + =+ f=0 + |- ^- ? + ?: =(e (dec a)) + & + ?: =(f (dec t.b)) + | + $(e (~(pro fo a) e e), f +(f)) + == + $(c +(c)) + == + :: + +Probable prime test + + ~zod/try=> (pram 31) + %.y + ~zod/try=> =+(a=2 |-(?:(=(a 31) ~ [i=(mod 31 a) t=$(a +(a))]))) + ~[1 1 3 1 1 3 7 4 1 9 7 5 3 1 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1] + ~zod/try=> =+(a=2 |-(?:(=(a 31) ~ [i=(mod 30 a) t=$(a +(a))]))) + ~[0 0 2 0 0 2 6 3 0 8 6 4 2 0 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0] + ~zod/try=> (pram 256) + %.n + ~zod/try=> (pram (dec (bex 127))) + %.y + +------------------------------------------------------------------------ + +### ++ramp + +`r-m` prime + + ++ ramp :: make r-m prime + |= [a=@ b=(list ,@) c=@] ^- @ux :: [bits snags seed] + => .(c (shas %ramp c)) + =+ d=_@ + |- + ?: =((mul 100 a) d) + ~|(%ar-ramp !!) + =+ e=(~(raw og c) a) + ?: &((levy b |=(f=@ !=(1 (mod e f)))) (pram e)) + e + $(c +(c), d (shax d)) + :: + +Random `a` bit prime, which isn't 1 modulo a list of other numbers, +using salt `c`. + + ~zod/try=> (ramp 20 ~ %hamelok) + 0xf.1f0d + ~zod/try=> (ramp 20 ~ %hameloe) + 0x2.d341 + ~zod/try=> (ramp 5 ~ %kole) + 0x1f + ~zod/try=> (ramp 7 ~ %kole) + 0x4f + ~zod/try=> (ramp 7 ~[0x4e] %kole) + 0x43 + ~zod/try=> `@uw`(ramp 128 ~ %late) + 0w3y.irKIL.l-pp1.2CkG4.3lsTF + +------------------------------------------------------------------------ + +### ++fo + +Prime engine + + ++ fo :: modulo prime + |_ a=@ + +XX DO NOT RERUN GET.LS, THERE EXIST ARM COLLISIONS + +Core for performing arithmetic modulo a prime number + + ~zod/try=> ~(. fo 79) + <7.get [@ud <373.jdd 100.kzl 1.ypj %164>]> + +------------------------------------------------------------------------ + +### ++dif + +Difference + + ++ dif + |= [b=@ c=@] + (sit (sub (add a b) (sit c))) + :: + +Subtract + + ~zod/try=> (~(dif fo 79) 10 5) + 5 + ~zod/try=> (~(dif fo 79) 5 10) + 74 + +------------------------------------------------------------------------ + +### ++exp + +Exponent + + ++ exp + |= [b=@ c=@] + ?: =(0 b) + 1 + =+ d=$(b (rsh 0 1 b)) + =+ e=(pro d d) + ?:(=(0 (end 0 1 b)) e (pro c e)) + :: + +Exponent + + ~zod/try=> (~(exp fo 79) 3 5) + 46 + +------------------------------------------------------------------------ + +### ++fra + +Divide + + ++ fra + |= [b=@ c=@] + (pro b (inv c)) + :: + +Divide + + ~zod/try=> (~(fra fo 79) 20 4) + 5 + ~zod/try=> (~(fra fo 79) 7 11) + 15 + +------------------------------------------------------------------------ + +### ++inv + +Inverse + + ++ inv + |= b=@ + =+ c=(dul:si u:(egcd b a) a) + c + :: + +Multiplicative inverse + + ~zod/try=> (~(inv fo 79) 12) + 33 + ~zod/try=> (~(pro fo 79) 12 33) + 1 + ~zod/try=> (~(inv fo 79) 0) + 0 + +------------------------------------------------------------------------ + +### ++pro + +Product + + ++ pro + |= [b=@ c=@] + (sit (mul b c)) + :: + +Product + + ~zod/try=> (~(pro fo 79) 5 10) + 50 + ~zod/try=> (~(pro fo 79) 5 20) + 21 + +------------------------------------------------------------------------ + +### ++sit + +Bounds + + ++ sit + |= b=@ + (mod b a) + :: + +Bounds check + + ~zod/try=> (~(sit fo 79) 9) + 9 + ~zod/try=> (~(sit fo 79) 99) + 20 + +------------------------------------------------------------------------ + +### ++sum + +Sum + + ++ sum + |= [b=@ c=@] + (sit (add b c)) + -- + +Add + + ~zod/try=> (~(sum fo 79) 9 9) + 18 + ~zod/try=> (~(sum fo 79) 70 9) + 0 + +------------------------------------------------------------------------ + +### ++ga + + ++ ga :: GF (bex p.a) + |= a=[p=@ q=@ r=@] :: dim poly gen + =+ si=(bex p.a) + =+ ma=(dec si) + => |% + +RSA internals + +XX document + +------------------------------------------------------------------------ + +### ++dif + + ++ dif :: add and sub + |= [b=@ c=@] + ~| [%dif-ga a] + ?> &((lth b si) (lth c si)) + (mix b c) + :: + +XX document + +------------------------------------------------------------------------ + +### ++dub + + ++ dub :: mul by x + |= b=@ + ~| [%dub-ga a] + ?> (lth b si) + ?: =(1 (cut 0 [(dec p.a) 1] b)) + (dif (sit q.a) (sit (lsh 0 1 b))) + (lsh 0 1 b) + :: + +XX document + +------------------------------------------------------------------------ + +### ++pro + + ++ pro :: slow multiply + |= [b=@ c=@] + ?: =(0 b) + 0 + ?: =(1 (dis 1 b)) + (dif c $(b (rsh 0 1 b), c (dub c))) + $(b (rsh 0 1 b), c (dub c)) + :: + +XX document + +------------------------------------------------------------------------ + +### ++toe + + ++ toe :: exp/log tables + =+ ^= nu + |= [b=@ c=@] + ^- (map ,@ ,@) + =+ d=*(map ,@ ,@) + |- + ?: =(0 c) + d + %= $ + c (dec c) + d (~(put by d) c b) + == + =+ [p=(nu 0 (bex p.a)) q=(nu ma ma)] + =+ [b=1 c=0] + |- ^- [p=(map ,@ ,@) q=(map ,@ ,@)] + ?: =(ma c) + [(~(put by p) c b) q] + %= $ + b (pro r.a b) + c +(c) + p (~(put by p) c b) + q (~(put by q) b c) + == + :: + +XX document + +------------------------------------------------------------------------ + +### ++sit + + ++ sit :: reduce + |= b=@ + (mod b (bex p.a)) + -- + +XX document + +------------------------------------------------------------------------ + +### ++fra + + ++ fra :: divide + |= [b=@ c=@] + (pro b (inv c)) + :: + +XX document + +------------------------------------------------------------------------ + +### ++inv + + ++ inv :: invert + |= b=@ + ~| [%inv-ga a] + =+ c=(~(get by q) b) + ?~ c !! + =+ d=(~(get by p) (sub ma u.c)) + (need d) + :: + +XX document + +------------------------------------------------------------------------ + +### ++pow + + ++ pow :: exponent + |= [b=@ c=@] + =+ [d=1 e=c f=0] + |- + ?: =(p.a f) + d + ?: =(1 (cut 0 [f 1] b)) + $(d (pro d e), e (pro e e), f +(f)) + $(e (pro e e), f +(f)) + :: + +XX document + +------------------------------------------------------------------------ + +### ++pro + + ++ pro :: multiply + |= [b=@ c=@] + ~| [%pro-ga a] + =+ d=(~(get by q) b) + ?~ d 0 + =+ e=(~(get by q) c) + ?~ e 0 + =+ f=(~(get by p) (mod (add u.d u.e) ma)) + (need f) + -- + +XX document + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2ex.md b/docs/pub/doc/hoon/library/2ex.md new file mode 100644 index 0000000000..bb30f121da --- /dev/null +++ b/docs/pub/doc/hoon/library/2ex.md @@ -0,0 +1,717 @@ +section 2eX, jetted crypto +========================== + +------------------------------------------------------------------------ + +### ++aesc + + ++ aesc :: AES-256 + ~% %aesc + ~ + |% + +XX document + +### ++en + + ++ en :: ECB enc + ~/ %en + |= [a=@I b=@H] ^- @uxH + =+ ahem + (be & (ex a) b) + +XX document + +### ++de + + ++ de :: ECB dec + ~/ %de + |= [a=@I b=@H] ^- @uxH + =+ ahem + (be | (ix (ex a)) b) + -- + +XX document + +### ++ahem + + ++ ahem :: AES helpers + :: XX should be in aesc, isn't for performance reasons + => + =+ =+ [gr=(ga 8 0x11b 3) few==>(fe .(a 5))] + =+ [pro=pro.gr dif=dif.gr pow=pow.gr ror=ror.few] + [pro=pro dif=dif pow=pow ror=ror nnk=8 nnb=4 nnr=14] + => |% + +XX document + +### ++cipa + + ++ cipa :: AES params + $_ ^? |% + +XX document + +### ++co + + ++ co [0xe 0xb 0xd 0x9] + +XX document + +### ++ix + + ++ ix :: key expand, inv + |= a=@ ^- @ + =+ [i=1 j=_@ b=_@ c=co:pin] + |- + ?: =(nnr i) + a + => .(b (cut 7 [i 1] a)) + => .(b (rep 5 (mcol (pode 5 4 b) c))) + => .(j (sub nnr i)) + %= $ + i +(i) + a + %+ can 7 + :~ [i (cut 7 [0 i] a)] + [1 b] + [j (cut 7 [+(i) j] a)] + == + == + -- + :: + +XX document + +### ++ro + + ++ ro [0 3 2 1] + +XX document + +### ++su + + ++ su 0x7d0c.2155.6314.69e1.26d6.77ba.7e04.2b17. + 6199.5383.3cbb.ebc8.b0f5.2aae.4d3b.e0a0. + ef9c.c993.9f7a.e52d.0d4a.b519.a97f.5160. + 5fec.8027.5910.12b1.31c7.0788.33a8.dd1f. + f45a.cd78.fec0.db9a.2079.d2c6.4b3e.56fc. + 1bbe.18aa.0e62.b76f.89c5.291d.711a.f147. + 6edf.751c.e837.f9e2.8535.ade7.2274.ac96. + 73e6.b4f0.cecf.f297.eadc.674f.4111.913a. + 6b8a.1301.03bd.afc1.020f.3fca.8f1e.2cd0. + 0645.b3b8.0558.e4f7.0ad3.bc8c.00ab.d890. + 849d.8da7.5746.155e.dab9.edfd.5048.706c. + 92b6.655d.cc5c.a4d4.1698.6886.64f6.f872. + 25d1.8b6d.49a2.5b76.b224.d928.66a1.2e08. + 4ec3.fa42.0b95.4cee.3d23.c2a6.3294.7b54. + cbe9.dec4.4443.8e34.87ff.2f9b.8239.e37c. + fbd7.f381.9ea3.40bf.38a5.3630.d56a.0952 + -- + :: + +XX document + +### ++pen + + ++ pen :: encrypt + ^- cipa + |% + +XX document + +### ++co + + ++ co [0xe 0xb 0xd 0x9] + +XX document + +### ++ix + + ++ ix :: key expand, inv + |= a=@ ^- @ + =+ [i=1 j=_@ b=_@ c=co:pin] + |- + ?: =(nnr i) + a + => .(b (cut 7 [i 1] a)) + => .(b (rep 5 (mcol (pode 5 4 b) c))) + => .(j (sub nnr i)) + %= $ + i +(i) + a + %+ can 7 + :~ [i (cut 7 [0 i] a)] + [1 b] + [j (cut 7 [+(i) j] a)] + == + == + -- + :: + +XX document + +### ++ro + + ++ ro [0 3 2 1] + +XX document + +### ++su + + ++ su 0x7d0c.2155.6314.69e1.26d6.77ba.7e04.2b17. + 6199.5383.3cbb.ebc8.b0f5.2aae.4d3b.e0a0. + ef9c.c993.9f7a.e52d.0d4a.b519.a97f.5160. + 5fec.8027.5910.12b1.31c7.0788.33a8.dd1f. + f45a.cd78.fec0.db9a.2079.d2c6.4b3e.56fc. + 1bbe.18aa.0e62.b76f.89c5.291d.711a.f147. + 6edf.751c.e837.f9e2.8535.ade7.2274.ac96. + 73e6.b4f0.cecf.f297.eadc.674f.4111.913a. + 6b8a.1301.03bd.afc1.020f.3fca.8f1e.2cd0. + 0645.b3b8.0558.e4f7.0ad3.bc8c.00ab.d890. + 849d.8da7.5746.155e.dab9.edfd.5048.706c. + 92b6.655d.cc5c.a4d4.1698.6886.64f6.f872. + 25d1.8b6d.49a2.5b76.b224.d928.66a1.2e08. + 4ec3.fa42.0b95.4cee.3d23.c2a6.3294.7b54. + cbe9.dec4.4443.8e34.87ff.2f9b.8239.e37c. + fbd7.f381.9ea3.40bf.38a5.3630.d56a.0952 + -- + :: + +XX document + +### ++pin + + ++ pin :: decrypt + ^- cipa + |% + +XX document + +### ++co + + ++ co [0xe 0xb 0xd 0x9] + +XX document + +### ++ix + + ++ ix :: key expand, inv + |= a=@ ^- @ + =+ [i=1 j=_@ b=_@ c=co:pin] + |- + ?: =(nnr i) + a + => .(b (cut 7 [i 1] a)) + => .(b (rep 5 (mcol (pode 5 4 b) c))) + => .(j (sub nnr i)) + %= $ + i +(i) + a + %+ can 7 + :~ [i (cut 7 [0 i] a)] + [1 b] + [j (cut 7 [+(i) j] a)] + == + == + -- + :: + +XX document + +### ++ro + + ++ ro [0 3 2 1] + +XX document + +### ++su + + ++ su 0x7d0c.2155.6314.69e1.26d6.77ba.7e04.2b17. + 6199.5383.3cbb.ebc8.b0f5.2aae.4d3b.e0a0. + ef9c.c993.9f7a.e52d.0d4a.b519.a97f.5160. + 5fec.8027.5910.12b1.31c7.0788.33a8.dd1f. + f45a.cd78.fec0.db9a.2079.d2c6.4b3e.56fc. + 1bbe.18aa.0e62.b76f.89c5.291d.711a.f147. + 6edf.751c.e837.f9e2.8535.ade7.2274.ac96. + 73e6.b4f0.cecf.f297.eadc.674f.4111.913a. + 6b8a.1301.03bd.afc1.020f.3fca.8f1e.2cd0. + 0645.b3b8.0558.e4f7.0ad3.bc8c.00ab.d890. + 849d.8da7.5746.155e.dab9.edfd.5048.706c. + 92b6.655d.cc5c.a4d4.1698.6886.64f6.f872. + 25d1.8b6d.49a2.5b76.b224.d928.66a1.2e08. + 4ec3.fa42.0b95.4cee.3d23.c2a6.3294.7b54. + cbe9.dec4.4443.8e34.87ff.2f9b.8239.e37c. + fbd7.f381.9ea3.40bf.38a5.3630.d56a.0952 + -- + :: + +XX document + +### ++mcol + + ++ mcol + |= [a=(list ,@) b=[p=@ q=@ r=@ s=@]] ^- (list ,@) + =+ c=[p=_@ q=_@ r=_@ s=_@] + |- ^- (list ,@) + ?~ a ~ + => .(p.c (cut 3 [0 1] i.a)) + => .(q.c (cut 3 [1 1] i.a)) + => .(r.c (cut 3 [2 1] i.a)) + => .(s.c (cut 3 [3 1] i.a)) + :_ $(a t.a) + %+ rep 3 + %+ turn + %- limo + :~ [[p.c p.b] [q.c q.b] [r.c r.b] [s.c s.b]] + [[p.c s.b] [q.c p.b] [r.c q.b] [s.c r.b]] + [[p.c r.b] [q.c s.b] [r.c p.b] [s.c q.b]] + [[p.c q.b] [q.c r.b] [r.c s.b] [s.c p.b]] + == + |= [a=[@ @] b=[@ @] c=[@ @] d=[@ @]] + :(dif (pro a) (pro b) (pro c) (pro d)) + :: + +XX document + +### ++pode + + ++ pode :: explode to block + |= [a=bloq b=@ c=@] ^- (list ,@) + =+ d=(rip a c) + =+ m=(met a c) + |- + ?: =(m b) + d + $(m +(m), d (weld d (limo [0 ~]))) + +XX document + +### ++sube + + ++ sube :: s-box word + |= [a=@ b=@] ^- @ + (rep 3 (turn (pode 3 4 a) |=(c=@ (cut 3 [c 1] b)))) + -- + |% + +XX document + +### ++be + + ++ be :: block cipher + |= [a=? b=@ c=@H] ^- @uxH + ~| %be-aesc + => %= . + + + => + + |% + +XX document + +### ++ankh + + ++ ankh + |= [a=cipa b=@ c=@] + (pode 5 nnb (cut 5 [(mul (ix.a b) nnb) nnb] c)) + +XX document + +### ++sark + + ++ sark + |= [c=(list ,@) d=(list ,@)] ^- (list ,@) + ?~ c ~ + ?~ d !! + [(mix i.c i.d) $(c t.c, d t.d)] + +XX document + +### ++srow + + ++ srow + |= [a=cipa b=(list ,@)] ^- (list ,@) + =+ [c=0 d=~ e=ro.a] + |- + ?: =(c nnb) + d + :_ $(c +(c)) + %+ rep 3 + %+ turn + (limo [0 p.e] [1 q.e] [2 r.e] [3 s.e] ~) + |= [f=@ g=@] + (cut 3 [f 1] (snag (mod (add g c) nnb) b)) + +XX document + +### ++subs + + ++ subs + |= [a=cipa b=(list ,@)] ^- (list ,@) + ?~ b ~ + [(sube i.b su.a) $(b t.b)] + -- + == + =+ [d=?:(a pen pin) e=(pode 5 nnb c) f=1] + => .(e (sark e (ankh d 0 b))) + |- + ?. =(nnr f) + => .(e (subs d e)) + => .(e (srow d e)) + => .(e (mcol e co.d)) + => .(e (sark e (ankh d f b))) + $(f +(f)) + => .(e (subs d e)) + => .(e (srow d e)) + => .(e (sark e (ankh d nnr b))) + (rep 5 e) + +XX document + +### ++ex + + ++ ex :: key expand + |= a=@I ^- @ + =+ [b=a c=0 d=su:pen i=nnk] + |- + ?: =(i (mul nnb +(nnr))) + b + => .(c (cut 5 [(dec i) 1] b)) + => ?: =(0 (mod i nnk)) + => .(c (ror 3 1 c)) + => .(c (sube c d)) + .(c (mix c (pow (dec (div i nnk)) 2))) + ?: &((gth nnk 6) =(4 (mod i nnk))) + .(c (sube c d)) + . + => .(c (mix c (cut 5 [(sub i nnk) 1] b))) + => .(b (can 5 [i b] [1 c] ~)) + $(i +(i)) + +XX document + +### ++ix + + ++ ix :: key expand, inv + |= a=@ ^- @ + =+ [i=1 j=_@ b=_@ c=co:pin] + |- + ?: =(nnr i) + a + => .(b (cut 7 [i 1] a)) + => .(b (rep 5 (mcol (pode 5 4 b) c))) + => .(j (sub nnr i)) + %= $ + i +(i) + a + %+ can 7 + :~ [i (cut 7 [0 i] a)] + [1 b] + [j (cut 7 [+(i) j] a)] + == + == + -- + :: + +XX document + +### ++curt + + ++ curt :: curve25519 + |= [a=@ b=@] + => %= . + + + => + + =+ =+ [p=486.662 q=(sub (bex 255) 19)] + =+ fq=~(. fo q) + [p=p q=q fq=fq] + |% + +XX document + +### ++cla + + ++ cla + |= raw=@ + =+ low=(dis 248 (cut 3 [0 1] raw)) + =+ hih=(con 64 (dis 127 (cut 3 [31 1] raw))) + =+ mid=(cut 3 [1 30] raw) + (can 3 [[1 low] [30 mid] [1 hih] ~]) + +XX document + +### ++sqr + + ++ sqr |=(a=@ (mul a a)) + +XX document + +### ++inv + + ++ inv |=(a=@ (~(exp fo q) (sub q 2) a)) + +XX document + +### ++cad + + ++ cad + |= [n=[x=@ z=@] m=[x=@ z=@] d=[x=@ z=@]] + =+ ^= xx + ;: mul 4 z.d + %- sqr %- abs:si + %+ dif:si + (sun:si (mul x.m x.n)) + (sun:si (mul z.m z.n)) + == + =+ ^= zz + ;: mul 4 x.d + %- sqr %- abs:si + %+ dif:si + (sun:si (mul x.m z.n)) + (sun:si (mul z.m x.n)) + == + [(sit.fq xx) (sit.fq zz)] + +XX document + +### ++cub + + ++ cub + |= [x=@ z=@] + =+ ^= xx + %+ mul + %- sqr %- abs:si + (dif:si (sun:si x) (sun:si z)) + (sqr (add x z)) + =+ ^= zz + ;: mul 4 x z + :(add (sqr x) :(mul p x z) (sqr z)) + == + [(sit.fq xx) (sit.fq zz)] + -- + == + =+ one=[b 1] + =+ i=253 + =+ r=one + =+ s=(cub one) + |- + ?: =(i 0) + =+ x=(cub r) + (sit.fq (mul -.x (inv +.x))) + =+ m=(rsh 0 i a) + ?: =(0 (mod m 2)) + $(i (dec i), s (cad r s one), r (cub r)) + $(i (dec i), r (cad r s one), s (cub s)) + :: + +XX document + +### ++ed + + ++ ed :: ed25519 + => + =+ =+ [b=256 q=(sub (bex 255) 19)] + =+ fq=~(. fo q) + =+ ^= l + %+ add + (bex 252) + 27.742.317.777.372.353.535.851.937.790.883.648.493 + =+ d=(dif.fq 0 (fra.fq 121.665 121.666)) + =+ ii=(exp.fq (div (dec q) 4) 2) + [b=b q=q fq=fq l=l d=d ii=ii] + ~% %coed +> ~ + |% + +### ++norm + + ++ norm |=(x=@ ?:(=(0 (mod x 2)) x (sub q x))) + :: + +XX document + +### ++xrec + + ++ xrec :: recover x-coord + |= y=@ ^- @ + =+ ^= xx + %+ mul (dif.fq (mul y y) 1) + (inv.fq +(:(mul d y y))) + =+ x=(exp.fq (div (add 3 q) 8) xx) + ?: !=(0 (dif.fq (mul x x) (sit.fq xx))) + (norm (pro.fq x ii)) + (norm x) + :: + +XX document + +### ++ward + + ++ ward :: edwards multiply + |= [pp=[@ @] qq=[@ @]] ^- [@ @] + =+ dp=:(pro.fq d -.pp -.qq +.pp +.qq) + =+ ^= xt + %+ pro.fq + %+ sum.fq + (pro.fq -.pp +.qq) + (pro.fq -.qq +.pp) + (inv.fq (sum.fq 1 dp)) + =+ ^= yt + %+ pro.fq + %+ sum.fq + (pro.fq +.pp +.qq) + (pro.fq -.pp -.qq) + (inv.fq (dif.fq 1 dp)) + [xt yt] + :: + +XX document + +### ++scam + + ++ scam :: scalar multiply + |= [pp=[@ @] e=@] ^- [@ @] + ?: =(0 e) + [0 1] + =+ qq=$(e (div e 2)) + => .(qq (ward qq qq)) + ?: =(1 (dis 1 e)) + (ward qq pp) + qq + :: + +XX document + +### ++etch + + ++ etch :: encode point + |= pp=[@ @] ^- @ + (can 0 ~[[(sub b 1) +.pp] [1 (dis 1 -.pp)]]) + :: + +XX document + +### ++curv + + ++ curv :: point on curve? + |= [x=@ y=@] ^- ? + .= 0 + %+ dif.fq + %+ sum.fq + (pro.fq (sub q (sit.fq x)) x) + (pro.fq y y) + (sum.fq 1 :(pro.fq d x x y y)) + :: + +XX document + +### ++deco + + ++ deco :: decode point + |= s=@ ^- (unit ,[@ @]) + =+ y=(cut 0 [0 (dec b)] s) + =+ si=(cut 0 [(dec b) 1] s) + =+ x=(xrec y) + => .(x ?:(!=(si (dis 1 x)) (sub q x) x)) + =+ pp=[x y] + ?. (curv pp) + ~ + [~ pp] + :: + +XX document + +### ++bb + + ++ bb + =+ bby=(pro.fq 4 (inv.fq 5)) + [(xrec bby) bby] + :: + -- + ~% %ed + ~ + |% + +XX document + +### ++puck + + ++ puck :: public key + ~/ %puck + |= sk=@I ^- @ + ?: (gth (met 3 sk) 32) !! + =+ h=(shal (rsh 0 3 b) sk) + =+ ^= a + %+ add + (bex (sub b 2)) + (lsh 0 3 (cut 0 [3 (sub b 5)] h)) + =+ aa=(scam bb a) + (etch aa) + +XX document + +### ++suck + + ++ suck :: keypair from seed + |= se=@I ^- @uJ + =+ pu=(puck se) + (can 0 ~[[b se] [b pu]]) + :: + +XX document + +### ++sign + + ++ sign :: certify + ~/ %sign + |= [m=@ se=@] ^- @ + =+ sk=(suck se) + =+ pk=(cut 0 [b b] sk) + =+ h=(shal (rsh 0 3 b) sk) + =+ ^= a + %+ add + (bex (sub b 2)) + (lsh 0 3 (cut 0 [3 (sub b 5)] h)) + =+ ^= r + =+ hm=(cut 0 [b b] h) + =+ ^= i + %+ can 0 + :~ [b hm] + [(met 0 m) m] + == + (shaz i) + =+ rr=(scam bb r) + =+ ^= ss + =+ er=(etch rr) + =+ ^= ha + %+ can 0 + :~ [b er] + [b pk] + [(met 0 m) m] + == + (~(sit fo l) (add r (mul (shaz ha) a))) + (can 0 ~[[b (etch rr)] [b ss]]) + :: + +XX document + +### ++veri + + ++ veri :: validate + ~/ %veri + |= [s=@ m=@ pk=@] ^- ? + ?: (gth (div b 4) (met 3 s)) | + ?: (gth (div b 8) (met 3 pk)) | + =+ cb=(rsh 0 3 b) + =+ rr=(deco (cut 0 [0 b] s)) + ?~ rr | + =+ aa=(deco pk) + ?~ aa | + =+ ss=(cut 0 [b b] s) + =+ ha=(can 3 ~[[cb (etch u.rr)] [cb pk] [(met 3 m) m]]) + =+ h=(shaz ha) + =((scam bb ss) (ward u.rr (scam u.aa h))) + :: + -- + :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +XX document + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/2ey.md b/docs/pub/doc/hoon/library/2ey.md new file mode 100644 index 0000000000..3a9485d565 --- /dev/null +++ b/docs/pub/doc/hoon/library/2ey.md @@ -0,0 +1,399 @@ +section 2eY, SHA-256 +==================== + +### ++shad + + ++ shad |=(ruz=@ (shax (shax ruz))) :: double sha-256 + +XX document + +### ++shaf + + ++ shaf :: half sha-256 + |= [sal=@ ruz=@] + =+ haz=(shas sal ruz) + (mix (end 7 1 haz) (rsh 7 1 haz)) + :: + +XX document + +### ++shak + + ++ shak :: XX shd be PBKDF + |= [who=@p wud=@] + (shas (mix %shak who) wud) + :: + +XX document + +### ++sham + + ++ sham :: noun hash + |= yux=* ^- @uvH ^- @ + ?@ yux + (shaf %mash yux) + (shaf %sham (jam yux)) + :: + +XX document + +### ++shas + + ++ shas :: salted hash + |= [sal=@ ruz=@] + (shax (mix sal (shax ruz))) + :: + +XX document + +### ++shax + + ++ shax :: sha-256 + ~/ %shax + |= ruz=@ ^- @ + ~| %sha + =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))] + =+ [sum=sum.few ror=ror.few net=net.few inv=inv.few] + =+ ral=(lsh 0 3 (met 3 ruz)) + =+ ^= ful + %+ can 0 + :~ [ral ruz] + [8 128] + [(mod (sub 960 (mod (add 8 ral) 512)) 512) 0] + [64 (~(net fe 6) ral)] + == + =+ lex=(met 9 ful) + =+ ^= kbx 0xc671.78f2.bef9.a3f7.a450.6ceb.90be.fffa. + 8cc7.0208.84c8.7814.78a5.636f.748f.82ee. + 682e.6ff3.5b9c.ca4f.4ed8.aa4a.391c.0cb3. + 34b0.bcb5.2748.774c.1e37.6c08.19a4.c116. + 106a.a070.f40e.3585.d699.0624.d192.e819. + c76c.51a3.c24b.8b70.a81a.664b.a2bf.e8a1. + 9272.2c85.81c2.c92e.766a.0abb.650a.7354. + 5338.0d13.4d2c.6dfc.2e1b.2138.27b7.0a85. + 1429.2967.06ca.6351.d5a7.9147.c6e0.0bf3. + bf59.7fc7.b003.27c8.a831.c66d.983e.5152. + 76f9.88da.5cb0.a9dc.4a74.84aa.2de9.2c6f. + 240c.a1cc.0fc1.9dc6.efbe.4786.e49b.69c1. + c19b.f174.9bdc.06a7.80de.b1fe.72be.5d74. + 550c.7dc3.2431.85be.1283.5b01.d807.aa98. + ab1c.5ed5.923f.82a4.59f1.11f1.3956.c25b. + e9b5.dba5.b5c0.fbcf.7137.4491.428a.2f98 + =+ ^= hax 0x5be0.cd19.1f83.d9ab.9b05.688c.510e.527f. + a54f.f53a.3c6e.f372.bb67.ae85.6a09.e667 + =+ i=0 + |- ^- @ + ?: =(i lex) + (rep 5 (turn (rip 5 hax) net)) + =+ ^= wox + =+ dux=(cut 9 [i 1] ful) + =+ wox=(rep 5 (turn (rip 5 dux) net)) + =+ j=16 + |- ^- @ + ?: =(64 j) + wox + =+ :* l=(wac (sub j 15) wox) + m=(wac (sub j 2) wox) + n=(wac (sub j 16) wox) + o=(wac (sub j 7) wox) + == + =+ x=:(mix (ror 0 7 l) (ror 0 18 l) (rsh 0 3 l)) + =+ y=:(mix (ror 0 17 m) (ror 0 19 m) (rsh 0 10 m)) + =+ z=:(sum n x o y) + $(wox (con (lsh 5 j z) wox), j +(j)) + =+ j=0 + =+ :* a=(wac 0 hax) + b=(wac 1 hax) + c=(wac 2 hax) + d=(wac 3 hax) + e=(wac 4 hax) + f=(wac 5 hax) + g=(wac 6 hax) + h=(wac 7 hax) + == + |- ^- @ + ?: =(64 j) + %= ^$ + i +(i) + hax %+ rep 5 + :~ (sum a (wac 0 hax)) + (sum b (wac 1 hax)) + (sum c (wac 2 hax)) + (sum d (wac 3 hax)) + (sum e (wac 4 hax)) + (sum f (wac 5 hax)) + (sum g (wac 6 hax)) + (sum h (wac 7 hax)) + == + == + =+ l=:(mix (ror 0 2 a) (ror 0 13 a) (ror 0 22 a)) :: s0 + =+ m=:(mix (dis a b) (dis a c) (dis b c)) :: maj + =+ n=(sum l m) :: t2 + =+ o=:(mix (ror 0 6 e) (ror 0 11 e) (ror 0 25 e)) :: s1 + =+ p=(mix (dis e f) (dis (inv e) g)) :: ch + =+ q=:(sum h o p (wac j kbx) (wac j wox)) :: t1 + $(j +(j), a (sum q n), b a, c b, d c, e (sum d q), f e, g f, h g) + :: + +XX document + +### ++shaw + + ++ shaw :: hash to nbits + |= [sal=@ len=@ ruz=@] + (~(raw og (shas sal (mix len ruz))) len) + :: + +XX document + +### ++og + + ++ og :: shax-powered rng + ~/ %og + |_ a=@ + +XX document + +### ++rad + + ++ rad :: random in range + |= b=@ ^- @ + =+ c=(raw (met 0 b)) + ?:((lth c b) c $(a +(a))) + :: + +XX document + +### ++rads + + ++ rads :: random continuation + |= b=@ + =+ r=(rad b) + [r +>.$(a (shas %og-s r))] + +XX document + +### ++raw + + ++ raw :: random bits + ~/ %raw + |= b=@ ^- @ + %+ can + 0 + =+ c=(shas %og-a (mix b a)) + |- ^- (list ,[@ @]) + ?: =(0 b) + ~ + =+ d=(shas %og-b (mix b (mix a c))) + ?: (lth b 256) + [[b (end 0 b d)] ~] + [[256 d] $(c d, b (sub b 256))] + +XX document + +### ++raws + + ++ raws :: random bits continuation + |= b=@ + =+ r=(raw b) + [r +>.$(a (shas %og-s r))] + -- + +XX document + +### ++shaz + + ++ shaz :: sha-512 + |= ruz=@ ^- @ + (shal [(met 3 ruz) ruz]) + +XX document + +### ++shal + + ++ shal :: sha-512 with length + ~/ %shal + |= [len=@ ruz=@] ^- @ + => .(ruz (cut 3 [0 len] ruz)) + =+ [few==>(fe .(a 6)) wac=|=([a=@ b=@] (cut 6 [a 1] b))] + =+ [sum=sum.few ror=ror.few net=net.few inv=inv.few] + =+ ral=(lsh 0 3 len) + =+ ^= ful + %+ can 0 + :~ [ral ruz] + [8 128] + [(mod (sub 1.920 (mod (add 8 ral) 1.024)) 1.024) 0] + [128 (~(net fe 7) ral)] + == + =+ lex=(met 10 ful) + =+ ^= kbx 0x6c44.198c.4a47.5817.5fcb.6fab.3ad6.faec. + 597f.299c.fc65.7e2a.4cc5.d4be.cb3e.42b6. + 431d.67c4.9c10.0d4c.3c9e.be0a.15c9.bebc. + 32ca.ab7b.40c7.2493.28db.77f5.2304.7d84. + 1b71.0b35.131c.471b.113f.9804.bef9.0dae. + 0a63.7dc5.a2c8.98a6.06f0.67aa.7217.6fba. + f57d.4f7f.ee6e.d178.eada.7dd6.cde0.eb1e. + d186.b8c7.21c0.c207.ca27.3ece.ea26.619c. + c671.78f2.e372.532b.bef9.a3f7.b2c6.7915. + a450.6ceb.de82.bde9.90be.fffa.2363.1e28. + 8cc7.0208.1a64.39ec.84c8.7814.a1f0.ab72. + 78a5.636f.4317.2f60.748f.82ee.5def.b2fc. + 682e.6ff3.d6b2.b8a3.5b9c.ca4f.7763.e373. + 4ed8.aa4a.e341.8acb.391c.0cb3.c5c9.5a63. + 34b0.bcb5.e19b.48a8.2748.774c.df8e.eb99. + 1e37.6c08.5141.ab53.19a4.c116.b8d2.d0c8. + 106a.a070.32bb.d1b8.f40e.3585.5771.202a. + d699.0624.5565.a910.d192.e819.d6ef.5218. + c76c.51a3.0654.be30.c24b.8b70.d0f8.9791. + a81a.664b.bc42.3001.a2bf.e8a1.4cf1.0364. + 9272.2c85.1482.353b.81c2.c92e.47ed.aee6. + 766a.0abb.3c77.b2a8.650a.7354.8baf.63de. + 5338.0d13.9d95.b3df.4d2c.6dfc.5ac4.2aed. + 2e1b.2138.5c26.c926.27b7.0a85.46d2.2ffc. + 1429.2967.0a0e.6e70.06ca.6351.e003.826f. + d5a7.9147.930a.a725.c6e0.0bf3.3da8.8fc2. + bf59.7fc7.beef.0ee4.b003.27c8.98fb.213f. + a831.c66d.2db4.3210.983e.5152.ee66.dfab. + 76f9.88da.8311.53b5.5cb0.a9dc.bd41.fbd4. + 4a74.84aa.6ea6.e483.2de9.2c6f.592b.0275. + 240c.a1cc.77ac.9c65.0fc1.9dc6.8b8c.d5b5. + efbe.4786.384f.25e3.e49b.69c1.9ef1.4ad2. + c19b.f174.cf69.2694.9bdc.06a7.25c7.1235. + 80de.b1fe.3b16.96b1.72be.5d74.f27b.896f. + 550c.7dc3.d5ff.b4e2.2431.85be.4ee4.b28c. + 1283.5b01.4570.6fbe.d807.aa98.a303.0242. + ab1c.5ed5.da6d.8118.923f.82a4.af19.4f9b. + 59f1.11f1.b605.d019.3956.c25b.f348.b538. + e9b5.dba5.8189.dbbc.b5c0.fbcf.ec4d.3b2f. + 7137.4491.23ef.65cd.428a.2f98.d728.ae22 + =+ ^= hax 0x5be0.cd19.137e.2179.1f83.d9ab.fb41.bd6b. + 9b05.688c.2b3e.6c1f.510e.527f.ade6.82d1. + a54f.f53a.5f1d.36f1.3c6e.f372.fe94.f82b. + bb67.ae85.84ca.a73b.6a09.e667.f3bc.c908 + =+ i=0 + |- ^- @ + ?: =(i lex) + (rep 6 (turn (rip 6 hax) net)) + =+ ^= wox + =+ dux=(cut 10 [i 1] ful) + =+ wox=(rep 6 (turn (rip 6 dux) net)) + =+ j=16 + |- ^- @ + ?: =(80 j) + wox + =+ :* l=(wac (sub j 15) wox) + m=(wac (sub j 2) wox) + n=(wac (sub j 16) wox) + o=(wac (sub j 7) wox) + == + =+ x=:(mix (ror 0 1 l) (ror 0 8 l) (rsh 0 7 l)) + =+ y=:(mix (ror 0 19 m) (ror 0 61 m) (rsh 0 6 m)) + =+ z=:(sum n x o y) + $(wox (con (lsh 6 j z) wox), j +(j)) + =+ j=0 + =+ :* a=(wac 0 hax) + b=(wac 1 hax) + c=(wac 2 hax) + d=(wac 3 hax) + e=(wac 4 hax) + f=(wac 5 hax) + g=(wac 6 hax) + h=(wac 7 hax) + == + |- ^- @ + ?: =(80 j) + %= ^$ + i +(i) + hax %+ rep 6 + :~ (sum a (wac 0 hax)) + (sum b (wac 1 hax)) + (sum c (wac 2 hax)) + (sum d (wac 3 hax)) + (sum e (wac 4 hax)) + (sum f (wac 5 hax)) + (sum g (wac 6 hax)) + (sum h (wac 7 hax)) + == + == + =+ l=:(mix (ror 0 28 a) (ror 0 34 a) (ror 0 39 a)) :: S0 + =+ m=:(mix (dis a b) (dis a c) (dis b c)) :: maj + =+ n=(sum l m) :: t2 + =+ o=:(mix (ror 0 14 e) (ror 0 18 e) (ror 0 41 e)) :: S1 + =+ p=(mix (dis e f) (dis (inv e) g)) :: ch + =+ q=:(sum h o p (wac j kbx) (wac j wox)) :: t1 + $(j +(j), a (sum q n), b a, c b, d c, e (sum d q), f e, g f, h g) + :: + +XX document + +### ++shan + + ++ shan :: sha-1 (deprecated) + |= ruz=@ + =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))] + =+ [sum=sum.few ror=ror.few rol=rol.few net=net.few inv=inv.few] + =+ ral=(lsh 0 3 (met 3 ruz)) + =+ ^= ful + %+ can 0 + :~ [ral ruz] + [8 128] + [(mod (sub 960 (mod (add 8 ral) 512)) 512) 0] + [64 (~(net fe 6) ral)] + == + =+ lex=(met 9 ful) + =+ kbx=0xca62.c1d6.8f1b.bcdc.6ed9.eba1.5a82.7999 + =+ hax=0xc3d2.e1f0.1032.5476.98ba.dcfe.efcd.ab89.6745.2301 + =+ i=0 + |- + ?: =(i lex) + (rep 5 (flop (rip 5 hax))) + =+ ^= wox + =+ dux=(cut 9 [i 1] ful) + =+ wox=(rep 5 (turn (rip 5 dux) net)) + =+ j=16 + |- ^- @ + ?: =(80 j) + wox + =+ :* l=(wac (sub j 3) wox) + m=(wac (sub j 8) wox) + n=(wac (sub j 14) wox) + o=(wac (sub j 16) wox) + == + =+ z=(rol 0 1 :(mix l m n o)) + $(wox (con (lsh 5 j z) wox), j +(j)) + =+ j=0 + =+ :* a=(wac 0 hax) + b=(wac 1 hax) + c=(wac 2 hax) + d=(wac 3 hax) + e=(wac 4 hax) + == + |- ^- @ + ?: =(80 j) + %= ^$ + i +(i) + hax %+ rep 5 + :~ + (sum a (wac 0 hax)) + (sum b (wac 1 hax)) + (sum c (wac 2 hax)) + (sum d (wac 3 hax)) + (sum e (wac 4 hax)) + == + == + =+ fx=(con (dis b c) (dis (not 5 1 b) d)) + =+ fy=:(mix b c d) + =+ fz=:(con (dis b c) (dis b d) (dis c d)) + =+ ^= tem + ?: &((gte j 0) (lte j 19)) + :(sum (rol 0 5 a) fx e (wac 0 kbx) (wac j wox)) + ?: &((gte j 20) (lte j 39)) + :(sum (rol 0 5 a) fy e (wac 1 kbx) (wac j wox)) + ?: &((gte j 40) (lte j 59)) + :(sum (rol 0 5 a) fz e (wac 2 kbx) (wac j wox)) + :(sum (rol 0 5 a) fy e (wac 3 kbx) (wac j wox)) + $(j +(j), a tem, b a, c (rol 0 30 b), d c, e d) + +XX document + +-- diff --git a/docs/pub/doc/hoon/library/2ez.md b/docs/pub/doc/hoon/library/2ez.md new file mode 100644 index 0000000000..93f2a68c60 --- /dev/null +++ b/docs/pub/doc/hoon/library/2ez.md @@ -0,0 +1,252 @@ +section 2eZ, OLD rendering +-------------------------- + +------------------------------------------------------------------------ + +### ++show + + ++ show :: XX deprecated, use type + |= vem=* + |^ ^- tank + ?: ?=(@ vem) + [%leaf (mesc (trip vem))] + ?- vem + [s=~ c=*] + [%leaf '\'' (weld (mesc (tape +.vem)) `tape`['\'' ~])] + :: + [s=%a c=@] [%leaf (mesc (trip c.vem))] + [s=%b c=*] (shop c.vem |=(a=@ ~(rub at a))) + [s=[%c p=@] c=*] + :+ %palm + [['.' ~] ['-' ~] ~ ~] + [[%leaf (mesc (trip p.s.vem))] $(vem c.vem) ~] + :: + [s=%d c=*] (shop c.vem |=(a=@ ~(rud at a))) + [s=%k c=*] (tank c.vem) + [s=%h c=*] + ?: =(0 c.vem) :: XX remove after 220 + [%leaf '#' ~] + :+ %rose + [['/' ~] ['/' ~] ~] + =+ yol=((list ,@ta) c.vem) + (turn yol |=(a=@ta [%leaf (trip a)])) + :: + [s=%o c=*] + %= $ + vem + :- [%m '%h:<[%d %d].[%d %d]>'] + [-.c.vem +<-.c.vem +<+.c.vem +>-.c.vem +>+.c.vem ~] + == + :: + [s=%p c=*] (shop c.vem |=(a=@ ~(rup at a))) + [s=%q c=*] (shop c.vem |=(a=@ ~(r at a))) + [s=%r c=*] $(vem [[%r ' ' '{' '}'] c.vem]) + [s=%t c=*] (shop c.vem |=(a=@ ~(rt at a))) + [s=%v c=*] (shop c.vem |=(a=@ ~(ruv at a))) + [s=%x c=*] (shop c.vem |=(a=@ ~(rux at a))) + [s=[%m p=@] c=*] (shep p.s.vem c.vem) + [s=[%r p=@] c=*] + $(vem [[%r ' ' (cut 3 [0 1] p.s.vem) (cut 3 [1 1] p.s.vem)] c.vem]) + :: + [s=[%r p=@ q=@ r=@] c=*] + :+ %rose + :* p=(mesc (trip p.s.vem)) + q=(mesc (trip q.s.vem)) + r=(mesc (trip r.s.vem)) + == + |- ^- (list tank) + ?@ c.vem + ~ + [^$(vem -.c.vem) $(c.vem +.c.vem)] + :: + [s=%z c=*] $(vem [[%r %$ %$ %$] c.vem]) + * !! + == + +XX document + +### ++shep + + ++ shep + |= [fom=@ gar=*] + ^- tank + =+ l=(met 3 fom) + =+ i=0 + :- %leaf + |- ^- tape + ?: (gte i l) + ~ + =+ c=(cut 3 [i 1] fom) + ?. =(37 c) + (weld (mesc [c ~]) $(i +(i))) + =+ d=(cut 3 [+(i) 1] fom) + ?. .?(gar) + ['\\' '#' $(i (add 2 i))] + (weld ~(ram re (show d -.gar)) $(i (add 2 i), gar +.gar)) + :: + +XX document + +### ++shop + + ++ shop + |= [aug=* vel=$+(a=@ tape)] + ^- tank + ?: ?=(@ aug) + [%leaf (vel aug)] + :+ %rose + [[' ' ~] ['[' ~] [']' ~]] + => .(aug `*`aug) + |- ^- (list tank) + ?: ?=(@ aug) + [^$ ~] + [^$(aug -.aug) $(aug +.aug)] + -- + +XX document + +### ++at + + ++ at + |_ a=@ + +XX document + +### ++r + + ++ r + ?: ?& (gte (met 3 a) 2) + |- + ?: =(0 a) + & + =+ vis=(end 3 1 a) + ?& ?|(=('-' vis) ?&((gte vis 'a') (lte vis 'z'))) + $(a (rsh 3 1 a)) + == + == + rtam + ?: (lte (met 3 a) 2) + rud + rux + :: + +XX document + +### ++rf + + ++ rf `tape`[?-(a & '&', | '|', * !!) ~] + +XX document + +### ++rn + + ++ rn `tape`[?>(=(0 a) '~') ~] + +XX document + +### ++rt + + ++ rt `tape`['\'' (weld (mesc (trip a)) `tape`['\'' ~])] + +XX document + +### ++rta + + ++ rta rt + +XX document + +### ++rtam + + ++ rtam `tape`['%' (trip a)] + +XX document + +### ++rub + + ++ rub `tape`['0' 'b' (rum 2 ~ |=(b=@ (add '0' b)))] + +XX document + +### ++rud + + ++ rud (rum 10 ~ |=(b=@ (add '0' b))) + +XX document + +### ++rum + + ++ rum + |= [b=@ c=tape d=$+(@ @)] + ^- tape + ?: =(0 a) + [(d 0) c] + =+ e=0 + |- ^- tape + ?: =(0 a) + c + =+ f=&(!=(0 e) =(0 (mod e ?:(=(10 b) 3 4)))) + %= $ + a (div a b) + c [(d (mod a b)) ?:(f [?:(=(10 b) ',' '-') c] c)] + e +(e) + == + :: + +XX document + +### ++rup + + ++ rup + =+ b=(met 3 a) + ^- tape + :- '-' + |- ^- tape + ?: (gth (met 5 a) 1) + %+ weld + $(a (rsh 5 1 a), b (sub b 4)) + `tape`['-' '-' $(a (end 5 1 a), b 4)] + ?: =(0 b) + ['~' ~] + ?: (lte b 1) + (trip (tos:po a)) + |- ^- tape + ?: =(2 b) + =+ c=(rsh 3 1 a) + =+ d=(end 3 1 a) + (weld (trip (tod:po c)) (trip (tos:po (mix c d)))) + =+ c=(rsh 3 2 a) + =+ d=(end 3 2 a) + (weld ^$(a c, b (met 3 c)) `tape`['-' $(a (mix c d), b 2)]) + :: + +XX document + +### ++ruv + + ++ ruv + ^- tape + :+ '0' + 'v' + %^ rum + 64 + ~ + |= b=@ + ?: =(63 b) + '+' + ?: =(62 b) + '-' + ?:((lth b 26) (add 65 b) ?:((lth b 52) (add 71 b) (sub b 4))) + :: + +XX document + +### ++rux + + ++ rux `tape`['0' 'x' (rum 16 ~ |=(b=@ (add b ?:((lth b 10) 48 87))))] + -- + :::::::::::::::::::::::::::::::::::::::::::::::::::::: :: + +XX document + +------------------------------------------------------------------------ diff --git a/docs/pub/doc/hoon/library/3ba.md b/docs/pub/doc/hoon/library/3ba.md new file mode 100644 index 0000000000..8917c642c5 --- /dev/null +++ b/docs/pub/doc/hoon/library/3ba.md @@ -0,0 +1,67 @@ +section 3bA, lite number theory +=============================== + +### ++fu + + ++ fu :: modulo (mul p q) + |= a=[p=@ q=@] + =+ b=?:(=([0 0] a) 0 (~(inv fo p.a) (~(sit fo p.a) q.a))) + |% + +XX document + +### ++dif + + ++ dif + |= [c=[@ @] d=[@ @]] + [(~(dif fo p.a) -.c -.d) (~(dif fo q.a) +.c +.d)] + :: + +XX document + +### ++exp + + ++ exp + |= [c=@ d=[@ @]] + :- (~(exp fo p.a) (mod c (dec p.a)) -.d) + (~(exp fo q.a) (mod c (dec q.a)) +.d) + :: + +XX document + +### ++out + + ++ out :: garner's formula + |= c=[@ @] + %+ add + +.c + (mul q.a (~(pro fo p.a) b (~(dif fo p.a) -.c (~(sit fo p.a) +.c)))) + :: + +XX document + +### ++pro + + ++ pro + |= [c=[@ @] d=[@ @]] + [(~(pro fo p.a) -.c -.d) (~(pro fo q.a) +.c +.d)] + :: + +XX document + +### ++sum + + ++ sum + |= [c=[@ @] d=[@ @]] + [(~(sum fo p.a) -.c -.d) (~(sum fo q.a) +.c +.d)] + :: + +XX document + +### ++sit + + ++ sit + |= c=@ + [(mod c p.a) (mod c q.a)] + +XX document diff --git a/docs/pub/doc/hoon/library/3bb.md b/docs/pub/doc/hoon/library/3bb.md new file mode 100644 index 0000000000..d73b5fb29a --- /dev/null +++ b/docs/pub/doc/hoon/library/3bb.md @@ -0,0 +1,600 @@ +section 3bB, cryptosuites +========================= + +### ++crua + + ++ crua !: :: cryptosuite A (RSA) + ^- acru + =| [mos=@ pon=(unit ,[p=@ q=@ r=[p=@ q=@] s=_*fu])] + => |% + +XX document + +### ++mx + + ++ mx (dec (met 0 mos)) :: bit length + +XX document + +### ++dap + + ++ dap :: OEAP decode + |= [wid=@ xar=@ dog=@] ^- [p=@ q=@] + =+ pav=(sub wid xar) + =+ qoy=(cut 0 [xar pav] dog) + =+ dez=(mix (end 0 xar dog) (shaw %pad-b xar qoy)) + [dez (mix qoy (shaw %pad-a pav dez))] + :: + +XX document + +### ++pad + + ++ pad :: OEAP encode + |= [wid=@ rax=[p=@ q=@] meg=@] ^- @ + =+ pav=(sub wid p.rax) + ?> (gte pav (met 0 meg)) + ^- @ + =+ qoy=(mix meg (shaw %pad-a pav q.rax)) + =+ dez=(mix q.rax (shaw %pad-b p.rax qoy)) + (can 0 [p.rax dez] [pav qoy] ~) + |% + +XX document + +### ++pull + + ++ pull |=(a=@ (~(exp fo mos) 3 a)) + +XX document + +### ++push + + ++ push |=(a=@ (~(exp fo mos) 5 a)) + +XX document + +### ++pump + + ++ pump + |= a=@ ^- @ + ?~ pon !! + (out.s.u.pon (exp.s.u.pon p.r.u.pon (sit.s.u.pon a))) + :: + +XX document + +### ++punt + + ++ punt + |= a=@ ^- @ + ?~ pon !! + (out.s.u.pon (exp.s.u.pon q.r.u.pon (sit.s.u.pon a))) + |% + +XX document + +### ++as + + ++ as + => |% + +XX document + +### ++haul + + ++ haul :: revealing haul + |= a=pass + !! + ^? + |% ++ seal + |= [a=pass b=@ c=@] + ^- @ + !! + +XX document + +### ++seal + + + XX document + + ###++sign + + ``` + ++ sign + |= [a=@ b=@] ^- @ + !! + ``` + + XX document + + ###++sure + + ``` + ++ sure + |= [a=@ b=@] + ^- (unit ,@) + !! + ``` + + XX document + + ###++tear + + ``` + ++ tear + |= [a=pass b=@] + ^- (unit ,[p=@ q=@]) + !! + :: + ``` + + XX document + + ###++de + + ``` + ++ de + |+ [key=@ cep=@] ^- (unit ,@) + !! + :: + ``` + + XX document + + ###++dy + + ``` + ++ dy + |+ [a=@ b=@] ^- @ + !! + ``` + + XX document + + ###++en + + ``` + ++ en + |+ [key=@ msg=@] ^- @ux + !! + :: + ``` + + XX document + + ###++ex + + ``` + ++ ex ^? + |% ++ fig ^- @uvH (shaf %bfig puc) + ``` + + XX document + + ###++fig + +XX document + +### ++pac + + ++ pac ^- @uvG (end 6 1 (shaf %acod sec)) + +XX document + +### ++pub + + ++ pub ^- pass (cat 3 'b' puc) + +XX document + +### ++sec + + ++ sec ^- ring sed + :: + +XX document + +### ++nu + + ++ nu + ^? + |% ++ com + |= a=@ + ^+ ^?(..nu) + ..nu(sed ~, puc a) + :: + +XX document + +### ++elcm + + ++ elcm + |= [a=@ b=@] + (div (mul a b) d:(egcd a b)) + :: + +XX document + +### ++eldm + + ++ eldm + |= [a=@ b=@ c=@] + (~(inv fo (elcm (dec b) (dec c))) a) + :: + +XX document + +### ++ersa + + ++ ersa + |= [a=@ b=@] + [a b [(eldm 3 a b) (eldm 5 a b)] (fu a b)] + ^? + |% ++ com + |= a=@ + ^+ ^?(..nu) + ..nu(mos a, pon ~) + :: + +XX document + +### ++com + + + XX document + + ###++pit + + ``` + ++ pit + |= [a=@ b=@] + ^+ ^?(..nu) + ..nu(sed b, puc (puck:ed b)) + :: + ``` + + XX document + + ###++nol + + ``` + ++ nol + |= a=@ + ^+ ^?(..nu) + ..nu(sed a, puc (puck:ed a)) + ``` + + XX document + + ###++bruw + + ``` + ++ bruw :: create keypair + |= [a=@ b=@] :: width seed + ^- acru + (pit:nu:crua a b) + :: + ``` + + XX document + + ###++haul + + ``` + ++ haul :: revealing haul + |= a=pass + !! + ^? + |% ++ seal + |= [a=pass b=@ c=@] + ^- @ + !! + ``` + + XX document + + ###++weur + + ``` + ++ weur :: activate secret key + |= a=ring + ^- acru + =+ [mag=(end 3 1 a) bod=(rsh 3 1 a)] + ?> =('A' mag) + (nol:nu:crua bod) + :: + ``` + + XX document + + ###++trua + + ``` + ++ trua :: test rsa + |= msg=@tas + ^- @ + =+ ali=(bruw 1.024 (shax 'ali')) + =+ bob=(bruw 1.024 (shax 'bob')) + =+ tef=(sign:as.ali [0 msg]) + =+ lov=(sure:as.ali [0 tef]) + ?. &(?=(^ lov) =(msg u.lov)) + ~|(%test-fail-sign !!) + =+ key=(shax (shax (shax msg))) + =+ sax=(seal:as.ali pub:ex.bob key msg) + =+ tin=(tear:as.bob pub:ex.ali sax) + ?. &(?=(^ tin) =(key p.u.tin) =(msg q.u.tin)) + ~|(%test-fail-seal !!) + msg + :: + ``` + + XX document + + ###++crub + + ``` + ++ crub :: cryptosuite B (Ed) + ^- acru + =| [puc=pass sed=ring] + => |% + ``` + + XX document + + ###++dap + + ``` + ++ dap :: OEAP decode + |= [wid=@ xar=@ dog=@] ^- [p=@ q=@] + =+ pav=(sub wid xar) + =+ qoy=(cut 0 [xar pav] dog) + =+ dez=(mix (end 0 xar dog) (shaw %pad-b xar qoy)) + [dez (mix qoy (shaw %pad-a pav dez))] + :: + ``` + + XX document + + ###++pad + + ``` + ++ pad :: OEAP encode + |= [wid=@ rax=[p=@ q=@] meg=@] ^- @ + =+ pav=(sub wid p.rax) + ?> (gte pav (met 0 meg)) + ^- @ + =+ qoy=(mix meg (shaw %pad-a pav q.rax)) + =+ dez=(mix q.rax (shaw %pad-b p.rax qoy)) + (can 0 [p.rax dez] [pav qoy] ~) + |% + ``` + + XX document + + ###++as + + ``` + ++ as + => |% + ``` + + XX document + + ###++haul + + ``` + ++ haul :: revealing haul + |= a=pass + !! + ^? + |% ++ seal + |= [a=pass b=@ c=@] + ^- @ + !! + ``` + + XX document + + ###++seal + +XX document + +### ++sign + + ++ sign + |= [a=@ b=@] ^- @ + !! + +XX document + +### ++sure + + ++ sure + |= [a=@ b=@] + ^- (unit ,@) + !! + +XX document + +### ++tear + + ++ tear + |= [a=pass b=@] + ^- (unit ,[p=@ q=@]) + !! + :: + +XX document + +### ++de + + ++ de + |+ [key=@ cep=@] ^- (unit ,@) + !! + :: + +XX document + +### ++dy + + ++ dy + |+ [a=@ b=@] ^- @ + !! + +XX document + +### ++en + + ++ en + |+ [key=@ msg=@] ^- @ux + !! + :: + +XX document + +### ++ex + + ++ ex ^? + |% ++ fig ^- @uvH (shaf %bfig puc) + +XX document + +### ++fig + + + XX document + + ###++pac + + ``` + ++ pac ^- @uvG (end 6 1 (shaf %acod sec)) + ``` + + XX document + + ###++pub + + ``` + ++ pub ^- pass (cat 3 'b' puc) + ``` + + XX document + + ###++sec + + ``` + ++ sec ^- ring sed + :: + ``` + + XX document + + ###++nu + + ``` + ++ nu + ^? + |% ++ com + |= a=@ + ^+ ^?(..nu) + ..nu(sed ~, puc a) + :: + ``` + + XX document + + ###++com + +XX document + +### ++pit + + ++ pit + |= [a=@ b=@] + ^+ ^?(..nu) + ..nu(sed b, puc (puck:ed b)) + :: + +XX document + +### ++nol + + ++ nol + |= a=@ + ^+ ^?(..nu) + ..nu(sed a, puc (puck:ed a)) + +XX document + +### ++brew + + ++ brew :: create keypair + |= [a=@ b=@] :: width seed + ^- acru + (pit:nu:crub a b) + :: + +XX document + +### ++hail + + ++ hail :: activate public key + |= a=pass + ^- acru + =+ [mag=(end 3 1 a) bod=(rsh 3 1 a)] + ?> =('b' mag) + (com:nu:crub bod) + :: + +XX document + +### ++wear + + ++ wear :: activate secret key + |= a=ring + ^- acru + =+ [mag=(end 3 1 a) bod=(rsh 3 1 a)] + ?> =('b' mag) + (nol:nu:crub bod) + :: + +XX document + +### ++trub + + ++ trub :: test ed + |= msg=@tas + ^- @ + =+ ali=(brew 1.024 (shax 'ali')) + =+ bob=(brew 1.024 (shax 'bob')) + =+ tef=(sign:as.ali [0 msg]) + =+ lov=(sure:as.ali [0 tef]) + ?. &(?=(^ lov) =(msg u.lov)) + ~|(%test-fail-sign !!) + =+ key=(shax (shax (shax msg))) + =+ sax=(seal:as.ali pub:ex.bob key msg) + =+ tin=(tear:as.bob pub:ex.ali sax) + ?. &(?=(^ tin) =(key p.u.tin) =(msg q.u.tin)) + ~|(%test-fail-seal !!) + msg + :: + +XX document + +### ++hmac + + ++ hmac :: HMAC-SHA1 + |= [key=@ mes=@] + =+ ip=(fil 3 64 0x36) + =+ op=(fil 3 64 0x5c) + =+ ^= kex + ?: (gth (met 3 key) 64) + (lsh 3 44 (shan (swap 3 key))) + (lsh 3 (sub 64 (met 3 key)) (swap 3 key)) + =+ inn=(shan (swap 3 (cat 3 (swap 3 mes) (mix ip kex)))) + (shan (swap 3 (cat 3 inn (mix op kex)))) + :: + +XX document diff --git a/docs/pub/doc/hoon/library/3bc.md b/docs/pub/doc/hoon/library/3bc.md new file mode 100644 index 0000000000..d2f89b8c1d --- /dev/null +++ b/docs/pub/doc/hoon/library/3bc.md @@ -0,0 +1,380 @@ +section 3bC, Gregorian UTC +========================== + +### ++dawn + +Weekday of Jan 1 + + ++ dawn :: weekday of jan 1 + |= yer=@ud + =+ yet=(sub yer 1) + %- mod :_ 7 + :(add 1 (mul 5 (mod yet 4)) (mul 4 (mod yet 100)) (mul 6 (mod yet 400))) + :: + +Computes which day of the week January 1st falls on for a year `yer`, +producing an atom. Weeks are zero-indexed beginning on Sunday. + +`yer` is an unsigned decimal, [`@ud`](). + + ~zod/try=> (dawn 2.015) + 4 + ~zod/try=> (dawn 1) + 1 + ~zod/try=> (dawn 0) + ! subtract-underflow + ! exit + +------------------------------------------------------------------------ + +### ++daws + +Weekday of date + + ++ daws :: weekday of date + |= yed=date + %- mod :_ 7 + (add (dawn y.yed) (sub (yawn [y.yed m.yed d.t.yed]) (yawn y.yed 1 1))) + :: + +Produces the day of the week of a given date `yed` as an atom. Weeks are +zero-indexed beginning on Sunday. + +`yed` is a [`date`](). + + ~zod/try=> (daws [[a=%.y y=2.014] m=6 t=[d=6 h=21 m=9 s=15 f=~[0xa16]]]) + 5 + ~zod/try=> (daws (yore -<-)) + 2 + +(second example always returns the current date). + +------------------------------------------------------------------------ + +### ++deal + +Add leap seconds + + ++ deal :: to leap sec time + |= yer=@da + =+ n=0 + =+ yud=(yore yer) + |- ^- date + ?: (gte yer (add (snag n lef:yu) ~s1)) + (yore (year yud(s.t (add n s.t.yud)))) + ?: &((gte yer (snag n lef:yu)) (lth yer (add (snag n lef:yu) ~s1))) + yud(s.t (add +(n) s.t.yud)) + ?: =(+(n) (lent lef:yu)) + (yore (year yud(s.t (add +(n) s.t.yud)))) + $(n +(n)) + :: + +Produces a [`date`]() with the 25 leap seconds added. + +`yer` is an absolute date, [`@da`](). + + ~zod/try=> (yore (bex 127)) + [[a=%.y y=226] m=12 t=[d=5 h=15 m=30 s=8 f=~]] + ~zod/try=> (deal `@da`(bex 127)) + [[a=%.y y=226] m=12 t=[d=5 h=15 m=30 s=33 f=~]] + ~zod/try=> (yore (bex 126)) + [[a=%.n y=146.138.512.088] m=6 t=[d=19 h=7 m=45 s=4 f=~]] + +------------------------------------------------------------------------ + +### ++lead + +Subtract leap seconds + + ++ lead :: from leap sec time + |= ley=date + =+ ler=(year ley) + =+ n=0 + |- ^- @da + =+ led=(sub ler (mul n ~s1)) + ?: (gte ler (add (snag n les:yu) ~s1)) + led + ?: &((gte ler (snag n les:yu)) (lth ler (add (snag n les:yu) ~s1))) + ?: =(s.t.ley 60) + (sub led ~s1) + led + ?: =(+(n) (lent les:yu)) + (sub led ~s1) + $(n +(n)) + :: + +Produces an absolute date ([`@ud`]()) with the 25 leap seconds +subtracted. + +`ley` is a [`date`](). + + ~zod/try=> (yore `@da`(bex 127)) + [[a=%.y y=226] m=12 t=[d=5 h=15 m=30 s=8 f=~]] + ~zod/try=> (lead (yore `@da`(bex 127))) + ~226.12.5..15.29.43 + ~zod/try=> (lead (yore `@da`(bex 126))) + ~146138512088-.6.19..07.44.39 + +------------------------------------------------------------------------ + +### ++dust + +Print UTC format + + ++ dust :: print UTC format + |= yed=date + ^- tape + =+ wey=(daws yed) + ;: weld + `tape`(snag wey (turn wik:yu |=(a=tape (scag 3 a)))) + ", " ~(rud at d.t.yed) " " + `tape`(snag (dec m.yed) (turn mon:yu |=(a=tape (scag 3 a)))) + " " (scag 1 ~(rud at y.yed)) (slag 2 ~(rud at y.yed)) " " + ~(rud at h.t.yed) ":" ~(rud at m.t.yed) ":" ~(rud at s.t.yed) + " " "+0000" + == + :: + +Produces a [tape]() of the date in UTC format. + +`yed` is a [`date`](). + + ~zod/try=> (dust (yore -<-)) + "Tue, 21 Oct 2014 21:35:12 +0000" + ~zod/try=> (dust [[a=%.y y=2.002] m=10 t=[d=11 h=12 m=20 s=55 f=~]]) + "Fri, 11 Oct 2002 12:20:55 +0000" + +------------------------------------------------------------------------ + +### ++stud + +Parse UTC format + + ++ stud :: parse UTC format + |= cud=tape + ^- (unit date) + =- ?~ tud ~ + `[[%.y &3.u.tud] &2.u.tud &1.u.tud &4.u.tud &5.u.tud &6.u.tud ~] + ^= tud + %+ rust cud + ;~ plug + ;~(pfix (stun [5 5] next) dim:ag) + :: + %+ cook + |= a=tape + =+ b=0 + |- ^- @ + ?: =(a (snag b (turn mon:yu |=(a=tape (scag 3 a))))) + +(b) + $(b +(b)) + (ifix [ace ace] (star alf)) + :: + ;~(sfix dim:ag ace) + ;~(sfix dim:ag col) + ;~(sfix dim:ag col) + dim:ag + (cold ~ (star next)) + == + :: + +Accepts a [tape]() containing a date in UTC format and produces the +[unit]() of a [`date`](). + + ~zod/try=> (stud "Tue, 21 Oct 2014 21:21:55 +0000") + [~ [[a=%.y y=2.014] m=10 t=[d=21 h=21 m=21 s=55 f=~]]] + ~zod/try=> (stud "Wed, 11 Oct 2002 12:20:55 +0000") + [~ [[a=%.y y=2.002] m=10 t=[d=11 h=12 m=20 s=55 f=~]]] + ~zod/try=> (stud "Wed, 11 Oct 2002") + ~ + +------------------------------------------------------------------------ + +### ++unt + +UGT to UTC time + + ++ unt :: UGT to UTC time + |= a=@da + (div (sub a ~1970.1.1) (bex 64)) + :: + + ~zod/try=/hom> (unt -<-) + 1.413.927.704 + ~zod/try=> (unt ~20014.1.1) + 569.413.670.400 + ~zod/try=> (unt ~2014.1.1) + 1.388.534.400 + +Transforms Urbit Galactic Time to UTC time, producing an atom. + +`a` is an [atom](). + +------------------------------------------------------------------------ + +### ++yu + +UTC format constants + + ++ yu :: UTC format constants + |% + + ~zod/try=/hom> yu + <4.pgn 250.tmw 41.cmo 414.rvm 101.jzo 1.ypj %164> + +------------------------------------------------------------------------ + +### ++mon + +Months + + ++ mon ^- (list tape) + :~ "January" "February" "March" "April" "May" "June" "July" + "August" "September" "October" "November" "December" + == + :: + +Produces a list of [tapes]() containing the 12 months of the year. + + ~zod/try=/hom> mon:yu + << + "January" + "February" + "March" + "April" + "May" + "June" + "July" + "August" + "September" + "October" + "November" + "December" + >> + ~zod/try=/hom> (snag 1 mon:yu) + "February" + +------------------------------------------------------------------------ + +### ++wik + +Weeks + + ++ wik ^- (list tape) + :~ "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" + "Friday" "Saturday" + == + :: + +Produces a list of [tapes]() containing the 7 days of the week, +beginning with Sunday. + + ~zod/try=/hom> wik:yu + <<"Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday">> + ~zod/try=/hom> (snag 2 wik:yu) + "Tuesday" + ~zod/try=/hom> (snag (daws (yore -<-)) wik:yu) + "Tuesday" + +------------------------------------------------------------------------ + +### ++les + +Leap second dates + + ++ les ^- (list ,@da) + :~ ~2012.7.1 ~2009.1.1 ~2006.1.1 ~1999.1.1 ~1997.7.1 ~1996.1.1 + ~1994.7.1 ~1993.7.1 ~1992.7.1 ~1991.1.1 ~1990.1.1 ~1988.1.1 + ~1985.7.1 ~1983.7.1 ~1982.7.1 ~1981.7.1 ~1980.1.1 ~1979.1.1 + ~1978.1.1 ~1977.1.1 ~1976.1.1 ~1975.1.1 ~1974.1.1 ~1973.1.1 + ~1972.7.1 + == + +Produces a list of the (absolute) dates ([`@da`]) of the 25 leap seconds + + ~zod/try=/hom> les:yu + ~[ + ~2012.7.1 + ~2009.1.1 + ~2006.1.1 + ~1999.1.1 + ~1997.7.1 + ~1996.1.1 + ~1994.7.1 + ~1993.7.1 + ~1992.7.1 + ~1991.1.1 + ~1990.1.1 + ~1988.1.1 + ~1985.7.1 + ~1983.7.1 + ~1982.7.1 + ~1981.7.1 + ~1980.1.1 + ~1979.1.1 + ~1978.1.1 + ~1977.1.1 + ~1976.1.1 + ~1975.1.1 + ~1974.1.1 + ~1973.1.1 + ~1972.7.1 + ] + ~zod/try=/hom> (snag 2 les:yu) + ~2006.1.1 + +------------------------------------------------------------------------ + +### ++lef + +Back-shifted leap second dates + + ++ lef ^- (list ,@da) + :~ ~2012.6.30..23.59.59 ~2008.12.31..23.59.58 + ~2005.12.31..23.59.57 ~1998.12.31..23.59.56 + ~1997.6.30..23.59.55 ~1995.12.31..23.59.54 + ~1994.6.30..23.59.53 ~1993.6.30..23.59.52 + ~1992.6.30..23.59.51 ~1990.12.31..23.59.50 + ~1989.12.31..23.59.49 ~1987.12.31..23.59.48 + ~1985.6.30..23.59.47 ~1983.6.30..23.59.46 + ~1982.6.30..23.59.45 ~1981.6.30..23.59.44 + ~1979.12.31..23.59.43 ~1978.12.31..23.59.42 + ~1977.12.31..23.59.41 ~1976.12.31..23.59.40 + ~1975.12.31..23.59.39 ~1974.12.31..23.59.38 + ~1973.12.31..23.59.37 ~1972.12.31..23.59.36 + ~1972.6.30..23.59.35 + == + :: + +Produces a list of absolute dates ([`@da`]()) that represent the Urbit +Galactc Time equivalents of the UTC leap second dates in [`++les`](). + + ~zod/try=/hom> lef:yu + ~[ + ~2012.6.30..23.59.59 + ~2008.12.31..23.59.58 + ~2005.12.31..23.59.57 + ~1998.12.31..23.59.56 + ~1997.6.30..23.59.55 + ~1995.12.31..23.59.54 + ~1994.6.30..23.59.53 + ~1993.6.30..23.59.52 + ~1992.6.30..23.59.51 + ~1990.12.31..23.59.50 + ~1989.12.31..23.59.49 + ~1987.12.31..23.59.48 + ~1985.6.30..23.59.47 + ~1983.6.30..23.59.46 + ~1982.6.30..23.59.45 + ~1981.6.30..23.59.44 + ~1979.12.31..23.59.43 + ~1978.12.31..23.59.42 + ~1977.12.31..23.59.41 + ~1976.12.31..23.59.40 + ~1975.12.31..23.59.39 + ~1974.12.31..23.59.38 + ~1973.12.31..23.59.37 + ~1972.12.31..23.59.36 + ~1972.6.30..23.59.35 + ] + ~zod/try=/hom> (snag 2 lef:yu) + ~2005.12.31..23.59.57 diff --git a/docs/pub/doc/hoon/library/3bd.md b/docs/pub/doc/hoon/library/3bd.md new file mode 100644 index 0000000000..eba82eec02 --- /dev/null +++ b/docs/pub/doc/hoon/library/3bd.md @@ -0,0 +1,1807 @@ +section 3bD, JSON and XML +========================= + +### ++moon + +Mime type to `++cord` + + ++ moon :: mime type to text + |= myn=mite + %+ rap + 3 + |- ^- tape + ?~ myn ~ + ?: =(~ t.myn) (trip i.myn) + (weld (trip i.myn) `tape`['/' $(myn t.myn)]) + :: + +Renders a [mime](http://en.wikipedia.org/wiki/MIME) type path with infix +`/` to a [cord](). + +`myn` is a ++[mite](), a list of [@ta](). + + ~zod/try=> `@t`(moon /image/png) + 'image/png' + ~zod/try=> `@t`(moon /text/x-hoon) + 'text/x-hoon' + ~zod/try=> `@t`(moon /application/x-pnacl) + 'application/x-pnacl' + +### ++perk + +Parse cube with fork + + ++ perk :: parse cube with fork + |* a=(pole ,@tas) + ?~ a fail + ;~ pose + (cold -.a (jest -.a)) + $(a +.a) + == + :: + +Parser generator. Produces a parser that succeeds upon encountering one +of the [`++term`]()s in a faceless list `a`. + +A- perk is an arm used to parse one of a finite set of options, formally +a choice between terms: if you want to match "true" or "false", and +nothing else, (perk \~[%true %false]) produces the relevant parser, +whose result type is `?(%true %false)`. For more complicated +transformations, a combintation of ++sear and map ++get is recommended, +e.g. `(sear ~(get by (mo ~[[%true &] [%false |]]))) sym)` will have a +similar effect but produce `?(& |)` ,a loobean. However, constructions +such as `(sear (flit ~(has in (sa %true %false %other ~))) sym)` are +needlessly unwieldy. + +`a` is a [`++pole`](), which is a [`++list`]() without [`%face`]()s + + ~zod/try=> (scan "ham" (perk %sam %ham %lam ~)) + %ham + ~zod/try=> (scan "ram" (perk %sam %ham %lam ~)) + ! {1 1} + ! exit + +### ++poja + +JSON parser core + + ++ poja :: JSON parser core + =< |=(a=cord (rush a apex)) + |% + +JSON parser core: parses a `++cord` `a` to the hoon structure for JSON, +a [`++json`](). + +`a` is [`++cord`](). + + ~zod/try=> (poja '[1,2,3]') + [~ [%a p=~[[%n p=~.1] [%n p=~.2] [%n p=~.3]]]] + ~zod/try=> (poja 'null') + [~ ~] + ~zod/try=> (poja 'invalid{json') + ~ + +### ++apex + +Parse object + + ++ apex ;~(pose abox obox) :: JSON object + +Top level parsing rule. Parses either a single JSON object, or an array +of JSON objects to a [`++json`](). See also: [`++abox`](), [`++obox`](). + +A- this is now called ++tops, and ++apex is the old ++valu, which +apparently didn't make its way into the docs. Apologies for the +confusion, many things have been restructured in ++shell inconsistently +with current test:urbit.git + + ~zod/try=> (rash '[1,2]' apex:poja) + [%a p=~[[%n p=~.1] [%n p=~.2]]] + ~zod/try=> (rash '{"sam": "kot"}' apex:poja) + [%o p={[p=~.sam q=[%s p=~.kot]]}] + ~zod/try=> (rash 'null' apex:poja) + ! {1 1} + ! exit + +### ++valu + +Parse value + + ++ valu :: JSON value + %+ knee *json |. ~+ + ;~ pfix spac + ;~ pose + (cold ~ (jest 'null')) + (jify %b bool) + (jify %s stri) + (cook |=(s=tape [%n p=(rap 3 s)]) numb) + abox + obox + == + == + +Parsing rule. Parses JSON values to [`++json`](). + + ~zod/try=> (rash '[1,2]' valu:poja) + [%a p=~[[%n p=~.1] [%n p=~.2]]] + ~zod/try=> (rash '{"sam": "kot"}' valu:poja) + [%o p={[p='sam' q=[%s p=~.kot]]}] + ~zod/try=> (rash 'null' valu:poja) + ~ + ~zod/try=> (rash '20' valu:poja) + [%n p=~.20] + ~zod/try=> (rash '"str"' valu:poja) + [%s p=~.str] + ~zod/try=> (rash 'true' valu:poja) + [%b p=%.y] + +### ++abox + +Parse array + + ++ abox (stag %a (ifix [sel (ws ser)] (more (ws com) valu))) + +Parsing rule. Parses a JSON array with values enclosed within `[]` and +delimited by a `,`. + + ~zod/try=> (rash '[1, 2,4]' abox:poja) + [[%n p=~.1] ~[[%n p=~.2] [%n p=~.4]]] + +JSON Objects +------------ + +### ++pair + +Parse key value pair + + ++ pair ;~(plug ;~(sfix (ws stri) (ws col)) valu) + +Parsing rule. Parses a [`++json`]() from a JSON key-value pair of a +string and value delimited by `:`. + + ~zod/try=> (rash '"ham": 2' pair:poja) + ['ham' [%n p=~.2]] + +### ++obje + +Parse array of objects + + ++ obje (ifix [(ws kel) (ws ker)] (more (ws com) pair)) + +Parsing rule. Parses a [`++json`]() from an array of JSON object +key-value pairs that are enclosed within `{}` and separated by `,`. + + ~zod/try=> (rash '{"ham": 2, "lam":true}' obje:poja) + [['ham' [%n p=~.2]] ~[['lam' [%b p=%.y]]]] + +### ++obox + +Parse boxed object + + ++ obox (stag %o (cook mo obje)) + +Parsing rule. Parses an array of JSON objects to a [`++json`]() map with +a tag of `%o`. See also: [`++json`](). + + ~zod/try=> (rash '{"ham": 2, "lam":true}' obox:poja) + [%o {[p='lam' q=[%b p=%.y]] [p='ham' q=[%n p=~.2]]}] + +JSON Booleans +------------- + +### ++bool + +Parse boolean + + ++ bool ;~(pose (cold & (jest 'true')) (cold | (jest 'false'))) + +Parsing rule. Parses a string of either `true` or `false` to a +[`++json`]() boolean. + + ~zod/try=> (rash 'true' bool:poja) + %.y + ~zod/try=> (rash 'false' bool:poja) + %.n + ~zod/try=> (rash 'null' bool:poja) + ! {1 1} + ! exit + +JSON strings +------------ + +### ++stri + +Parse string + + ++ stri + (cook crip (ifix [doq doq] (star jcha))) + +Parsing rule. Parse a string to a [`++cord`](). A JSON string is a list +of characters enclosed in double quotes along with escaping `\`s, to a +[`++cord`](). See also [`++jcha`](). + + ~zod/try=> (rash '"ham"' stri:poja) + 'ham' + ~zod/try=> (rash '"h\\nam"' stri:poja) + 'h + am' + ~zod/try=> (rash '"This be \\"quoted\\""' stri:poja) + 'This be "quoted"' + +### ++jcha + +Parse char from string + + ++ jcha ;~(pose ;~(less doq bas prn) esca) :: character in string + +Parsing rule. Parses either a literal or escaped character from a JSON +string to a [`++cord`](). + + ~zod/try=> (rash 'a' jcha:poja) + 'a'. + ~zod/try=> (rash '!' jcha:poja) + '!' + ~zod/try=> (rash '\\"' jcha:poja) + '"' + ~zod/try=> (rash '\\u00a4' jcha:poja) + '¤' + ~zod/try=> (rash '\\n' jcha:poja) + ' + ' + +### ++esca + +Parse escaped char + + ++ esca :: Escaped character + ;~ pfix bas + ;~ pose + doq fas soq bas + (sear ~(get by `(map ,@t ,@)`(mo b/8 t/9 n/10 f/12 r/13 ~)) low) + ;~(pfix (just 'u') (cook tuft qix:ab)) :: 4-digit hex to UTF-8 + == + +Parsing rule. Parses a backslash-escaped special character, low ASCII, +or UTF16 codepoint, to a [`++cord`](). + + ~zod/try=> (rash 'b' esca:poja) + ! {1 1} + ! exit + ~zod/try=> (rash '\n' esca:poja) + ~ + ~zod/try=> (rash '\\n' esca:poja) + ' + ' + ~zod/try=> `@`(rash '\\r' esca:poja) + 13 + ~zod/try=> (rash '\\u00c4' esca:poja) + 'Ä' + ~zod/try=> (rash '\\u00df' esca:poja) + 'ß' + +JSON numbers +------------ + +A- JSON numbers are stored as cords internally in lieu of full float +support, so ++numb and subarms are really more *validators* than parsers +per se. + +### ++numb + +Parse number + + ++ numb + ;~ (comp twel) + (mayb (piec hep)) + ;~ pose + (piec (just '0')) + ;~(plug (shim '1' '9') digs) + == + (mayb frac) + (mayb expo) + == + +Parsing rule. Parses decimal numbers with an optional `-`, fractional +part, or exponent part, to a [`++cord`](). + + ~zod/try=> (rash '0' numb:poja) + ~[~~0] + ~zod/try=> (rash '1' numb:poja) + ~[~~1] + ~zod/try=> `tape`(rash '1' numb:poja) + "1" + ~zod/try=> `tape`(rash '12.6' numb:poja) + "12.6" + ~zod/try=> `tape`(rash '-2e20' numb:poja) + "-2e20" + ~zod/try=> `tape`(rash '00e20' numb:poja) + ! {1 2} + ! exit + +### ++digs + +Parse 1-9 + + ++ digs (star (shim '0' '9')) + +Parsing rule. Parses digits `0` through `9` to a [`++tape`](). + + ~zod/try=> (rash '' digs:poja) + "" + ~zod/try=> (rash '25' digs:poja) + "25" + ~zod/try=> (rash '016' digs:poja) + "016" + ~zod/try=> (rash '7' digs:poja) + "7" + +### ++expo + +Parse exponent part + + ++ expo :: Exponent part + ;~ (comp twel) + (piec (mask "eE")) + (mayb (piec (mask "+-"))) + digs + == + +Parsing rule. Parses an exponent to a [`++cord`](). An exponent is an +`e`, followed by an optional `+` or `-`, followed by digits. + + ~zod/try=> `tape`(rash 'e7' expo:poja) + "e7" + ~zod/try=> `tape`(rash 'E17' expo:poja) + "E17" + ~zod/try=> `tape`(rash 'E-4' expo:poja) + "E-4" + +### ++frac + +Fractional part + + ++ frac ;~(plug dot digs) :: Fractional part + +Parsing rule. Parses a dot followed by digits to a [`++cord`](). + + ~zod/try=> (rash '.25' frac:poja) + [~~~. "25"] + ~zod/try=> (rash '.016' frac:poja) + [~~~. "016"] + ~zod/try=> (rash '.7' frac:poja) + [~~~. "7"] + +whitespace +---------- + +### ++spac + +Parse whitespace + + ++ spac (star (mask [`@`9 `@`10 `@`13 ' ' ~])) + +Parsing rule. Parses a whitespace to a [`++tape`](). + + ~zod/try=> (scan "" spac:poja) + "" + ~zod/try=> (scan " " spac:poja) + " " + ~zod/try=> `*`(scan `tape`~[' ' ' ' ' ' `@`9 ' ' ' ' `@`13] spac:poja) + [32 32 32 9 32 32 13 0] + ~zod/try=> (scan " m " spac:poja) + ! {1 4} + ! exit + +### ++ws + +Allow prefix whitespace + + ++ ws |*(sef=_rule ;~(pfix spac sef)) + +Parser modifier. Produces a rule that allows for a whitespace before +applying `sef`. + +`sef` is a [`++rule`](). + + ~zod/try=> (rash ' 4' digs:poja) + ! {1 1} + ! exit + ~zod/try=> (rash ' 4' (ws digs):poja) + "4" + ~zod/try=> (rash ''' + + 4 + ''' (ws digs):poja) + "4" + +Plumbing +-------- + +### ++mayb + +Maybe parse + + ++ mayb |*(bus=_rule ;~(pose bus (easy ""))) + +Parser modifier. Need to document, an example showing failure. + + ~zod/try=> (abox:poja 1^1 "not-an-array") + [p=[p=1 q=1] q=~] + ~zod/try=> ((mayb abox):poja 1^1 "not-an-array") + [p=[p=1 q=1] q=[~ [p="" q=[p=[p=1 q=1] q="not-an-array"]]]] + +### ++twel + +Weld two tapes + + ++ twel |=([a=tape b=tape] (weld a b)) + +Concatenates two tapes, `a` and `b`, producing a `++tape`. + +`a` is a [++tape](). + +`b` is a [++tape](). + + ~zod/try=> (twel "sam" "hok"):poja + ~[~~s ~~a ~~m ~~h ~~o ~~k] + ~zod/try=> (twel "kre" ""):poja + ~[~~k ~~r ~~e] + +### ++piec + +Parse char to list + + ++ piec + |* bus=_rule + (cook |=(a=@ [a ~]) bus) + :: + +Parser modifer. Parses an atom with `bus` and then wraps it in a +[`++list`](). + +`bus` is a [`++rule`](). + + ~zod/try=> (scan "4" (piec:poja dem:ag)) + [4 ~] + +### ++pojo + +Print JSON + + ++ pojo :: print json + |= val=json + ^- tape + ?~ val "null" + ?- -.val + %a + ;: weld + "[" + =| rez=tape + |- ^+ rez + ?~ p.val rez + $(p.val t.p.val, rez :(weld rez ^$(val i.p.val) ?~(t.p.val ~ ","))) + "]" + == + :: + %b ?:(p.val "true" "false") + %n (trip p.val) + %s + ;: welp + "\"" + %+ reel + (turn (trip p.val) jesc) + |=([p=tape q=tape] (welp +<)) + "\"" + == + %o + ;: welp + "\{" + =+ viz=(~(tap by p.val) ~) + =| rez=tape + |- ^+ rez + ?~ viz rez + %= $ + viz t.viz + rez + :(welp rez "\"" (trip p.i.viz) "\":" ^$(val q.i.viz) ?~(t.viz ~ ",")) + == + "}" + == + == + :: + +Renders a `++json` `val` as a [++tape](). + +`val` is a [`json`](). + + ~zod/try=> (pojo [%n '12.6']) + "12.6" + ~zod/try=> (crip (pojo %n '12.6')) + '12.6' + ~zod/try=> (crip (pojo %s 'samtel')) + '"samtel"' + ~zod/try=> (crip (pojo %a ~[(jone 12) (jape "ha")])) + '[12,"ha"]' + ~zod/try=> (crip (pojo %a ~[(jone 12) ~ (jape "ha")])) + '[12,null,"ha"]' + ~zod/try=> (crip (pojo %o (mo sale/(jone 12) same/b/| ~))) + '{"same":false,"sale":12}' + +### ++poxo + +Print XML + + ++ poxo :: node to tape + =< |=(a=manx `tape`(apex a ~)) + |_ unq=? :: unq + +Renders a `++manx` `a` as a [`++tape`](). + +`a` is a [`++manx`](). + + ~zod/try=> (poxo ;div;) + "
" + ~zod/try=> (poxo ;div:(p a)) + "
" + ~zod/try=> (poxo ;div:(p:"tree > text" a)) + "

tree > text

" + +### ++apex + +Inner XML printer + + ++ apex :: top level + |= [mex=manx rez=tape] + ^- tape + ?: ?=([%$ [[%$ *] ~]] g.mex) + (escp v.i.a.g.mex rez) + =+ man=`mane`n.g.mex + =. unq |(unq =(%script man) =(%style man)) + =+ tam=(name man) + =. rez :(weld "" rez) + =+ att=`mart`a.g.mex + :- '<' + %+ welp tam + =. rez ['>' (many c.mex rez)] + ?~(att rez [' ' (attr att rez)]) + :: + +Renders a `++manx` as a [`++tape](), appending a suffix`rez\`. + +`rez` is a [`++tape`](). + + ~zod/try=> (apex:poxo ;div; "") + "
" + ~zod/try=> (apex:poxo ;div:(p a) ""). + "

" + ~zod/try=> (apex:poxo ;div:(p a) "--sfix") + "

--sfix" + ~zod/try=> (apex:poxo ;div:(p:"tree > text" a) "") + "

tree > text

" + ~zod/try=> (~(apex poxo &) ;div:(p:"tree > text" a) "") + "

tree > text

" + +### ++attr + +Print attributes + + ++ attr :: attributes to tape + |= [tat=mart rez=tape] + ^- tape + ?~ tat rez + =. rez $(tat t.tat) + ;: weld + (name n.i.tat) + "=\"" + (escp(unq |) v.i.tat '"' ?~(t.tat rez [' ' rez])) + == + +Render XML attributes as a [`++tape`](). + +`tat` is a [`++mart`](). + +`rez` is a [`++tape`](). + + ~zod/try=> (attr:poxo ~ "") + "" + ~zod/try=> (crip (attr:poxo ~[sam/"hem" [%tok %ns]^"reptor"] "")) + 'sam="hem" tok:ns="reptor"' + ~zod/try=> (crip (attr:poxo ~[sam/"hem" [%tok %ns]^"reptor"] "|appen")) + 'sam="hem" tok:ns="reptor"|appen' + +### ++escp + +Escape XML + + ++ escp :: escape for xml + |= [tex=tape rez=tape] + ?: unq + (weld tex rez) + =+ xet=`tape`(flop tex) + |- ^- tape + ?~ xet rez + %= $ + xet t.xet + rez ?- i.xet + 34 ['&' 'q' 'u' 'o' 't' ';' rez] + 38 ['&' 'a' 'm' 'p' ';' rez] + 39 ['&' '#' '3' '9' ';' rez] + 60 ['&' 'l' 't' ';' rez] + 62 ['&' 'g' 't' ';' rez] + * [i.xet rez] + == + == + :: + +Escapes the XML special characters `"`, `&`, `'`, `<`, `>`. + +`tex`is a [`++tape`](). + +`rez` is a [`++tape`](). + + ~zod/try=> (escp:poxo "astra" ~) + ~[~~a ~~s ~~t ~~r ~~a] + ~zod/try=> `tape`(escp:poxo "astra" ~) + "astra" + ~zod/try=> `tape`(escp:poxo "x > y" ~) + "x > y" + ~zod/try=> `tape`(~(escp poxo &) "x > y" ~) + "x > y" + +### ++name + +Print name + + ++ name :: name to tape + |= man=mane ^- tape + ?@ man (trip man) + (weld (trip -.man) `tape`[':' (trip +.man)]) + :: + +Renders a `++mane` as a `++tape`. + +`man` is a [`++mane`](). + + ~zod/try=> (name:poxo %$) + "" + ~zod/try=> (name:poxo %ham) + "ham" + ~zod/try=> (name:poxo %ham^%tor) + "ham:tor" + +### ++many + +Print node list + + ++ many :: nodelist to tape + |= [lix=(list manx) rez=tape] + |- ^- tape + ?~ lix rez + (apex i.lix $(lix t.lix)) + :: + +Renders multiple XML nodes as a [`++tape`]() + +`lix` is a [`++list`]() of [`++manx`](). + +`rez` is a [`++tape`](). + + ~zod/try=> (many:poxo ~ "") + "" + ~zod/try=> (many:poxo ;"hare" "") + "hare" + ~zod/try=> (many:poxo ;"hare;{lep}ton" "") + "hareton" + ~zod/try=> ;"hare;{lep}ton" + [[[%~. [%~. "hare"] ~] ~] [[%lep ~] ~] [[%~. [%~. "ton"] ~] ~] ~] + +------------------------------------------------------------------------ + +### ++poxa + +Parse XML + + ++ poxa :: xml parser + =< |=(a=cord (rush a apex)) + |% + +Parses an XML node from a [`++cord`](), producing a unit [`++manx`](). + +`a` is a [`++cord`](). + + ~zod/try=> (poxa '
') + [~ [g=[n=%div a=~] c=~]] + ~zod/try=> (poxa ' ') + [~ [g=[n=%html a=~] c=~[[g=[n=%head a=~] c=~] [g=[n=%body a=~] c=~]]]] + ~zod/try=> (poxa '" + +Here we go through a similar example, passing a list of urls for a +script tag to a gate that produces a `" + "" Here we go through a similar example, passing a list of urls for a script tag to a gate that produces a `