MarpaX-Hoonlint

 view release on metacpan or  search on metacpan

hoons/arvo/app/dojo.hoon  view on Meta::CPAN

      |=  a/type  ^-  tank
      =-  >[-]<
      |-  ^-  $?  $%  {$atom @tas (unit @)}
                      {$cell _$ _$}
                      {$cube * _$}
                      {$face {what $@(term tune)} _$}
                      {$fork (set _$)}
                      {$hold _$ hoon}
                  ==
                  wain                :: "<|core|>"
                  $?($noun $void)
              ==
      ?+  a  a
        {?($cube $face) ^}  a(q $(a q.a))
        {$cell ^}  a(p $(a p.a), q $(a q.a))
        {$fork *}  a(p (silt (turn ~(tap in p.a) |=(b/type ^$(a b)))))
        {$help *}  !!
        {$core ^}  `wain`/core
        {$hold *}  a(p $(a p.a))
      ==
    ::
    ++  dy-shown
      $?  hoon
          $^  {dy-shown dy-shown}
          $%  {$ur (unit knot) purl:eyre}
              {$dv path}
              {$sa mark}
              {$as mark dy-shown}
              {$do hoon dy-shown}
              {$ge path (list dy-shown) (map term (unit dy-shown))}
          ==
      ==
    ::
    ++  dy-show-source
      |=  a/dojo-source  ^-  tank
      =-  >[-]<
      =+  `{@ bil/dojo-build}`a
      |-  ^-  dy-shown
      ?-  -.bil
        $?($ur $dv $sa)  bil
        $ex  ?.  ?=({$cltr *} p.bil)  p.bil
                 |-  ^-  hoon
                 ?~  p.p.bil  !!
                 ?~  t.p.p.bil  i.p.p.bil
                 [i.p.p.bil $(p.p.bil t.p.p.bil)]
        $tu  ?~  p.bil  !!
             |-
             ?~  t.p.bil  ^$(bil q.i.p.bil)
             [^$(bil q.i.p.bil) $(p.bil t.p.bil)]
        $as  bil(q $(bil q.q.bil))
        $do  bil(q $(bil q.q.bil))
        $ge  :+  %ge  q.p.p.bil
             [(turn p.q.p.bil ..$) (~(run by q.q.p.bil) (lift ..$))]
      ==
    ::
    ++  dy-edit                                         ::  handle edit
      |=  cal/sole-change
      ^+  +>+>
      =^  dat  say  (~(transceive sole say) cal)
      ?:  |(?=(^ per) ?=(^ pux) ?=($~ pro))
        ~&  %dy-edit-busy
        =^  lic  say  (~(transmit sole say) dat)
        (dy-diff %mor [%det lic] [%bel ~] ~)
      (dy-slam(per `dat) /edit u.pro !>((tufa buf.say)))
    ::
    ++  dy-type                                         ::  sole action
      |=  act/sole-action
      ?-  -.act
        $det  (dy-edit +.act)
        $ret  (dy-done (tufa buf.say))
        $clr  dy-stop
      ==
    ::
    ++  dy-cage       |=(num/@ud (~(got by rez) num))   ::  known cage
    ++  dy-vase       |=(num/@ud q:(dy-cage num))       ::  known vase
    ++  dy-silk-vase  |=(vax/vase [%$ %noun vax])       ::  vase to silk
    ++  dy-silk-sources                                 ::  arglist to silk
      |=  src/(list dojo-source)  ^-  silk:ford
      %-  dy-silk-vase
      |-
      ?~  src  !>(~)
      (slop (dy-vase p.i.src) $(src t.src))
    ::
    ++  dy-silk-config                                  ::  configure
      |=  {cay/cage cig/dojo-config}
      ^-  {wire silk:ford}
      ?.  (~(nest ut [%cell [%atom %$ ~] %noun]) | p.q.cay)
        ::  
        ::  naked gate
        ::
        ?.  &(?=({* $~} p.cig) ?=($~ q.cig))     
          ~|(%one-argument !!)
        :-  /noun
        :+  %call  (dy-silk-vase q.cay)
        (dy-silk-vase (dy-vase p.i.p.cig)) 
      ::
      ::  normal generator
      ::
      :-  ?+  -.q.q.cay  ~|(%bad-gen ~_((sell (slot 2 q.cay)) !!))
            $say  /gent
            $ask  /dial
            $get  /scar
          ==
      =+  gat=(slot 3 q.cay)
      :+  %call  (dy-silk-vase gat)
      :+  (dy-silk-vase !>([now=now.hid eny=eny.hid bec=he-beak]))
        (dy-silk-sources p.cig)
      :+  %mute  (dy-silk-vase (fall (slew 27 gat) !>(~)))
      %+  turn  ~(tap by q.cig)
      |=  {a/term b/(unit dojo-source)}
      ^-  (pair wing silk:ford)
      :-  [a ~]
      %-  dy-silk-vase
      ?~(b !>([~ ~]) (dy-vase p.u.b))
    ::
    ++  dy-hoon-head                                    ::  dynamic state
      ::  todo: how do i separate the toplevel 'dojo state' comment?
      :>  dojo state
      :>
      :>  our: the name of this urbit
      :>  now: the current time



( run in 2.361 seconds using v1.01-cache-2.11-cpan-5e09290becf )