http://conal.net/papers/compiling-to-categories/compiling-to-categories.pdf
There is a paper where author uses some Haskell internal tricks (I think it is compiler plugins) i.e. reusing compiler’s API to implement simplification of terms. Have anybody tried to reimplement this in OCaml infrastructure or at least thought about it?