OCaml type for custom block

What type should I use for custom blocks (created in C code) in OCaml?

  1. Is it safe to declare abstract type and then use it for custom blocks?

  2. Is it safe to declare extensible variant type with some constructors and then use it as a type for custom block? I.e.

    type t = …
    type t += Str of string
    extern cstub : unit -> t = “cstub”
    (* and then I create custom block in cstub *)

You should declare custom blocks as abstract types on the OCaml side.

1 Like