Introduction
Polymorphic variants in Rescript are strange beasts. They aren’t generally that useful in pure Rescript programming, but are frequently necessary in binding to Javascript.
Polymorphic variants are extremely flexible (too flexible), but one of the most
common uses is to represent a list of constant strings that a JS binding can
accept. For example, the ubiquitous on function used for event handlers
typically takes a string as its first parameter, as in on("click"...). In
Rescript, you can prevent typoing that string using Polymorphic variants:
on(#click).