Using true false in a polymorphic variant

type parent_workspace = {
  type_: [#workspace],
  workspace: [@as("true") #tru],
}
let x = {type_: #workspace, workspace: #tru}

# output
var x = {
  type_: "workspace",
  workspace: "tru"
};

The value workspace is always true just as the value type_ is always workspace. Is it possible to get set true at the value using a ploymorphice variant or some other method?

Thank you.

Nope. But you can use a bool instead.

EDIT: sorry, the above is incorrect. You can actually use #"true" to specify that it must always compile as "true".

1 Like
type parent_workspace = {
  @as("type")
  type_: [#workspace],
  workspace: [ #"true"],
}
let x = {type_: #workspace, workspace: #"true"}

playground

Thank you @yawaramin

1 Like