I defined the following interface and module:
module type TYPE = sig type t end module Type = (struct type t = | TBot | T of int | TTop end: TYPE)
Now I understand that if I write outside Type.T 5 , the compiler will give me an error Error: Unbound constructor Type.T If I delete the signature and save the module, the error will disappear.
1) So, my first question is: how do I change the signature so that I can use the constructors outside?
2) One way is to define the constructor explicitly as follows, do you think this is the usual way? One drawback that I see now is that it does not allow building a TBot or TTop .
module type TYPE = sig type t val make : int -> t end module Type = (struct ... let make (i: int) : t = T i end: TYPE)
3) Is it always necessary that the outside can build the value inside the module?
source share