3 ms·
>Ocaml is that operators aren't overloaded Which is good since SML ad-hoc polymorphism is broken. Right way to do an ad-hoc is to use classes, type classes or
by ernst_klim 9y ago
>Ocaml is that operators aren't overloaded
Which is good since SML ad-hoc polymorphism is broken. Right way to do an ad-hoc is to use classes, type classes or modular implicits.
- hajile 9y agoSML overloading of builtins isn't specifically broken -- it just makes implicit assumptions about data types. That said, I'm with you about typeclasses and Ocaml's modular implicits. If full-blown operator overloading is going to be allowed, modular implicits are definitely the way to go. If only builtin operators can be overloaded (probably a better solution in maintainable software), then a few specific typeclasses (like the current equality one) could be a more pragmatic solution. In this particular case, I'd hedge my bets and use modular implicits, but limit them to a small list of builtin operators.