Can ReScript read modules/types from *.ml files?

In OCaml, I have some code that looks like this:

module Fixed_String_16 = struct
  type t = string;;
end


module Row_Brower_Event = struct
  type t = {
    name: string;
    short_code: Fixed_String_16.t;
    age: int
  };;
end

I’m wondering if there is a way to, without manually converting it, import it in ReScript ?

The goal is to share data OCaml <-> ReScript by writing the struct once and not having to maintain two (possibly out of date) declarations.

It is possible, yes. You can use the OCaml file as a regular module.

(* Types.ml *)
module Fixed_String_16 = struct
  type t = string
end
// Impl.res
let x: Types.Fixed_String_16.t = ""
1 Like