-
Notifications
You must be signed in to change notification settings - Fork 471
Description
I recently discovered that coercion works for variants where everything is represented by the same primitive type:
https://rescript-lang.org/docs/manual/latest/variant#coercing-variants-to-primitives
This is great, but I have a function that returns one of these variants and I can't coerce that. It seems to work for no-argument functions, but not functions with arguments.
https://rescript-lang.org/try?version=v11.1.1&code=C4TwDgpgBAhgzgSQHbCgXigHygAXgCgEYBKKAeSWmzznwCZSAVAdwHstcCBmJgCwCcIEAFDCANhFStKyYAC5YiFOnKVxkqMFayV+aRB1yAfFACWKYqImpBwAK78ksgKpJTqDPlJoTFEdahbBycUAGVzAHMJXQB9b181dVQtWQAxQl0gxxc3VGMofDtc9BNzYGJLAJSUVLpMyWDZcKQo6Hz8AHIYErMLYiA
The specific example I'm trying to model is array sort, so I'd need it to work on 2-argument functions as well.
https://rescript-lang.org/try?version=v11.1.1&code=C4TwDgpgBAxg9gWzAQwE4EsDOcB2UC8AUFFAD5QACymAFALQCMAlFADISaYAqAFsjsTKVqNAAwsAogEcArsgA2g8lVrMoAcVQRkwCKl79ChOJDwApTADoAgqlTIQAJkLyIwKNlTv8UGmlQANFAAfgBmAFy+AOTIQTEs+AB8sIgoGNg4CYmCnsAAkjgACvLIMBAA6ujAPH52dImY8uhlAGKoiGJMQTShUOHJ6DjATExAA