[mercury-users] Is there something like string__from_anything?

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Sep 7 00:58:47 AEST 2001

On 06-Sep-2001, Ondrej Bojar <oboj7042 at ss1000.ms.mff.cuni.cz> wrote:
> I wonder if there is a hidden predicate something like:
> :- pred string__from_anything(T::in, string::out) is det.
> It should do what io__write(T, io__state, io__state) does, that is print
> any structure in a human readable format, but the output should go into a
> string, not into an output stream.

Currently no.

However, it is possible to write such a procedure
using Mercury's RTTI support (deconstruct, univ_to_type, etc.).
The source code for io__write is a good example of how to do it.

Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe

More information about the users mailing list