Open SiriusStarr opened 3 years ago
@SiriusStarr: I think the latter issue about converting things to JSON/Type
could be resolved by adding a toJSON
keyword as suggested in https://github.com/dhall-lang/dhall-lang/issues/336
I completely agree that that would solve the usecase as well and would probably be less cumbersome, since the current nice, unambiguous nature of to-directory-tree
would still apply then.
(On an unrelated note, is there a way to render JSON compactly rather than "pretty" that I'm missing? I went ahead and did the tedious work, but that's the one thing I haven't figured out.)
@SiriusStarr: The old JSON renderer used to render compactly before we changed it to pretty-print. The algorithm is pretty simple:
https://github.com/dhall-lang/dhall-lang/blob/v11.0.0/Prelude/JSON/render
@SiriusStarr: The old JSON renderer used to render compactly before we changed it to pretty-print. The algorithm is pretty simple:
https://github.com/dhall-lang/dhall-lang/blob/v11.0.0/Prelude/JSON/render
Thanks, just wanted to make sure there wasn't a canonical way to do it with the current Prelude before I resorted to something along these lines. :-)
We could always add back the simpler renderer to the Prelude if desired
I think it would be a good option to have, though it's easy enough to work around as is. I am generally in favor of making more functionality available in the Prelude, since I abhor boilerplate. "Pretty" is the more sensible default, of course.
I have a pull request up for restoring the compact rendering logic here: https://github.com/dhall-lang/dhall-lang/pull/1087
Unsure if it would be useful for anyone else, but I find myself wishing that
dhall to-directory-tree
supported file content other thanText
. What are people's thoughts on rendering files usingdhall-to-json
? The biggest issue I foresee would be determining when to "terminate", i.e. when to stop treating records as directories and render them out as JSON instead.Currently the only way to go about this is to use the JSON rendering in the Prelude, but that requires doing all the work to turn whatever are your terminal file contents into
JSON/Type
, which is tedious if you have any non-trivial structure.