Hi Lucas,
The reason your example fails is that sharing is only allowed between non-ground types. You are attempting to share a non-ground type (BVertex.Boundary.data) with a ground type (RGVertex.Boundary.data = unit). In this instance you would need a "where" clause instead. I agree that the PolyML error message isn't clear.
If you replace BVertex with Vertex, there is no constraint on RGVertex.Boundary.data because Vertex doesn't include a Boundary substructure. In SML 97, structure sharing is just an abbreviation for sharing the types that are present in both structures.
Dave.
At 16:35 23/05/2008, Lucas Dixon wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I've been trying to use the module system and come across a few issues, some of which I cannot easily pin down, and one which I can.
The issue I can clearly identify concerns what seems to be failure of associativity in structure sharing, and is demonstrated in the following:
signature ORD_DATA = sig type data end; signature VERTEX = sig type name type data end;
signature BVERTEX = sig structure Boundary : ORD_DATA include VERTEX end;
signature GRAPH = sig structure Vertex : VERTEX type T; end;
signature BGRAPH = sig include GRAPH; structure BVertex : BVERTEX sharing Vertex = BVertex end;
signature RG_VERTEX = sig include BVERTEX where type Boundary.data = unit end;
signature RG_GRAPH = sig include BGRAPH structure RGVertex : RG_VERTEX sharing BVertex = RGVertex (* why is it OK if I change BVertex to Vertex? *) end
Running this gives the error: Error: in '/tmp/sml25644bEn', line 26. Cannot share: (unit) is a type function Found near sig include BGRAPH structure RGVertex : RG_VERTEX sharing BVertex = RGVertex end
Exception- Fail Static errors (pass2) raised
Apart from just being confused by what the error means, I am confused that given, in BGraph, "sharing Vertex = BVertex", later I get an error if "BVertex = RGVertex" but not if "Vertex = RGVertex".
Is there some subtle (or obvious?) thing I'm missing?
Another thing I don't quite understand, but which I suspect is just part of the definition of ML, is that you cannot write "sharing type localtype = globaltype", is there some clever reason why this isn't allowed? Or even "sharing local_structure = global_structure", would sometimes be nice. :)
The other issue I have is with the names given to types being printed in error messages; is there any way to control this? I sometimes seem to get mis-typed types; which makes errors hard to spot. A common thing I find is that a parameterised type loses it's parameter. I have example of this I can repeat, but they require a large amount of code... I'll try to find a smaller example.
any suggestions/corrections/infomration, and possibly bug fixes, very welcome! :)
cheers, lucas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFINuQvogMqU4edHsMRAnq3AKDEOOZK6W4Yl9qLIybMvIYRmrGu8ACeKZIG 2RtB76HxIEiw+Kxd/xiYvGw= =mxpJ -----END PGP SIGNATURE----- _______________________________________________ polyml mailing list polyml@inf.ed.ac.uk http://lists.inf.ed.ac.uk/mailman/listinfo/polyml
-- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.