urbit/main/lib/pony.hoon

116 lines
2.9 KiB
Plaintext
Raw Normal View History

2013-09-29 00:21:18 +04:00
!:
:: /=main=/lib/pony/hoon
::
|%
++ polo :: prompt
|= [gim=(list gift) pim=prom pro=tape def=tape use=tape]
|* [rul=_rule woo=||([@da *] bowl)]
^- bowl
:- gim :- ~
:- :~ [[%polo ~] [%up pim pro def]]
==
|= [now=@da pax=path nut=note]
^- bowl
?> &(=([%polo ~] pax) ?=(%up -.nut))
=+ rey=(rush p.nut rul)
?~ rey
:- [[%la %leaf ?~(use "invalid response" use)] ~]
:- ~
[[[[%polo ~] [%up pim pro def]] ~] ..$]
(woo now u.rey)
::
++ pomo |=([gud=gift bol=bowl] [[gud p.bol] q.bol])
++ pomp |=([tix=tape bol=bowl] (pomo la/leaf/tix bol))
++ pond :: show text block
|= [lub=@ bol=bowl]
^- bowl
:_(q.bol (weld (turn (lore lub) |=(a=@t la/leaf/(trip a))) p.bol))
::
++ posh :: pause until
|= end=@da
|= [gim=(list gift) wop=||(@da bowl)]
^- bowl
:- gim :- ~
:- ^- (list slip)
:~ [~ %wa end]
==
|= [now=@da pax=path nut=note]
(wop now)
::
++ post :: request/response
|= [him=@p cav=@tas msg=*]
2013-09-29 00:21:18 +04:00
|= woo=||([@da (unit ,*)] bowl)
^- bowl
=+ leg="waiting for {(scow %p him)}"
:- :~ [%sq him cav /request msg]
==
:- ~
2013-09-29 00:21:18 +04:00
:- ^- (list slip)
:~ [/request [%rt ~]]
2013-09-29 00:21:18 +04:00
[/prompt [%up %none leg ~]]
==
|= [now=@da pax=path nut=note]
^- bowl
?+ -.nut ~& [%bad-nut nut] !!
%rt (woo now p.nut)
2013-09-29 00:21:18 +04:00
==
::
++ pour
|= $: est=@da
dyz=(list ,[p=@tas q=[p=ship q=disc r=moat]])
wop=||([@da (map ,@tas ,[p=@ud q=(list frog)])] bowl)
2013-09-29 00:21:18 +04:00
==
^- bowl
?~ dyz (wop est ~)
=+ :* zyd=(~(gas by *(map ,@tas ,[p=ship q=disc r=moat])) dyz)
fyx=*(map ,@tas ,[p=@ud q=(list frog)])
2013-09-29 00:21:18 +04:00
==
=< apex
|%
++ apex
^- bowl
?~ zyd done
:- ~ :- ~
:- bite
|= [now=@da how=path wat=note]
?> ?=([%eg *] wat)
?> ?=([%pull @ ~] how)
apex:(bice(est now) i.t.how p.wat)
::
++ bice
|= [cyt=@tas rot=riot]
^+ +>
?~ rot
~& [%bice-done cyt]
+>(zyd (~(del by zyd) cyt))
?> ?=(%ud -.q.p.u.rot)
=+ geb=(need (~(get by zyd) cyt))
=+ saq=(~(get by fyx) cyt)
2013-09-29 00:21:18 +04:00
%= +>.$
zyd
%+ ~(put by zyd) cyt
?> =(p.p.r.geb p.q.p.u.rot)
geb(p.r [%ud +(p.q.p.u.rot)])
2013-09-29 00:21:18 +04:00
::
fyx
%+ ~(put by fyx) cyt
:- ?~(saq p.q.p.u.rot p.u.saq)
[((hard frog) r.u.rot) ?~(saq ~ q.u.saq)]
2013-09-29 00:21:18 +04:00
==
::
++ bite
^- (list slip)
=+ who=?>(?=(^ zyd) p.n.zyd)
:- `slip`[/prod [%up %none "waiting for <who> at <est>..." ~]]
=+ fuh=(~(tap by zyd) ~)
%+ turn fuh
|= [a=@tas b=[p=ship q=disc r=moat]]
=+ bys=`slip`[[%pull a ~] %es p.b q.b [%| r.b]]
bys
2013-09-29 00:21:18 +04:00
::
++ done
^- bowl
(wop est fyx)
--
--