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
|
(* include must copy values, exceptions and, with the latest changes, value constructors. *)
signature S1 =
sig
val x : int
type t
datatype s = A | B of t | C of int
val y : int
end;
signature S2 =
sig
val a: int
include S1
val b : int
end;
functor F(Q: S2) =
struct
fun f (Q.A) = Q.x
| f (Q.B _) = Q.b
| f (Q.C i) = i
datatype s = datatype Q.s
end;
structure P = F(struct val x = 1; type t = bool datatype s = A | B of t | C of int;
val y = 3; val a = 4 val b = 5 end);
if P.f(P.A) = 1
then ()
else raise Fail "WRONG";
signature S2 =
sig
val a: int
include
sig
val x : int
type t
datatype s = A | B of t | C of int
val y : int
end
val b : int
end;
functor F(Q: S2) =
struct
fun f (Q.A) = Q.x
| f (Q.B _) = Q.b
| f (Q.C i) = i
datatype s = datatype Q.s
end;
structure P = F(struct val x = 1; type t = bool datatype s = A | B of t | C of int;
val y = 3; val a = 4 val b = 5 end);
if P.f(P.A) = 1
then ()
else raise Fail "WRONG";
|