urbit/arvo/gall.hoon

553 lines
20 KiB
Plaintext
Raw Normal View History

2014-05-28 12:57:00 +04:00
!: :: %gall, user-level applications
2014-04-30 21:04:07 +04:00
!? 164
::::
|= pit=vase
2014-05-28 12:57:00 +04:00
=> =~
2014-06-02 01:07:13 +04:00
|% :::::::::::::::::::::::::::::::::::::::::::::::::::::: structures
2014-04-30 21:04:07 +04:00
++ axle :: all %gall state
2014-05-31 02:10:39 +04:00
$: %0 :: state version
2014-05-28 12:57:00 +04:00
pol=(map ship mast) :: apps by ship
== ::
2014-05-07 21:42:31 +04:00
++ bone ,@ud :: opaque duct
++ gift :: out result <-$
2014-05-28 12:57:00 +04:00
$% [%back p=?] :: %mess ack good/bad
2014-06-02 01:07:13 +04:00
[%bust ~] :: reset duct
2014-05-28 12:57:00 +04:00
[%crud p=(list tank)] :: error
2014-06-02 01:07:13 +04:00
[%rash p=json] :: web reaction
[%rasp p=cage] :: urbit reaction
[%rush p=@da q=json] :: web result
[%rust p=@da q=cage] :: urbit result
[%meta p=vase] :: meta-gift
2014-05-28 12:57:00 +04:00
== ::
++ kiss :: in request ->$
2014-06-02 01:07:13 +04:00
$% [%cuff p=(unit cuff) q=kiss] :: controlled kiss
[%mesh p=hasp q=path r=json] :: web message (json)
[%mess p=hasp q=cage] :: urbit message
[%mush p=hasp q=path r=cage] :: web message (mime)
2014-05-28 20:20:07 +04:00
[%nuke p=hasp] :: reset this duct
2014-06-02 01:07:13 +04:00
:: [%puke p=(list tank) q=kiss] :: kiss will fail
[%shah p=hasp q=(unit hope)] :: web subscribe
[%show p=hasp q=(unit hope)] :: urbit subscribe
2014-05-28 12:57:00 +04:00
[%soft p=*] :: soft kiss
== ::
2014-05-28 09:44:18 +04:00
++ knob :: pending action
2014-05-28 12:57:00 +04:00
$% [%boot ~] :: boot/reboot
2014-05-29 02:06:52 +04:00
[%crud p=(list tank)] :: error
2014-06-02 01:07:13 +04:00
[%mess p=cage] :: message
2014-05-28 20:20:07 +04:00
[%nuke ~] :: reboot
2014-06-02 01:07:13 +04:00
[%show p=(unit hope)] :: subscription
2014-05-28 12:57:00 +04:00
[%take p=path q=vase] :: user result
== ::
++ mast :: apps by ship
2014-05-28 12:57:00 +04:00
$: bum=(map ,@ta seat) :: apps by name
== ::
++ move ,[p=duct q=(mold note gift)] :: typed move
++ note curd :: out request $->
2014-05-28 12:57:00 +04:00
++ rapt |*(a=$+(* *) (qual path path ,@da a)) :: versioned result
++ scar :: opaque duct system
$: p=@ud :: bone sequence
2014-06-02 01:07:13 +04:00
q=(map duct ,[p=bone q=(unit cuff)]) :: by duct
2014-05-28 12:57:00 +04:00
r=(map bone duct) :: by bone
== ::
++ seat :: the living app
2014-05-28 12:57:00 +04:00
$: huv=(unit vase) :: application vase
qic=(unit toil) :: project
vey=(qeu toil) :: pending calls
2014-05-29 02:06:52 +04:00
orm=(unit ,@da) :: last buildtime
ped=(set (pair ship desk)) :: dependencies
2014-05-28 12:57:00 +04:00
zam=scar :: opaque ducts
== ::
2014-05-28 09:44:18 +04:00
++ sign :: in result $-<
2014-05-28 12:57:00 +04:00
$% [%made p=(each beet (list tank))] :: computed result
2014-05-29 02:06:52 +04:00
[%ruse p=curd] :: user wrapper
[%writ p=riot] :: version result
2014-05-28 12:57:00 +04:00
== ::
2014-05-28 09:44:18 +04:00
++ toil (pair duct knob) :: work in progress
2014-05-28 12:57:00 +04:00
-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::
|% :::::::::::::::::::::::::::::::::::::::::::::::::::::: functions
2014-05-27 13:47:19 +04:00
++ byby :: double bind
|* [a=(unit (unit)) b=$+(* *)]
?~ a ~
?~ u.a [~ u=~]
[~ u=[~ u=(b u.u.a)]]
:: ::
++ colt :: reduce to save
|= all=axle ::
all
::
++ read :: read permission
2014-06-02 01:07:13 +04:00
|= law=(unit cuff)
2014-05-27 13:47:19 +04:00
^- (unit (set monk))
?~(law [~ ~] p.u.law)
::
2014-05-28 09:44:18 +04:00
++ ride :: all permission
|= [use=(unit (set monk)) say=(unit (set monk))]
2014-06-02 01:07:13 +04:00
^- (unit cuff)
2014-05-28 09:44:18 +04:00
?~(say ~ `[use u.say])
::
2014-05-27 13:47:19 +04:00
++ rite :: write permission
2014-06-02 01:07:13 +04:00
|= law=(unit cuff)
2014-05-27 13:47:19 +04:00
^- (unit (set monk))
?~(law ~ `q.u.law)
::
++ grom :: merge sets
|* [one=(set) two=(set)]
^+ one
(~(gas in one) (~(tap in two) ~)) :: XX ugh
::
++ grum :: merge maps
|* [one=(map) two=(map)]
^+ one
(~(gas by one) (~(tap by two) ~)) :: XX ugh
::
2014-06-02 01:07:13 +04:00
++ limp :: merge cuffs
|= [a=(unit cuff) b=(unit cuff)]
^- (unit cuff)
2014-05-27 13:47:19 +04:00
?~ a b
?~ b a
:- ~
:- ?~(p.u.a ~ ?~(p.u.b ~ `(grom u.p.u.b u.p.u.a)))
(grom q.u.b q.u.a)
::
++ lump :: position
|= pax=path
^- [p=[p=ship q=term] q=path]
?> ?=([@ @ *] pax)
:- :- (need (slaw %p i.pax))
(need ((sand %tas) i.t.pax))
t.t.pax
--
. == :: end preface
=| all=axle :: all vane state
|= $: now=@da :: urban time
eny=@ :: entropy
2014-05-31 23:40:02 +04:00
ska=sled :: activate
== :: opaque core
2014-05-27 13:47:19 +04:00
=< ^?
|% :: vane interface
++ call :: handle request
|= [hen=duct hil=(hypo kiss)]
2014-05-27 13:47:19 +04:00
|- ^- [p=(list move) q=_..^^$]
2014-06-02 01:07:13 +04:00
=+ =| law=(unit cuff)
|- ^- $: law=(unit cuff)
2014-05-29 02:06:52 +04:00
hap=hasp
kon=knob
==
?- -.q.hil
2014-06-02 01:07:13 +04:00
%cuff $(q.hil q.q.hil, law (limp p.q.hil law))
%mesh !!
2014-05-29 02:06:52 +04:00
%mess [law p.q.hil %mess q.q.hil]
2014-06-02 01:07:13 +04:00
%mush !!
%shah !!
%show [law p.q.hil %show q.q.hil]
2014-05-29 02:06:52 +04:00
%soft $(q.hil ((hard kiss) p.q.hil))
%nuke [law p.q.hil %nuke ~]
==
abet:work:(quem:(boar:(goat hap) hen law) kon)
2014-05-27 13:47:19 +04:00
::
++ take :: accept response
2014-05-28 09:44:18 +04:00
|= [pax=path hen=duct hil=(hypo sign)] ::
2014-06-02 03:28:49 +04:00
^- [p=(list move) q=_..^$]
2014-05-27 13:47:19 +04:00
=+ lum=(lump pax)
2014-05-28 09:44:18 +04:00
=< abet =< work
(more:(bear:(gaur p.lum) hen) q.lum hil)
2014-05-27 13:47:19 +04:00
::
++ scry
|= $: use=(unit (set monk))
ren=@tas
who=ship
syd=desk
lot=coin
tyl=path
==
2014-06-01 00:22:49 +04:00
^- (unit (unit (pair lode ,*)))
2014-05-29 02:06:52 +04:00
=+ ^= vew ^- lens :: XX future scry
2014-05-27 13:47:19 +04:00
%. :- use
:- [who syd ((hard case) p.lot)]
(flop tyl)
|= $: use=(unit (set monk)) :: observers
bid=bead :: position
== ::
(beef:(gaur p.bid q.bid) use r.bid s.bid)
2014-06-01 00:22:49 +04:00
%+ bind
?+ ren ~
%u u.vew
%v v.vew
%w w.vew
%x x.vew
%y y.vew
%z z.vew
==
|=(a=(unit) (bind a |=(b=* [%noun b])))
2014-05-27 13:47:19 +04:00
::
2014-05-31 02:51:31 +04:00
++ doze
|= [now=@da hen=duct]
^- (unit ,@da)
~
2014-05-27 13:47:19 +04:00
::
2014-05-31 02:51:31 +04:00
++ load
2014-05-31 23:40:02 +04:00
|= old=axle
2014-05-31 02:51:31 +04:00
^+ ..^$
2014-05-31 23:40:02 +04:00
..^$(all old)
2014-05-31 02:51:31 +04:00
::
2014-05-31 23:40:02 +04:00
++ stay `axle`+>-.$
2014-05-27 13:47:19 +04:00
--
|% :: inner core
++ gaur :: take and go
|= [our=@p app=@tas]
=+ mat=(need (~(get by pol.all) our))
=+ sat=(need (~(get by bum.mat) app))
~(. go [our app] mat sat)
::
++ goat :: call and go
|= [our=@p app=@tas]
=+ ^= mat ^- mast
=+ mat=(~(get by pol.all) our)
?~(mat *mast u.mat)
=+ ^= sat ^- seat
=+ sat=(~(get by bum.mat) app)
?^ sat u.sat
*seat
:: %* . *seat
:: eny (shax (mix now eny))
:: lat now
:: ==
~(. go [our app] mat sat)
::
++ go :: application core
|_ $: $: our=@p :: application owner
app=@tas :: application name
== ::
mat=mast :: per owner
sat=seat :: per application
2014-04-30 21:04:07 +04:00
== ::
2014-05-27 13:47:19 +04:00
++ abet :: resolve
%_ ..$
all
%_ all
pol %+ ~(put by pol.all) our
mat(bum (~(put by bum.mat) app sat))
==
==
2014-05-28 09:44:18 +04:00
++ away :: application path
|= pax=path ^- path
[(scot %p our) app pax]
::
++ bear :: write backward
|= hen=duct
2014-05-27 13:47:19 +04:00
=+ orf=(need (~(get by q.zam.sat) hen))
2014-05-28 09:44:18 +04:00
~(apex bo:~(. au (read q.orf)) hen p.orf (rite q.orf) ~)
::
++ beef :: read in
2014-05-27 13:47:19 +04:00
|= [use=(unit (set monk)) lok=case pax=path]
2014-05-28 12:57:00 +04:00
^- lens
?. =([%da now] lok) *lens
(~(show au use) pax)
::
++ boar :: write forward
|= $: hen=duct :: cause
2014-06-02 01:07:13 +04:00
law=(unit cuff) :: permissions
==
2014-05-27 13:47:19 +04:00
=^ orf zam.sat
=+ orf=(~(get by q.zam.sat) hen)
?^ orf
2014-05-27 13:47:19 +04:00
[[p=p.u.orf q=(limp law q.u.orf)] zam.sat]
:^ [p=p.zam.sat q=law] +(p.zam.sat)
(~(put by q.zam.sat) hen [p.zam.sat law])
(~(put by r.zam.sat) p.zam.sat hen)
2014-05-28 09:44:18 +04:00
~(apex bo:~(. au (read q.orf)) hen p.orf (rite q.orf) ~)
::
++ au :: read
2014-05-27 13:47:19 +04:00
|_ use=(unit (set monk)) :: read permission
++ abet ^abet :: resolve
2014-05-28 12:57:00 +04:00
++ show :: view
2014-05-27 13:47:19 +04:00
|= pax=path
2014-05-28 12:57:00 +04:00
^- lens
2014-05-29 03:43:30 +04:00
?~ huv.sat *lens
=+ gat=(slap u.huv.sat [%cnzy %peek])
=+ cor=(slam gat !>(pax))
=+ ^= dek
|* fun=$+(vase *)
|= nam=@tas
=+ vax=(slap cor [%cnzy nam])
^- (unit (unit fun))
?: =(~ q.vax) ~
?: =([~ ~] q.vax) [~ ~]
[~ ~ (fun (slot 7 vax))]
=+ ^= nib
|= vax=vase
((hard null) q.vax)
=+ ^= yob
|= vax=vase ^- cage
[((hard lode) -.q.vax) (slot 3 vax)]
=+ ^= yar
|= vax=vase ^- arch
((hard arch) q.vax)
=+ ^= dif
|= vax=vase ^- (unit cage)
?: =(~ q.vax) ~
[~ (yob (slot 3 vax))]
|%
++ u ((dek nib) %u)
++ v ((dek yob) %v)
++ w ((dek dif) %w)
++ x ((dek yob) %x)
++ y ((dek yar) %y)
++ z ((dek yob) %z)
--
2014-05-27 13:47:19 +04:00
::
++ bo
2014-05-27 13:47:19 +04:00
|_ $: hen=duct :: system cause
ost=bone :: opaque cause
2014-05-28 09:44:18 +04:00
say=(unit (set monk)) :: write permission
2014-05-27 13:47:19 +04:00
mow=(list move) :: actions
==
2014-05-27 13:47:19 +04:00
++ abet [(flop mow) ^abet] :: resolve
2014-05-28 09:44:18 +04:00
++ apex
^+ .
?. &(=(~ huv.sat) =(~ qic.sat) =(~ vey.sat)) .
%_(. vey.sat (~(put to vey.sat) hen [%boot ~]))
::
++ bing :: reset to duct
|= neh=duct
=+ orf=(need (~(get by q.zam.sat) hen))
%_ +>.$
hen neh
ost p.orf
use (read q.orf)
say (rite q.orf)
==
::
2014-05-29 02:06:52 +04:00
++ cave :: vase as silk
|= vax=vase
[%done ~ %$ vax]
::
2014-05-28 12:57:00 +04:00
++ conf :: configured core
|= vax=vase
2014-05-29 02:06:52 +04:00
^- silk
2014-05-28 12:57:00 +04:00
:+ %mute (core vax)
2014-05-29 02:06:52 +04:00
:~ [[%$ 6]~ (cave !>([[our app] now eny]))]
2014-05-28 12:57:00 +04:00
==
2014-05-28 09:44:18 +04:00
++ core |=(vax=vase (cove %core vax)) :: core as silk
++ cove :: cage as silk
|= cay=cage
^- silk
[%done ~ cay]
::
2014-05-29 02:06:52 +04:00
++ drug :: set dependencies
|= pen=(set (pair ship desk))
^+ +>
=+ ^= new ^- (list move)
%+ turn
%+ skip (~(tap in pen) ~)
|=(a=(pair ship desk) (~(has in ped.sat) a))
|= a=(pair ship desk)
:- hen
:^ %toss %c (away %s %drug (scot %p p.a) q.a ~)
`card`[%warp [our p.a] q.a ~ %| [%da now] [%da (add now ~d1000)]]
=+ ^= old ^- (list move)
%+ turn
%+ skip (~(tap in ped.sat) ~)
|=(a=(pair ship desk) (~(has in pen) a))
|= a=(pair ship desk)
:- hen
:^ %toss %c (away %s %drug (scot %p p.a) q.a ~)
`card`[%warp [our p.a] q.a ~]
%_(+>.$ ped.sat pen, mow :(weld new old mow))
::
++ drum :: raw dependencies
2014-06-01 00:22:49 +04:00
|= dep=(set bead)
2014-05-29 02:06:52 +04:00
^+ +>
?> ?=(^ 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)
::
2014-05-28 09:44:18 +04:00
++ ford :: exec to ford
|= [pan=term kas=silk]
%_ +>.$
mow
:_(mow [hen [%toss %f (away [%s pan ~]) [%exec our `kas]]])
==
::
++ gate :: gate as silk
|= [arm=term kas=silk]
^- silk
[%pass kas [%1 [%cnzy arm]]]
::
++ give :: return card
|= gip=gift
%_(+> mow [[hen %give gip] mow])
::
2014-05-29 02:06:52 +04:00
++ gone %_(. qic.sat ~) :: done work
2014-05-28 12:57:00 +04:00
++ game :: invoke core
|= [[pan=term arm=term] vax=vase sam=vase]
%+ ford pan
[%call (gate arm (conf vax)) (cove %$ sam)]
::
2014-05-28 09:44:18 +04:00
++ home :: load application
^- silk
:+ %boil %core
2014-06-01 00:22:49 +04:00
[[our %main [%da now]] %app ~]
2014-05-27 13:47:19 +04:00
::
2014-05-28 09:44:18 +04:00
++ more :: accept result
2014-05-27 13:47:19 +04:00
|= $: pax=path :: internal position
2014-05-28 09:44:18 +04:00
hil=(hypo sign) :: urbit event
==
2014-05-28 09:44:18 +04:00
^+ +>
?: ?=([%u *] pax)
?. ?=(%ruse -.q.hil)
~& [%more-card -.q.hil pax]
!!
%_ +>.$
vey.sat
%- ~(put to vey.sat)
2014-05-29 02:06:52 +04:00
[hen [%take t.pax (spec (slot 3 hil))]]
2014-05-28 09:44:18 +04:00
==
?> ?=([%s @ ~] pax)
?> !=(~ qic.sat)
?+ i.t.pax !!
%boot
2014-05-29 02:06:52 +04:00
~& %more-boot
2014-05-28 09:44:18 +04:00
?> ?=([~ * %boot ~] qic.sat)
?> ?=(%made -.q.hil)
?- -.p.q.hil
2014-05-29 02:06:52 +04:00
& (drum:(morn:gone q.q.p.p.q.hil) p.p.p.q.hil)
2014-05-28 09:44:18 +04:00
| (mort p.p.q.hil)
==
2014-05-28 12:57:00 +04:00
::
2014-05-29 02:06:52 +04:00
%drug
~& %more-drug
?> ?=(%writ -.q.hil)
?~ p.q.hil +>.$
+>.$(vey.sat (~(put to vey.sat) hen %boot ~))
::
%step
~& %more-step
?> ?=(%made -.q.hil)
?- -.p.q.hil
& %- obey:(morn:gone (slot 3 q.q.p.p.q.hil))
(slot 2 q.q.p.p.q.hil)
| (give %crud p.p.q.hil)
==
2014-05-28 09:44:18 +04:00
==
::
++ morn :: successful boot
2014-05-29 02:06:52 +04:00
|= vax=vase
%_(+> huv.sat `vax)
2014-05-27 13:47:19 +04:00
::
2014-05-28 09:44:18 +04:00
++ mort :: failed boot
|= tan=(list tank)
~& [%boot-lost our app]
2014-05-29 02:06:52 +04:00
(give %crud tan)
2014-05-28 09:44:18 +04:00
::
++ nile [%done ~ [%$ [%atom %n] ~]] :: null silk
2014-05-29 02:06:52 +04:00
++ obey :: process result
|= vax=vase
%_(+> mow (weld (flop (said vax)) mow))
::
++ quem :: queue action
|= kon=knob :: content
%_(+> vey.sat (~(put to vey.sat) hen kon))
::
++ said
|= vud=vase
|- ^- (list move)
?: =(~ q.vud) ~
[(sump (slot 2 vud)) $(vud (slot 3 vud))]
2014-05-27 13:47:19 +04:00
::
++ show :: subscribe
2014-06-02 01:07:13 +04:00
|= hup=(unit hope) :: subscription
2014-05-27 13:47:19 +04:00
^+ +>
2014-06-02 01:07:13 +04:00
%_(+> vey.sat (~(put to vey.sat) hen %show hup))
2014-05-29 02:06:52 +04:00
::
++ sump
|= wec=vase
^- move
:- ((hard duct) -.q.wec)
=+ caq=(spec (slot 3 wec))
?+ q.caq ~&(%sump-bad !!)
::
[%toss p=@tas q=* r=[p=@tas q=*]]
:^ %toss (need ((sand %tas) ((hard ,@) p.q.caq)))
((hard path) q.q.caq)
[%meta (spec (slot 15 caq))]
::
[%give p=[p=@tas q=*]]
[%give [%meta (spec (slot 3 caq))]]
::
[%slip p=@tas q=[p=@tas q=*]]
:+ %slip
(need ((sand %tas) ((hard ,@) p.q.caq)))
[%meta (spec (slot 7 caq))]
==
2014-05-28 09:44:18 +04:00
::
++ work :: eat queue
^+ .
~& %gall-work
?: |(?=(^ qic.sat) =(~ vey.sat)) . :: nothing to do
=^ yev vey.sat [p q]:~(get to vey.sat)
work:(yawn:(bing p.yev) q.yev)
::
++ yawn :: start event
|= kon=knob
^+ +>
=. qic.sat `[hen kon]
?- -.kon
%boot
~& %yawn-boot
2014-05-29 02:06:52 +04:00
=. orm.sat `now
2014-05-28 09:44:18 +04:00
%+ ford %boot
^- silk
:+ %call
(gate %prep home)
2014-05-29 02:06:52 +04:00
?~ huv.sat nile
[nile (gate %save (conf u.huv.sat))]
2014-05-28 20:20:07 +04:00
::
%crud
~& %yawn-crud
?~ huv.sat
~& [%crud-none our app]
gone:(give %crud p.kon)
%^ game [%step %pain] u.huv.sat
2014-05-29 02:06:52 +04:00
!>([ost use p.kon])
2014-05-28 09:44:18 +04:00
::
%mess
~& %yawn-mess
?~ huv.sat
~& [%mess-none our app]
gone:(give %back |)
2014-05-28 20:20:07 +04:00
%^ game [%step %poke] u.huv.sat
2014-05-28 12:57:00 +04:00
:(slop [[%atom %ud] ost] !>((ride use say)) q.p.kon)
2014-05-28 20:20:07 +04:00
::
%nuke
~& %yawn-mess
?~ huv.sat
~& [%nuke-none our app]
gone
(game [%step %punk] u.huv.sat !>([ost ~]))
2014-05-28 12:57:00 +04:00
::
%show
~& %yawn-show
?~ huv.sat
~& [%show-none our app]
2014-06-02 01:07:13 +04:00
gone:(give %bust ~)
2014-05-28 20:20:07 +04:00
%^ game [%step %peer] u.huv.sat
2014-06-02 01:07:13 +04:00
!>([ost use p.kon])
2014-05-28 09:44:18 +04:00
::
2014-05-28 20:20:07 +04:00
%take
~& %yawn-take
?> ?=(^ huv.sat)
%^ game [%step %peck] u.huv.sat
:(slop [[%atom %ud] ost] !>((ride use say)) !>(p.kon) q.kon)
2014-05-28 09:44:18 +04:00
==
--
--
--
2014-04-30 21:04:07 +04:00
--