1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
(* If type abbreviations contain type variables that are not present
on the right-hand side we have to reduce the abbreviation before
unification and applying the value restriction.
The first part of the example was provided by Phil Clayton. *)
signature A =
sig
type ('a, 'b) t
val mkT : int -> ('a, int) t
end
structure A :> A =
struct
type ('a, 'b) t = 'b
fun mkT n = n
end
signature B =
sig
type 'a t
val x : ('a t, int) A.t
end
structure B :> B =
struct
type 'a t = unit
val x = A.mkT 2
end;
type 'a t = int;
val x: 'a t = 1 +1;
(* A further example from Phil. *)
signature A =
sig
type ('a, 'b) t
val mkT : int -> ('a, int) t
end
structure A :> A =
struct
type ('a, 'b) t = 'b
fun mkT n = n
end
signature B =
sig
type 'a t
val x : ('a t, int) A.t
end
structure B :> B =
struct
type 'a t1 = unit
type 'a t = 'a t1 * 'a t1 (* two levels of phantom types *)
val x = A.mkT 2
end;
(* A further check. This has worked correctly for a long time because of the
way equality is handled. Include it here just in case it gets broken by
a change in the future. *)
fun f (x: real t) y = x = y;
|