View Source gradualizer_tracer (gradualizer v0.2.0)
A utility module to make troubleshooting problems by tracing Gradualizer internals more efficient. Configuration of this module is compile time, but using the tracing facilities is more efficient than traditional printf-debugging anyway.
Together with the shell interface of gradualizer
, we can use this module to inspect or debug the inner workings of the type checker live. Watch out for the trace sizes - they can grow huge!
> gradualizer_tracer:start().
ok
> gradualizer:type_of("[a]").
{trace,<0.1296.0>,call,
{typechecker,type_check_expr,[{venv,#{}},{cons,1,{atom,1,a},{nil,1}}]}}
{trace,<0.1296.0>,call,{typechecker,type_check_expr,[{venv,#{}},{atom,1,a}]}}
{trace,<0.1296.0>,return_from,
{typechecker,type_check_expr,2},
{{atom,0,a},{venv,#{}},{constraints,#{},#{},#{}}}}
{trace,<0.1296.0>,return_to,{typechecker,do_type_check_expr,2}}
{trace,<0.1296.0>,call,{typechecker,type_check_expr,[{venv,#{}},{nil,1}]}}
{trace,<0.1296.0>,return_from,
{typechecker,type_check_expr,2},
{{type,0,nil,[]},{venv,#{}},{constraints,#{},#{},#{}}}}
{trace,<0.1296.0>,return_to,{typechecker,do_type_check_expr,2}}
{trace,<0.1296.0>,return_from,
{typechecker,type_check_expr,2},
{{type,0,nonempty_list,[{atom,0,a}]},
{venv,#{}},
{constraints,#{},#{},#{}}}}
{trace,<0.1296.0>,return_to,{g,type_of,2}}
{type,0,nonempty_list,[{atom,0,a}]}
Link to this section Summary
Link to this section Functions
debug/1
is a trace point to trace when pinpointing issues across several candidate locations. Uncomment the below in start/0
:
dbg:tpl(?MODULE, debug, x)
Then insert the following somewhere in code, recompile and check the trace for the line from which debug/1
was called:
gradualizer_tracer:debug(?LINE)
Start tracing.
Check out the source code of this function to see trace pattern examples matching specific parts of the type checker. Uncomment the relevant ones or add your own, recompile the project, and start tracing.