List typing issue

Hello. Could you suggest how to deal with the following typing issue:

type obj = unit Ctypes.ptr

type 'a spec =
  { cmd_t : 'a Ctypes.fn
  ; imp : obj -> 'a
  }

let methods =
  [ { cmd_t = Ctypes.(returning int)
    ; imp = (fun _self -> 42) }
  ; { cmd_t = Ctypes.(returning string)
    ; imp = (fun _self -> "Hello") }
  ]

The methods list does not typecheck because the records have different types.
What approaches are available to get around this?

For more context why I need it, see project.

Is there at least one function poly_f that work on all 'a spec with a return type independent of 'a?
If the answer is yes, you can either replace your list of spec by a list of closure:

let close spec () = poly_f spec
let methods = [
 close { cmd_t = Ctypes.(returning int) ; imp = (fun _self -> 42) };
 close { cmd_t = Ctypes.(returning string); imp = (fun _self -> "Hello") }
]

or erase the type information behind an existential quantification with

type any_spec = Any: 'a spec -> any_spec
let methods =[
  Any { cmd_t = Ctypes.(returning int) ; imp = (fun _self -> 42) };
  Any { cmd_t = Ctypes.(returning string); imp = (fun _self -> "Hello") }
]

with the guarantee that at least List.map (fun (Any s) -> poly_f s) will work on the methods list.