Why is the result of the following functor not opaque?

72 Views Asked by At

Consider the following SML program:

signature BinaryOp =
sig
    type domain
    val operation: (domain * domain) -> domain
end;

signature INTEGER =
sig
    val value: int
end;

functor ModularInt(K: INTEGER) :> BinaryOp =  (* I *)
struct
    type domain = int;
    fun operation (a,b) = (a+b) mod K.value;
end;

structure Z3 = ModularInt(struct val value=3 end);

structure Z3' :> BinaryOp = Z3;  (* II *)

It turns out that Z3 is not opaque, meaning that Z3.domain is compatible with integers (i.e., val x: Z3.domain = 0 works), whereas Z3' is opaque.

Why is opaque signature ascription (:>) doing its job on line II but not on line I?

0

There are 0 best solutions below