[erlang-questions] Pretty printing records

Ulf Wiger ulf@REDACTED
Thu Nov 20 17:44:26 CET 2008


You can use the same function as the shell, namely:

io_lib_pretty:print(Term, RecDefFun)

where RecDefFun is a fun/2:

fun(Tag, NoOfFields) -> [FieldTag] | no

The RecDefFun can be somewhat generalized through use of
the exprecs parse transform.

This is (almost) described in:

http://forum.trapexit.org/viewtopic.php?p=21790#21790

You could make a module that includes definitions of all
relevant records, and "exports" them using exprecs.
Then you could modify the code in the example so that it
returns 'no' for terms that are not representations of some
exported record.

BR,
Ulf W

2008/11/20 Vance Shipley <vances@REDACTED>:
> The shell now does a nice job of pretty printing records,
> once you've loaded them with rr().  Currently I'm writing
> test suites using common_test and would love the web page
> reports generated to pretty print the (record) return values.
>
> Is there any easy way to do that?
>
>        -Vance
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list