[mercury-users] Is there something like string__from_anything?

Robert Bossy bossy at ccr.jussieu.fr
Fri Sep 7 01:37:16 AEST 2001

[ Thu, 6 Sep 2001 16:52:33 +0200 (CEST) ] Ondrej Bojar <oboj7042 at ss1000.ms.mff.cuni.cz> -> <mercury-users at cs.mu.OZ.AU>

> Hi.
> 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.
> (Maybe one can somehow just twist the pipes, catch output stream into a
> string, but I do not know how...)

I was amazed not to find the predicate io__read_from_string (inverse of io__print_to_string).

But you can call term__type_to_term/2 and (recursively) build a string.
Predicates from the 'ops' module allow to test if an atom is a pre/post/in-fix operator.

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