[m-users.] Converting types to printable form

Sean Charles (emacstheviking) objitsu at gmail.com
Wed May 12 06:10:29 AEST 2021


How do you convert a discriminated union to a printable string? I have this:

    % Character classification types.
:- type char_type ---> ws; chr; op; cp; ol; cl; om; cm; sq; dq; tk.
:- type tokstate
        --->    skip_ws
        ;       eat_token.

Do I have to explicitly code a predicate for each type I define or not? In Haskell I can just add (show) to the definition and it does the write(!) thing. Can Mercury do that other than using io.print_line, sometimes I don’t want a new line!

Thanks
Sean


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20210511/89507030/attachment.html>


More information about the users mailing list