[m-users.] Printing any value with io.print

Volker Wysk post at volker-wysk.de
Mon Mar 16 04:46:31 AEDT 2020


Hi!

The io.print predicates are able to print values of any type. I'm
curious how this is possible. In Haskell, the types must be in the
"Show" type class and you define a member function, which handles
values of the type. How does io.print know how to handle values of ANY
type...?

I need to write an algebraic data type, as a term, to a string, just
like io.print does, when it writes it to an output stream. How should
this be done? I couldn't find a string_output_stream feature... Is the
"format anything" capability of io.print available outside of io.print?

Regards,
Volker



More information about the users mailing list