I find this to be an invaluable tool:
import terminal
template echox(x: typed) =
terminal.setForegroundColor stdout, fgRed
echo x.astToStr
terminal.setForegroundColor stdout, fgBlue
echo x
terminal.resetAttributes()
proc f(x = 3): int = x
echox 1 + 2 * f()
output (without colors):
1 + 2 * f(3)
7
This could be extended with this for example http://nim-lang.org/docs/system.html#instantiationInfo