I want to write two React components, one for rendering AndGroup and OrGroup, the other for rendering a simple condition(Eq,IsEmpty, IsOneOf).
I come from TypeScript, in TS I might write:
If you want to combine variant types, take a look at polymorphic variants in the manual, they explain how to do it, basically they’re structural variants and allow you do this:
type red = [#Ruby | #Redwood | #Rust]
type blue = [#Sapphire | #Neon | #Navy]
// Contains all constructors of red and blue.
// Also adds #Papayawhip
type color = [red | blue | #Papayawhip]
But for your use case, this is not going to work well because your type is recursive, I think you’ll have to create mutually recursive modules to have react components that can reference themselves, the downside of this solution is that you have to manually define the signature of these modules which makes it a bit verbose but is definitely doable, take a look at the example in the playground.