No, you cannot, because it will violate type inference.
btw, you can use the module namespace to fix this:
module Name = struct type t = { r0:int; ... } end module Func = struct type t = { name: string; ... } end
And then later you can prefix the field name with the correct module:
let get_type r = r.Name.typ let name = { Name.r0=1; r1=2; ... } let f = { Func.name="foo"; typ=...; ... }
Note that you only need the prefix of only the first field, and the compiler will automatically understand what type of value you write has.
Thomas
source share