OCaml newbie here. I’ve run into a problem I’m struggling to resolve.
I’m working on an existing codebase, and I’d like to refactor one of its functions, which has the interface:
let do_something (l : 'a list) : 'a list = ...
This function is called with arguments of several different types, and its current implementation depends on polymorphic comparison.
My question: is there a way to pass a polymorphic Comparator here so that do_something can keep the same polymorphic interface? I’m imagining something that would be used like this:
Core_kernel.Set.stable_dedup_list (module Comparator.Poly(??)) my_list;;
Or is there a better way to go about this?
Ideally I’d like to get rid of the polymorphic comparison someday, which I assume would require passing down the appropriate comparator at every callsite. But I’d like to avoid that for now, if possible.