Various fixes and improvements.

This commit is contained in:
C. Guy Yarvin 2014-05-13 17:04:23 -07:00
parent 4e2f9738f2
commit 7f0b2cf5e4
3 changed files with 141 additions and 91 deletions

View File

@ -451,7 +451,7 @@
~
?~ sur (fail 500 "no vessel available to proxy {<him>}")
?. (gth (met 3 him) (met 3 u.sur)) :: very permissive
(fail 500 "<u.sur> cannot proxy for <him>")
(fail 500 "{<u.sur>} cannot proxy for {<him>}")
=+ ^= rot ^- rote
=+ rut=(~(get by fon) him)
?^ rut u.rut

View File

@ -7,54 +7,92 @@
|% :: structures
++ axle :: all %ford state
$: ven=%0 :: version for update
tad=[p=@ud q=(map ,@ud task)] :: tasks by number
pol=(map ship baby) ::
== ::
++ baby :: state by ship
$: tad=[p=@ud q=(map ,@ud task)] :: tasks by number
dym=(map duct ,@ud) :: duct to number
tiz=(map cash twig) :: file hash to twig
== ::
++ bolt :: gonadic edge
|* a=$+(* *) :: product clam
$% [%0 p=(set beam) q=a] :: depends/product
[%1 p=(set ,[p=beam q=(list tank)])] :: blocks
[%2 p=(list tank)] :: error
$: 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
== ::
== ::
:: ::
++ burg :: gonadic rule
|* [a=$+(* *) b=$+(* *)] :: from and to
$+(silk (bolt a)) ::
:: ::
++ cafe :: live cache
$: p=(set calx) :: used
q=(map ,* calx) :: cache
== ::
:: ::
++ calf :: abstract cache line
|* [a=@tas b=$+(* *) c=$+(* *)] :: key, value
,[_a p=b q=@da r=c] :: key and last used
:: ::
++ calm ,@da :: cache metrics
++ calx :: concrete cache line
$%
:: [%comp p=calm q=@t r=twig] :: compile by text
:: [%coop p=calm q=@uvI r=twig] :: compile by mug
[%fake p=calm q=@ r=@]
== ::
:: ::
++ plan :: full construction
$: hov=@ud :: hoon version
bek=beak :: load context
kas=silk :: design
== ::
++ task :: problem in progress
$: wor=writ :: rights and powers
nah=duct :: cause
$: nah=duct :: cause
kas=silk :: problem
kig=[p=@ud q=(map ,@ud beam)] :: blocks
== ::
-- ::
|% ::
++ calk :: cache lookup
|= a=cafe ::
|* [b=@tas c=*] ::
=+ d=(~(get by q.a) [b c]) ::
?~ d [~ a] ::
[?>(?=(_b -.u.d) d) a(p (~(put in p.a) u.d))] ::
:: ::
++ camp ::
|= [a=cafe b=calx] :: cache install
^- cafe ::
a(q (~(put by q.a) [-.b q.b] b)) ::
:: ::
++ chub :: cache merge
|= [a=cafe b=cafe] ::
^- cafe ::
[(grom p.a p.b) (grum q.a q.b)] ::
:: ::
++ colt :: reduce to save
|= lex=axle ::
lex
::
++ fine |*(a=* [%0 p=*(set beam) q=a])
++ flew |=(a=(set ,[p=beam q=(list tank)]) [%1 p=a])
++ flaw |=(a=(list tank) [%2 p=a])
++ fine |*(a=* [p=*cafe q=[%0 p=*(set beam) q=a]])
++ flaw |=(a=(list tank) [p=*cafe q=[%2 p=a]])
::
++ grim :: merge sets
|= [one=(set beam) two=(set beam)]
^- (set beam)
++ grom :: merge sets
|* [one=(set) two=(set)]
^+ one
(~(gas in one) (~(tap in two) ~)) :: XX ugh
::
++ grum :: merge sets
|= [one=(set ,[p=beam q=(list tank)]) two=(set ,[p=beam q=(list tank)])]
^- (set ,[p=beam q=(list tank)])
(~(gas in one) (~(tap in two) ~)) :: XX ugh
++ grum :: merge maps
|* [one=(map) two=(map)]
^+ one
(~(gas by one) (~(tap by two) ~)) :: XX ugh
::
++ za :: per event
=| $: $: $: wor=writ :: event authority
=| $: $: $: our=ship :: computation owner
tea=wire :: event place
hen=duct :: event floor
fav=card :: event data
@ -65,13 +103,12 @@
== ::
mow=(list move) :: pending actions
== ::
axle :: all vane state
bay=baby :: all owned state
== ::
=* lex ->
|%
++ abet
^- [(list move) axle]
[(flop mow) lex]
^- [(list move) baby]
[(flop mow) bay]
::
++ apex
|- ^+ +.$
@ -79,7 +116,7 @@
?> ?=([@ @ ~] tea)
=+ num=(need (slaw %ud i.tea))
?> ?=([%writ *] fav)
=+ tus=(~(get by q.tad) num)
=+ tus=(~(get by q.tad.bay) num)
?~ tus
~& [%ford-lost num]
+.$
@ -87,24 +124,24 @@
::
?+ -.fav +.$
%exec
=+ num=p.tad
?> !(~(has by dym) hen)
=: p.tad +(p.tad)
dym (~(put by dym) hen num)
=+ 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`[wor hen p.fav 0 ~]])
~(exec zo [num `task`[hen p.fav 0 ~]])
::
%kill
=+ num=(need (~(get by dym) hen))
=+ tas=(need (~(get by q.tad) num))
=+ num=(need (~(get by dym.bay) hen))
=+ tas=(need (~(get by q.tad.bay) num))
:: ~(kill zo [num tas])
!!
==
::
++ zo
|_ [num=@ud task]
++ abet %_(..zo q.tad (~(put by q.tad) num +<+))
++ amok %_(..zo q.tad (~(del by q.tad) num))
++ abet %_(..zo q.tad.bay (~(put by q.tad.bay) num +<+))
++ amok %_(..zo q.tad.bay (~(del by q.tad.bay) num))
++ camp :: request a file
|= [ren=care bem=beam]
^+ +>
@ -114,50 +151,57 @@
==
%= $
mow :_ mow
:+ [~ wor]
:+ [~ %iron our]
[/c [%f (scot %ud num) (scot %ud tik) ~] hen]
[%warp p.bem q.bem [~ %& %x r.bem s.bem]]
==
::
++ coax :: bolt across
|* [hoc=(bolt) fun=(burg)]
?- -.hoc
?- -.q.hoc
%0 =+ nuf=(fun)
?- -.nuf
%0 [%0 p=(grim p.hoc p.nuf) q=[q.hoc q.nuf]]
%1 nuf
%2 nuf
:- p=(chub p.hoc 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)
?- -.nuf
%0 hoc
%1 ~! p.nuf
~! p.hoc
~! *(set ,[p=beam q=(list tank)])
(flew `(set ,[p=beam q=(list tank)])`(grum p.nuf p.hoc))
%2 nuf
:- p=(chub p.hoc p.nuf)
^= q
?- -.q.nuf
%0 q.hoc
%1 [%1 p=(grom p.q.nuf p.q.hoc)]
%2 q.nuf
==
%2 hoc
==
::
++ cope :: bolt along
|* [hoc=(bolt) fun=(burg)]
?- -.hoc
?- -.q.hoc
%2 hoc
%1 hoc
%0 =+ nuf=(fun q.hoc)
?- -.nuf
%2 nuf
%1 nuf
%0 [%0 p=(grim p.hoc p.nuf) q=q.nuf]
%0 =+ nuf=(fun q.q.hoc)
:- p=(chub p.hoc 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]
== ==
::
++ coup :: toon to bolt
|* [ton=toon fun=(burg)]
:- p=*cafe
^= q
?- -.ton
%2 [%2 p=p.ton]
%0 [%0 p=~ q=(fun p.ton)]
%1 =- ?- faw
%1 =- :- p=*cafe
^= q
?- faw
& [%1 p=(turn p.faw |=(a=beam [a *(list tank)]))]
| [%2 p=p.faw]
==
@ -173,7 +217,6 @@
& [%& u.zis p.nex]
| nex
==
%2 [%2 p=p.ton]
==
::
++ exec :: execute app
@ -181,10 +224,10 @@
?: !=(~ q.kig) ..zo
|- ^+ ..zo
=+ bot=(make kas)
?- -.bot
%0 amok:(expo [%made %& p.bot q.bot])
%2 amok:(expo [%made %| p.bot])
%1 =+ zuk=(~(tap by 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
@ -194,20 +237,21 @@
::
++ expo :: return card
|= fav=card
%_(+> mow :_(mow [[~ wor] hen fav]))
%_(+> mow :_(mow [[~ %iron our] hen fav]))
::
++ krab :: load to twig
|= [for=logo rem=spur bem=beam]
|= [for=logo how=logo rem=spur bem=beam]
^- (bolt vase)
%+ cope (make %bake for bem)
%+ cope (make %bake how bem)
|= cay=cage
?. ?=(@ q.q.cay) [%2 (smyt (tope bem)) ~]
?. ?=(@ q.q.cay)
(flaw (smyt (tope bem)) ~)
=+ vex=((full vest) [[1 1] (trip q.q.cay)])
?~ q.vex
[%2 [%leaf "syntax error: {<p.p.vex>} {<q.p.vex>}"] ~]
(flaw [%leaf "syntax error: {<p.p.vex>} {<q.p.vex>}"] ~)
%+ cope (maim pit p.u.q.vex)
|= gat=vase
(maul gat !>([`beak`[p.bem q.bem r.bem] s.bem rem]))
(maul gat !>([`beak`[p.bem q.bem r.bem] for +:s.bem rem]))
::
++ lace :: load and check
|= [for=logo rem=spur bem=beam]
@ -218,10 +262,10 @@
?^ q.arc
(cope (liar bem) (lake for bek))
?: (~(has by r.arc) %hoon)
%+ cope (krab %hoon rem bem)
%+ cope (krab for %hoon rem bem)
(lake for bek)
?: (~(has by r.arc) %hook)
%+ cope (krab %hook rem bem)
%+ cope (krab for %hook rem bem)
|= vax=vase
%+ cope ((lair for bem) vax)
|= vax=vase
@ -234,7 +278,7 @@
^- (bolt (unit vase))
?: ?=(?(%gate %core %hoon %hook) for)
(fine ~ sam)
%+ cope (make %bake %gate p.bek q.bek r.bek /ref/[for]/sys)
%+ cope (make %boil %gate p.bek q.bek r.bek /ref/[for]/sys)
|= cay=cage
%+ cope (lane p.q.cay [%cnzy %$])
|= ref=type
@ -249,7 +293,7 @@
|= vax=vase
^- (bolt vase)
?. (~(nest ut -:!>(*silk)) | p.vax)
[%2 (smyt (tope bem)) ~]
(flaw (smyt (tope bem)) ~)
%+ cope (make ((hard silk) q.vax))
|= cay=cage
=+ too=`logo`?@(p.cay p.cay %noun)
@ -264,7 +308,7 @@
|= bem=beam
^- (bolt arch)
=+ von=(ska %cy (tope bem))
?~ von [%1 [bem ~] ~ ~]
?~ von [p=*cafe q=[%1 [bem ~] ~ ~]]
(fine ((hard arch) (need u.von)))
::
++ liar :: load vase
@ -272,9 +316,9 @@
^- (bolt vase)
=+ von=(ska %cx (tope bem))
?~ von
[%1 [[bem ~] ~ ~]]
[p=*cafe q=[%1 [[bem ~] ~ ~]]]
?~ u.von
[%2 (smyt (tope bem)) ~]
(flaw (smyt (tope bem)) ~)
(fine ?^(u.u.von [%cell %noun %noun] [%atom %$]) u.u.von)
::
++ lily :: translation targets
@ -301,11 +345,10 @@
(turn (~(tap by r.arc) ~) |=([a=@tas b=~] a))
|= wuy=(unit (list ,@tas))
?~ wuy (fine ~)
=+ yaw=(flop u.wuy)
?> ?=(^ yaw)
%+ cope (make %bake i.yaw bem)
?> ?=(^ u.wuy)
%+ cope (make %bake i.u.wuy bem)
|= hoc=cage
%+ cope (lope i.yaw t.yaw [p.bem q.bem r.bem] q.hoc)
%+ cope (lope i.u.wuy t.u.wuy [p.bem q.bem r.bem] q.hoc)
|= vax=vase
(fine ~ vax)
::
@ -317,7 +360,7 @@
|= vux=(unit vase)
?^ vux (fine u.vux)
?~ s.bem
[%2 (smyt (tope mob)) ~]
(flaw (smyt (tope mob)) ~)
^$(s.bem t.s.bem, rem [i.s.bem rem])
::
++ link :: translate
@ -326,7 +369,7 @@
?: =(too for) (fine vax)
?: &(=(%hoot too) =(%hoon for))
(fine !>(ream))
%+ cope (make %bake %gate p.bek q.bek r.bek /[too]/tan/[for]/sys)
%+ cope (make %boil %gate p.bek q.bek r.bek /[too]/tan/[for]/sys)
|= cay=cage
(maul q.cay vax)
::
@ -335,18 +378,19 @@
^- (bolt (unit (list ,@tas)))
=| war=(set ,@tas)
=< -:(apex (fine fro))
|%
|% :: XX improve monads
++ apex
|= rof=(bolt (list ,@tas))
^- [(bolt (unit (list ,@tas))) _+>]
?. ?=(%0 -.rof) [rof +>.$]
?~ q.rof
[(fine ~) +>.$]
=^ orf +>.$ (apse i.q.rof)
?. ?=(%0 -.orf) [orf +>.$]
?~ q.orf
$(q.rof t.q.rof)
[(fine q.orf) +>.$]
?. ?=(%0 -.q.rof) [rof +>.$]
?~ q.q.rof
[[p.rof [%0 p.q.rof ~]] +>.$]
=^ orf +>.$ (apse i.q.q.rof)
?. ?=(%0 -.q.orf)
[[(chub p.rof p.orf) q.orf] +>.$]
?~ q.q.orf
$(q.q.rof t.q.q.rof)
[[(chub p.rof p.orf) [%0 (grom p.q.rof p.q.orf) q.q.orf]] +>.$]
::
++ apse
|= for=@tas
@ -366,6 +410,7 @@
::
++ lope
|= [for=logo yaw=(list logo) bek=beak vax=vase]
~& [%lope for yaw bek]
^- (bolt vase)
?~ yaw (fine vax)
%+ cope (link i.yaw for bek vax)
@ -385,6 +430,7 @@
==
::
|= [bor=cage heg=cage] ^- (bolt cage)
:- *cafe
:+ %0 ~
[[p.bor p.heg] (slop q.bor q.heg)]
==
@ -428,7 +474,7 @@
^- (bolt vase)
=+ puz=(mule |.((~(mint ut p.vax) [%noun gen])))
?- -.puz
| [%2 p.puz]
| (flaw p.puz)
& %+ coup (mock [q.vax q.p.puz] (mole ska))
|= val=*
`vase`[p.p.puz val]
@ -439,7 +485,7 @@
^- (bolt vase)
=+ top=(mule |.((slit p.gat p.sam)))
?- -.top
| [%2 p.top]
| (flaw p.top)
& %+ coup (mong [q.gat q.sam] (mole ska))
|= val=*
`vase`[p.top val]
@ -465,9 +511,12 @@
|= [wru=(unit writ) tea=wire hen=duct fav=card]
^- [p=(list move) q=vane]
?~ wru ~|(%beat-whom !!)
=^ mos lex
abet:~(apex za [[u.wru tea hen fav] [now eny ska] ~] lex)
[mos ..^$]
=+ ^= bay ^- baby
=+ buy=(~(get by pol.lex) q.u.wru)
?~(buy *baby u.buy)
=^ mos bay
abet:~(apex za [[q.u.wru tea hen fav] [now eny ska] ~] bay)
[mos ..^$(pol (~(put by pol) q.u.wru bay))]
::
++ come
|= [sam=? old=vase]
@ -483,7 +532,7 @@
|= old=vase
^- vane
?. (~(nest ut -:!>(`axle`+>-.^$)) | p.old)
~& %eyre-reset
~& %ford-reset
..^$
..^$(+>- (axle q.old))
::

View File

@ -2725,6 +2725,7 @@
$& [p=silk q=silk] :: cons
$% [%bake p=logo q=beam] :: local synthesis
[%boil p=logo q=beam] :: general synthesis
[%cage p=cage] ::
[%call p=silk q=silk] :: slam
[%cast p=logo q=beak r=silk] :: translate
:: [%done p=(set beam) q=cage] :: literal