What’s the closest thing to Haskell’s typeclasses in OCaml?
It really depends what you want to achieve. If you are happy with the OCaml polymorphic comparison function (which will not work on cyclic and functional values), you can simply write: let my_sort l = List.sort Pervasives.compare l The more generic way to mimic type classes is to use functors: module type COMPARABLE = sig … Read more