2

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.

Peng Wang
  • 93
  • 4

1 Answers1

3

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
Andreas Rossberg
  • 34,518
  • 3
  • 61
  • 72