This might be a general ML question, but perhaps you can help... I'm
curious why type functions cannot be shared, but datatypes can: the
following code is fine:
----
signature A = sig type T end;
signature B = sig
type T
datatype Pair = Pair of T * T
end;
signature CA = sig structure a : A end;
signature CB = sig structure b : B end;
signature D = sig
structure b : B
structure cb : CB sharing cb.b = b
structure ca : CA sharing ca.a = b
end;
-----
However, the following complains:
-----
signature A = sig type T end;
signature B = sig
type T
type Pair = T * T
end;
signature CA = sig structure a : A end;
signature CB = sig structure b : B end;
signature D = sig
structure b : B
structure cb : CB sharing cb.b = b
structure ca : CA sharing ca.a = b
end;
-----
with the error message:
Error:
Cannot share: (D.cb.b.Pair) is a type function
Found near
sig
structure b : B
structure cb : CB
sharing cb.b = b
structure ca : CA
sharing ca.a = b
end
Static errors (pass2)
Is there a theoretical reason for this? (I cannot think of one)
I have been thinking of things like:
type tname = ....
as type abbreviations to save me typing, and I'm curious why wrapping
the type into a datatype should allow sharing... ?
cheers,
lucas