3 ms·
Here's an example (top-left corner, ReasonML syntax): https://reasonml.github.io/try/?reason=LYewJgrgNgpgBAQTGOBeOBvAUHOsAucAlgHb4AUAHgDRwCeAlGnJXANT0DcOeMhAzvg
by yawaramin 9y ago
Here's an example (top-left corner, ReasonML syntax): https://reasonml.github.io/try/?reason=LYewJgrgNgpgBAQTGOBeOBvAUHOsAucAlgHb4AUAHgDRwCeAlGnJXANT0DcOeMhAzvgBOpAOZVajZqzYc63XATggADuQCGyGENo16TdJrDaJ+7gF9uWJUJj9o+AIzMkYAHSryrt6Xy1HtABMDNw2dg6BLsgeat6CIiSitABEABYwUFAgKSkA7iBCUGDJIVhAA https://reasonml.github.io/try/?reason=LYewJgrgNgpgBAQTGOBeO...
The key idea is delegating the type-specific operations to specific implementations which handle them, and then statically (at compile time) choosing which specific implementation you're calling.
In OCaml (ReasonML) you have to pass in the implementations manually, but Haskell and Scala have the ability to automatically choose the implementation based on the types of the arguments, so that it looks dynamic even though it's static and type-safe.