Haskell code can be debugged using Debug.Trace (trace), to show the evaluation
of variables for each call of a function.
trace is inserted in the function with the following syntax
<function name> = trace (<string to display on evaluation>) (<function body>)Examples
import Debug.Trace (trace)
(^) :: Int -> Int
:{
m ^ 0 = 1
m ^ n = trace (show m ++ "^" ++ show n) (m * (m ^ (n-1)))
:}
2^32^3 2^2 2^1 8