This is not a matter of representing memory. When comparing a type declaration with a type signature, or, in general, when checking to see if the declaration is t1less general than the declaration t2, currently, type checking only checks for three cases:
t2 - abbreviation for abstract type or typet1 t2 -t1 t2 -
. t1 ( ) , t2 () . .
: type_declarations /includemod.ml.
, foo.ml :
type u = Foo of string
type t = u
, . .
: , , . , , :
module Test : sig
type t = Foo
type u = t (* to the outside, t and u would be equal *)
end = struct
type t = Foo (* while internally they are different *)
type u = Foo (* sum/records are generative/nominative *)
end
( ) :
module Test : sig
type t = Foo
type u = Foo
end = struct
type t = Foo
type u = t = Foo
end;;
fun (x : Test.t) -> (x : Test.u);;
(* Error: This expression has type Test.t but an expression
was expected of type Test.u *)
, ( ) :
module Test : sig
type r = { x : float; y : float; z : float } (* boxed float record *)
end = struct
type 'a t = { x : 'a; y : 'a; z : 'a } (* polymorphic record *)
type r = float t
end