[MLton-user] ascription in MLton source
Matthew Fluet
fluet at tti-c.org
Fri Feb 29 01:13:10 PST 2008
On Sat, 23 Feb 2008, Matthew Fluet wrote:
> Second, nearly every declared type is defined as a datatype, which is
> generative and creates a new type. If the datatype constructor(s) are not
> revealed by the signature, then the type is effectively opaque. Consider:
> structure S1 : sig type t end = struct datatype t = T of int end
> structure S2 :> sig type t end = struct type t = int end
> Although S1 uses a transparent signature ascription, no client of S1 can
> exploit the data implementation details -- there is no way to create or
> destruct values of type S1.t without the S1.T data constructor.
It turns out that there is one (ever so slight) implementation detail that
a client of S1 can exploit that a client of S2 cannot -- polymorphic
equality. That is, the transparent signature ascription on S1 (although
it hides the T data constructor) does reveal that S1.t is an equality
type, whereas the opaque signature ascription on S2 does not reveal that
S2.t is an equality type.
One could take this observation as another argument against equality types
in SML.
More information about the MLton-user
mailing list