Merge pull request #1310 from urbit/gut-by

+gut:by: value by key, or default
This commit is contained in:
Fang 2019-07-10 19:57:35 +02:00 committed by GitHub
commit 84c9bfded3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 73 additions and 70 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4a471b053252770f870c4a06b19387e4afa7d5e16e282011ec7afbbfb67abc05
size 8555195
oid sha256:980cc9a756e49e6ba600ebfef91d09735eae1239da265cbc78fb6f783eab0f4c
size 8481672

View File

@ -67,7 +67,7 @@
::
++ pe
|= who=ship
=+ (fall (~(get by piers) who) *pier)
=+ (~(gut by piers) who *pier)
=* pier-data -
|%
++ abet-pe

View File

@ -80,7 +80,7 @@
::
++ pe
|= who=ship
=+ (fall (~(get by piers) who) *pier)
=+ (~(gut by piers) who *pier)
=* pier-data -
|%
++ abet-pe

View File

@ -72,7 +72,7 @@
::
++ pe
|= who=ship
=+ (fall (~(get by piers) who) *pier)
=+ (~(gut by piers) who *pier)
=* pier-data -
|%
::

View File

@ -49,7 +49,7 @@
++ poke-noun
|= [what=?(%save %load) =name]
^- (quip move _+>)
=+ eye=(fall (~(get by eyes) name) *eye)
=+ eye=(~(gut by eyes) name *eye)
?- what
%save
=/ pax=path

View File

@ -827,7 +827,7 @@
|- ^+ ..ta-take
?~ sos ..ta-take
=. ..ta-take
=+ (fall (~(get by stories) p.i.sos) *story)
=+ (~(gut by stories) p.i.sos *story)
=> (~(so-bear so p.i.sos ~ -) q.i.sos)
=. acs (flop acs)
|- ^+ ..ta-take
@ -838,7 +838,7 @@
::TODO runtime error
::%+ roll ~(tap by sos.piz)
::|= {{n/name b/burden} _..ta-take}
::=+ (fall (~(get by stories) n) *story)
::=+ (~(gut by stories) n *story)
::so-done:(~(so-bear so n ~ -) b)
::
$circle
@ -870,7 +870,7 @@
$new
=? +> !(~(has by stories) nom.rum)
(ta-delta %story +.rum)
=> =+ (fall (~(get by stories) nom.rum) *story)
=> =+ (~(gut by stories) nom.rum *story)
%- ~(so-bear so nom.rum ~ -)
[~ [cof.rum.rum ~] [~ ~]]
=. acs (flop acs)
@ -880,7 +880,7 @@
$(acs t.acs)
::TODO runtime error
::=< so-done
::%- ~(so-bear so nom.rum ~ (fall (~(get by stories) nom.rum) *story))
::%- ~(so-bear so nom.rum ~ (~(gut by stories) nom.rum *story))
::[~ [cof.rum.rum ~] [~ ~]]
==
::
@ -1160,7 +1160,7 @@
=/ old/(unit status)
?: =(cir.rum so-cir) (~(get by locals) who.rum)
=- (~(get by -) who.rum)
(fall (~(get by remotes) cir.rum) *group)
(~(gut by remotes) cir.rum *group)
:: ignore if it won't result in change.
?. ?| &(?=($remove -.dif.rum) ?=(^ old))
?=(~ old)
@ -1225,7 +1225,7 @@
=? deltas !=(`gou (~(get by remotes) wer))
%+ welp deltas
=+ gop=~(tap by gou)
=+ hav=(fall (~(get by remotes) wer) *group)
=+ hav=(~(gut by remotes) wer *group)
=| l/(list delta)
|- ^+ l
?~ gop l
@ -1617,7 +1617,7 @@
%+ roll nes
|= {nev/envelope max/@ud}
?:((gth num.nev max) num.nev max)
?. (gth num (fall (~(get by sequence) src) 0))
?. (gth num (~(gut by sequence) src 0))
+>.$
(so-delta-our %sequent src num)
::
@ -1631,7 +1631,7 @@
|= {src/circle nev/envelope}
^+ +>
=. +> (so-learn src gam.nev)
?. (gth num.nev (fall (~(get by sequence) src) 0))
?. (gth num.nev (~(gut by sequence) src 0))
+>
(so-delta-our %sequent src num.nev)
::
@ -1719,7 +1719,7 @@
$mailbox !(~(has in sis.con.shape) her) :: author blacklist
$custom :: custom rule
=/ rul/$-({ship ?($r $w) bowl:gall} ?)
(fall (~(get by custom-rules) nom) |=(* |))
(~(gut by custom-rules) nom |=(* |))
(rul her %w bol)
==
::
@ -1736,7 +1736,7 @@
$mailbox (team:title our.bol her) :: our team
$custom :: custom rule
=/ rul/$-({ship ?($r $w) bowl:gall} ?)
(fall (~(get by custom-rules) nom) |=(* |))
(~(gut by custom-rules) nom |=(* |))
(rul her %r bol)
==
--
@ -1877,7 +1877,7 @@
%+ roll ses
|= {s/serial o/_outbox}
=? o ?=(~ o) outbox
=+ t=(fall (~(get by o) s) *tracking)
=+ t=(~(gut by o) s *tracking)
%+ ~(put by o) s
(~(put by t) cir %pending)
%+ da-emit ost.bol
@ -1960,7 +1960,7 @@
?+ -.det
=< sa-done
%. det
=+ (fall (~(get by stories) nom) *story)
=+ (~(gut by stories) nom *story)
~(sa-change sa nom -)
::
$new (da-create nom +.det)
@ -2134,7 +2134,7 @@
(~(del by locals) who.det)
%+ ~(put by locals) who.det
%+ change-status:hall-lib
(fall (~(get by locals) who.det) *status)
(~(gut by locals) who.det *status)
dif.det
==
==
@ -2149,7 +2149,7 @@
|= {src/circle num/@ud}
^+ +>
=- +>.$(sourced -)
=+ sed=(fall (~(get by sourced) src) ~)
=+ sed=(~(gut by sourced) src ~)
?^ (find ~[num] sed) sourced
(~(put by sourced) src [num sed])
::
@ -2197,7 +2197,7 @@
+>(mirrors (~(del by mirrors) cir.det))
=/ new/config
%+ change-config:hall-lib
(fall (~(get by mirrors) cir.det) *config)
(~(gut by mirrors) cir.det *config)
dif.det
+>.$(mirrors (~(put by mirrors) cir.det new))
::
@ -2205,9 +2205,9 @@
%_ +>.$
remotes
%+ ~(put by remotes) cir.det
=+ ole=(fall (~(get by remotes) cir.det) *group)
=+ ole=(~(gut by remotes) cir.det *group)
?: ?=($remove -.dif.det) (~(del by ole) who.det)
=+ old=(fall (~(get by ole) who.det) *status)
=+ old=(~(gut by ole) who.det *status)
(~(put by ole) who.det (change-status:hall-lib old dif.det))
==
==
@ -3297,7 +3297,7 @@
?~ aud.t ~&(%strange-aud [our.bol %inbox])
n.aud.t
%+ ~(put by s) src
[c (fall (~(get by s) src) ~)]
[c (~(gut by s) src ~)]
soy(count c, known k, sourced s)
?: =(a 'refederate')
~& 'refederating. may take a while...'

View File

@ -433,7 +433,7 @@
(ta-open nev.rum)
::
$config
=+ cur=(fall (~(get by mirrors) cir.rum) *config)
=+ cur=(~(gut by mirrors) cir.rum *config)
=. +>.$
=< sh-done
%- ~(sh-show-config sh cli)
@ -477,8 +477,8 @@
==
::
$status
=+ rem=(fall (~(get by remotes) cir.rum) *group)
=+ cur=(fall (~(get by rem) who.rum) *status)
=+ rem=(~(gut by remotes) cir.rum *group)
=+ cur=(~(gut by rem) who.rum *status)
=. +>.$
=< sh-done
%- ~(sh-show-status sh cli)
@ -1212,7 +1212,7 @@
%- zing
=/ sos
=- ~(tap in src:-)
(fall (~(get by mirrors) incir) *config)
(~(gut by mirrors) incir *config)
%+ turn ~(tap in pas)
|= c/circle
%+ skim sos
@ -1373,7 +1373,7 @@
=< (sh-fact %mor (murn (sort ~(tap by remotes) aor) .))
|= {cir/circle gop/group} ^- (unit sole-effect:sole-sur)
?. |(=(~ cis) (~(has in cis) cir)) ~
?: =(%mailbox sec.con:(fall (~(get by mirrors) cir) *config)) ~
?: =(%mailbox sec.con:(~(gut by mirrors) cir *config)) ~
?. (~(has in sources) cir) ~
=- `[%tan rose+[", " `~]^- leaf+~(cr-full cr cir) ~]
=< (murn (sort ~(tap by gop) aor) .)
@ -1461,7 +1461,7 @@
%+ turn
:: make sure to exclude {nom} itself.
=- ~(tap in (~(del in src:-) [cir ~]))
(fall (~(get by mirrors) cir) *config)
(~(gut by mirrors) cir *config)
|= s/^source
^- sole-effect:sole-sur
:- %txt
@ -2059,7 +2059,7 @@
?^ han han
=+ gop=(~(get by remotes) cir)
?~ gop ~
han.man:(fall (~(get by u.gop) hos.one) *status)
han.man:(~(gut by u.gop) hos.one *status)
?~ nic (cr-curt |)
=+ raw=(scag 14 (trip u.nic))
=+ len=(sub 14 (lent raw))

View File

@ -45,7 +45,7 @@
|= {a/mane b/tape} ^- {cord json}
:_ (tape:enjs b)
?^ a (mane-to-cord a)
(fall (~(get by react-attrs) a) a)
(~(gut by react-attrs) a a)
==
::
++ mane-to-cord :: namespaced xml names

View File

@ -132,7 +132,7 @@
::::
::
|= {hid/bowl:gall part} :: main drum work
=+ (fall (~(get by bin) ost.hid) *source)
=+ (~(gut by bin) ost.hid *source)
=* dev -
=> |% :: arvo structures
++ pear :: request

View File

@ -34,7 +34,7 @@
:::: :: ::
:: :: ::
|: $:{bowl:gall part} :: main helm work
=+ sez=(fall (~(get by hoc) ost) $:session)
=+ sez=(~(gut by hoc) ost $:session)
=> |% :: arvo structures
++ card ::
$% [%bonk wire ~] ::

View File

@ -366,7 +366,7 @@
::
++ auto
|= kiln-sync
=+ (fall (~(get by syn) syd her sud) [let=*@ud ust=ost])
=+ (~(gut by syn) [syd her sud] [let=*@ud ust=ost])
|%
++ abet
..auto(syn (~(put by syn) [syd her sud] let ust))
@ -470,7 +470,7 @@
++ work :: state machine
|= syd/desk
=+ ^- per-desk
%+ fall (~(get by rem) syd)
%+ ~(gut by rem) syd
=+ *per-desk
%_(- cas [%da now])
|%

View File

@ -1490,10 +1490,14 @@
$(a l.a)
$(a r.a)
::
++ got
++ got :: need value by key
|* b/*
(need (get b))
::
++ gut :: fall value by key
|* [b=* c=*]
(fall (get b) c)
::
++ has :: key existence check
~/ %has
|* b/*

View File

@ -1497,7 +1497,7 @@
:: pass .task to the |message-pump and apply state mutations
::
=/ =message-pump-state
(fall (~(get by snd.peer-state) bone) *message-pump-state)
(~(gut by snd.peer-state) bone *message-pump-state)
::
=^ client-duct ossuary.peer-state
(get-duct ossuary.peer-state bone duct)
@ -1591,7 +1591,7 @@
:: pass .task to the |message-still and apply state mutations
::
=/ =message-still-state
(fall (~(get by rcv.peer-state) bone) *message-still-state)
(~(gut by rcv.peer-state) bone *message-still-state)
::
=/ message-still (make-message-still message-still-state channel)
=^ still-gifts message-still-state (work:message-still task)

View File

@ -309,7 +309,7 @@
|= her=ship
^+ lax
=/ fod=dore
(fall (~(get by hoc.ton) her) (gur her))
(~(gut by hoc.ton) her (gur her))
~(. lax [her fod])
::
++ nux :: install dore
@ -1018,7 +1018,7 @@
++ deer :: deer:la:ho:um:am
|= [cha=path num=@ud dut=(unit)] :: interpret message
^+ +>
=+ rum=(fall (~(get by raz.bah) cha) *race)
=+ rum=(~(gut by raz.bah) cha *race)
:: ~& [%rx kay cha num [dod.rum did.rum] ?=(~ dut)]
=* bad (~(has in bad.fox) her)
=. kay ?.((~(has in bad.fox) her) kay ~&(%blocked %dead))
@ -1030,8 +1030,7 @@
:: or negative ack if this ship is blocked
::
=* cop ^- coop
%+ fall
(~(get by bum.rum) num)
%+ ~(gut by bum.rum) num
?:(bad ~ ``[%blocked ~])
con:(cook (~(get by bum.rum) num) cha `[ryn dam])
::
@ -1177,7 +1176,7 @@
++ wool :: wool:ho:um:am
|= [hen=duct cha=path val=*] :: send a statement
^+ +>
=/ rol=rill (fall (~(get by ryl.bah) cha) *rill)
=/ rol=rill (~(gut by ryl.bah) cha *rill)
=/ sex=@ud sed.rol
:: ~& [%tx [our her] cha sex]
:: if we don't have a public key for :her,

View File

@ -2629,13 +2629,13 @@
:: no duct, foreign +rede or default
::
:- ~
=/ rus rus:(fall (~(get by hoy.ruf) her) *rung)
%+ fall (~(get by rus) syd)
=/ rus rus:(~(gut by hoy.ruf) her *rung)
%+ ~(gut by rus) syd
[lim=~2000.1.1 ref=`*rind qyx=~ dom=*dome per=~ pew=~]
:: administrative duct, domestic +rede
::
:- `hun.rom.ruf
=/ jod (fall (~(get by dos.rom.ruf) syd) *dojo)
=/ jod (~(gut by dos.rom.ruf) syd *dojo)
[lim=now ref=~ [qyx dom per pew]:jod]
::
=* red=rede ->
@ -2647,7 +2647,7 @@
?. =(our her)
:: save foreign +rede
::
=/ run (fall (~(get by hoy.ruf) her) *rung)
=/ run (~(gut by hoy.ruf) her *rung)
=? rit.run =(0 rit.run)
(fall (rift-scry her) *rift)
=/ rug (~(put by rus.run) syd red)
@ -4075,7 +4075,7 @@
:: would make clay violate referential transparency.
::
=/ =desk des.req
=/ =dojo (fall (~(get by dos.rom.ruf) desk) *dojo)
=/ =dojo (~(gut by dos.rom.ruf) desk *dojo)
?: =(0 let.dom.dojo)
(handle-task hen req)
=/ sutil (state:util dom.dojo dom.dojo ran.ruf)
@ -4149,7 +4149,7 @@
?: =(%$ des.req)
~|(%info-no-desk !!)
=. act.ruf
=/ =dojo (fall (~(get by dos.rom.ruf) des.req) *dojo)
=/ =dojo (~(gut by dos.rom.ruf) des.req *dojo)
=/ writer=form:commit-clad
%- %- commit
:* our
@ -4205,7 +4205,7 @@
?: =(%$ des.req)
~&(%merg-no-desk !!)
=. act.ruf
=/ =dojo (fall (~(get by dos.rom.ruf) des.req) *dojo)
=/ =dojo (~(gut by dos.rom.ruf) des.req *dojo)
=/ writer=form:merge-clad
%- %- merge
:* our
@ -4229,7 +4229,7 @@
%mont
=. hez.ruf ?^(hez.ruf hez.ruf `[[%$ %sync ~] ~])
=. act.ruf
=/ =dojo (fall (~(get by dos.rom.ruf) q.bem.req) *dojo)
=/ =dojo (~(gut by dos.rom.ruf) q.bem.req *dojo)
=/ writer=form:mount-clad
%- %- mount
:* our

View File

@ -770,7 +770,7 @@
^+ builds
%+ ~(put by builds) schematic.build
::
=/ dates (fall (~(get by builds) schematic.build) ~)
=/ dates (~(gut by builds) schematic.build ~)
|-
^+ dates
?~ dates
@ -809,7 +809,7 @@
|= =build
^- (unit ^build)
::
=/ dates=(list @da) (fall (~(get by builds) schematic.build) ~)
=/ dates=(list @da) (~(gut by builds) schematic.build ~)
::
|- ^- (unit ^build)
?~ dates ~
@ -823,7 +823,7 @@
|= =build
^- (unit ^build)
::
=/ dates=(list @da) (flop (fall (~(get by builds) schematic.build) ~))
=/ dates=(list @da) (flop (~(gut by builds) schematic.build ~))
::
|- ^- (unit ^build)
?~ dates ~

View File

@ -264,7 +264,7 @@
++ mo-bale :: assign outbone
|= him/ship
^- {@ud _+>}
=+ sad=(fall (~(get by sap.mas) him) `scad`[1 ~ ~])
=+ sad=(~(gut by sap.mas) him `scad`[1 ~ ~])
=+ nom=(~(get by q.sad) hen)
?^ nom [u.nom +>.$]
:- p.sad
@ -504,7 +504,7 @@
?: |(!(~(has by bum.mas) dap) (~(has by wub.mas) dap))
~& >> [%mo-not-running dap -.cub]
:: ~& [%mo-club-qeu dap cub]
=+ syf=(fall (~(get by wub.mas) dap) *sofa)
=+ syf=(~(gut by wub.mas) dap *sofa)
+>.$(wub.mas (~(put by wub.mas) dap syf(kys (~(put to kys.syf) [hen pry cub]))))
(mo-clip dap pry cub)
::
@ -604,7 +604,7 @@
?. ?=($diff -.p.q.cov)
[%give %unto p.q.cov]
=+ cay=`cage`p.p.q.cov
=+ mar=(fall (~(get by pyl) p.cov) p.cay)
=+ mar=(~(gut by pyl) p.cov p.cay)
?: =(mar p.cay) [%give %unto p.q.cov]
:+ %pass
[%sys %pel dap ~]
@ -741,7 +741,7 @@
::
++ ap-fill :: add to queue
^- {? _.}
=+ suy=(fall (~(get by qel.ged) ost) 0)
=+ suy=(~(gut by qel.ged) ost 0)
=/ subscriber=(unit (pair ship path))
(~(get by sup.ged) ost)
?: ?& =(20 suy)

View File

@ -1409,11 +1409,11 @@
++ get-public
|= who=ship
^- public
%+ fall (~(get by kyz) who)
%+ ~(gut by kyz) who
::NOTE we can only do this because ++pubs:feel
:: sends out entire new state, rather than
:: just the processed changes.
%+ fall (~(get by kyz.puk) who)
%+ ~(gut by kyz.puk) who
*public
::
++ file-keys
@ -1477,7 +1477,7 @@
~| sunk-unknown+who
=< continuity-number
%+ fall
net:(fall (~(get by pos.eth) who) *point)
net:(~(gut by pos.eth) who *point)
*[life pass continuity-number=@ud [? @p] (unit @p)]
%+ weld
:: %- flop
@ -1493,7 +1493,7 @@
:: pon: updated point
:: new: new keypair or "kept continuity?" (yes is no-op)
^- [pon=point new=(each (pair life pass) ?)]
=+ pot=(fall (~(get by pos.eth) who) *point)
=+ pot=(~(gut by pos.eth) who *point)
::
:: sanity checks, should never fail if we operate correctly
::
@ -1612,13 +1612,13 @@
:: :: ++able:ex:ur
++ able :: initialize
%_ .
shy (fall (~(get by pry) rex) *(map ship safe))
shy (~(gut by pry) rex *(map ship safe))
==
:: :: ++deal:ex:ur
++ deal :: alter rights
|= {pal/ship del/bump}
^+ +>
=/ gob (fall (~(get by shy) pal) *safe)
=/ gob (~(gut by shy) pal *safe)
=* hep (~(update up gob) del)
%_ +>.$
shy (~(put by shy) pal hep)
@ -1628,7 +1628,7 @@
++ hail :: ++hail:ex:ur
|= {pal/ship rem/remote} :: report rights
^+ +>
=/ gob (fall (~(get by shy) pal) *safe)
=/ gob (~(gut by shy) pal *safe)
:: yer: pair of change and updated safe.
=/ yer ^- (pair bump safe)
?- -.rem
@ -2224,7 +2224,7 @@
~(tap by yen.puk.sub)
|- ^+ +>.^$
?~ subs +>.^$
=/ pub (fall (~(get by kyz.snap) p.i.subs) *public)
=/ pub (~(gut by kyz.snap) p.i.subs *public)
=. +>.^$ (exec q.i.subs [%give %pubs pub])
$(subs t.subs)
:: update vent subscribers

View File

@ -153,7 +153,7 @@
=+ buh=(~(get by pol) p.p.kec)
?~ buh
~& [%ames-from p.p.kec]
=+ nut=(fall (~(get by ech) p.p.kec) *mute)
=+ nut=(~(gut by ech) p.p.kec *mute)
%_ +>.$
fex [[%veil p.p.kec] fex]
ech (~(put by ech) p.p.kec nut(inn [+.job inn.nut]))
@ -164,7 +164,7 @@
=+ buh=(~(get by pol) p.job)
?~ buh
~& [%ames-unto p.job]
=+ nut=(fall (~(get by ech) p.job) *mute)
=+ nut=(~(gut by ech) p.job *mute)
%_ +>.$
fex [[%veil p.job] fex]
ech (~(put by ech) p.job nut(out [+>.job out.nut]))
@ -623,7 +623,7 @@
:: ~& [%hy-carp-early liq laq]
+>
:: neb: current incomplete message
=+ neb=`bait`(fall (~(get by nys) liq) [syn 0 [cnt ~]])
=+ neb=`bait`(~(gut by nys) liq [syn 0 [cnt ~]])
:: all fragments must agree on the message parameters
?> &(=(p.neb syn) (gth p.r.neb p.far) =(p.r.neb cnt))
=+ doy=(~(get by q.r.neb) p.far)