We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The following ReScript code
type status1 = OPEN | CLOSED let isOpen1 = (status: status1) => switch status { | OPEN => true | CLOSED => false } type status2 = [#OPEN | #CLOSED] let isOpen2 = (status: status2) => switch status { | #OPEN => true | #CLOSED => false }
creates the following JS output:
function isOpen1(status) { if (status === "OPEN") { return true; } else { return false; } } function isOpen2(status) { return status === "OPEN"; }
So there is some optimization applied for polymorphic variants that is not applied for normal variants.
https://rescript-lang.org/try?version=v11.1.0&code=C4TwDgpgBAzsCGwCuMByB7ATgW3gGwDV5MBLeAO2CgF4oB5ABQFFUoAfKAYQBk6BlJgBEAUMLwQqJGHUjkMOfEVIUqtABRxEKAFywEyNFlyFiZSgEoaAPmFRYAdxLAAxgAs9WmFADet9vWZWaisoYEwkCD8OHn4haygAM3wYSLsAX1FQSA8DBnQ8EGwsMFcSZyUzVSgAbQBiRhZ-WpiBQQBdUXFJaVk8gqLMErKKlRooDX0dHJQ+wuLS8tMVS2C-GEcXd00DHyioesD4sIi95t5W+KS8FL8MoA
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The following ReScript code
creates the following JS output:
So there is some optimization applied for polymorphic variants that is not applied for normal variants.
https://rescript-lang.org/try?version=v11.1.0&code=C4TwDgpgBAzsCGwCuMByB7ATgW3gGwDV5MBLeAO2CgF4oB5ABQFFUoAfKAYQBk6BlJgBEAUMLwQqJGHUjkMOfEVIUqtABRxEKAFywEyNFlyFiZSgEoaAPmFRYAdxLAAxgAs9WmFADet9vWZWaisoYEwkCD8OHn4haygAM3wYSLsAX1FQSA8DBnQ8EGwsMFcSZyUzVSgAbQBiRhZ-WpiBQQBdUXFJaVk8gqLMErKKlRooDX0dHJQ+wuLS8tMVS2C-GEcXd00DHyioesD4sIi95t5W+KS8FL8MoA
The text was updated successfully, but these errors were encountered: