diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 77dcab7ab..61f021644 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -298,9 +298,17 @@ ?: =(~ mog) luv ?+ -.luv luv %mid - =+ str=(trip q.q.luv) - =+ scr=|-(^-(tape ?~(mog ~ (xmlt & i.mog $(mog t.mog))))) - =+ rep=(need (repg "" str (weld "" scr))) + ?. =('')) + ;~(plug prn (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)] == ++ lofe :: variables in head diff --git a/arvo/ford.hoon b/arvo/ford.hoon index aaa403d12..626f981cf 100644 --- a/arvo/ford.hoon +++ b/arvo/ford.hoon @@ -19,30 +19,30 @@ == :: ++ hood :: assembly plan $: zus=@ud :: zuse kelvin - sur=(list hook) :: structures + 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 -++ hook (pair bean hoof) :: structure gate/core +++ hoot (pair bean hoof) :: structure gate/core ++ hoop :: source in hood $% [%& p=twig] :: direct twig [%| p=beam] :: resource location == :: ++ horn :: resource tree - $% [%and p=twig] :: /& twig by hand + $% [%ape p=twig] :: /& twig by hand [%arg p=twig] :: /$ argument - [%day p=horn] :: /| @dr map by @dr + [%day p=horn] :: /| list by @dr [%dub p=term q=horn] :: /= apply face - [%fan p=(list horn)] :: /: list + [%fan p=(list horn)] :: /. list [%for p=path q=horn] :: /, descend - [%hub p=horn] :: /@ map by @ud - [%man p=(map term horn)] :: /* map by hand - [%nap p=horn] :: /% map by @tas - [%now p=horn] :: /& map by @da + [%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 + [%see p=beam q=horn] :: /: relative to [%sic p=tile q=horn] :: /^ cast [%toy p=mark] :: /mark/ static == :: @@ -209,9 +209,13 @@ |= kus=(unit silk) ^+ +> ?~ kus + =+ nym=(~(get by dym.bay) hen) + ?~ nym :: XX should never + ~& [%ford-mystery hen] + +>.$ =+ num=(need (~(get by dym.bay) hen)) - =+ tas=(need (~(get by q.tad.bay) num)) - amok:~(camo zo [num tas]) + =+ 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) @@ -409,7 +413,7 @@ ++ fang :: protocol door |= [cof=cafe for=mark bek=beak] ^- (bolt vase) - =+ pax=/door/[for]/mac + =+ pax=/door/[for]/mar =+ ^= bem ^- beam :_ pax ?: =(p.bek our) bek @@ -443,7 +447,7 @@ == :: ;~ pose - (ifix [;~(plug fas hep gap) gap] (most ;~(plug com gaw) hook)) + (ifix [;~(plug fas hep gap) gap] (most ;~(plug com gaw) hoot)) (easy ~) == :: @@ -467,7 +471,7 @@ == == :: - ++ hook + ++ hoot ;~ pose (stag %| ;~(pfix tar hoof)) (stag %& hoof) @@ -488,8 +492,8 @@ ;~ pfix fas ;~ pose (stag %toy ;~(sfix sym fas)) - (stag %and ;~(pfix and:sign and:read)) - (stag %arg ;~(pfix arg:sign and:read)) + (stag %ape ;~(pfix ape:sign ape:read)) + (stag %arg ;~(pfix arg:sign ape:read)) (stag %day ;~(pfix day:sign day:read)) (stag %dub ;~(pfix dub:sign dub:read)) (stag %fan ;~(pfix fan:sign fan:read)) @@ -498,6 +502,7 @@ (stag %man ;~(pfix man:sign man:read)) (stag %nap ;~(pfix nap:sign day:read)) (stag %now ;~(pfix now:sign day:read)) + (stag %saw ;~(pfix saw:sign saw:read)) (stag %see ;~(pfix see:sign see:read)) (stag %sic ;~(pfix sic:sign sic:read)) == @@ -509,7 +514,7 @@ ;~(pose wid tal) :: ++ read - |% ++ and + |% ++ ape %+ rail (ifix [sel ser] (stag %cltr (most ace wide:vez))) ;~(pfix gap tall:vez) @@ -546,28 +551,33 @@ :: ++ see %+ rail - ;~(plug (ifix [sel ser] have) apex(tol |)) + ;~(plug ;~(sfix have col) apex(tol |)) ;~(pfix gap ;~(plug have ;~(pfix gap apex))) + :: + ++ saw + %+ rail + ;~(plug ;~(sfix wide:vez sem) apex(tol |)) + ;~(pfix gap ;~(plug tall:vez ;~(pfix gap apex))) :: ++ sic %+ rail - ;~(plug (ifix [sel ser] toil:vez) apex(tol |)) + ;~(plug ;~(sfix toil:vez ket) apex(tol |)) ;~(pfix gap ;~(plug howl:vez ;~(pfix gap apex))) -- :: ++ sign - |% ++ and ;~(pose pam (jest %and)) + |% ++ ape ;~(pose sig (jest %ape)) ++ arg ;~(pose buc (jest %arg)) ++ day ;~(pose bar (jest %day)) ++ dub ;~(pose tis (jest %dub)) - ++ fan ;~(pose col (jest %fan)) + ++ fan ;~(pose dot (jest %fan)) ++ for ;~(pose com (jest %for)) ++ hub ;~(pose pat (jest %hub)) ++ man ;~(pose tar (jest %man)) ++ nap ;~(pose cen (jest %nap)) ++ now ;~(pose fas (jest %now)) ++ saw ;~(pose sem (jest %saw)) - ++ see ;~(pose dot (jest %see)) + ++ see ;~(pose col (jest %see)) ++ sic ;~(pose ket (jest %sic)) -- -- @@ -963,40 +973,62 @@ |= [cof=cafe sel=_..body] ^$(cof cof, src t.src, ..body sel) :: - ++ chai :: atomic map + ++ 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)) + :: + ++ chai :: atomic map + |= [cof=cafe bax=vase hon=horn] + ^- (bolt vase) + %+ cope (lend cof how) + |= [cof=cafe arc=arch] %+ cope |- ^- (bolt (map ,@ vase)) - ?~ yep (fine cof ~) - %+ cope $(yep l.yep) + ?~ r.arc (fine cof ~) + %+ cope $(r.arc l.r.arc) |= [cof=cafe lef=(map ,@ vase)] - %+ cope `(bolt (map ,@ vase))`^$(cof cof, yep r.yep) + %+ cope `(bolt (map ,@ vase))`^$(cof cof, r.arc r.r.arc) |= [cof=cafe rig=(map ,@ vase)] - %+ cope (chap(s.how [q.n.yep s.how]) cof bax hon) + %+ cope (chap(s.how [p.n.r.arc s.how]) cof bax hon) |= [cof=cafe nod=vase] - (fine cof [[p.n.yep nod] lef rig]) + (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 doe] p.n.doy] q.n.doy) + (slop [[%atom %a] p.n.doy] q.n.doy) (slop $(doy l.doy) $(doy r.doy)) :: ++ chap :: produce resources |= [cof=cafe bax=vase hon=horn] ^- (bolt vase) ?- -.hon - %and (maim cof bax p.hon) + %ape (maim cof bax p.hon) %arg %+ cope (maim cof bax p.hon) |= [cof=cafe gat=vase] (maul cof gat !>([how arg])) :: - %day (chai cof bax %dr p.hon) + %day (chad cof bax %dr p.hon) %dub %+ cope $(hon q.hon) |= [cof=cafe vax=vase] @@ -1018,7 +1050,7 @@ (slop i.tev $(tev t.tev)) :: %for $(hon q.hon, s.how (weld (flop p.hon) s.how)) - %hub (chai cof bax %ud p.hon) + %hub (chad cof bax %ud p.hon) %man |- ^- (bolt vase) ?~ p.hon (fine cof [[%cube 0 [%atom %n]] 0]) @@ -1033,9 +1065,8 @@ (slop [[%atom %tas] p.n.p.hon] vax) (slop lef rig) :: - %now (chai cof bax %da p.hon) - %nap (chai cof bax %tas p.hon) - :: + %now (chad cof bax %da p.hon) + %nap (chai cof bax p.hon) %see $(hon q.hon, how p.hon) %saw %+ cope $(hon q.hon) @@ -1051,13 +1082,13 @@ |= [cof=cafe tug=vase] ?. (~(nest ut p.tug) | p.vax) (flaw cof [%leaf "type error: {} {}"]~) - (fine cof vax) + (fine cof [p.tug q.vax]) :: %toy (cope (make cof %bake p.hon how ~) feel) == :: ++ head :: consume structures - |= [cof=cafe bir=(list hook)] + |= [cof=cafe bir=(list hoot)] |- ^- (bolt ,_..head) ?~ bir (fine cof ..head) diff --git a/arvo/hoon.hoon b/arvo/hoon.hoon index 601fd61e9..6235d573e 100644 --- a/arvo/hoon.hoon +++ b/arvo/hoon.hoon @@ -9889,7 +9889,7 @@ %pass ~? &(!lac !=(%$ p.gum)) :^ %pass [p.gum p.q.r.gum] - [(,@tas -.q.gum) p.r.gum] + [(,@tas +>-.q.q.r.gum) p.r.gum] q.gum [p.q.r.gum ~ [[p.gum p.r.gum] q.gum] q.q.r.gum] :: diff --git a/main/app/appbug-2/core.hook b/main/app/appbug-2/core.hook deleted file mode 100644 index 365deea39..000000000 --- a/main/app/appbug-2/core.hook +++ /dev/null @@ -1,38 +0,0 @@ -!: -::::::::: Appbug: a simple application. -:: -|_ [hid=hide vat=[%0 p=@ud]] -++ poke - |= [ost=bone *] - :_ +>(p.vat +(p.vat)) - :~ [ost %give %nice ~] - == -:: -++ peek - |= [you=ship pax=path] - :- %hymn - ^- manx - ;html - ;head - ;title: Appbug! - ;script: appl = '{(trip app.hid)}' - == - ;body - ;p: Dude, a better answer is {}. - ;button(onclick "bump()"): (Bump.) - ;script - ; var mess = 0; - ; - ; function bump() { - ; xhr = new XMLHttpRequest(); - ; xhr.onload = function() { mess++; } - ; xhr.open("PUT", "/tim/" + [user, port, mess].join("/")); - ; xhr.setRequestHeader("content-type", "text/json"); - ; xhr.send(JSON.stringify({oryx: oryx, xyro: {ship: ship, appl: appl, data: {}}})); - ; } - == - == - == --- - - diff --git a/main/app/demo/core.hook b/main/app/demo/core.hook new file mode 100644 index 000000000..38f8d38a4 --- /dev/null +++ b/main/app/demo/core.hook @@ -0,0 +1,39 @@ +!: +::::::::: Appbug: a simple application. +:: +|_ [hid=hide vat=[%0 p=@ud]] +++ poke + |= [ost=bone *] + :_ +>(p.vat +(p.vat)) + :~ [ost %give %nice ~] + == +:: +++ peek + |= [you=ship pax=path] + :- %hymn + ^- manx + ;html + ;head + ;title: Demo! + ;script: urb.appl = '{(trip app.hid)}' + == + ;body + ;p: State is {}. + ;button(onclick "bump()"): (Bump.) + ;script + ; var mess = 0 + ; + ; function bump() { + ; xhr = new XMLHttpRequest() + ; xhr.onload = function() { mess++} + ; xhr.open("PUT", "/tim/" + [urb.user, urb.port, mess].join("/")) + ; xhr.setRequestHeader("content-type", "text/json") + ; xyro = {ship: urb.ship, appl: urb.appl, data: {}} + ; xhr.send(JSON.stringify({oryx: urb.oryx, xyro: xyro})) + ; } + == + == + == +-- + + diff --git a/main/app/foobug/core.hook b/main/app/foobug/core.hook deleted file mode 100644 index 2e5dd06b7..000000000 --- a/main/app/foobug/core.hook +++ /dev/null @@ -1,103 +0,0 @@ -!: -=> |% - ++ axle - $% [%0 p=@ud] - == - ++ gult - $% [%json p=json] - :: [%hymn p=manx] - == - ++ gilt - $% :: [%json p=json] - [%hymn p=manx] - == - ++ gift - $% [%rust gilt] - [%nice gult] - == - ++ move ,[p=bone q=[%give p=gift]] - -- -|_ [hid=hide vat=axle] -++ page - ^- manx - ;html - ;head - ;title: Foobug! - == - ;body - ;p: Word: {}. - ;button(onclick "goof()"): Goof! - ;script:''' - var c = 0; - var d = 1; - var x = 0; - - function pickup() { - xhr = new XMLHttpRequest(); - - console.log("WTF???"); - xhr.open("GET", "/zod/goe/foobug/"+port+"/frog/"+d); - xhr.onload = function() { - console.log("pickup"); - console.log(this) - change(JSON.parse(this.responseText)) - update(); - d++; - pickup(); - } - xhr.send(); - } - - function dude() { - xhr = new XMLHttpRequest(); - - xhr.open("POST", "/zod/pos/foobug/"+port+"/frog/goof"); - xhr.setRequestHeader("content-type", "text/json") - xhr.onload = function() { - console.log("dude"); - console.log(this) - change(JSON.parse(this.responseText)) - update(); - pickup(); - } - xhr.send("{\"a\":1}") - } - dude(); - - function change(jon) { - x = jon.x; - } - - function update() { - document.getElementsByTagName("p")[0].innerHTML = "WORD: " + x; - } - - function goof() { - xhr = new XMLHttpRequest(); - xhr.onload = function() { - console.log("hi"); - console.log(arguments) - c++ - } - xhr.open("POST", - "/zod/pom/foobug/"+port+"/"+c) - xhr.setRequestHeader("content-type", "text/json") - xhr.send("{\"a\":1}") - } - ''' - == - == -:: -++ peer - |= [ost=bone you=ship pax=path] - ^- [(list move) _+>] - [[ost %give %rust %hymn page]~ +>] -:: -++ poke-json - |= [ost=bone you=ship jon=json] - ^- [(list move) _+>] - ~& [%poke [%state p.vat] ost you jon] - :_ +>(p.vat +(p.vat)) - :~ [ost %give %nice %json jon] - == --- diff --git a/main/app/philbug/app.js b/main/app/philbug/app.js deleted file mode 100644 index 5151c8fb2..000000000 --- a/main/app/philbug/app.js +++ /dev/null @@ -1,45 +0,0 @@ - -window.onload = function() { - var data = {} - - change = function(_data) { - for(i in _data) { - data[i] = _data[i] - } - } - - update = function() { - for (var i in data) { - if ($('#'+i).length < 1) { - var e = document.createElement('tr') - e.id = i - $('#cont tbody').append(e) - } - $('#'+i).html("~"+i+""+data[i]+"") - } - $('#cont tbody').append([].sort.call($('#cont tr'), function (a, b) { - return parseInt(b.childNodes[1].innerText) - - parseInt(a.childNodes[1].innerText) - })) - } - - goof = function(e) { - d = $.map($(".sel"), function(el) {return el.id}) - window.urb.send(d) - } - - window.urb.send(null); - /*window.urb.subscribe("frog","goof",*/ function(err,res) { - if(err) - return console.log('cannot connect to frog/goof') - change(res.data) - update() - - return true - }) - - $('#cont').on('click', 'tr', function (e) { - if (!e.ctrlKey) { $('.sel').removeClass('sel') } - $(this).addClass('sel') - }) -} diff --git a/main/app/philbug/core.hook b/main/app/philbug/core.hook deleted file mode 100644 index 40014f4b0..000000000 --- a/main/app/philbug/core.hook +++ /dev/null @@ -1,116 +0,0 @@ -!: -=> |% - ++ axle - $% [%0 p=(map ,@p ,@ud)] - == - ++ gilt - $% [%json p=json] - [%hymn p=manx] - == - ++ gift - $% [%rust gilt] - [%nice gilt] - == - ++ move ,[p=bone q=[%give p=gift]] - ++ phil - $% [%new ~] - [%add p=(list ,@p)] - == - -- -|_ [hid=hide vat=axle] -++ incl - |= wal=wall - %+ turn wal - |= tape ;script(type "text/javascript", src +<); -:: -++ root - /(scot %p our.hid)/main/(scot %da lat.hid)/app/[app.hid] -:: -++ respond :: respond to message - |= ost=bone - `move`[ost %give %nice %json *json] -:: -++ update :: update subscribers - ^- (list move) - %+ turn - ^- (list bone) - %+ ~(rep by sup.hid) *(list bone) - |= [p=[p=bone q=[ship path]] q=(list bone)] ^- (list bone) - ?. =(/goof +.q.p) q - [p.p q] - send-vat -:: -++ render - ^- manx - ;html - ;head - ;title: Foobug! - ;style - ; .sel {background: lightgray} - ; #cont {border-collapse: collapse} - == - ;* %- incl :~ - "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js" - == - ;script ;- (trip ;;(,@ .^(%cx (welp root /urb/js)))) - == - ;script ;- (trip ;;(,@ .^(%cx (welp root /app/js)))) - == - == - ;body - ;p: Yo. - ;table#cont:tbody; - ;p: Select a ship - ;button(onclick "goof()"): Give 5 points - == - == -:: -++ peer - |= [ost=bone you=ship pax=path] - ^- [(list move) _+>] - :_ +> - ?: =(/ pax) - [ost %give %rust %hymn render]~ - [(send-vat ost) ~] -:: -++ poke-phil - |= [ost=bone you=ship pil=phil] - =. p.vat - ?- -.pil - %new (~(put by p.vat) you (fall (~(get by p.vat) you) _@ud)) - %add %- ~(urn by p.vat) - |= [u=@p n=@ud] - ?. (lien p.pil |=(a=@p =(a u))) - n - (add 5 n) - == - [[(respond ost) update] +>.$] -:: -++ poke-json - |= [ost=bone you=ship jon=json] - ~& [%poke-json jon] - %^ poke-phil ost you - ^- phil - ?+ -.jon !! - %o [%new ~] - %a :- %add - %+ turn p.jon - |= a=json - ?> ?=([%s *] a) - (slav %p (cat 3 '~' p.a)) - == -:: -++ send-vat - |= ost=bone - =+ luz=(~(tap by p.vat) ~) - ^- move - :* ost %give %rust %json %o - ^- (map ,@t jval) - %- mo - %+ turn luz - |= [a=@p b=@ud] - :- (rsh 3 1 (scot %p a)) - :- %n - (rsh 3 2 (scot %ui b)) - == --- diff --git a/main/app/philbug/urb.js b/main/app/philbug/urb.js deleted file mode 100644 index d4d8017b4..000000000 --- a/main/app/philbug/urb.js +++ /dev/null @@ -1,111 +0,0 @@ -window.urb = { - ship: ship, - port: port, - auto: auto, - oryx: oryx, - user: user, - appn: appn, - seqn: 0, - seqp: 1, - dely: 0, - - req: function(method,url,data,json,cb) { - var xhr = new XMLHttpRequest() - xhr.open(method.toUpperCase(), url) - if(json) - xhr.setRequestHeader("content-type", "text/json") - if(data) - xhr.send(JSON.stringify(data)) - else - xhr.send() - if(cb) { - xhr.onload = function() { - cb(null,{ - "status":this.status, - "data":JSON.parse(this.responseText) - }) - } - xhr.onerror = function() { - cb({ - "status":this.status, - "data":this.responseText - }) - } - } - }, - - subscribe: function(stream,path,cb) { - if(!cb) - throw new Error("You must supply a callback to urb.subscribe.") - - var method, perm, url, $this - - method = "post" - perm = "pis" - url = [this.ship,perm,this.user,this.appn,this.port] - if(stream) { - url.push(stream) - if(path) - url.push(path) - } - url = "/"+url.join("/") - - - $this = this - this.req(method,url,{},true,function(err,data) { - cb.apply(this,arguments) - if(!err) { $this.poll(stream,cb); } - }) - }, - - send: function(data,cb) { - if(!data) { data = {}; } - if(!cb) { cb = function() {}; } - - var method, perm, url, $this - - method = "post" - perm = "pim" - url = [this.ship,perm,this.user,this.appn,this.port,this.seqn] - url = "/"+url.join("/") - - this.seqn++ - - $this = this - this.req(method,url,data,true,function(err,data) { - if(err) { $this.seqn--; } - cb.apply(this,arguments) - }) - }, - - poll: function(stream,cb) { - if(!stream) - throw new Error("You must supply a stream to urb.poll.") - if(!cb) - throw new Error("You must supply a callback to urb.poll.") - - var method, perm, url, $this - - method = "get" - perm = "gie" - if(!stream) { return false; } - url = [this.ship,perm,this.user,this.appn,this.port,stream,this.seqp] - url = "/"+url.join("/") - - $this = this - this.req(method,url,null,false,function(err,data) { - if(cb.apply(this,arguments) === false) { return; } - - if(err) - $this.dely += 1000 - else { - $this.dely = 0 - $this.seqp++ - } - - setTimeout(function() { - $this.poll(stream,cb) - },$this.dely) - }) - } -} diff --git a/main/app/readed/core.hook b/main/app/readed/core.hook deleted file mode 100644 index 47c9424ea..000000000 --- a/main/app/readed/core.hook +++ /dev/null @@ -1,45 +0,0 @@ -!: -:: Read :: -|_ [hid=hide vat=tape] -++ peer - |= [ost=bone ship pax=path] - ~& pax - ?~ pax - $(pax ~[(rsh 3 1 (scot %p our.hid))]) - ?> ?=([cord ~] pax) - :_ +>.$ - :~ [ost %pass /ret %g %show [(slav %p (cat 3 '~' i.pax)) %written] our.hid /] - :: :^ ost %pass /heyya - :: :^ %g %mess [(slav %p (cat 3 '~' i.pax)) %written] - :: :+ our.hid %json !>(`json`[%s %hola]) - :: :^ ost %pass /heyya - :: :^ %g %mess [(slav %p (cat 3 '~' i.pax)) %written] - :: :+ our.hid %json !>(`json`[%s %buenos-dias]) - :: :^ ost %pass /heyya - :: :^ %g %mess [(slav %p (cat 3 '~' i.pax)) %written] - :: :+ our.hid %json !>(`json`[%s %buenas-tardes]) - :: :^ ost %pass /heyya - :: :^ %g %mess [(slav %p (cat 3 '~' i.pax)) %written] - :: :+ our.hid %json !>(`json`[%s %buenas-tardes]) - == -++ pour - |= [pax=path sin=*] - :_ +> - ?: =(/ret pax) - =+ sin=;;(,[%g p=@tas q=*] sin) - ?: ?=(%nice p.sin) - ~& %pour-nice ~ - ?: ?=(%mean p.sin) - ~& %pour-mean ~ - =+ sin=;;(,[%g p=@tas q=mark r=*] sin) - ~& [%pour-ret p.sin q.sin] - =+ gif=;;(,[?(%rust %rush) %hymn manx] +.sin) - %+ turn (~(tap by sup.hid)) - |= [ost=bone you=ship pax=path] - [ost give/gif] - ?: =(/heyya pax) - ~& [%pour-acked sin] - ~ - ~& %pour-bad ~ --- - diff --git a/main/app/written/core.hook b/main/app/written/core.hook deleted file mode 100644 index 3e97aa7b7..000000000 --- a/main/app/written/core.hook +++ /dev/null @@ -1,49 +0,0 @@ -!: -=> |% - ++ gift - $% [%mean p=ares] - [%nice ~] - [%rust %hymn manx] - == - ++ move ,[p=bone q=(mold note gift)] - ++ note ,~ - -- -:: Write :: -|_ [hid=hide vat=tape] -++ root - [(crip ) %main (crip ) ~] -:: -++ page - :- %hymn - ;html - ;head - ;title: Writer - ;script:"{(trip (,@ (need (file (welp root /lib/urb/js)))))}" - == - ;body - ;p: Write things! - ;+ =+ js="urb.send(\{appl:{<`@t`app.hid>}, data:texx.value})" - ;textarea(id "texx", onchange js):"{vat}" - == - == -++ peer - |= [ost=bone you=ship pax=path] - :_ +>.$ :_ ~ - :^ ost %give %rust - page -:: ^- [(list move) _+>] -:: :_ +>.$ :_ ~ -:: [ost %give %rust page] -++ poke-json - |= [ost=bone you=ship jon=json] - ^- [(list move) _+>] - =. vat (need (sa:jo jon)) - ~& [%poke-vat vat] - :_ +>.$ - :* [ost %give %mean ~ %alan-kay ~[leaf/"is a failure"]] - ~ -:: %+ turn (~(tap by sup.hid)) -:: |= [ost=bone you=ship pax=path] -:: [ost %give %rust page] - == --- diff --git a/main/lib/example/core.hook b/main/lib/example/core.hook new file mode 100644 index 000000000..614952169 --- /dev/null +++ b/main/lib/example/core.hook @@ -0,0 +1,5 @@ +|% +++ fib |=(x=@ ~+(?:((lth x 2) 1 (add $(x (dec x)) $(x (sub x 2)))))) +-- + + diff --git a/main/mac/html/door.hook b/main/mac/html/door.hook deleted file mode 100644 index 8a0648966..000000000 --- a/main/mac/html/door.hook +++ /dev/null @@ -1,16 +0,0 @@ -:: -:::: /hoon/core/html/pro - :: -/? 314 - :: -:::: compute - :: -|_ htm=@t -:: -++ grow :: convert to - |% - ++ mime :: convert to %mime - [/text/html (met 3 htm) htm] - -- --- - diff --git a/main/mac/down/door.hook b/main/mar/down/door.hook similarity index 98% rename from main/mac/down/door.hook rename to main/mar/down/door.hook index 9df7970cd..9763cc9f9 100644 --- a/main/mac/down/door.hook +++ b/main/mar/down/door.hook @@ -155,9 +155,9 @@ %+ cold ~ %- full ;~ pose - ;~(plug (stun [0 3] ace) hep wits hep wits hep (star ;~(pose hep wite))) - ;~(plug (stun [0 3] ace) tar wits tar wits tar (star ;~(pose tar wite))) - ;~(plug (stun [0 3] ace) cab wits cab wits cab (star ;~(pose cab wite))) + ;~(plug (stun [0 3] ace) hep wits hep wits hep (star ;~(pose hep ace))) + ;~(plug (stun [0 3] ace) tar wits tar wits tar (star ;~(pose tar ace))) + ;~(plug (stun [0 3] ace) cab wits cab wits cab (star ;~(pose cab ace))) == :: ++ html (stag %hem apex:xmlp) :: html barb @@ -273,9 +273,8 @@ (plus ;~(pose emph cods link (text fail))) :: ++ text |*(res=_rule (stag %tex (plus ;~(less ;~(pose res dont) chrd)))) - ++ whit (mask ~[`@`0x20 `@`0x9 `@`0xa]) :: whitespace w/nl - ++ wite (mask ~[`@`0x20 `@`0x9]) :: whitespace - ++ wits (star wite) + ++ whit (mask ~[`@`0x20 `@`0xa]) :: whitespace w/nl + ++ wits (star ace) -- :: ++ noun :: convert from %noun diff --git a/main/mar/html/door.hook b/main/mar/html/door.hook new file mode 100644 index 000000000..c4665b0f6 --- /dev/null +++ b/main/mar/html/door.hook @@ -0,0 +1,16 @@ +:: +:::: /hoon/core/html/pro + :: +/? 314 + :: +:::: compute + :: +|_ htm=@t +:: +++ grow :: convert to + |% :: + ++ mime [/text/html (met 3 htm) htm] :: to %mime + ++ hymn (rash htm apex:xmlp) :: to %hymn + -- :: +-- + diff --git a/main/mac/hymn/door.hook b/main/mar/hymn/door.hook similarity index 100% rename from main/mac/hymn/door.hook rename to main/mar/hymn/door.hook diff --git a/main/mac/json/door.hook b/main/mar/json/door.hook similarity index 100% rename from main/mac/json/door.hook rename to main/mar/json/door.hook diff --git a/main/mac/md/door.hook b/main/mar/md/door.hook similarity index 100% rename from main/mac/md/door.hook rename to main/mar/md/door.hook diff --git a/main/mac/mime/door.hook b/main/mar/mime/door.hook similarity index 100% rename from main/mac/mime/door.hook rename to main/mar/mime/door.hook diff --git a/main/mac/user/door.hook b/main/mar/user/door.hook similarity index 100% rename from main/mac/user/door.hook rename to main/mar/user/door.hook diff --git a/main/mac/users/door.hook b/main/mar/users/door.hook similarity index 100% rename from main/mac/users/door.hook rename to main/mar/users/door.hook diff --git a/main/mac/zing/door.hook b/main/mar/zing/door.hook similarity index 100% rename from main/mac/zing/door.hook rename to main/mar/zing/door.hook diff --git a/main/mac/zong/door.hook b/main/mar/zong/door.hook similarity index 100% rename from main/mac/zong/door.hook rename to main/mar/zong/door.hook diff --git a/main/mac/zongs/door.hook b/main/mar/zongs/door.hook similarity index 100% rename from main/mac/zongs/door.hook rename to main/mar/zongs/door.hook diff --git a/main/mac/zung/door.hook b/main/mar/zung/door.hook similarity index 100% rename from main/mac/zung/door.hook rename to main/mar/zung/door.hook diff --git a/main/pub/fab/fun/five/hymn.hook b/main/pub/fab/fun/five/hymn.hook new file mode 100644 index 000000000..ec639a03d --- /dev/null +++ b/main/pub/fab/fun/five/hymn.hook @@ -0,0 +1,12 @@ +/= ctx /$ |=([p=beam q=path] +<) +:: +;html + ;head + ;title: Fun Experiment Five + == + ;body + ;p: This page was built at {<(tope p.ctx)>}. + ;br; + ;p: The remainder path was {}. + == +== diff --git a/main/pub/fab/fun/four/hymn.hook b/main/pub/fab/fun/four/hymn.hook new file mode 100644 index 000000000..b1f580920 --- /dev/null +++ b/main/pub/fab/fun/four/hymn.hook @@ -0,0 +1,19 @@ +/= gas /$ fuel +:: +=+ arg=(biff (~(get by qix.gas) %number) (slat %ud)) +=+ fib=|=(x=@ ~+(?:((lth x 2) 1 (add $(x (dec x)) $(x (sub x 2)))))) +:: +;html + ;head + ;title: Fun Experiment Four + == + ;body + ;p: Welcome, {}! + ;+ ?~ arg + ;p: Usage: ?number=x + ;p ; This is an ;{i "HTML file"} which + ; computes the Fibonacci number + ; of {}: {<(fib u.arg)>}. + == + == +== diff --git a/main/pub/fab/fun/one.md b/main/pub/fab/fun/one.md new file mode 100644 index 000000000..da60c9d95 --- /dev/null +++ b/main/pub/fab/fun/one.md @@ -0,0 +1 @@ +This is a *fun experiment* in markdown. diff --git a/main/pub/fab/fun/three/hymn.hook b/main/pub/fab/fun/three/hymn.hook new file mode 100644 index 000000000..6474e1f20 --- /dev/null +++ b/main/pub/fab/fun/three/hymn.hook @@ -0,0 +1,11 @@ +=+ fib=|=(x=@ ?:((lth x 2) 1 (add $(x (dec x)) $(x (sub x 2))))) +;html + ;head ;title: Fun Experiment Three + == + ;body + ;p ; This is an ;{i "HTML file"} which + ; computes the Fibonacci number + ; of 12: {<(fib 12)>}. + == + == +== diff --git a/main/pub/fab/fun/two/down.hook b/main/pub/fab/fun/two/down.hook new file mode 100644 index 000000000..ad0730342 --- /dev/null +++ b/main/pub/fab/fun/two/down.hook @@ -0,0 +1,5 @@ +:~ :- %par + :~ tex/"This is a " + emp/bent/~[tex/"fun experiment "] + tex/"in markdown; 2 + 2 is {<(add 2 2)>}." +== == diff --git a/main/pub/fab/mad/five/down.hook b/main/pub/fab/mad/five/down.hook new file mode 100644 index 000000000..b01b026bc --- /dev/null +++ b/main/pub/fab/mad/five/down.hook @@ -0,0 +1,9 @@ +/- down +^- down +:~ :- %par + :~ tex/"This is a " + emp/bent/~[tex/"fun experiment "] + tex/"in markdown; 2 + 2 is {<(add 2 2)>}." +== == + + diff --git a/main/pub/fab/mad/four/hymn.hook b/main/pub/fab/mad/four/hymn.hook new file mode 100644 index 000000000..4d1441643 --- /dev/null +++ b/main/pub/fab/mad/four/hymn.hook @@ -0,0 +1,21 @@ +:: This fourth experiment is profoundly biblical. +:: +:::: /hoon/four/mad/fab/pub + :: +/= bible /: /======/res/bible + /; |= a=(list (pair ,@ manx)) + (turn a |=([* b=manx] b)) + /@ + /hymn/ +:: +:::: ~tasfyn-partyv + :: +!: +;html + ;head + ;title: Mad Experiment Four + == + ;body + ;* bible + == +== diff --git a/main/pub/fab/mad/one/hymn.hook b/main/pub/fab/mad/one/hymn.hook new file mode 100644 index 000000000..bbd3a73ec --- /dev/null +++ b/main/pub/fab/mad/one/hymn.hook @@ -0,0 +1,25 @@ +:: Our first experiment with major hood runes. +:: +:::: /hoon/one/mad/src/pub + :: +/= gas /$ fuel +// /===/pub/src/mad/fib +:: +:::: ~tasfyn-partyv + :: +=+ arg=(biff (~(get by qix.gas) %number) (slat %ud)) +:: +;html + ;head + ;title: Mad Experiment One + == + ;body + ;+ ?~ arg + ;p: Usage: ?number=x + ;p ; This is an ;{i "HTML file"} which + ; computes the Fibonacci number + ; of {}: {<(fib u.arg)>}. + == + == +== + diff --git a/main/pub/fab/mad/res/bible/1.html b/main/pub/fab/mad/res/bible/1.html new file mode 100644 index 000000000..43824a4df --- /dev/null +++ b/main/pub/fab/mad/res/bible/1.html @@ -0,0 +1 @@ +

The earth was without form, and void.

diff --git a/main/pub/fab/mad/res/bible/2.html b/main/pub/fab/mad/res/bible/2.html new file mode 100644 index 000000000..57da8bcbd --- /dev/null +++ b/main/pub/fab/mad/res/bible/2.html @@ -0,0 +1 @@ +

Then Cain slew Abel.

diff --git a/main/pub/fab/mad/res/bible/3.html b/main/pub/fab/mad/res/bible/3.html new file mode 100644 index 000000000..e6e8d8abe --- /dev/null +++ b/main/pub/fab/mad/res/bible/3.html @@ -0,0 +1 @@ +

I bring not peace, but a sword.

diff --git a/main/pub/fab/mad/res/bible/4.html b/main/pub/fab/mad/res/bible/4.html new file mode 100644 index 000000000..9c628a449 --- /dev/null +++ b/main/pub/fab/mad/res/bible/4.html @@ -0,0 +1 @@ +

And I saw a pale horse, and upon him a pale rider.

diff --git a/main/pub/fab/mad/res/hello/hymn.hook b/main/pub/fab/mad/res/hello/hymn.hook new file mode 100644 index 000000000..161b00caf --- /dev/null +++ b/main/pub/fab/mad/res/hello/hymn.hook @@ -0,0 +1 @@ +;p: Hello, world. diff --git a/main/pub/fab/mad/six/hymn.hook b/main/pub/fab/mad/six/hymn.hook new file mode 100644 index 000000000..85603dcf5 --- /dev/null +++ b/main/pub/fab/mad/six/hymn.hook @@ -0,0 +1,23 @@ +:: Our sixth experiment with major hood runes. +:: +:::: /hoon/six/mad/fab/pub + :: +/+ example +/= gas /$ fuel +:: +:::: ~tasfyn-partyv + :: +=+ arg=(biff (~(get by qix.gas) %number) (slat %ud)) +;html + ;head + ;title: Mad Experiment Two + == + ;body + ;+ ?~ arg + ;p: Usage: ?number=x + ;p ; This is an ;{i "HTML file"} which + ; computes the Fibonacci number + ; of {}: {<(fib u.arg)>}. + == + == +== diff --git a/main/pub/fab/mad/three/hymn.hook b/main/pub/fab/mad/three/hymn.hook new file mode 100644 index 000000000..9655eeaac --- /dev/null +++ b/main/pub/fab/mad/three/hymn.hook @@ -0,0 +1,17 @@ +:: This third experiment wears the horns. +:: +:::: /hoon/three/mad/fab/pub + :: +/= hello /^ manx /:/======/res/hello:/hymn/ +:: +:::: ~tasfyn-partyv + :: +;html + ;head + ;title: Mad Experiment Three + == + ;body + ;+ hello + == +== + diff --git a/main/pub/fab/mad/two/hymn.hook b/main/pub/fab/mad/two/hymn.hook new file mode 100644 index 000000000..08c8bdd9a --- /dev/null +++ b/main/pub/fab/mad/two/hymn.hook @@ -0,0 +1,25 @@ +:: Our second experiment with major hood runes. +:: +:::: /hoon/two/mad/src/pub + :: +/= gas /$ fuel +// /===/pub/src/mad/tools +:: +:::: ~tasfyn-partyv + :: +=+ arg=(biff (~(get by qix.gas) %number) (slat %ud)) +:: +;html + ;head + ;title: Mad Experiment Two + == + ;body + ;+ ?~ arg + ;p: Usage: ?number=x + ;p ; This is an ;{i "HTML file"} which + ; computes the Fibonacci number + ; of {}: {<(fib u.arg)>}. + == + == +== + diff --git a/main/pub/src/doc/ref/nock.md b/main/pub/src/doc/ref/nock.md index 3f6bc715c..6a01ee478 100644 --- a/main/pub/src/doc/ref/nock.md +++ b/main/pub/src/doc/ref/nock.md @@ -607,13 +607,67 @@ original **subject** and the new variable. 35 :: *[a 9 b c] *[a 7 c 2 [0 1] 0 b] -**Operator 9** takes a **subject** and produces a new **subject** containing both code and data, also known as a **core**. A formula is then both extracted from, and applied to this new **core** **subject**. As its breakdown demonstrates, **Operator 9** is a macro that can compose recursive functions, as it encapsulates the functionality of both **Operator 7**(function composition) and **Operator 2** (recursion). +**Operator 9** takes a **subject** and produces a new **subject** containing +both code and data. A formula is then extracted, and then reflexively applied +to this newly generated **subject**. A subject of this structure, `[code +data]`, is officially called a **core**, in which code and data are renamed +**battery** and **payload**, respectively. **Cores** allow us to carry around +data structures that contain both code and data; **Operator 9** allows for code +from within the **battery** of a **core** to then be applied to data from +within the **payload** of that same **core**. + +There are different names for several different classes of **cores**: a +**door** is any **core** whose **payload** is of the form `[sample context]`, +where the **sample** is the argument (or arguments), and the **context** is any +other code available to be called. For almost every expression, the context +contains at least the entire kernel. The **battery** of a **door** contains one +or more **arms**, which are formulas that, when called, can produce a **gate**, +another type of **core** whose **battery** has just one arm of an empty name, +**++$**, called **buc** (++ is used to denote **arms** in Hoon), with a payload of `[sample context]`. **Gates** are +the closest thing Nock and Hoon have to functions in the traditional FP sense. + +Take, for example, a **door** with a **battery** of two arms, **++add** and +**++subtract**, a **payload** with a +**sample** **cell** of `[43 40]`, and a **context** consisting of the entire +kernel. If **Operator 9** were used to pull the address of the **arm** +**++subtract** from within this **door's** battery of **arms**, **++subtract** +would produce a new **core** by pushing both an **arm**, **++$**--which would +contain the code that, when called, would actually execute the subtraction--and +a new sample onto the **subject**. The **context** of this new **gate** would +be the previous **door** from which the **gate** was generated. + +The pseudocode below demonstrates this clearly: + +Door: + + [[subtract add] [[43 40] [kernel]]] + [Battery [Sample Context ]] + +Operator 9, calling subtract + + [[$, with the executable subtract code] [[43 40] [[subtract add] [[43 40] [kernel]]]]] + [[ Formula [[Sample][ Context (former door) ]]]] + +If **$** is called from within this new gate, it will subtract `40` from `43`. +However, some may notice the definition of **subtract** contains calls to +**decrement**. How does it gain access this function? The **decrement** arm is +contained within the **context** inside of the kernel. + +As its breakdown demonstrates, **Operator 9** is a macro that encapsulates the +functionality of both **Operator 7** (function composition) and **Operator 2** +(recursion). It produces a **core**, from whose **battery** an **arm** (or **arms**) is +extracted. These **arm(s)** are then reflexively applied to this new **core**. The reduced pseudo code demonstrates this clearly: *[*[a c] *[*[a c] 0 b]] -Here, `c` is some formula that produces a **core** when applied to **subject** `a`. This new **core** is then paired with a formula extracted from **axis** `b` within an identical copy of the new **core**. In higher-level languages that compile to Nock, functions that loop recursively often generate **Operator 9**, as it is the most concise way for a function (or **gate**, to use proper Hoon technology) to recall itself with changes made to its data. +Here, `c` is some formula that produces a **core** when applied to **subject** +`a`. This new **core** is then paired with a formula extracted from **axis** +`b` within an identical copy of the new **core**. In higher-level languages +that compile to Nock, functions that loop recursively often generate **Operator +9**, as it is the most concise way for a function (or **gate**, to use proper +Hoon technology) to recall itself with changes made to its data. ##Op 10: Hint @@ -623,17 +677,33 @@ Here, `c` is some formula that produces a **core** when applied to **subject** ` **Operator 10** serves as a hint to the interpreter. -As shown above, there are two cases of **Operator 10**. The latter has the formula `[10 b c]`, which then simply reduces to `c`. Although `[10 b c]` has to be semantically equivalent to `c`, it doesn't have to be practically equivalent. Since whatever information in `b` is discarded, a practical interpreter is free to ignore it, or to use it as a hint, as long as it does not affect the results of the computation. - -The former case is slightly more complicated. While it may appear that its reduction `*[*[[*[a c] a] 0 3] d]` could be reduced further to simply `[a d]`, as `*[[*[a c] a] 0 3]` could seem to return just `a`. However, there is a possibility that `c` does not terminate, in which case `[a d]` would be incorrect. Therefore, `*[*[[*[a c] a] 0 3] d]` is the most this case can be reduced. This is because **Operator 10** is a hint. If `x` in `[10 x y]` is an atom, we reduce line 37 and `x` is simply discarded. Otherwise, `x` is a cell `[b c]`; b is discarded, but `c` is computed as a formula and its result is discarded. - -Effectively, this mechanism lets us feed both static and dynamic information into the interpreter's hint mechanism. - - - +If `b` is an atom and `c` is a **formula**, the **formula** `[10 b c]` appears +to be equivalent to `c`. Likewise if `[b c]` is a **cell**, `[10 [b c] d]` +appears to be equivalent to `d`. **Operator 10** is actually a hint operator. +The `b` or `[b c]`is discarded information - it is not used, formally, in the +computation. It may help the interpreter compute the expression more +efficiently, however. +Every Nock computes the same result - but not all at the same speed. What hints +are supported? What do they do? Hints are a higher-level convention which do +not, and should not, appear in the Nock spec. Some are defined in Hoon. Indeed, +a naive Nock interpreter not optimized for Hoon will run Hoon quite poorly. +When it gets the product, however, the product will be right. (Why is the `c` +in `[b c]` computed? Because `c` could crash. A correct Nock cannot simply +ignore it, and treat both variants of `10` as equivalent.) ##Crash default 39 :: *a *a + +The nock function is defined for every **noun**, but on many **nouns** it does nothing +useful. For instance, if `a` is an **atom**, `*a` reduces to... `*a`. In theory, this +means that Nock spins forever in an infinite loop. In other words, Nock +produces no result - and in practice, your interpreter will stop. + +(Another way to see this is that Nock has "crash-only" semantics. There is no +exception mechanism. The only way to catch Nock errors is to simulate Nock in a +higher-level virtual Nock - which, in fact, we do all the time. A simulator (or +a practical low-level interpreter) can report, out of band, that Nock would not +terminate. It cannot recognize all in. diff --git a/main/pub/src/mad/fib.hoon b/main/pub/src/mad/fib.hoon new file mode 100644 index 000000000..ceacdcb1c --- /dev/null +++ b/main/pub/src/mad/fib.hoon @@ -0,0 +1,3 @@ +|% +++ fib |=(x=@ ~+(?:((lth x 2) 1 (add $(x (dec x)) $(x (sub x 2)))))) +-- diff --git a/main/pub/src/mad/tools/fib.hoon b/main/pub/src/mad/tools/fib.hoon new file mode 100644 index 000000000..2c77e5b21 --- /dev/null +++ b/main/pub/src/mad/tools/fib.hoon @@ -0,0 +1 @@ +|=(x=@ ~+(?:((lth x 2) 1 (add $(x (dec x)) $(x (sub x 2)))))) diff --git a/main/sur/down/gate.hook b/main/sur/down/gate.hook index 5581fa713..f807577fd 100644 --- a/main/sur/down/gate.hook +++ b/main/sur/down/gate.hook @@ -4,3 +4,4 @@ /? 314 /- *markdown down + diff --git a/main/sur/markdown/core.hook b/main/sur/markdown/core.hook index 53d35cf23..a6bba3726 100644 --- a/main/sur/markdown/core.hook +++ b/main/sur/markdown/core.hook @@ -19,3 +19,4 @@ [%tex p=tape] :: text == :: -- +