Replies: 2 comments
-
@TristonianJones - would you be able to help me with this? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi @davenewza, Here are a few tips in no specific order:
Since The error message for comparing two unequal types is probably about as clear as we can get since we don't have a sense of intent during type-checking. -Tristan |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In our language context we have dynamic enum-like types. For example, a query might be:
The enum type
Status
acts like how we typically understand enum types - it is defined with a set of options. For example,Status.Married
orStatus.Single
would be the defined values.I'm unsure exactly how to define this with the custom type provider. I've achieved a working solution by defining the enum type as a constant object type and its values as opaque types.
Could this be considered a reasonable approach?
We define all our types dynamically at runtime (and not using Go structs or proto definitions). The below Gist very simply illustrates how I have achieved this:
https://gist.github.com/davenewza/81ebf3f30b0fde94419d9ba090327a5c
What isn't so great about this approach is:
person.status == Status.wrong
isundefined field 'wrong'
but enums don't really have fields.person.status == Status
isfound no matching overload for '_==_' applied to '(Status, StatusEnumDefinition)'
whereas I might prefer something likevalue expected for Status
types.NewNullableType()
doesn't seem to let define nullable fields on opaque typesBeta Was this translation helpful? Give feedback.
All reactions