ctypes-zarith Demo code how to mix ctypes and "custom" OCaml types. mpz_t/mpz_struct (C) is exposed as Z.t (OCaml) and mpq_struct as Q.t. Interface Example code