What recommendations would you give for OCaml libraries and tooling for writing type inference (or specifically unification) algorithms?
I often find myself writing small programming languages in OCaml. Thanks to Menhir and OCamllex, the parsing part of that problem is pretty straightforward, and the use of ADTs makes the subsequent compilation process fairly easy as well.
However, the last time I tried implementing a type inference algorithm for a non-trivial small language, I spent around a week doing it, and ended up with a buggy unification algorithm, with errors that that were quite hard to wrap my head around.
Are there any libraries that I could outsource to do the unification part for me (performance be damned)? Ideally, It would be best if I could express the typing judgements as declarative statements, and have the library handle resolving type variables to their instantiations.
ELPI seems like the most promising solution, but its documentation leaves a lot to be desired, and after a few hours trying to navigate its rather complex API, have little to show for it.