dhall-haskell
dhall-haskell copied to clipboard
Produce unquoted YAML from Dhall
Hello,
I'm trying to produce templated YAML from Dhall; the desired output is
kind: Deployment
spec:
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
Basically I would want the output string to be unquoted so that the templating engine can pick up "/configmap.yaml"
(I came from a question here, as far as I can tell there isn't a canonical solution!)
Thanks!
yeah, there still isn't a way to do this
i'd be open to a pr that added support for this; the main open question is whether the quoting should be disabled globally in the generated YAML or just for a specific field (and if so, then how)
Where does dhall-to-yaml generate quoted strings today? I'd like to dig into the code a little as I have this same issue.
So there is the dhall-to-yaml executable (which is provided by the dhall-json package for reasons) and the dhall-to-yaml-ng executable (which is provided by the dhall-yaml package). The dhall-yaml README provides a brief explanation of why there are two such executables.
For the dhall-to-yaml executable, you can find the relevant logic for that here:
https://github.com/dhall-lang/dhall-haskell/blob/main/dhall-json/src/Dhall/JSON/Yaml.hs
For the dhall-to-yaml executable, you can find the relevant logic for that here:
https://github.com/dhall-lang/dhall-haskell/blob/main/dhall-yaml/src/Dhall/Yaml.hs
I would say that unquoted strings are special options that should be supported by adding those options to a Dhall data type. Right now there is already a JSON data type in the Dhall prelude. That data type can be enhanced to include an option for unquoted strings. When converting the JSON data type to YAML, that option may be taken into account.