Search code examples
dhall

dhall-to-yaml funtion Text output is being output in double quotes


I have the following function which its output get enclosed with double quotes when processed via dhall-to-yaml yet a static string injected in a record is not enclosed in quotes, how can I control what get enclosed in double quotes and what doesn't?

let base64 = \(encode : Text) -> "!Base64 ${encode}"
let john : Profile =
    { person =
        { name = base64 "test"
        , age  = 67
        }
    , address =
        { country = "United States"
        , state   = "Pennsylvania"
        , city    = "Philadelphia"
        }
    }

Output

address:
  city: Philadelphia
  country: United States
  state: Pennsylvania
person:
  age: 67
  name: "!Base64 test"

Desired Output:

address:
  city: Philadelphia
  country: United States
  state: Pennsylvania
person:
  age: 67
  name: !Base64 test

Solution

  • Currently the dhall-to-yaml and dhall-to-yaml-ng commands quote string fields if they have special characters in order to ensure that Dhall Text values can only be interpreted as plain data when converted to YAML. Also, there is not yet an option to omit the quoting behavior if you desire unescaped text (such as for emitting tags), nor is there a standard way to specify tags, either.

    You might want to open an issue at https://github.com/dhall-lang/dhall-haskell/issues to discuss possible ways to resolve your problem since I imagine you're not the only one who would like to emit tags in the YAML output.