You can call OCaml code like a C library: https://ocaml.org/manual/5.3/intfc.html#s%3Ac-callback
have to admit, I've never tried that! I should explore it more.