Portability | portable |
---|---|

Stability | provisional |

Maintainer | bram@typlab.com |

This module contains convenience methods for logging/tracing function calls and their arguments. More examples of how this library can be used can be found in Debug.TraceCall.Examples.

A traceCall function can be applied to a normal function and transforms that function into a function that will log its output. unsafeTraceCall takes as argument a pure function and transforms it into a function which uses Debug.Trace.trace to log its argument and result. The normal traceCall function works on function of the form a -> IO b and does its logging through IO.

For a tracecall to work all arguments should be an instance of Show. The only exception are function arguments. The normal traceCall functions will ignore the function arguments in their report. The -Deep versions of traceCall will also add traces to function arguments, so the usages of the function arguments will also be logged. To try this out, type in th following in ghci:

unsafeTraceCallDeep "map" map sqrt [1..5]

- traceCall :: TCIO a => String -> a -> a
- traceCallDeep :: TCDeepIO a => String -> a -> a
- unsafeTraceCall :: TCUnsafe a => String -> a -> a
- unsafeTraceCallDeep :: TCDeepUnsafe a => String -> a -> a

# Tracing functions

## IO tracing

traceCall transforms function of the form (MonadIO m ) => a -> m b to a function which log their arguments. It will not trace the calls of function arguments. To also trace the calls to function arguments use traceCallDeep.

traceCallDeep :: TCDeepIO a => String -> a -> aSource

## Pure tracing

This transforms pure functions to a function which logs its arguments via Debug.Trace.trace. It will not trace the calls of function arguments. To also trace the calls to function arguments use traceCallDeep.

unsafeTraceCall :: TCUnsafe a => String -> a -> aSource

unsafeTraceCallDeep :: TCDeepUnsafe a => String -> a -> aSource