dhall-haskell icon indicating copy to clipboard operation
dhall-haskell copied to clipboard

Produce unquoted YAML from Dhall

Open vmchale opened this issue 2 years ago • 4 comments
trafficstars

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!

vmchale avatar Mar 28 '23 19:03 vmchale

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)

Gabriella439 avatar Apr 01 '23 15:04 Gabriella439

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.

m4dc4p avatar Oct 25 '23 17:10 m4dc4p

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

Gabriella439 avatar Nov 04 '23 02:11 Gabriella439

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.

winitzki avatar Jun 23 '24 20:06 winitzki