shrub/gen/cat/pretty.hoon
2017-03-28 17:18:59 -04:00

31 lines
708 B
Plaintext

:: Pretty-printing util, should be in lib/
::
:::: /hoon/pretty/cat/gen
::
/? 310
::
|%
++ pretty-noun
|= pri/* ^- tank
?~ pri
leaf+"~"
?@ pri
leaf+?:(((sane %tas) pri) <`@tas`pri> <pri>)
=< rose+[" " ?:(- "~[" "[") "]"]^+
|- ^- {? (list tank)}
?~ +.pri
[& ^$(pri -.pri) ~]
?@ +.pri
[| ^$(pri -.pri) ^$(pri +.pri) ~]
[+< - +>]:[^$(pri -.pri) $(pri +.pri)]
::
++ vale-cord |=(a/cord `?`(levy (trip a) |=(b/@ |((gte b 32) =(10 b)))))
::
++ pretty-file
=+ wain-to-tang=|=(a/wain (turn a |=(b/cord leaf+(trip b))))
|= fyl/* ^- tang
=+ `(unit wain)`?@(fyl `(to-wain:format fyl) ((soft wain) fyl))
?^ - (wain-to-tang u)
[(pretty-noun fyl)]~
--