Testing parametric code with print statements

Say you want to inspect the implementation of some parametric code
dynamically by printing data on test cases. print() does not work for any
t@ype, so it would be nice to assert:

a is printable
a = a specific type .

So as to not “dumb down” the implementation by removing the
parameterization.

I tried to do this with a praxi but failed.

Or, is there some other alternative?

You can use ‘print_val (…)’ or fprint_val (…)'.On Tuesday, January 14, 2014 3:39:01 PM UTC-5, Brandon Barker wrote:

Say you want to inspect the implementation of some parametric code
dynamically by printing data on test cases. print() does not work for any
t@ype, so it would be nice to assert:

a is printable
a = a specific type .

So as to not “dumb down” the implementation by removing the
parameterization.

I tried to do this with a praxi but failed.

Or, is there some other alternative?

These have already been implemented:

val () = print_val (0)
val () = print_val (“0”)
val () = print_val (0.0)

To print out a list, you can use fprint_list or fprint_list_sep.On Tuesday, January 14, 2014 3:39:01 PM UTC-5, Brandon Barker wrote:

Say you want to inspect the implementation of some parametric code
dynamically by printing data on test cases. print() does not work for any
t@ype, so it would be nice to assert:

a is printable
a = a specific type .

So as to not “dumb down” the implementation by removing the
parameterization.

I tried to do this with a praxi but failed.

Or, is there some other alternative?

Great, I implemented it in ATS1 like this, and show how to use it to print
a list_vt:

extern
fun{a:t0p} print_val(x: a): void

implement
print_val (x) = print(x)

fun{a:t0p} print_lvt(xsl: !List_vt (a)): void =
begin (
list_vt_foreach_fun (xsl, lam x =<1> (print_val (x); print ’ '));
print_newline();
) end

In ATS2, this relies on the function ‘tostrptr_val’. Perhaps I am just
failing with my greps, but would it be useful if I implemented this for
some of the common types (int, double, char, strings, etc)?On Tuesday, January 14, 2014 3:50:18 PM UTC-5, gmhwxi wrote:

You can use ‘print_val (…)’ or fprint_val (…)'.

On Tuesday, January 14, 2014 3:39:01 PM UTC-5, Brandon Barker wrote:

Say you want to inspect the implementation of some parametric code
dynamically by printing data on test cases. print() does not work for any
t@ype, so it would be nice to assert:

a is printable
a = a specific type .

So as to not “dumb down” the implementation by removing the
parameterization.

I tried to do this with a praxi but failed.

Or, is there some other alternative?