Hi,
I'm a new Haskell programmer and am trying to output the values of some of the variables (for debugging) as the program executes.
At the moment to output the value of the function I use:
f x y z = trace (show moves) moves
where moves = [complicated expression of x y z]
But really what I want is to be able to write:
f x y z = trace2 [complicated expression of x y z]
Is there a standard function to do this? I tried:
trace2 a = trace (show a) a
But I got the error:
Couldn't match expected type `t1 -> t'
against inferred type `String'
In the expression: (show a) a
In the definition of `trace2': trace2 a = (show a) a
How do I fix it?
Thanks,
Ben