traceM :: (Monad m) => String -> m ()
traceM message = trace message $ return ()
Which can be used to implement traceIO.
traceIO :: String -> IO ()
traceIO = traceM
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.
Would traceM be a wanted addition to Debug.Trace?
Regards,
Chris Seaton