[MLton] withtype in signature?

Henry Cejtin henry.cejtin@sbcglobal.net
Tue, 06 Sep 2005 10:33:48 -0500


The  second  work-around  suggested by Matthew definitely specifies something
quite different.  If I say

    signature A =
       sig
          datatype t = T of int
       end

then I am just requiring that any matching structure  have  a  datatype  that
`looks  like'  what  I wrote: it have only a single constructor T carrying an
int value.

If, on the other hand, I write

    structure B =
       struct
          datatype t = T of int
       end

    signature A =
       sig
          datatype t = datatype B.t
       end

then I am requring any matching structure to actually have the SAME datatype.
I.e.,  because of the generative nature of datatypes, the following code will
fail to typecheck

    structure B =
       struct
          datatype t = T of int
       end

    signature A =
       sig
          datatype t = datatype B.t
       end

    structure C: A =
       struct
          datatype t = T of int
       end

I don't know of any way that avoids writing the datatype definition  in  both
the structure and the signature that has the same effect as duplicating it.