trace
When called, trace outputs the string in its first argument, before returning the second argument as its result. The trace function is not referentially transparent, and should only be used for debugging, or for monitoring execution. Some implementations of trace may decorate the string that's output to indicate that you're tracing. The function is implemented on top of putTraceMsg.
Like trace, but uses show on the argument to convert it to a String.
> traceShow = trace . show
trace-call provides generic functions for logging the arguments and results of function calls
Version 0.1
Example:
You have a pure function that may be giving you incorrect results.
> fib :: Int -> Int
> fib n | n < 2 = n
> | otherwise = fib (n-1) - fib (n-2)
>>> fib 3 0
Insert a call to traceFunction to aid with debugging.
> fib, fib' :: Int -> Int
> fib = traceFunction "fib" fib'
> fib' n | n < 2 = n
> | otherwise = fib (n-1) - fib (n-2)
Calls to your pure function now provide its parameters and result as debugging information.
>>> fib 3 fib 1 = 1 fib 0 = 0 fib 2 = 1 fib 1 = 1 fib 3 = 0 0
Hopefully this will help you home in on your bug.
Note that traceFunction works with functions of more than one parameter...
> traceElem :: Eq a => a -> [a] -> Bool
> traceElem = traceFunction "elem" elem
...and with "functions" of no parameters at all.
> alpha = traceFunction "Fine-structure constant" $
> e * e * c * mu0 / 2 / h
Parameters and results must implement the Show typeclass. As a special case, parameters may instead be functions, and are shown as an underscore (_).
>>> :set -XNoMonomorphismRestriction >>> let map' = traceFunction "map" map >>> map' (2 *) [1..3] map _ [1,2,3] = [2,4,6] [2,4,6]
KNOWN BUG: The resultant function is strict, even when the input function is non-strict in some of its parameters. In particular,
* if one of the parameters is error "foo", the return value when the resultant function call is evaluated will be error "foo"; no trace message will be output
* if one of the parameters doesn't terminate when evaluated, the resultant function call will not terminate when evaluated either; no trace message will be output
Version 0.1
The module defines a type constructor Traced, which allows evaluation of values to be traced. Instances for all numeric types make tracing numeric evaluation especially easy.
Version 2009.7.20
Functions that should have been in Debug.Trace
Version 0.1.0.1
putTraceMsg function outputs the trace message from IO monad. Usually the output stream is System.IO.stderr but if the function is called from Windows GUI application then the output will be directed to the Windows debug console.
Convenience functions and instances for tracing, based on Debug.Trace.
Version 0.12
Haskell interface to the DTrace system tracing utility
Version 0.1
A ray tracing library with acceleration structure and many supported primitives.
Version 0.1.2
HarmTrace: Harmony Analysis and Retrieval of Music with Type-level Representations of Abstract Chords Entities
We present HarmTrace, a system for automatically analysing the harmony of music sequences. HarmTrace is described in the paper:
* Jose Pedro Magalhaes and W. Bas de Haas. Experience Report: Functional Modelling of Musical Harmony. International Conference on Functional Programming, 2011. http://dreixel.net/research/pdf/fmmh.pdf
Version 1.0
An incomplete component of the Hpc toolkit which provides the ability to step through coverage ticks as they happen, giving a poor mans debugger. Requires the binary being traced to be build using a specific version of ghc-6.7, so YMWV. The plan is to port this to the new GHC API, giving both tracing and free variable examination via an Ajax interface.
Version 0.3.1
Hierarchical tracing (like Debug.Trace.trace but with indentation) for debugging of lazy evaluation
Version 0.1
An interface for using ptrace to inspect the state of other processes, under Linux.
Version 0.1.2