urbit/main/app/dojo/core.hook

432 lines
17 KiB
Plaintext
Raw Normal View History

2015-02-22 01:42:36 +03:00
:: :: ::
:::: /hook/core/dojo/app :: ::
:: :: ::
/? 314 :: zuse version
/- *console :: console structures
/+ console :: console library
:: :: ::
:::: :: ::
!: :: ::
=> |% :: external structures
++ house :: all state
$: hoc=(map bone session) :: conversations
== ::
++ session :: per conversation
$: say=console-share :: command-line state
poy=(unit dojo-project) :: working
var=(map term cage) :: variable state
old=(set term) :: used TLVs
== ::
++ dojo-command ::
$% [%poke p=hapt q=dojo-source] :: make and poke
[%save p=? q=term r=dojo-source] :: save/print
== ::
++ dojo-source ::
$: inx=@ud :: index, assigned
mod=dojo-model ::
== ::
++ dojo-model :: data source
2015-03-06 00:22:39 +03:00
$% [%& twig] :: direct expression
[%| (trel term term dojo-config)] :: command engine
2015-02-22 01:42:36 +03:00
== ::
++ dojo-config :: configuration
$: ord=(list dojo-source) :: by order
key=(map term dojo-source) :: by keyword
== ::
++ dojo-project :: construction state
$: mad=dojo-command :: operation
num=@ud :: number of tasks
cur=@ud :: currently solving
2015-03-06 00:22:39 +03:00
pro=(unit vase) :: prompting loop
idl=? :: not calling ford
per=(unit console-edit) :: pending reverse
2015-02-22 01:42:36 +03:00
job=(map ,@ud dojo-source) :: problems
rez=(map ,@ud cage) :: results
== ::
++ bead ,[p=(set beam) q=cage] :: computed result
++ gift :: out result <-$
$% [%mean p=ares] :: error
[%nice ~] :: acknowledge
[%rush %console-effect console-effect] ::
== ::
++ hapt ,[p=ship q=path] ::
++ move ,[p=bone q=(mold note gift)] ::
++ hood :: assembly plan
$: zus=@ud :: zuse kelvin
sur=(list hoot) :: structures
lib=(list hoof) :: libraries
fan=(list horn) :: resources
src=(list hoop) :: program
== ::
++ hoof (pair term (unit (pair case ship))) :: resource reference
++ hoot (pair bean hoof) :: structure gate/core
++ hoop :: source in hood
$% [%& p=twig] :: direct twig
[%| p=beam] :: resource location
== ::
++ horn :: resource tree
$% [%ape p=twig] :: /~ twig by hand
[%arg p=twig] :: /$ argument
[%day p=horn] :: /| list by @dr
[%dub p=term q=horn] :: /= apply face
[%fan p=(list horn)] :: /. list
[%for p=path q=horn] :: /, descend
2015-03-06 01:58:04 +03:00
[%hel p=@ud q=horn] :: /% propagate heel
2015-02-22 01:42:36 +03:00
[%hub p=horn] :: /@ list by @ud
[%man p=(map span horn)] :: /* hetero map
[%nap p=horn] :: /_ homo map
[%now p=horn] :: /& list by @da
[%saw p=twig q=horn] :: /; operate on
[%see p=beam q=horn] :: /: relative to
[%sic p=tile q=horn] :: /^ cast
[%toy p=mark] :: /mark/ static
== ::
2015-03-06 01:58:04 +03:00
++ silk :: construction layer
2015-02-22 01:42:36 +03:00
$& [p=silk q=silk] :: cons
$% [%bake p=mark q=beam r=path] :: local synthesis
[%boil p=mark q=beam r=path] :: general synthesis
[%call p=silk q=silk] :: slam
[%cast p=mark q=silk] :: translate
[%done p=(set beam) q=cage] :: literal
[%dude p=tank q=silk] :: error wrap
[%dune p=(set beam) q=(unit cage)] :: unit literal
[%mute p=silk q=(list (pair wing silk))] :: mutant
[%plan p=beam q=spur r=hood] :: structured assembly
[%reef ~] :: kernel reef
[%ride p=twig q=silk] :: silk thru twig
[%vale p=mark q=ship r=*] :: validate [our his]
== ::
++ note-ford :: note to ford
$% [%exec p=@p q=(unit silk)] :: make / kill
== ::
++ note-gall :: note to %gall
$% [%mess p=[p=ship q=path] q=ship r=cage] ::
== ::
++ sign-gall :: sign from %gall
$% [%mean p=ares] ::
[%nice ~] ::
== ::
++ sign-ford :: sign from ford
$% [%made p=(each bead (list tank))] :: computed result
== ::
++ note :: out request $->
$% [%f note-ford] ::
[%g note-gall] ::
== ::
++ sign :: in result $<-
$% [%f sign-ford] ::
[%g sign-gall] ::
== ::
-- ::
:: ::
:::: ::
:: ::
|_ $: hid=hide :: system state
house :: program state
== ::
++ he :: per session
|_ [[ost=bone moz=(list move)] session] ::
++ dy :: project work
|_ dojo-project ::
++ dy-abet +>(poy `+<) :: resolve
++ dy-amok +>(poy ~) :: terminate
2015-03-06 00:22:39 +03:00
++ dy-ford :: send to ford
|= [pax=path kas=silk]
^+ +>+>
(he-pass(poy `+>+<(idl %|)) pax %f %exec our.hid `kas)
::
++ dy-slam :: call to ford
|= [pax=path gat=vase sam=vase]
^+ +>+>
(dy-ford pax %call [%done ~ %noun gat] [%done ~ %noun sam])
::
++ dy-rush :: send effects, abet
|= fec=console-effect
^+ +>+>
(he-rush(poy `+>+<) fec)
::
++ dy-rash :: send effects, amok
|= fec=console-effect
^+ +>+>
(he-rush(poy ~) fec)
::
2015-02-22 01:42:36 +03:00
++ dy-init-ordered :: prepare source list
|= ord=(list dojo-source)
^+ [ord +>]
?~ ord [~ +>.$]
=^ fir +>.$ (dy-init-source i.ord)
=^ mor +>.$ $(ord t.ord)
[[fir mor] +>.$]
::
++ dy-init-named :: prepare source map
|= key=(map term dojo-source)
^+ [key +>.$]
?~ key [~ +>.$]
=^ top +>.$ (dy-init-source q.n.key)
=^ lef +>.$ $(key l.key)
=^ rit +>.$ $(key r.key)
[[[p.n.key top] lef rit] +>.$]
::
++ dy-init-model :: prepare dojo-model
|= mod=dojo-model
^+ [mod +>]
?- -.mod
%& [mod +>]
2015-03-06 00:22:39 +03:00
%| =^ cig +> (dy-init-config r.mod)
[mod(r cig) +>.$]
2015-02-22 01:42:36 +03:00
==
::
++ dy-init-source :: prepare source
|= src=dojo-source
^+ [src +>]
=^ mod +> (dy-init-model mod.src)
=: inx.src num
mod.src mod
==
[src +>.$(num +(num), job (~(put by job) num src))]
::
++ dy-init-config :: prepare config
|= cig=dojo-config
^+ [cig +>]
=^ ord +>.$ (dy-init-ordered ord.cig)
=^ key +>.$ (dy-init-named key.cig)
[[ord key] +>.$]
::
++ dy-init
=+ dam=mad
?- -.dam
%poke =^ src + (dy-init-source q.dam)
+>(mad dam(q src))
%save =^ src + (dy-init-source r.dam)
+>(mad dam(r src))
==
::
2015-03-06 00:22:39 +03:00
++ dy-work :: console action
|= act=console-action
?- -.act
%det (he-stir +.act)
%ret (he-done (tufa buf.say))
==
::
++ dy-hand :: complete step
2015-02-22 01:42:36 +03:00
|= cag=cage
^+ +>+>
dy-step(cur +(cur), rez (~(put by rez) cur cag))
::
2015-03-06 00:22:39 +03:00
++ dy-made-edit :: console edit
|= cag=cage
^+ +>+>
?> ?=(^ per)
?^ q.q.cag
~& %dy-made-edit-good
dy-abet(per ~)
~& %dy-made-edit-bad
=^ lic say (~(transmit cs say) u.per)
(dy-rush(per ~) %mor [%bel ~] [%det lic] ~)
::
++ dy-made-make :: created prompt
|= cag=cage
^+ +>+>
~& %dy-made-make
(dy-slam /dial q.cag [[%atom %n] ~])
::
++ dy-made-dial :: dialog result
|= cag=cage
?. ?=([~ ~ a=* b=*] q.q.cag)
~& %dy-made-init-fail
(dy-rash %bel ~)
=. +>+>
?: =(a.q.q.cag ~)
+>+>
(he-rush %tan ((list tank) a.q.q.cag))
?+ -.b.q.q.cag (dy-rash %bel ~)
%&
?~ +.b.q.q.cag
(dy-rash %bel ~)
(dy-hand %noun (slot 63 q.cag))
::
%|
(dy-rush(pro `(slot 63 q.cag)) %pro (console-prompt +<.b.q.q.cag))
==
::
++ dy-done
|= txt=tape
~& %dy-done
?> ?=(^ pro)
(dy-slam /dial u.pro (slop [[%atom %n] ~] !>(txt)))
::
++ dy-over :: finish construction
2015-02-22 01:42:36 +03:00
^+ +>
?- -.mad
%poke
(he-pass(poy ~) /poke %g %mess p.mad our.hid (~(got by rez) inx.q.mad))
::
%save
=+ cag=(~(got by rez) inx.r.mad)
=. var (~(put by var) q.mad cag)
?. p.mad +>+
(he-rush(poy ~) [%tan (sell q.cag) ~])
==
::
2015-03-06 00:22:39 +03:00
++ dy-edit :: handle edit
|= cal=console-change
^+ +>+>
=+ old=buf.say
=^ dat say (~(receive cs say) cal)
=. dat (~(inverse cs say(buf old)) dat)
?: |(?=(^ per) !idl ?=(~ pro))
~& %dy-edit-busy
=^ lic say (~(transmit cs say) dat)
(dy-rush %mor [%det lic] [%bel ~] ~)
(dy-slam(per `dat) /edit u.pro !>(buf.say))
::
++ dy-work :: handle input
|= act=console-action
^+ +>+>
?- -.act
%det (dy-edit +.act)
%ret (dy-done (tufa buf.say))
==
::
2015-02-22 01:42:36 +03:00
++ dy-step :: advance project
^+ +>
?: =(cur num)
dy-over
=+ src=(~(got by job) cur)
?- -.mod.src
%&
2015-03-06 00:22:39 +03:00
%- he-pass(poy `+>-)
[/hand %f %exec our.hid `[%ride +.mod.src [%reef ~]]]
2015-02-22 01:42:36 +03:00
::
2015-03-06 00:22:39 +03:00
%|
%- he-pass(poy `+>-)
:* /make
%f
%exec
our.hid
~
%boil
%noun
[[our.hid %main %da lat.hid] [p.mod.src %mad q.mod.src ~]]
~
==
2015-02-22 01:42:36 +03:00
==
--
::
++ he-abet :: resolve
2015-03-06 00:22:39 +03:00
[(flop moz) %_(+> hoc (~(put by hoc) ost +<+))]
::
2015-02-22 01:42:36 +03:00
++ he-give :: emit gift
|= git=gift
^+ +>
%_(+> moz [[ost %give git] moz])
::
++ he-pass
|= [pax=path noy=note]
2015-03-06 01:58:04 +03:00
~& [%he-pass pax noy]
2015-02-22 01:42:36 +03:00
%_(+> moz [[ost %pass pax noy] moz])
::
++ he-rush :: emit update
|= fec=console-effect
^+ +>
(he-give %rush %console-effect fec)
::
++ he-peer :: subscribe to
he-prom
::
++ he-prom :: send prompt
%- he-rush
:- %pro
[& %$ (tuba (weld (scow %p our.hid) ":dojo> "))]
::
++ he-ford :: sign from ford
|= [pax=path rey=(each bead (list tank))]
^+ +>
?> ?=(^ poy)
?- -.rey
2015-03-06 00:22:39 +03:00
%& =+ dye=~(. dy u.poy)
=. idl.dye &
?+ pax ~&(%he-ford-path !!)
[%hand ~] (dy-hand:dye q.p.rey)
[%dial ~] (dy-made-dial:dye q.p.rey)
[%make ~] (dy-made-make:dye q.p.rey)
[%edit ~] (dy-made-edit:dye q.p.rey)
2015-02-22 01:42:36 +03:00
==
%| (he-rush(poy ~) %tan p.rey)
==
::
++ he-like :: filter line
|= buf=(list ,@c)
^- ?
=+ txt=(tufa buf)
=(+((lent txt)) q.p:(wide:(vang & ~) [1 1] txt))
::
++ he-stir :: apply change
|= cal=console-change
^+ +>
2015-03-06 00:22:39 +03:00
=^ dut say (~(remit cs say) cal he-like)
2015-02-22 01:42:36 +03:00
?~ dut
+>.$
(he-rush %mor [%det u.dut] [%bel ~] ~)
::
++ he-plan :: execute command
|= mad=dojo-command
^+ +>
?> ?=(~ poy)
=< dy-step
2015-03-06 00:22:39 +03:00
~(dy-init dy mad [0 0 ~ %& ~ ~ ~])
2015-02-22 01:42:36 +03:00
::
++ he-done :: parse command
|= txt=tape
^+ +>
=+ foy=(rust txt wide:(vang & ~))
?~ foy
(he-rush %bel ~)
=+ old=(weld "> " (tufa buf.say))
2015-02-25 02:42:28 +03:00
=^ cal say (~(transmit cs say) [%set ~])
2015-02-22 01:42:36 +03:00
%- =< he-plan
%- he-rush
:~ %mor
[%txt old]
[%nex ~]
[%det cal]
==
2015-03-06 00:22:39 +03:00
`dojo-command`[%save & %foo 0 %& u.foy]
2015-02-22 01:42:36 +03:00
::
++ he-work :: apply input
|= act=console-action
^+ +>
2015-03-06 00:22:39 +03:00
?^ poy
(~(dy-work dy u.poy) act)
2015-02-22 01:42:36 +03:00
?- -.act
%det (he-stir +.act)
%ret (he-done (tufa buf.say))
==
--
::
++ peer
|= [ost=bone her=ship pax=path]
^- [(list move) _+>]
?< (~(has by hoc) ost)
?> =(/console pax)
?> =(her our.hid)
he-abet:~(he-peer he [ost ~] *session)
::
++ poke-console-action
|= [ost=bone her=ship act=console-action]
2015-03-06 00:22:39 +03:00
~& %poke-console-action
2015-02-22 01:42:36 +03:00
^- [(list move) _+>]
he-abet:(~(he-work he [ost [ost %give %nice ~]~] (~(got by hoc) ost)) act)
::
++ pour
|= [ost=bone pax=path sih=*]
^- [(list move) _+>]
=+ sih=((hard sign) sih)
?- -.sih
%f
he-abet:(~(he-ford he [[ost ~] (~(got by hoc) ost)]) pax +>.sih)
::
%g !!
==
--