<meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: verdana, geneva, helvetica, arial, sans-serif; font-size: 13px; border-collapse: collapse; ">Hi, <br>I'm a new Haskell programmer and am trying to output the values of some of the variables (for debugging) as the program executes. <br>
<br>At the moment to output the value of the function I use: <br>f x y z = trace (show moves) moves <br> where moves = [complicated expression of x y z] <br><br>But really what I want is to be able to write: <br>f x y z = trace2 [complicated expression of x y z] <br>
<br>Is there a standard function to do this? I tried: <br>trace2 a = trace (show a) a <br><br>But I got the error: <br> Couldn't match expected type `t1 -> t' <br> against inferred type `String' <br>
In the expression: (show a) a <br> In the definition of `trace2': trace2 a = (show a) a <br><br>How do I fix it? <br><br>Thanks, </span><br clear="all"><br>
<div>Ben</div>