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 68 69 70 71 72 73 74 75 76 77
|
abstype t = T
with
val eq = op =
end
val _ = eq (3, 3)
abstype t = T
with
val t = T
val eq = op =
end
val _ = eq (t, t)
abstype t = T
with
val t = T
val eq = op =
val _ = eq (t, t)
end
val _ = eq (2, 3)
abstype t = T
with
val t = T
val eq = op =
val _ = eq (t, t)
end
val _ = eq (t, t)
abstype t = T
with
val t = T
val eq = op =
val _ = eq (t, t) andalso eq (2, 3)
end
val _ = eq (2, 3)
(* with abstype *)
structure S =
struct
abstype s = S
with
val a = S
end
end
signature F =
sig
val b : S.s
end
functor F() : F =
struct
type s = S.s
val b = S.a
end
functor K() =
struct
structure F = F()
end
structure K = K()
(* abstype.sml *)
(* Checks equality inferred for abstype environments. *)
abstype t = T with
datatype u = U of t
val eq = op=
end
fun eq1(t1, t2) = U t1 = U t2;
fun eq2(t1, t2 : t) = eq(t1, t2);
|