Function passing line by line

This user guide:

http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-debugger.html

advertises:

Execution can be one-step: the evaluator pauses execution after about each reduction, allowing local variables to be inspected. This is equivalent to setting a breakpoint at each point in the program.

However, I cannot find anything in the document that tells me how to do this. Under the heading:

2.5.2. Step by step

It describes how to go from a breakpoint to a breakpoint. But I do not want to set a breakpoint on each line. Was the announcement false or is there a way to execute the program line by line?

Thanks.

+4
source share
2 answers

OK I understood:

ghci> :step function_name arg1 arg2 ... ... ghci> :step ... ... ghci> :step 

If you forget the function arguments, you will receive a critical 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 can cause hair to be torn out. And if you want to skip to the end:

 ghci> :continue 
+3
source

After setting and reaching a breakpoint, you can call :step from the debugger.

There are other one-step options. Input :help once at a breakpoint will tell you more about what you can do.

+6
source

Source: https://habr.com/ru/post/1481842/


All Articles