[Haskell-cafe] Trace

Ben Derrett ben.derrett at googlemail.com
Fri Mar 19 16:03:52 EDT 2010

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?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100319/086ce7c5/attachment.html

More information about the Haskell-Cafe mailing list