shrub/ren/tree/json.hoon

89 lines
2.3 KiB
Plaintext
Raw Normal View History

2015-08-04 02:49:34 +03:00
::
2016-02-05 06:05:37 +03:00
:::: /hoon/json/tree/ren
2015-08-04 06:54:39 +03:00
::
2016-02-18 02:25:53 +03:00
/? 310
2016-07-30 01:19:44 +03:00
/- tree-include
2015-08-04 04:37:19 +03:00
/+ tree
2015-08-04 02:49:34 +03:00
/= gas /$ fuel
/= dat /^ tree-include /tree-include/
2016-02-12 00:53:14 +03:00
/= kid /^ (map knot tree-include)
/_ /tree-include/
2016-11-01 03:12:56 +03:00
=, js:eyre
2015-08-04 04:37:19 +03:00
!:
2015-08-04 02:49:34 +03:00
::::
::
2015-08-04 04:37:19 +03:00
|%
2016-02-11 23:53:34 +03:00
++ schema (dict {term $@(mark schema)})
2016-02-12 00:53:14 +03:00
++ dict |*(a/_* $^({a (dict a)} a))
2016-02-12 01:35:58 +03:00
++ plist (list {term $@(mark plist)})
2015-08-04 04:37:19 +03:00
++ query
2016-02-11 23:53:34 +03:00
$% {$kids p/(list query)}
{$name $t}
{$path $t}
{$spur $t}
::
2016-07-30 01:19:44 +03:00
{$bump $t}
2016-03-30 01:29:22 +03:00
{$beak $t}
2016-02-11 23:53:34 +03:00
{$comt $j}
2016-03-29 01:36:59 +03:00
{$plan $j}
2016-02-11 23:53:34 +03:00
{$head $r}
{$sect $j}
{$snip $r}
{$body $r}
{$meta $j}
{$mime $m}
2015-08-04 04:37:19 +03:00
==
2016-02-12 01:35:58 +03:00
++ schema-to-plist :: pad improper list
|= a/schema ^- plist
?@(-.a [(to-item a) ~] [(to-item -.a) $(a +.a)])
::
++ to-item
|= b/{term $@(mark schema)} ^- {term $@(mark plist)}
?@(+.b b [-.b (schema-to-plist +.b)])
2015-08-04 02:49:34 +03:00
::
2015-08-04 04:37:19 +03:00
++ from-type :: XX holding out for noun odors
2016-02-11 23:53:34 +03:00
|= a/$%({$t p/cord} {$r p/json} {$j p/json} {$m mime})
2015-08-04 04:37:19 +03:00
?- -.a
2016-02-11 23:53:34 +03:00
$t [%s p.a]
$m (jobe mite+[%s (moon p.a)] octs+(jape (sifo q.q.a)) ~)
2016-02-11 23:53:34 +03:00
$r p.a
$j p.a
2015-08-04 04:37:19 +03:00
==
++ from-queries
2016-02-11 23:53:34 +03:00
|= {bem/beam quy/(list query)}
2015-08-04 04:37:19 +03:00
=< (jobe (turn quy .))
2016-02-11 23:53:34 +03:00
|= a/query
2015-08-04 04:37:19 +03:00
:- -.a
?- -.a
2016-02-11 23:53:34 +03:00
$name (from-type +.a ?^(s.bem i.s.bem q.bem))
2016-03-30 01:29:22 +03:00
$beak (from-type +.a (crip (spud (tope bem(s /)))))
2016-02-11 23:53:34 +03:00
$path (from-type +.a (crip (spud (flop s.bem))))
$spur (from-type +.a (crip (spud s.bem)))
2016-07-30 01:19:44 +03:00
$bump (from-type +.a bump.dat)
2016-03-29 01:36:59 +03:00
$plan (from-type +.a plan.dat)
2016-02-11 23:53:34 +03:00
$comt (from-type +.a comt.dat)
$head (from-type +.a head.dat)
$snip (from-type +.a snip.dat)
$sect (from-type +.a sect.dat)
$meta (from-type +.a meta.dat)
$mime (from-type +.a mime.dat)
$body (from-type +.a body.dat)
2016-02-12 00:53:14 +03:00
$kids ?< (~(has by (malt p.a)) %kids) :: XX recursion?
2016-02-11 23:53:34 +03:00
=< o+(~(urn by kid) .)
2016-02-12 00:53:14 +03:00
|= {dir/knot dak/tree-include} ^- json
2015-08-06 05:13:41 +03:00
^^$(quy p.a, s.bem [dir s.bem], dat dak, kid ~)
==
2015-08-04 04:37:19 +03:00
--
2015-08-04 02:49:34 +03:00
!:
::::
::
2015-09-02 03:24:18 +03:00
[tree .]
2015-08-04 02:49:34 +03:00
^- json
2016-07-30 01:19:44 +03:00
=+ default='spur.t_body.r_comt.j_plan.j_beak.t_meta.j_kids_meta.j_head.r_bump.t'
2015-08-04 04:37:19 +03:00
=+ ^= schem
=+ seh=(fall (~(get by qix.gas) 'q') default)
2016-02-11 23:53:34 +03:00
~|(bad-noun+seh ;;(schema (rash seh read-schem)))
2016-03-30 01:29:22 +03:00
%+ from-queries bem.gas
2016-02-12 01:35:58 +03:00
~| invalid-query+schem
;;((list query) (schema-to-plist schem))