Rob, Rob Arthan wrote:
Previously, the code checked whether there was circularity and just printed "..." when it detected it. That's not really possible with the current code so it relies on the print depth (PolyML.print_depth) to stop infinite looping. Setting print_depth to 10 in your example produces much more sensible output.
That works. Even better for me, if I change the order of compilation so that my user-defined pretty-printer for the circular type is installed first, that works too.
I've now set the default value of print_depth to 10 rather than 100 so it shouldn't cause this problem again.
I don't know if I mentioned before that there's been a major change in the way type-specific printing is done. The old pretty-printing functions have been replaced by functions that generate the PolyML.pretty datatype: datatype pretty = PrettyBlock of int * bool * context list * pretty list | PrettyBreak of int * int | PrettyString of string
with the context type defined as datatype context = ContextLocation of location | ContextParentStructure of string * context list | ContextProperty of string * string
The context type may be extended in the future. ContextLocation and ContextParentStructure are used by the compiler when outputting information. ContextProperty isn't used or generated by the compiler and is intended for application programs which may want to pass information from a type-dependent pretty printer to a top-level printer.
PolyML.install_pp has been retained for backwards compatibility but PolyML.addPrettyPrinter is probably a better way to go.
There's also a function similar to PolyML.makestring: PolyML.prettyRepresentation: 'a * int -> pretty which takes a type-specific value and a print-depth and returns the "pretty" datatype for the value. I found it useful when writing some of the pretty printers for the basis library since it meant that a pretty-printer for a datatype that in effect extended an existing type could just be written as a function that returned prettyRepresentation of the base type.
Note that abstract types and opaque signatures no longer hide their representation when printing. There was some discussion on whether this was the best approach but it seems that the advantage of being able to install a pretty printer inside an opaque type and have it available outside outweighs the disadvantages.
Section 4.9 of the ML97 definitions describes something called Abs(TE, VE) that I think is changing the types declared between "abstype" and "with" into non-equality types and getting rid of their constructors. I think the conflict you mention is why there is a Successor ML proposal to do what you have done.
You, and Dave, are correct. Somehow I'd missed that. I've now changed it so that abstypes are no longer equality types.
David