trace package:ghc-lib-parser

The trace function outputs the trace message given as its first argument, before returning the second argument as its result. For example, this returns the value of f x and outputs the message to stderr. Depending on your terminal (settings), they may or may not be mixed.
>>> let x = 123; f = show

>>> trace ("calling f with x = " ++ show x) (f x)
calling f with x = 123
"123"
The trace function should only be used for debugging, or for monitoring execution. The function is not referentially transparent: its type indicates that it is a pure function but it has the side effect of outputting the trace message.
Tracing utilities
Trace a command (when verbosity level >= 3)
Record in the eventlog when the given tool command starts and finishes, prepending the given String with "systool:", to easily be able to collect and process all the systool events. For those events to show up in the eventlog, you need to run GHC with -v2 or -ddump-timings.
Outputs a debugging message at verbosity level of -v or higher
Output a string debugging message at verbosity level of -v or higher
If debug output is on, show some SDoc on the screen along with a call stack when available.
If debug output is on, show some SDoc on the screen
pprTraceException desc x action runs action, printing a message if it throws an exception.