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

Mark Brown mark at csse.unimelb.edu.au
Wed Nov 1 17:23:41 AEDT 2006


On 01-Nov-2006, Peter Ross <pro at missioncriticalit.com> wrote:
> On 11/1/06, Ralph Becket <rafe at csse.unimelb.edu.au> wrote:
> >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.
> >
> Only one issue, this should be
> 
> :- pred io.pprint(int::in, T::in, pprint.doc::out, io::di, io::uo) is det.
> 
> Then the user can decide where they want to print the doc.

In this case the first argument should be dropped, since the line width
won't be required until the doc is to be printed (I think).

Also, a predicate that converts, say, a map to its pretty form will need
to call this predicate in the io module recursively, so that the keys and
values can also be converted using the same mutable.

Cheers,
Mark.

--------------------------------------------------------------------------
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