This user guide:
http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-debugger.html
advertises:
Execution can be single-stepped: the evaluator will suspend execution approximately after every reduction, allowing local variables to be inspected. This is equivalent to setting a breakpoint at every point in the program.
Yet, I can find nothing in the document that tells me how to do that. Under the heading:
2.5.2. Single-stepping
It describes how to step from breakpoint to breakpoint. But I don't want to have to set a breakpoint on every line. Was the advertisement false or is there a way to step through a program line by line?
Thanks.
Stepping Into a FunctionSet a breakpoint at the function call line. Step through your code line by line until you reach the function call. While the program is paused at the function call line, click the Step Into button.
Stepping through code means executing the code one line at a time. Stepping allows you to see the exact sequence of execution and the value of the various variables at each step. This can be invaluable when your script is not giving the results that you expect.
"Step into" will stop on the first executable line inside the function. Note, if you have optimisation enabled, the "first executable line" may not be the one you expect. 8/15/2021. 1and0. There is also a "Step Out" allowing you to step out of a function which you are currently stepping through.
The step up command returns the program to the caller function after you have stepped into a function.
After having set and reached a breakpoint, you can call :step
from the debugger.
There are other single-step possibilities. Typing :help
once at a breakpoint would tell you more about what you can do.
Okay, I figured it out:
ghci> :step function_name arg1 arg2
...
...
ghci> :step
...
...
ghci> :step
If you forget the function arguments, then you will get the cryptic error message:
<interactive>:138:1:
No instance for (Show (String -> Double))
arising from a use of `print'
Possible fix:
add an instance declaration for (Show (String -> Double))
In a stmt of an interactive GHCi command: print it
...which might lead you to tear your hair out. And if you want to skip to the end:
ghci> :continue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With