mherzl
mherzl

Reputation: 6200

How to exit a running computation in the Ghci debugger?

I am in the process of learning to use the Ghci debugger, following the debugger section of the GHCi user guide.

Following those instructions and that example I am able to set breakpoints and run code such that the debugger stops at them.

*Main> :break qsort                                                                     │~                                                                                      
Breakpoint 0 activated at qsort.hs:2:12-13                                              │~                                                                                      
Breakpoint 1 activated at qsort.hs:3:16-47                                              │~                                                                                      
*Main> main                                                                             │~                                                                                      
Stopped in Main.qsort, qsort.hs:3:16-47                                                 │~                                                                                      
_result :: [Integer] = _                                                                │~                                                                                      
a :: Integer = 8                                                                        │~                                                                                      
left :: [Integer] = _                                                                   │~                                                                                      
right :: [Integer] = _                                                                  │~                                                                                      
[qsort.hs:3:16-47] *Main> 

I reach a point where the debugger has stopped the program mid-execution. From this state, when I want to re-run the program from its start, I typically quit ghci via :q and restart ghci, reloading the program entirely.

How can I exit the running program, in order to re-run main from the start without having to exit ghci? Preferably this could be done without needing to reset breakpoints either.

Upvotes: 2

Views: 961

Answers (1)

mherzl
mherzl

Reputation: 6200

:abandon

To find this command in ghci documentation:

From within ghci, run :? to bring up ghci's Commands available from the prompt help doc, where :abandon can be found within the Commands for debugging section.

 -- Commands for debugging:

   :abandon                    at a breakpoint, abandon current computation

Upvotes: 2

Related Questions