Modular implicits - what's the story here?


One of the first significant stumbling blocks I encountered with Reason was with ad-hoc polymorphism (I didn’t actually realize that this is what it was called at the time, though). As I understand, modular implicits will be the OCaml answer to ad-hoc polymorphism. Can someone explain what this is, show some example pseudocode and compare/contrast with Haskell type classes?


See for a discussion and links to the original papers (the OCaml modular implicits paper is pretty readable).


My understanding is that modular implicits are nowhere near ready to be used, it’s just a prototype at this stage. Someone should correct me if I’m wrong.


I recall seeing a project that used the modular implicits compiler fork to demonstrate what an ocaml stdlib with monads etc might look like. But I can’t find it now :frowning:

Here’s a very detailed discussion with examples - it’s in ocaml syntax but hopefully you get the idea (or can copy/paste into one of the conversion tools):


From the OCaml discourse forum: