Dependent signature specialization

65 views Asked by At

Can I specialize a type in a signature using types before that type and in the signature? Here is an example:

signature A = sig 
  type t
  type s
end

Can I specialize A by the following?

signature B = A where type s = t list

Both SML/NJ and Mlton complain that t is unbound.

1

There are 1 answers

0
Andreas Rossberg On BEST ANSWER

No, that indeed cannot be done directly. The reasons are rather technical, it is not easy to ascribe a well-behaved semantics to such an operation in the general case.

The closest you can get is by introducing another auxiliary type:

signature B =
sig
  type t'
  include A with type t = t' with type s = t' list
end