shrub/arvo/clay.hoon

507 lines
16 KiB
Plaintext
Raw Normal View History

2014-04-24 06:34:32 +04:00
!:
2013-09-29 00:21:18 +04:00
:: clay (4c), revision control
::
2013-12-15 09:42:27 +04:00
|= pit=vase
2013-09-29 00:21:18 +04:00
^- vane
=>
::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 4cA, filesystem logic ::
::
|%
::
++ un :: per ship
2013-12-15 09:42:27 +04:00
|= [who=@p now=@da ruf=raft]
2013-09-29 00:21:18 +04:00
=+ ^= yar ^- room
=+ yar=(~(get by fat.ruf) who)
?~(yar *room u.yar)
=| yel=(list ,[p=duct q=card])
=| byn=(list ,[p=duct q=riot])
2013-09-29 00:21:18 +04:00
=| vag=(list ,[p=duct q=card])
=| say=(list ,[p=duct q=ship r=[p=@ud q=riff]])
|%
++ abet
^- [(list move) raft]
:_ ruf(fat (~(put by fat.ruf) who yar))
;: weld
%+ turn (flop yel)
2013-12-15 09:42:27 +04:00
|=([a=duct b=card] [[~ %gold who] hun.yar b])
2013-09-29 00:21:18 +04:00
::
%+ turn (flop byn)
2013-12-15 09:42:27 +04:00
|=([a=duct b=riot] [[~ %gold who] a [%writ b]])
2013-09-29 00:21:18 +04:00
::
%+ turn (flop vag)
2013-12-15 09:42:27 +04:00
|=([a=duct b=card] [[~ %gold who] a b])
2013-09-29 00:21:18 +04:00
::
%+ turn (flop say)
2013-12-15 09:42:27 +04:00
|= [a=duct b=ship c=[p=@ud q=riff]]
:+ [~ %gold who]
[/a a]
2014-05-16 22:49:15 +04:00
[%want [who b] [%q %re p.q.c (scot %ud p.c) ~] q.c]
2013-09-29 00:21:18 +04:00
==
::
++ doze
2013-12-15 09:42:27 +04:00
=+ saz=(turn (~(tap by dos.yar) ~) |=([a=@tas b=*] a))
2013-09-29 00:21:18 +04:00
=| nex=(unit ,@da)
|- ^+ nex
?~ saz nex
$(saz t.saz, nex (hunt nex doze:(di i.saz)))
::
++ wake
^+ .
2013-12-15 09:42:27 +04:00
=+ saz=(turn (~(tap by dos.yar) ~) |=([a=@tas b=*] a))
2013-09-29 00:21:18 +04:00
|- ^+ ..wake
?~ saz ..wake
$(saz t.saz, ..wake abet:wake:(di i.saz))
2013-09-29 00:21:18 +04:00
::
2013-10-08 04:40:45 +04:00
++ zest
2013-12-15 09:42:27 +04:00
|= his=@p
2013-10-08 09:56:57 +04:00
:~ :- %load
2013-10-08 04:40:45 +04:00
=+ sim=(scot %p his)
=+ sod=(~(tap by dos.yar) ~)
|- ^- (list ,[p=@tas q=path q=rave])
?~ sod ~
=+ xiq=(~(tap by `cult`p.q.i.sod) ~)
|- ^- (list ,[p=@tas q=path r=rave])
?~ xiq ^$(sod t.sod)
=+ nex=$(xiq t.xiq)
?. ?& ?=([[%c @ *] *] p.i.xiq)
2013-10-08 04:40:45 +04:00
=(sim i.t.i.p.i.xiq)
== nex
2013-10-08 04:40:45 +04:00
[[p.i.sod t.t.i.p.i.xiq q.i.xiq] nex]
2013-10-08 09:56:57 +04:00
::
:- %know
=+ rob=(~(get by rid.yar) his)
?~ rob ~
=+ vob=(~(tap by u.rob) ~)
2013-10-08 05:58:06 +04:00
|-
?~ vob ~
:- p.i.vob
:~ [%lim lim.q.i.vob]
[%qyx qyx.q.i.vob]
?~ ref.q.i.vob
~
:~ [%nix nix.u.ref.q.i.vob]
[%bom bom.u.ref.q.i.vob]
[%fod fod.u.ref.q.i.vob]
==
==
==
2013-10-08 04:40:45 +04:00
::
++ zeta
2013-12-15 09:42:27 +04:00
|= [his=@p syd=@tas lok=case tyl=path]
2013-10-08 04:40:45 +04:00
^- (unit)
?. ?=([%da @] lok) ~
?. ?=(~ tyl) ~
2014-01-04 11:28:16 +04:00
?+ syd ~
%show [~ `tank`>(zest his)<]
%tell [~ (zest his)]
2013-10-08 04:40:45 +04:00
==
::
2013-09-29 00:21:18 +04:00
++ de :: per desk
|_ [for=@p syd=@ta rede]
++ abet
?: =(for who)
%_(..de dos.yar (~(put by dos.yar) syd qyx dom))
%_ ..de
rid.yar
=+ ^= rob ^- (map ,@tas rede)
=+ rob=(~(get by rid.yar) for)
?~(rob ~ u.rob)
(~(put by rid.yar) for (~(put by rob) syd `rede`+<+>.abet))
2013-09-29 00:21:18 +04:00
==
::
++ aver :: read
2013-12-15 09:42:27 +04:00
|= mun=mood
2013-09-29 00:21:18 +04:00
^- (unit (unit ,*))
=+ ezy=?~(ref ~ (~(get by haw.u.ref) mun))
?^ ezy ezy
=+ nao=(~(aeon ze lim dom) q.mun)
:: ~& [%aver-mun nao [%from syd lim q.mun]]
?~(nao ~ [~ (~(avid ze lim dom) u.nao mun)])
2013-09-29 00:21:18 +04:00
::
++ balk :: read and send
2013-12-15 09:42:27 +04:00
|= [hen=duct oan=@ud mun=mood]
2013-09-29 00:21:18 +04:00
^+ +>
=+ vid=(~(avid ze lim dom) oan mun)
2013-09-29 00:21:18 +04:00
?~ vid (blob hen) (blab hen mun u.vid)
::
++ blab :: ship result
2013-12-15 09:42:27 +04:00
|= [hen=duct mun=mood dat=*]
2013-09-29 00:21:18 +04:00
^+ +>
+>(byn [[hen ~ [p.mun q.mun syd] r.mun dat] byn])
::
++ bleb :: ship sequence
2013-12-15 09:42:27 +04:00
|= [hen=duct ins=@ud hip=(list frog)]
2013-09-29 00:21:18 +04:00
^+ +>
?~ hip +>
%= $
hip t.hip
ins +(ins)
+> (blab hen [%w [%ud ins] ~] i.hip)
==
2013-09-29 00:21:18 +04:00
::
++ blob :: ship stop
2013-12-15 09:42:27 +04:00
|= hen=duct
2013-09-29 00:21:18 +04:00
%_(+> byn [[hen ~] byn])
::
++ doze :: sleep until
=+ xiq=(~(tap by qyx) ~)
=| nex=(unit ,@da)
|- ^+ nex
?~ xiq nex
=+ ^= zis ^+ nex
?- -.q.i.xiq
& ?.(?=(%da -.q.p.q.i.xiq) ~ [~ p.q.p.q.i.xiq])
::
|
=+ mot=`moat`p.q.i.xiq
%+ hunt
2013-10-19 10:30:43 +04:00
?. ?=(%da -.p.mot) ~
?.((lth now p.p.mot) ~ [~ p.p.mot])
?. ?=(%da -.q.mot) ~
?.((lth now p.q.mot) [~ now] [~ p.q.mot])
2013-09-29 00:21:18 +04:00
==
$(xiq t.xiq, nex (hunt nex zis))
::
++ duce :: produce request
2013-12-15 09:42:27 +04:00
|= [hen=duct rav=rave]
^+ +>
2013-12-30 02:24:29 +04:00
=. qyx (~(put by qyx) hen rav)
?~ ref +>
2013-12-24 00:49:15 +04:00
|- ^+ +>+.$
=+ ^= vaw ^- rave
?. ?=([%& %v *] rav) rav
[%| [%ud let.dom] `case`q.p.rav]
=+ inx=nix.u.ref
2013-12-24 00:49:15 +04:00
%= +>+.$
say [[[[%c (scot %ud inx) ~] hen] 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)
==
::
++ ease :: release request
2013-12-15 09:42:27 +04:00
|= hen=duct
2013-09-29 00:21:18 +04:00
^+ +>
=. qyx (~(del by qyx) hen)
?~ ref +>
2013-12-24 00:49:15 +04:00
|- ^+ +>+.$
=+ nux=(~(get by fod.u.ref) hen)
2013-12-24 00:49:15 +04:00
?~ nux +>+.$
%= +>+.$
say [[[[%c (scot %ud u.nux) ~] hen] for [u.nux syd ~]] say]
fod.u.ref (~(del by fod.u.ref) hen)
bom.u.ref (~(del by bom.u.ref) u.nux)
==
2013-09-29 00:21:18 +04:00
::
++ eave :: subscribe
2013-12-15 09:42:27 +04:00
|= [hen=duct rav=rave]
^+ +>
2013-09-29 00:21:18 +04:00
?- -.rav
&
=+ ver=(aver p.rav)
?~ ver
(duce hen rav)
2013-09-29 00:21:18 +04:00
?~ u.ver
(blob hen)
(blab hen p.rav u.u.ver)
::
|
=+ nab=(~(aeon ze lim dom) p.p.rav)
2013-09-29 00:21:18 +04:00
?~ nab
?> =(~ (~(aeon ze lim dom) q.p.rav))
(duce hen rav)
=+ huy=(~(aeon ze lim dom) q.p.rav)
2013-09-29 00:21:18 +04:00
?: &(?=(^ huy) |((lth u.huy u.nab) &(=(0 u.huy) =(0 u.nab))))
(blob hen)
=+ top=?~(huy let.dom u.huy)
=+ seb=(slag (sub let.dom top) hit.dom)
=+ wid=(sub top u.nab)
=+ fud=(flop (scag wid seb))
=. +>.$ (bleb hen u.nab fud)
?^ huy
2013-09-29 00:21:18 +04:00
(blob hen)
=+ ^= ptr ^- case
2013-12-17 08:48:40 +04:00
?: =(0 u.nab) [%da _@da]
2013-09-29 00:21:18 +04:00
=+(old=(slag wid seb) ?>(?=(^ old) `case`[%da p.i.old]))
(duce hen `rave`[%| ptr q.p.rav])
2013-09-29 00:21:18 +04:00
==
::
++ echo :: announce changes
2013-12-15 09:42:27 +04:00
|= [hen=duct wen=@da lem=nori]
2013-09-29 00:21:18 +04:00
^+ +>
%= +>
vag ?~(hez.yar vag :_(vag [u.hez.yar [%ergo who syd let.dom]]))
yel
=+ pre=`path`~[(scot %p for) syd (scot %ud let.dom)]
?- -.lem
| :_ yel
[hen %note '=' %leaf :(weld (trip p.lem) " " (spud pre))]
& |- ^+ yel
?~ q.q.lem yel
:_ $(q.q.lem t.q.q.lem)
:- hen
:+ %note
?-(-.q.i.q.q.lem %del '-', %ins '+', %mut ':')
[%leaf (spud (weld pre p.i.q.q.lem))]
2013-09-29 00:21:18 +04:00
==
==
::
++ edit :: apply changes
2013-12-15 09:42:27 +04:00
|= [wen=@da lem=nori]
^+ +>
+>(dom +<+:(~(axel ze lim dom) wen lem))
::
2013-09-29 00:21:18 +04:00
++ exec :: change and update
2013-12-15 09:42:27 +04:00
|= [hen=duct wen=@da lem=nori]
2013-09-29 00:21:18 +04:00
^+ +>
(echo:wake:(edit wen lem) hen wen lem)
::
++ knit :: external change
2013-12-15 09:42:27 +04:00
|= [inx=@ud rot=riot]
^+ +>
2013-12-24 00:49:15 +04:00
?> ?=(^ ref)
|- ^+ +>+.$
=+ ruv=(~(get by bom.u.ref) inx)
2013-12-24 00:49:15 +04:00
?~ 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
2013-12-24 00:49:15 +04:00
%= +>+.$
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)
2013-12-24 00:49:15 +04:00
?. ?=(%w p.p.u.rot) +>+.$
|- ^+ +>+.^$
=+ nez=[%w [%ud let.dom] ~]
=+ nex=(~(get by haw.u.ref) nez)
2013-12-24 00:49:15 +04:00
?~ nex +>+.^$
?~ u.nex +>+.^$ :: should never happen
%= $
haw.u.ref (~(del by haw.u.ref) nez)
2013-12-24 00:49:15 +04:00
+>+.^$ =+ roo=(edit ((hard frog) u.u.nex))
?>(?=(^ ref.roo) roo)
==
2013-09-29 00:21:18 +04:00
::
++ wake :: update subscribers
^+ .
=+ xiq=(~(tap by qyx) ~)
=| xaq=(list ,[p=duct q=rave])
|- ^+ ..wake
?~ xiq
..wake(qyx (~(gas by *cult) xaq))
2013-09-29 00:21:18 +04:00
?- -.q.i.xiq
&
=+ cas=?~(ref ~ (~(get by haw.u.ref) `mood`p.q.i.xiq))
?^ cas
%= $
xiq t.xiq
..wake ?~ u.cas (blob p.i.xiq)
(blab p.i.xiq p.q.i.xiq u.u.cas)
==
=+ nao=(~(aeon ze lim dom) q.p.q.i.xiq)
2013-09-29 00:21:18 +04:00
?~ nao $(xiq t.xiq, xaq [i.xiq xaq])
$(xiq t.xiq, ..wake (balk p.i.xiq u.nao p.q.i.xiq))
::
|
=+ mot=`moat`p.q.i.xiq
=+ nab=(~(aeon ze lim dom) p.mot)
2013-10-08 20:47:25 +04:00
?~ nab
2013-09-29 00:21:18 +04:00
$(xiq t.xiq, xaq [i.xiq xaq])
=+ huy=(~(aeon ze lim dom) q.mot)
2013-09-29 00:21:18 +04:00
?~ huy
2013-10-08 20:47:25 +04:00
?: =(let.dom u.nab)
$(xiq t.xiq, xaq [i.xiq xaq])
?> ?=(^ hit.dom)
2013-09-29 00:21:18 +04:00
=+ ptr=[%da p.i.hit.dom]
=+ fud=(flop (scag (sub let.dom u.nab) `(list frog)`hit.dom))
%= $
xiq t.xiq
xaq [[p.i.xiq [%| ptr q.mot]] xaq]
..wake (bleb p.i.xiq let.dom fud)
==
=+ yad=(slag (sub let.dom u.huy) `(list frog)`hit.dom)
=+ fud=(flop (scag (sub u.huy u.nab) yad))
%= $
xiq t.xiq
2013-10-10 21:58:41 +04:00
..wake (blob:(bleb p.i.xiq +(u.nab) fud) p.i.xiq)
2013-09-29 00:21:18 +04:00
==
==
--
::
++ di
2013-12-15 09:42:27 +04:00
|= syd=@ta
2014-05-02 03:33:15 +04:00
=+ ^= saq ^- dojo
2013-09-29 00:21:18 +04:00
=+ saq=(~(get by dos.yar) syd)
2014-05-02 03:33:15 +04:00
?~(saq *dojo u.saq)
~(. de who syd now p.saq ~ q.saq)
2013-09-29 00:21:18 +04:00
::
++ do
2013-12-15 09:42:27 +04:00
|= [him=ship syd=@tas]
=+ ^= red ^- rede
=+ roy=(~(get by rid.yar) him)
=+ yit=?~(roy ~ (~(get by u.roy) syd))
?^(yit u.yit `rede`[~2000.1.1 ~ [~ *rind] *dome])
:: ~& [%do-qyx him syd qyx.red]
~(. de him syd red)
2013-09-29 00:21:18 +04:00
--
--
::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 4cA, filesystem vane ::
:: ::
=| :: instrument state
$: ruf=raft :: revision tree
== ::
2014-05-02 03:33:15 +04:00
|= [now=@da eny=@ ska=$+(* (unit (unit)))] :: activate
2013-09-29 00:21:18 +04:00
^? :: opaque core
|% ::
++ beat :: update
2014-04-29 02:24:32 +04:00
|= [wru=(unit writ) tea=wire hen=duct fav=card]
2013-09-29 00:21:18 +04:00
^- [p=(list move) q=vane]
?+ -.fav [[[wru hen fav] ~] ..^$]
%crud
[[[wru [/d hen] %flog fav] ~] ..^$]
::
%deem
~& [%beat-deem wru hen]
=. wru
2013-09-29 00:21:18 +04:00
?^ wru wru
?. =(%gold (adit hen)) ~
[~ %gold p.fav]
2013-09-29 00:21:18 +04:00
$(fav q.fav)
::
%init
:: [[%tell %0 %leaf "clay: home for {~(rend co ~ %p q.u.wru)}"] ~]
2013-12-24 00:49:15 +04:00
?> ?=(^ wru)
[~ ..^$(fat.ruf (~(put by fat.ruf) q.u.wru [hen ~ ~ ~]))]
2013-09-29 00:21:18 +04:00
::
?(%info %into)
=. wru
2013-09-29 00:21:18 +04:00
?^ wru wru
?. =(%gold (adit hen)) ~
[~ %gold p.fav]
2013-12-24 00:49:15 +04:00
?> &(?=(^ wru) =(q.u.wru p.fav))
2013-09-29 00:21:18 +04:00
?: =(%$ q.fav)
?. ?=(%into -.fav) [~ ..^$]
=+ yar=(need (~(get by fat.ruf) p.fav))
[~ ..^$(fat.ruf (~(put by fat.ruf) p.fav yar(hez [~ hen])))]
=^ mos ruf
2013-09-29 00:21:18 +04:00
=+ ^= zot
abet:(exec:(di:wake:(un q.u.wru now ruf) q.fav) hen now r.fav)
2013-09-29 00:21:18 +04:00
abet:zot(hez.yar ?.(=(%into -.fav) hez.yar.zot [~ hen]))
[mos ..^$]
::
%waft
?> ?=([@ @ ~] tea)
2013-12-24 00:49:15 +04:00
?> ?=(^ wru)
=+ syd=(need (slaw %tas i.tea))
=+ inx=(need (slaw %ud i.t.tea))
2013-09-29 00:21:18 +04:00
=^ mos ruf
=< abet
=< abet
=< wake
%. [inx ((hard riot) q.fav)]
2014-05-17 00:57:49 +04:00
knit:(do:(un p.p.fav now ruf) q.p.fav syd)
2013-09-29 00:21:18 +04:00
[mos ..^$]
::
%warp
?> ?=(^ wru)
=^ mos ruf
=< abet
=+ une=(un q.u.wru now ruf)
:: ~& [%clay-warp q.u.wru fav]
=+ wex=?.(=(q.u.wru p.fav) (do:une p.fav p.q.fav) (di:une p.q.fav))
2013-09-29 00:21:18 +04:00
?~ q.q.fav
abet:(ease:wex hen)
abet:(eave:wex hen u.q.q.fav)
2013-09-29 00:21:18 +04:00
[mos ..^$]
::
%wart
?> ?=(^ wru)
?> ?=(%re q.fav)
=+ ryf=((hard riff) s.fav)
:_ ..^$
:~ :+ [~ %iron q.u.wru]
[/c [%c (scot %p p.fav) r.fav] hen]
`card`[%warp q.u.wru ryf]
==
2013-09-29 00:21:18 +04:00
::
%writ
2013-09-29 00:21:18 +04:00
?> ?=([@ *] tea)
2014-05-16 22:49:15 +04:00
?> ?=(^ wru)
=+ him=(need (slaw %p i.tea))
:_ ..^$
:~ :+ wru
[/a [%c ~] hen]
2014-05-16 22:49:15 +04:00
`card`[%want [q.u.wru him] [%r %re %c t.tea] p.fav]
==
::
%went :: XX should actually propagate
?: =(%good q.fav) [~ ..^$]
2013-10-27 07:55:53 +04:00
~& [%clay-lost p.fav tea]
[~ ..^$]
2013-09-29 00:21:18 +04:00
::
%wake
2013-12-15 09:42:27 +04:00
=+ dal=(turn (~(tap by fat.ruf) ~) |=([a=@p b=room] a))
2013-09-29 00:21:18 +04:00
=| mos=(list move)
|- ^- [p=(list move) q=vane]
?~ dal [mos ..^^$(las.ruf now)]
2013-09-29 00:21:18 +04:00
=^ som ruf abet:wake:(un i.dal now ruf)
$(dal t.dal, mos (weld som mos))
==
::
++ come
2014-01-06 05:52:37 +04:00
|= [sam=? old=vase]
2013-09-29 00:21:18 +04:00
^- vane
2014-01-07 00:37:42 +04:00
(load old)
2013-09-29 00:21:18 +04:00
::
++ doze
2013-12-15 09:42:27 +04:00
|= [now=@da hen=duct]
2013-09-29 00:21:18 +04:00
=| nex=(unit ,@da)
2013-12-15 09:42:27 +04:00
=+ dal=(turn (~(tap by fat.ruf) ~) |=([a=@p b=room] a))
2013-09-29 00:21:18 +04:00
|- ^+ nex
?~ dal nex
$(dal t.dal, nex (hunt nex doze:(un i.dal now ruf)))
::
++ load
2014-04-21 21:02:09 +04:00
|= old=vase
2013-09-29 00:21:18 +04:00
^- vane
2014-04-21 21:02:09 +04:00
?. (~(nest ut -:!>(ruf)) & p.old)
2014-04-17 20:37:22 +04:00
~& %clay-reset
..^$
2014-04-21 21:02:09 +04:00
..^$(ruf (raft q.old))
2013-09-29 00:21:18 +04:00
::
++ raze
^- vane
..$(ruf *raft)
::
++ scry :: inspect
2014-05-09 04:34:57 +04:00
|= [our=ship ren=@tas his=ship syd=desk lot=coin tyl=path]
2014-04-30 21:33:50 +04:00
^- (unit (unit))
2013-09-29 00:21:18 +04:00
=+ luk=?.(?=(%$ -.lot) ~ ((soft case) p.lot))
2014-05-02 03:33:15 +04:00
?~ luk [~ ~]
2013-10-08 04:40:45 +04:00
=+ une=(un our now ruf)
?: =(%$ ren)
2014-05-02 03:33:15 +04:00
[~ (zeta:une his syd u.luk tyl)]
2013-10-08 04:40:45 +04:00
=+ run=((soft care) ren)
2014-05-02 03:33:15 +04:00
?~ run [~ ~]
%. [u.run u.luk tyl]
=+ dud=?.(=(our his) (do:une his syd) (di:une syd))
:: ~& [%scry-at [our his] now lim.dud]
aver:dud
2013-09-29 00:21:18 +04:00
::
++ stay `vase`!>(ruf)
2014-01-07 00:37:42 +04:00
++ vern [164 0]
2013-09-29 00:21:18 +04:00
--