When I program in Javascript, I find it extremely convenient to be able to use the debugger to halt program execution at any point and to be able to runs commands and inspect variables from there.
Now, back in Haskell, is there a way to run arbitrary functions in the interactive GHCI REPL or am I limited to things declared at the toplevel?
What is the “standard” approach to working and debugging inner functions and values?
When you are stopped at a breakpoint in GHCi, you can access anything that’s in scope. Let’s say you have a function like this:
You can set a breakpoint on
fooand try calling it:gis not in scope yet at this point, so we have to step once:Now that
gis in scope, we can use it like any top-level function: