How to construct a record which its type was defined in another file?

The type annotation that you added (let ki : Klib.kinfo = ...) is enough for the compiler to disambiguate and pick up the correct type in this case. The reason it’s not doing so in this case is that lib/klib.mli is exposing the kinfo type as an abstract type so bin/main.ml can’t see its internals and construct an instance of it.

Adding the type definition to lib/klib.mli should solve it. lib/klib.mli should be

type kinfo = {
  name: string
}
1 Like