Re-exported variant type with instantiated type parameters

Hello,

What is wrong with the following code?

type 'a t = A
type 'a s = int t = A

I get

Error: This variant or record definition does not match that of type int t
Their constraints differ.

According to the OCaml manual

Re-exported variant type or record type: an equation, a representation.

In this case, the type constructor is defined as an abbreviation for the type expression given in the equation, but in addition the constructors or fields given in the representation remain attached to the defined type constructor. The type expression in the equation part must agree with the representation: it must be of the same kind (record or variant) and have exactly the same constructors or fields, in the same order, with the same arguments.

I thought the above code could type check?

Best regards,
Keiko

Shouldn’t the second line of code be type 'a s = int s rather than type 'a s=int t ?

No, I’d like to re-export int t as 'a s. (This is a simplified example from my use case, in which the type 'a s is defined in a separate module.)

The problem is that you cannot add a new constraints on the type of A when you re-export the constructor. Otherwise, you would have two contradictory views on A : the original definition for which A has type 'a. 'a t and the re-exported one where A necessarily has type int t.

ah, yes, that makes perfect sense!

Best regards,
Keiko