shrub/ren/tree/json.hoon

80 lines
1.9 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
::
2015-08-04 02:49:34 +03:00
/? 314
2015-08-04 04:37:19 +03:00
/+ tree
2015-08-04 02:49:34 +03:00
/= gas /$ fuel
/= dat /^ tree-include /tree-include/
2015-08-04 04:37:19 +03:00
/= kid /^ (map span tree-include)
/_ /tree-include/
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)})
++ dict |*(a=_* $^({a (dict a)} a))
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-02-11 23:53:34 +03:00
{$comt $j}
{$head $r}
{$sect $j}
{$snip $r}
{$body $r}
{$meta $j}
{$mime $m}
2015-08-04 04:37:19 +03:00
==
++ to-queries
2016-02-11 23:53:34 +03:00
|= a/schema ^- (list query)
2015-08-04 04:37:19 +03:00
?@(-.a [(to-query a) ~] [(to-query -.a) $(a +.a)])
2015-08-04 02:49:34 +03:00
::
2015-08-04 04:37:19 +03:00
++ to-query
2016-02-11 23:53:34 +03:00
|= a/{term $@(mark schema)}
~| invalid-query+a
2015-08-04 04:37:19 +03:00
?+ -.a ;;(query a)
%kids [%kids (to-queries ?@(+.a !! +.a))]
==
++ 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+[%s q.q.a] ~)
$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))
$path (from-type +.a (crip (spud (flop s.bem))))
$spur (from-type +.a (crip (spud s.bem)))
$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)
$kids ?< (~(has by (mo p.a)) %kids) :: XX recursion?
=< o+(~(urn by kid) .)
|= {dir/span dak/tree-include}
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
=+ default='spur.t_mime.m_body.r_comt.j_kids.name.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)))
2015-08-04 04:37:19 +03:00
(from-queries bem.gas(s but.gas) (to-queries schem))