<div dir="ltr">I use printf-style debugging a lot, so I am always adding and removing applications of trace. There is the Debug.Trace.traceIO function that makes this easy to do in the IO monad (it just applies <span style="color:rgb(0,0,0)">hPutStrLn stderr), but is that specialisation to IO </span>unnecessary?<div>
<br></div><div style>I find myself always using this utility function:</div><div style><br></div><div style><div>traceM :: (Monad m) =&gt; String -&gt; m ()</div><div>traceM message = trace message $ return ()</div><div><br>
</div><div style>Which can be used to implement traceIO.</div><div><br></div><div><div>traceIO :: String -&gt; IO ()</div><div>traceIO = traceM</div></div><div><br></div><div style>That way I can traceM in whatever monad I am in. It is easier to add and remove an application of trace, because I do not have to wrap it around something, and I do not have to remember the return. Of course, you are still subject to however your monad chooses to order the execution of these traces, but that is what people expect when using trace.</div>
<div style><br></div><div style>Would traceM be a wanted addition to Debug.Trace?</div><div style><br></div><div style>Regards,</div><div style><br></div><div style>Chris Seaton</div><div style><div><br></div></div></div>
</div>