[ocaml] implement well_typed function at the second pass