A polyvariant subset problem

Hey. I encountered a problem related to polymorphic variants.

Is it possible to make this code compile while typing the array explicitly:
https://rescript-lang.org/try?ext=re&code=C4TwDgpgBAhlC8UDaUA+UAGMCMbMwCY8sBmAXQG4AoUSKAIwWWPoAoBnYAJwEsA7AOYBKSjXDR6Ae2AALJijjp6oqgHoAVOqpR1UAJJQ+ECABMowSefHmZPdrC5cYIc5Yh8AZpK4BjaD2AoST4AGxcZGHsANxgQnjMAiABbdgA6bXVVKhCIQJgAIQBXYAs+dgAuBycQVhgheVQsbAAafAJW0lQVJMkTQpyoIpLgpgBvbWQAAS4IGB9gVJ9JJLBg92AyCZzApJgAa2hEVgA-YIBhCMEISqQAHgZpGTIEAD4oQr4A+vg38ah-qC3F4TAFQUYFYqldgg0EAWhe+QgIQWAEFHM5UrswKxEklXjDQQDbvRISNznEfHt4KMAPqvIJ8C4wK444DJIQAX2BhJ5-wARHo2Uk+fCAEqzeapTi8QQEnm3VQk4Z8bm8qBCOVQMUShYwdEgDly4mkvgMs4Uqm0+nnS4CCCsDBsPkACSRIUkfKEnNVPL5+SgrpC7pFL3FcwW0v4AiNipNPsBqhe1H+HOoqaoQA

I need that array to be explicitly typed because in real life those items are passed to an external function that only accepts items of type a

Any help would be appreciated.

Here you go

Added clarification: it requires a hint to compiler that a type of passed item is a subtype of expected both type in the form of item :> both

1 Like

Nice! Thanks a lot. I didn’t even know about that syntax :smiley:

1 Like