interpolating enums/unions - Dhall

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

John Rinehart

I have a problem encoding an enum (union) value as a JSON string. dhall-json has no problem encoding the enum value as a string as long as it's not in a string interpolation, but that's exactly where I'd like to use it.

John Rinehart

So, here's something that works:

let EditorRole = < moderator | administrator >

let makeUser = \(role: EditorRole) ->
      let userRole = role
      in  { role = userRole }
      in  [
          makeUser EditorRole.administrator,
      ]
John Rinehart

Here's the thing that doesn't work. It's unclear how to accomplish what I want.

let EditorRole = < moderator | administrator >

let makeUser = \(role: EditorRole) ->
    let
    jsonRole = "${role}"
      in  { role = jsonRole }
      in  [
          makeUser EditorRole.administrator,
      ]