shrub/pkg/arvo/lib/pretty-file.hoon
Jared Tobin b3901ab42f Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8'
git-subtree-dir: pkg/arvo
git-subtree-mainline: 9c8f40bf6c
git-subtree-split: c20e2a185f
2019-06-28 12:48:05 +08:00

32 lines
711 B
Plaintext

:: Untyped best-guess printer
::
:::: /hoon/pretty-file/lib
::
/? 310
::
=< pretty-file
|%
++ 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)))))
::
++ wain-to-tang |=(a/wain (turn a |=(b/cord leaf+(trip b))))
++ pretty-file
|= fyl/* ^- tang
=+ `(unit wain)`?@(fyl `(to-wain:format fyl) ((soft wain) fyl))
?^ - (wain-to-tang u)
[(pretty-noun fyl)]~
--