Since in the interface, you have defined type t as an abstract type, you can’t create a value of this type using the record syntax, since the fact that it is a record is now a hidden implementation detail (that’s the whole purpose of the abstract type).
If you do not want to make it abstract, then you need to declare it in the mli file the same as you did in the ml fie:
lcon.mli: type t ={a:bool;b:int}
This will reveal the implementation and will allow users of your module to construct values directly, here are some syntaxes that are acceptable by OCaml:
Beware that the third syntax can lead to subtle bugs due to type directed disambiguation:
module type S = sig type t = {a:bool; b:int} end
module M : S = struct type t = {a:bool; b:int} end
module N : S = struct type t = {a:bool; b:int} end
(*
here the fields `a` and `b' in the right hand side are
interpreted as M.a and M.b due to type directed disambiguation.
*)
M.({a=true;b=3}) = N.({a=true;b=3})
- : bool = true
(* compare to this type-checking error *)
{M.a = true; b = 3} = {N.a = true; b = 3};;
Error: The field N.a belongs to the record type N.t
but a field was expected belonging to the record type M.t