Expense proposal: Pure Dhall function to render YAML


I’d like to propose creating a $100 feature bounty for a new contributor to implement the following Prelude utility:

-- ./Prelude/JSON/renderYAML : JSON → Text

In other words, this would render a value of type JSON as the corresponding YAML string, using Text/show for rendering YAML strings (for simplicity; no multi-line rendering necessary).

My selfish motivation for proposing this is that I’m currently implementing a dhall-kubernetes-charts repository to replace Helm with Dhall and this would benefit the repository in a few ways:

  • It would allow me to implement the entire repository logic in pure Dhall, including rendering the Kubernetes resources as YAML

  • I would like to write certain test assertions to compare against a rendered YAML string instead of comparing against the equivalent Dhall value

    The reason why is that the Dhall value representing a Kubernetes resource might be enormous (with a lot of None field), whereas the corresponding rendered YAML value (with nulls filtered out) will be much more compact.

However, I assume this would also benefit other people, too, since this could eventually replace the dhall-to-yaml utility in some cases.

I can implement this utility myself but part of the reason for proposing this bounty is to begin creating a few representative expenses that potential donors can refer to as an example of how their donations could be used. I would also like to use these sorts of bounties to grow the pool of contributors to the Dhall ecosystem.

According to the expense guidelines I need to formally document the following:

  • What purpose is the expense for?

    To create a “pure Dhall” utility for rendering YAML

  • Is this a one-time or recurring expense?


  • What is the amount that you wish to expense?


Also, the expense has to be approved by the same process that we approve changes to the language standard



How do you intend to coordinate the payout in this case?


@singpolyma: I believe the way it works is that anybody can submit an expense here:


… as long as:

  • they provide an invoice
  • a core contributor approves the expense


@Gabriel439 great idea, big yes from me! :clap:


It seems like this has been implemented by https://github.com/dhall-lang/dhall-lang/pull/799 . Thanks!


Yep, and the expense was submitted and approved, so this was successful!


This might sounds like a dumb question, but how are we suppose to use the renderYAML function… Do we have to manually transform objects to JSON types or is there a procedure to do that automatically?

In other words, given such test.dhall file:

{ test = 42 }

Could dhall-to-yaml --file ./test.dhall be replaced by some sort of dhall text <<< 'let Prelude = .. let obj = ./test.dhall in Prelude.JSON.renderYAML obj' ?

I am asking because I was wondering if the renderYAML function could be modified to render comments and sort the keys (e.g. using special record keys such as yamlComment and yamlOrder, similarly to mapKey/mapValue) to produce a prettier output.


@tristanC: You have to convert the value to a value of type JSON. There is no automatic procedure to do that within the language That’s why this is not a complete replacement for dhall-to-yaml


Alright. Then is there existing examples that uses the renderYAML function? For example you mentioned it could be used to render the Kubernetes resources and facilitate test assertions, is this going to use or need an extra convertion procedure?

Thank you for the prompt feedback.


@tristanC: Currently there aren’t any examples outside the tests for the renderYAML function. My plan is to use this function to render Kubernetes resources by auto-generating a family of */toJSON functions for each resource type


That makes sense, thanks. Then I am looking forward how to generate such */toJSON function from dhall types.