urbit/mar/plan.hoon

103 lines
3.1 KiB
Plaintext
Raw Normal View History

2016-03-24 23:57:05 +03:00
::
:::: /hoon/plan/mar
::
/? 310
/- plan-acct, plan-diff
2016-11-17 04:42:58 +03:00
::
2016-03-24 23:57:05 +03:00
:::: ~fyr
::
=, eyre
=, html
=, format
|_ all/{{who/@txname loc/@txloc} acc/(map knot plan-acct)}
2016-03-24 23:57:05 +03:00
::
++ grow :: convert to
2016-03-26 02:19:48 +03:00
=+ all
2016-03-24 23:57:05 +03:00
|%
++ txt
2016-03-26 02:19:48 +03:00
^- wain
2016-03-26 02:27:17 +03:00
:+ (cat 3 'User ' ?~(who 'of Urbit' who))
(cat 3 'Location ' ?~(loc %unknown loc))
%+ turn (sort ~(tap by acc) aor)
2016-03-29 01:36:59 +03:00
|= {a/knot b/plan-acct} ^- cord
2016-03-26 02:19:48 +03:00
%+ rap 3
2016-03-29 01:36:59 +03:00
:^ a ': ' usr.b
?~(url.b ~ [', ' (apix:en-purl u.url.b)])
2016-03-29 01:36:59 +03:00
::
++ plan-json
2016-12-03 02:47:16 +03:00
%- pairs:enjs :~
2016-03-29 01:36:59 +03:00
who+?~(who ~ s+who)
loc+?~(loc ~ s+loc)
2016-03-29 01:36:59 +03:00
acc+o+(~(run by acc) json-acct)
==
2019-01-18 08:37:34 +03:00
++ json-acct :: helper
2016-03-29 01:36:59 +03:00
|= a/plan-acct ^- json
=/ url ?~(url.a ~ (tape:enjs (apix:en-purl u.url.a)))
2016-12-03 02:47:16 +03:00
(pairs:enjs usr+s+usr.a url+url ~)
2016-03-24 23:57:05 +03:00
--
++ grab |% :: convert from
++ noun {{cord cord} (map knot plan-acct)} :: clam from %noun
2016-03-24 23:57:05 +03:00
++ txt
2016-03-26 02:19:48 +03:00
|^ |= a/wain ^+ all
?> ?=({@t @t *} a)
2016-03-26 02:27:17 +03:00
:- [(rash i.a user) (rash i.t.a location)]
(malt (turn t.t.a |=(b/cord (rash b account))))
2016-03-26 02:19:48 +03:00
::
2016-03-26 02:27:17 +03:00
++ user ;~(pfix (jest 'User ') (cook crip (star prn)))
++ knot %+ cook crip
(plus ;~(pose nud low hig hep dot sig cab))
++ location ;~(pfix (jest 'Location ') (cook crip (star prn)))
2016-03-26 02:27:17 +03:00
++ account
2016-03-26 02:19:48 +03:00
;~ plug
knot
;~(pfix col ace knot)
(punt ;~(pfix com ace aurf:de-purl))
2016-03-26 02:19:48 +03:00
==
--
++ mime |=({* a/octs} (txt (to-wain q.a))) :: XX mark translation
2016-03-24 23:57:05 +03:00
--
++ grad
2019-01-18 08:37:34 +03:00
|%
2016-03-24 23:57:05 +03:00
++ form %plan-diff
++ diff
|= neu/_all ^- plan-diff :: XXX map functions
:+ ?:(=(-.all -.neu) ~ (some -.neu))
2018-03-19 07:18:20 +03:00
=< (malt `(list {knot ~})`(murn ~(tap by acc.all) .))
|= {a/knot *} ^- (unit {knot ~})
?:((~(has by acc.neu) a) ~ (some [a ~]))
=< (malt (murn ~(tap by acc.neu) .))
|= {a/knot b/plan-acct} ^- (unit {knot plan-acct})
2016-03-26 02:27:17 +03:00
?: =([~ b] (~(get by acc.all) a))
2016-03-24 23:57:05 +03:00
~
(some [a b])
::
++ pact
|= dif/plan-diff ^+ all :: XXX map functions
:- (fall inf.dif -.all)
2016-03-24 23:57:05 +03:00
=; neu (~(uni by neu) put.dif)
=+ del=~(tap by del.dif)
2016-03-26 02:27:17 +03:00
|- ^+ acc.all
?~ del acc.all
$(del t.del, acc.all (~(del by acc.all) p.i.del))
2016-03-25 00:34:19 +03:00
::
++ can-join
|= {ali/plan-diff bob/plan-diff} ^- ?
?& !&(?=({{^ *} {^ *}} +<) !=(u.inf.ali u.inf.bob)) :: compatible info
2016-03-26 02:19:48 +03:00
=(~ (~(int by `(map knot *)`del.ali) put.bob)) :: no del-put
2016-03-25 00:34:19 +03:00
=(~ (~(int by `(map knot *)`put.ali) del.bob)) :: conflicts
.= (~(int by put.ali) put.bob) :: and all put
(~(int by put.bob) put.ali) :: values match
==
::
++ join
|= {ali/plan-diff bob/plan-diff}
^- (unit plan-diff)
?. (can-join ali bob)
~
%^ some
(mate inf.ali inf.bob)
(~(uni by del.ali) del.bob)
(~(uni by put.ali) put.bob)
2016-03-24 23:57:05 +03:00
--
--