A common criticism of OCaml is its lack of support for ad-hoc polymorphism. The classic example of this is OCaml’s separate addition operators for integers
(+) and floating-point numbers
(+.). Another example is the need for type-specific printing functions (
print_string, etc.) rather than a single print function which works across multiple types.
Taking inspiration from Scala’s implicits and Modular Type Classes, we propose a system for ad-hoc polymorphism in OCaml based on using modules as type-directed implicit parameters. You can try out an interactive REPL of a prototype implementation online.
Our modular implicits prototype was initially developed between Jan 2014 - Feb 2015, with more work taking place now in early 2017.