Nit: any particular reason why you chose to leave this function on the ocaml side? (I'm fine with it staying on the OCaml side, I'm just curious.)