[m-dev.] User-controlled pretty-printing

Ralph Becket rafe at csse.unimelb.edu.au
Wed Nov 1 14:44:11 AEDT 2006


An oft cited request for the debugger is the ability to control how
different types are pretty-printed.  To date we have assumed that this
requires dynamic type class casts so we could ask of any value X whether
it is a member of the pretty_printable type class and if so use the
pretty_printable method, otherwise use the default method.  For
technical reasons, dynamic type class casts are still some way off.

I have an alternative proposal that should work for the debugger and
program output in general.  The idea is that we have a global mutable
attached to the IO state consisting of a list of predicates with the
signature

	pred(univ::in, pprint.doc::out) is semidet

and we add a predicate

	% io.pprint(LineWidth, Value, !IO).
	%
:- pred io.pprint(int::in, T::in, io::di, io::uo) is det.

A program can affect how io.pprint works by extending the list of pretty
printers attached to the IO state.  Typically this would be done by an
initialiser.

We could conceivably extend io.pprint with parameters controlling more
precisely how values values should be printed (e.g., the accuracy of
floats) or how much of them should be printed.

I'd like to flesh this idea out more thoroughly, but thought I'd put it
up for consideration first before spending much time on coding.

-- Ralph
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list