Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.
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.
dhall-json
So, here's something that works:
let EditorRole = < moderator | administrator > let makeUser = \(role: EditorRole) -> let userRole = role in { role = userRole } in [ makeUser EditorRole.administrator, ]
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, ]
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.So, here's something that works:
Here's the thing that doesn't work. It's unclear how to accomplish what I want.