1 (* From Chapter
5 of Elsman
's PhD thesis
; these examples should
4 (* Decrease
in generativity
*)
6 functor f() = struct type a
= int
15 val _
= print ("f.a = " ^ f
.pr f
.a ^
"\n")
17 functor g() = struct datatype a
= A | B
22 end :> sig type a
type b
25 val pr_a
: a
-> string
26 val pr_b
: b
-> string
30 val _
= print ("g.A = " ^ g
.pr_a g
.A ^
"\n")
31 val _
= print ("g.B = " ^ g
.pr_b g
.B ^
"\n")
34 functor h(s
: sig type a
val pr
: a
-> string val a
: a
end) =
44 structure h
= h(struct type a
= int val pr
= Int.toString
val a
= 343 end)
45 val _
= print ("h.b = " ^ h
.pr h
.b ^
"\n")
47 (* Increase
in generativity
*)
49 functor i() = struct datatype a
= A
53 fun pr (A
,B
) = "(A,B)"
55 end :> sig type c
val c
: c
val pr
: c
-> string end
58 val _
= print ("i.c = " ^ i
.pr i
.c ^
"\n")
60 (* Signature S below is well
-formed
, but after opacity elimination it
61 * is not
. No
real structure (i
.e
., a
structure existing outside
of a
62 * functor body
) can match the
signature S
. The
signature should
63 * elaborate
, however
. *)
65 structure S
= struct type s
= int * int
66 end :> sig eqtype s
end
68 signature S
= sig datatype u
= A
69 end where type u
= S
.s