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
|
signature A = sig type t val a : t end
functor F(A : sig type t val pr : t -> string end) =
struct datatype k = A of A.t
fun pr (A t) = "A(" ^ A.pr t ^ ")"
end
functor G(A : A) =
struct type t = A.t val b = A.a end
functor H(A : sig type t type s val a : s
sharing type t = s
val pr : t -> string
end) =
struct
structure A1 : sig type t val pr : t -> string end = A
structure A2 = F(A1)
structure A3 = G(A)
val a = A2.A A.a
val _ = print ("value is " ^ A2.pr a ^ "\n")
end
structure B1 =
struct
datatype t = J | K
type s = t
val a = K
fun pr K = "K"
| pr J = "J"
end
structure B2 =
struct open B1
val a = J
end
structure H1 = H(B1)
structure H2 = H(B2)
signature S = sig end
functor F (): S = struct end
signature S = sig val y: int end
structure C = F ()
|