shrub/arvo/ford.hoon

496 lines
16 KiB
Plaintext
Raw Normal View History

2014-04-23 21:02:36 +04:00
!: :: %ford, new execution control
!? 164
::::
|= pit=vase
^- vane
=> =~
|% :: structures
++ axle :: all %ford state
2014-04-30 21:04:07 +04:00
$: ven=%0 :: version for update
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
2014-04-23 21:02:36 +04:00
== ::
2014-05-07 21:42:31 +04:00
++ bolt :: gonadic edge
|* a=$+(* *) :: product clam
$% [%0 p=(set beam) q=a] :: depends/product
[%1 p=(set ,[p=beam q=(list tank)])] :: blocks
2014-04-30 21:04:07 +04:00
[%2 p=(list tank)] :: error
2014-04-23 21:02:36 +04:00
== ::
2014-05-07 21:42:31 +04:00
:: ::
++ burg :: gonadic rule
|* [a=$+(* *) b=$+(* *)] :: from and to
$+(silk (bolt a)) ::
:: ::
++ plan :: full construction
$: hov=@ud :: hoon version
bek=beak :: load context
sik=silk :: design
== ::
2014-04-30 21:04:07 +04:00
++ task :: problem in progress
$: wor=writ :: rights and powers
nah=duct :: cause
2014-05-02 03:33:15 +04:00
bek=beak :: context
2014-05-07 21:42:31 +04:00
sik=silk :: problem
2014-05-09 04:34:57 +04:00
kig=[p=@ud q=(map ,@ud beam)] :: blocks
2014-04-23 21:02:36 +04:00
== ::
2014-05-07 21:42:31 +04:00
-- ::
2014-04-30 21:04:07 +04:00
|% ::
++ colt :: reduce to save
2014-05-07 21:42:31 +04:00
|= lex=axle ::
2014-04-30 21:04:07 +04:00
lex
::
2014-05-07 21:42:31 +04:00
++ fine |*(a=* [%0 p=*(set beam) q=a])
2014-05-09 04:34:57 +04:00
++ flew |=(a=(set ,[p=beam q=(list tank)]) [%1 p=a])
2014-05-07 21:42:31 +04:00
++ flaw |=(a=(list tank) [%2 p=a])
::
++ grim :: merge sets
2014-05-09 04:34:57 +04:00
|= [one=(set beam) two=(set beam)]
^- (set beam)
(~(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)])
2014-05-07 21:42:31 +04:00
(~(gas in one) (~(tap in two) ~)) :: XX ugh
::
++ tome :: parse path
|= pax=path
^- (unit beam)
?. ?=([* * * *] pax) ~
2014-05-09 04:47:34 +04:00
%+ biff (slaw %p i.pax)
2014-05-07 21:42:31 +04:00
|= who=ship
2014-05-09 04:47:34 +04:00
%+ biff (slaw %tas i.t.pax)
2014-05-07 21:42:31 +04:00
|= dex=desk
2014-05-09 04:47:34 +04:00
%+ biff (slay i.t.t.pax)
2014-05-09 04:34:57 +04:00
|= cis=coin
?. ?=([%$ case] cis) ~
`(unit beam)`[~ who dex `case`p.cis (flop t.t.t.pax)]
2014-05-07 21:42:31 +04:00
::
++ tope :: beam to path
|= bem=beam
^- path
[(scot %p p.bem) q.bem (scot r.bem) (flop s.bem)]
2014-05-02 03:33:15 +04:00
::
2014-04-30 21:04:07 +04:00
++ za :: per event
=| $: $: $: wor=writ :: event authority
tea=wire :: event place
hen=duct :: event floor
fav=card :: event data
== ::
$: now=@da :: event date
eny=@ :: unique entropy
2014-05-07 21:42:31 +04:00
ska=$+(* (unit (unit))) :: system namespace
== ::
mow=(list move) :: pending actions
== ::
2014-04-30 21:04:07 +04:00
axle :: all vane state
== ::
2014-04-30 21:04:07 +04:00
=* lex ->
|%
2014-04-30 21:04:07 +04:00
++ abet
^- [(list move) axle]
[(flop mow) lex]
::
++ apex
2014-05-09 04:34:57 +04:00
|- ^+ +.$
2014-04-30 21:04:07 +04:00
?^ tea
?> ?=([@ @ ~] tea)
=+ num=(need (slaw %ud i.tea))
?> ?=([%writ *] fav)
=+ tus=(~(get by q.tad) num)
?~ tus
~& [%ford-lost num]
+.$
(~(resp zo [num u.tus]) (need (slaw %ud i.t.tea)) p.fav)
::
2014-05-09 04:34:57 +04:00
?+ -.fav +.$
2014-04-30 21:04:07 +04:00
%exec
=+ num=p.tad
?> !(~(has by dym) hen)
=: p.tad +(p.tad)
2014-05-09 04:34:57 +04:00
dym (~(put by dym) hen num)
==
~(exec zo [num `task`[wor hen p.fav q.fav 0 ~]])
2014-04-30 21:04:07 +04:00
::
%kill
=+ num=(need (~(get by dym) hen))
=+ tas=(need (~(get by q.tad) num))
2014-05-09 04:34:57 +04:00
:: ~(kill zo [num tas])
!!
2014-04-30 21:04:07 +04:00
==
::
++ zo
|_ [num=@ud task]
++ abet %_(..zo q.tad (~(put by q.tad) num +<+))
++ amok %_(..zo q.tad (~(del by q.tad) num))
++ camp :: request a file
2014-05-07 21:42:31 +04:00
|= [ren=care bem=beam]
2014-04-30 21:04:07 +04:00
^+ +>
=+ tik=(scot %ud p.kig)
=: p.kig +(p.kig)
2014-05-09 04:34:57 +04:00
q.kig (~(put by q.kig) p.kig bem)
2014-04-30 21:04:07 +04:00
==
%= $
mow :_ mow
:+ [~ wor]
2014-05-09 04:34:57 +04:00
[/c [%f (scot %ud num) (scot %ud tik) ~] hen]
2014-05-07 21:42:31 +04:00
[%warp p.bem q.bem [~ %& %x r.bem s.bem]]
==
::
++ coax :: bolt across
|* [hoc=(bolt) fun=(burg)]
?- -.hoc
%0 =+ nuf=(fun)
?- -.nuf
%0 [%0 p=(grim p.hoc p.nuf) q=[q.hoc q.nuf]]
%1 nuf
%2 nuf
==
%1 =+ nuf=(fun)
?- -.nuf
%0 hoc
2014-05-09 04:34:57 +04:00
%1 ~! p.nuf
~! p.hoc
~! *(set ,[p=beam q=(list tank)])
(flew `(set ,[p=beam q=(list tank)])`(grum p.nuf p.hoc))
2014-05-07 21:42:31 +04:00
%2 nuf
==
%2 hoc
==
::
++ cope :: bolt along
|* [hoc=(bolt) fun=(burg)]
?- -.hoc
%2 hoc
%1 hoc
%0 =+ nuf=(fun q.hoc)
?- -.nuf
%2 nuf
%1 nuf
2014-05-09 04:34:57 +04:00
%0 [%0 p=(grim p.hoc p.nuf) q=q.nuf]
2014-05-07 21:42:31 +04:00
== ==
::
++ coup :: toon to bolt
|* [ton=toon fun=(burg)]
?- -.ton
2014-05-09 04:34:57 +04:00
%2 [%2 p=p.ton]
%0 [%0 p=~ q=(fun p.ton)]
2014-05-07 21:42:31 +04:00
%1 =- ?- faw
2014-05-09 04:34:57 +04:00
& [%1 p=(turn p.faw |=(a=beam [a *(list tank)]))]
| [%2 p=p.faw]
2014-05-07 21:42:31 +04:00
==
^= faw
|- ^- (each (list beam) (list tank))
?~ p.ton [%& ~]
=+ nex=$(p.ton t.p.ton)
=+ pax=(path i.p.ton)
=+ zis=(tome (path i.p.ton))
?~ zis
[%| (smyt pax) ?:(?=(& -.nex) ~ p.nex)]
?- -.nex
2014-05-09 04:34:57 +04:00
& [%& u.zis p.nex]
2014-05-07 21:42:31 +04:00
| nex
==
2014-05-09 04:34:57 +04:00
%2 [%2 p=p.ton]
2014-04-30 21:04:07 +04:00
==
2014-05-07 21:42:31 +04:00
::
++ exec :: execute app
2014-04-30 21:04:07 +04:00
^+ ..zo
2014-05-09 04:34:57 +04:00
?: !=(~ q.kig) ..zo
2014-04-30 21:04:07 +04:00
|- ^+ ..zo
2014-05-09 04:34:57 +04:00
=+ bot=(make sik)
2014-04-30 21:04:07 +04:00
?- -.bot
2014-05-09 04:34:57 +04:00
%0 amok:(expo [%made %& p.bot q.bot])
%2 amok:(expo [%made %| p.bot])
%1 =+ zuk=(~(tap by p.bot) ~)
=< abet
|- ^+ ..exec
?~ zuk ..exec
=+ foo=`_..exec`(camp %x `beam`p.i.zuk)
$(zuk t.zuk, ..exec foo)
2014-04-30 21:04:07 +04:00
==
2014-05-07 21:42:31 +04:00
::
2014-05-09 04:34:57 +04:00
++ expo :: return card
|= fav=card
%_(+> mow :_(mow [[~ wor] hen fav]))
::
2014-05-07 21:42:31 +04:00
++ krab :: load hoon to twig
|= [for=logo bem=beam]
^- (bolt twig)
%+ cope (make %bake for bem)
|= cay=cage
?. ?=(@ q.q.cay) [%2 (smyt (tope bem)) ~]
=+ vex=((full vest) [[1 1] (trip q.q.cay)])
?~ q.vex
[%2 [%leaf "syntax error: {<p.p.vex>} {<q.p.vex>}"] ~]
(fine p.u.q.vex)
::
++ lace :: load and check
|= [for=logo rem=spur bem=beam]
2014-05-09 04:34:57 +04:00
^- (bolt (unit vase))
2014-05-07 21:42:31 +04:00
%+ cope (lend bem)
|= arc=arch
?^ q.arc
(cope (liar bem) (lake for [p.bem q.bem r.bem]))
?. (~(has by r.arc) %hoon) (fine ~)
2014-05-09 04:34:57 +04:00
%+ cope (krab %hoon bem)
2014-05-07 21:42:31 +04:00
|= gen=twig
%+ cope (maim pit gen)
|= gat=vase
%+ cope (maul gat !>(rem))
(lake for [p.bem q.bem r.bem])
::
++ lake :: check/coerce
|= [for=logo bek=beak]
|= sam=vase
2014-05-09 04:34:57 +04:00
^- (bolt (unit vase))
2014-05-07 21:42:31 +04:00
?: ?=(?(%gate %core) for)
2014-05-09 04:34:57 +04:00
(fine ~ sam)
2014-05-07 21:42:31 +04:00
%+ cope (make %bake %gate p.bek q.bek r.bek /ref/[for]/sys)
2014-05-09 04:34:57 +04:00
|= cay=cage
%+ cope (lane p.q.cay [%cnzy %$])
2014-05-07 21:42:31 +04:00
|= ref=type
?: (~(nest ut ref) | p.sam)
2014-05-09 04:34:57 +04:00
(fine ~ sam)
%+ cope (maul q.cay sam)
2014-05-07 21:42:31 +04:00
|= pro=vase
2014-05-09 04:34:57 +04:00
(fine ~ pro)
2014-05-07 21:42:31 +04:00
::
++ lane :: type infer
|= [typ=type gen=twig]
%+ coup (mule |.((~(play ut typ) gen)))
|=(ref=type ref)
::
++ lend :: load arch
|= bem=beam
^- (bolt arch)
=+ von=(ska %cy (tope bem))
?~ von [%1 [bem ~] ~ ~]
(fine ((hard arch) (need u.von)))
::
++ liar :: load vase
|= bem=beam
^- (bolt vase)
=+ von=(ska %cx (tope bem))
?~ von
[%1 [[bem ~] ~ ~]]
?~ u.von
[%2 (smyt (tope bem)) ~]
(fine ?^(u.u.von [%cell %noun %noun] [%atom %$]) u.u.von)
::
++ lily :: translation targets
|= [for=logo bek=beak]
^- (bolt (list ,@tas))
%+ cope
%+ cope (lend p.bek q.bek r.bek `path`~[%tan for %sys])
|= arc=arch
(fine (turn (~(tap by r.arc) ~) |=([a=@tas b=~] a)))
|= all=(list ,@tas)
(fine ?.(=(%hoon for) all [%hoot all]))
::
++ lima :: load at depth
|= [for=logo rem=spur bem=beam]
^- (bolt (unit vase))
%+ cope (lend bem)
|= arc=arch
2014-05-09 04:34:57 +04:00
^- (bolt (unit vase))
2014-05-07 21:42:31 +04:00
?: (~(has by r.arc) for)
(lace for rem bem(s [for s.bem]))
2014-05-09 04:34:57 +04:00
%+ cope
%^ lion for
[p.bem q.bem r.bem]
(turn (~(tap by r.arc) ~) |=([a=@tas b=~] a))
|= wuy=(unit (list ,@tas))
?~ wuy (fine ~)
=+ yaw=(flop u.wuy)
2014-05-07 21:42:31 +04:00
?> ?=(^ yaw)
%+ cope (make %bake i.yaw bem)
2014-05-09 04:34:57 +04:00
|= hoc=cage
2014-05-07 21:42:31 +04:00
%+ cope (lope i.yaw t.yaw [p.bem q.bem r.bem] q.hoc)
|= vax=vase
(fine ~ vax)
::
++ lime :: load beam
|= [for=logo bem=beam]
2014-05-09 04:34:57 +04:00
=+ [mob=bem rem=*path]
2014-05-07 21:42:31 +04:00
|- ^- (bolt vase)
2014-05-09 04:34:57 +04:00
%+ cope (lima for rem bem)
|= vux=(unit vase)
?^ vux (fine u.vux)
2014-05-07 21:42:31 +04:00
?~ s.bem
[%2 (smyt (tope mob)) ~]
2014-05-09 04:34:57 +04:00
$(s.bem t.s.bem, rem [i.s.bem rem])
2014-05-07 21:42:31 +04:00
::
++ link :: translate
|= [too=logo for=logo bek=beak vax=vase]
^- (bolt vase)
?: &(=(%hoot too) =(%hoon for))
(fine !>(ream))
%+ cope (make %bake %gate p.bek q.bek r.bek /[too]/tan/[for]/sys)
2014-05-09 04:34:57 +04:00
|= cay=cage
(maul q.cay vax)
2014-05-07 21:42:31 +04:00
::
2014-05-09 04:34:57 +04:00
++ lion :: translation search
2014-05-07 21:42:31 +04:00
|= [too=@tas bek=beak fro=(list ,@tas)]
2014-05-09 04:34:57 +04:00
^- (bolt (unit (list ,@tas)))
2014-05-07 21:42:31 +04:00
=| war=(set ,@tas)
2014-05-09 04:34:57 +04:00
=< -:(apex (fine fro))
2014-05-07 21:42:31 +04:00
|%
++ apex
|= rof=(bolt (list ,@tas))
2014-05-09 04:34:57 +04:00
^- [(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) +>.$]
2014-05-07 21:42:31 +04:00
::
++ apse
|= for=@tas
2014-05-09 04:34:57 +04:00
^- [(bolt (unit (list ,@tas))) _+>]
?: =(for too)
[(fine [~ too ~]) +>.$]
?: (~(has in war) for) [(fine ~) +>]
2014-05-07 21:42:31 +04:00
=. war (~(put in war) for)
=^ orf +>.$ (apex (lily for bek))
:_ +>.$
2014-05-09 04:34:57 +04:00
%+ cope orf
|= ked=(unit (list ,@tas))
?~ ked
(fine ~)
(fine ~ [for u.ked])
2014-05-07 21:42:31 +04:00
--
::
++ lope
|= [for=logo yaw=(list logo) bek=beak vax=vase]
^- (bolt vase)
2014-05-09 04:34:57 +04:00
?~ yaw (fine vax)
2014-05-07 21:42:31 +04:00
%+ cope (link i.yaw for bek vax)
|= yed=vase
2014-05-09 04:34:57 +04:00
^$(yaw t.yaw, vax yed)
2014-05-07 21:42:31 +04:00
::
++ make :: reduce silk
|= kas=silk
^- (bolt cage)
?- -.kas
2014-04-30 21:04:07 +04:00
^
2014-05-07 21:42:31 +04:00
%. [p.kas q.kas]
;~ cope
;~ coax
|=([p=silk q=silk] ^$(kas p.kas))
|=([p=silk q=silk] ^$(kas q.kas))
==
::
|= [bor=cage heg=cage] ^- (bolt cage)
:+ %0 ~
[[p.bor p.heg] (slop q.bor q.heg)]
==
2014-04-30 21:04:07 +04:00
::
2014-05-09 04:34:57 +04:00
%bake
%+ cope (lima p.kas ~ q.kas)
|= vux=(unit vase)
?~ vux
(flaw (smyt (tope q.kas)) ~)
(fine [p.kas u.vux])
::
%boil (cope (lime p.kas q.kas) |=(a=vase (fine [p.kas a])))
2014-04-30 21:04:07 +04:00
%call
2014-05-07 21:42:31 +04:00
%. [p.kas q.kas]
;~ cope
;~ coax
|=([p=silk q=silk] ^$(kas p))
|=([p=silk q=silk] ^$(kas q))
==
::
2014-05-09 04:34:57 +04:00
|= [gat=cage sam=cage]
(maul q.gat q.sam)
2014-05-07 21:42:31 +04:00
::
|= vax=vase
2014-05-09 04:34:57 +04:00
(fine %noun vax)
2014-05-07 21:42:31 +04:00
==
2014-04-30 21:04:07 +04:00
::
2014-05-09 04:34:57 +04:00
%reef (fine %noun pit)
2014-05-07 21:42:31 +04:00
==
::
++ maim :: slap
|= [vax=vase gen=twig]
^- (bolt vase)
=+ puz=(mule |.((~(mint ut p.vax) [%noun gen])))
?- -.puz
| [%2 p.puz]
2014-05-09 04:34:57 +04:00
& %+ coup (mock [q.vax q.p.puz] (mole ska))
|= val=*
`vase`[p.p.puz val]
==
2014-04-30 21:04:07 +04:00
::
++ maul :: slam
2014-05-02 03:33:15 +04:00
|= [gat=vase sam=vase]
2014-05-07 21:42:31 +04:00
^- (bolt vase)
=+ top=(mule |.((slit p.gat p.sam)))
2014-05-02 03:33:15 +04:00
?- -.top
2014-05-07 21:42:31 +04:00
| [%2 p.top]
2014-05-09 04:34:57 +04:00
& %+ coup (mong [q.gat q.sam] (mole ska))
|= val=*
`vase`[p.top val]
==
2014-04-30 21:04:07 +04:00
::
++ resp
|= [tik=@ud rot=riot]
^+ ..zo
?> (~(has by q.kig) tik)
?~ rot
2014-05-09 04:34:57 +04:00
amok:(expo [%made %| (smyt (tope (need (~(get by q.kig) tik)))) ~])
2014-04-30 21:04:07 +04:00
exec(q.kig (~(del by q.kig) tik))
--
--
--
2014-04-23 21:02:36 +04:00
. ==
=| axle
=* lex -
2014-05-02 03:33:15 +04:00
|= [now=@da eny=@ ska=$+(* (unit (unit)))] :: activate
2014-04-23 21:02:36 +04:00
^? :: opaque core
|% ::
++ beat :: process move
2014-05-09 04:47:34 +04:00
|= [wru=(unit writ) tea=wire hen=duct fav=card]
2014-04-23 21:02:36 +04:00
^- [p=(list move) q=vane]
2014-04-30 21:04:07 +04:00
?~ wru ~|(%beat-whom !!)
=^ mos lex
2014-05-07 21:42:31 +04:00
abet:~(apex za [[u.wru tea hen fav] [now eny ska] ~] lex)
2014-04-23 21:02:36 +04:00
[mos ..^$]
::
++ come
|= [sam=? old=vase]
^- vane
(load old)
::
++ doze
|= [now=@da hen=duct]
^- (unit ,@da)
~
::
++ load
|= old=vase
^- vane
2014-04-30 21:04:07 +04:00
?. (~(nest ut -:!>(`axle`+>-.^$)) | p.old)
2014-04-23 21:02:36 +04:00
~& %eyre-reset
..^$
2014-04-30 21:04:07 +04:00
..^$(+>- (axle q.old))
2014-04-23 21:02:36 +04:00
::
++ raze
^- vane
2014-04-30 21:04:07 +04:00
..$(+>- *axle)
2014-04-23 21:02:36 +04:00
::
++ scry
2014-05-09 04:47:34 +04:00
|= [our=ship ren=@tas who=ship syd=desk lot=coin tyl=path]
2014-05-09 21:18:23 +04:00
^- (unit (unit))
2014-04-23 21:02:36 +04:00
~
::
++ stay
2014-04-30 21:04:07 +04:00
`vase`!>((colt `axle`+>-.$))
2014-04-23 21:02:36 +04:00
++ vern [164 0]
--