`@unwrap` for generic types?

e.g. option<@unwrap [#Str(string) | #Int(int)]> (or array)? they’re in the signature of an external method and there are no warnings nor errors but they aren’t getting unwrapped

this question has been asked before: Unwrap array of polymorphic variants? - #2 by yawaramin
but imo that’s a non-answer - i’m wondering why it’s not like that, not looking for an alternative (plus %identity is kinda nasty so i’d like to avoid that solution if possible)

Can you provide a concrete code sample, preferably a Playground link, showing what the current behaviour is, and explain what the expected behaviour is?


expected behavior being, the unwrapping properly happening

@unwrap works only when it completely ‘wraps’ the parameter type, due to limitations of ReScript’s binding system. So this works:

@val external foo: @unwrap [#Str(option<string>) | #Int(option<int>)] => unit = "log"


i guess it works there… i guess i shouldn’t have tried to oversimplify

i was hoping i could pass unwrapped heterogeneous arrays to js using this. oh well…

using the old %identity trick… is a thing i can do, it’s just that it’s really painful having the inconsistency from being able to use @unwrap almost (but not quite) everywhere