Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to abort execution in GHCI?

Tags:

haskell

ghci

When I launch

ghci> last [0..]

I can interrupt it with Ctrl+C.

However

ghci> last (repeat 0)

cannot be aborted with Ctrl+C. GHCI silently ignores the keystrokes.

How to abort this command in GHCI? Is it a bug?

like image 833
ominug Avatar asked Jun 16 '15 19:06

ominug


2 Answers

You can quit GHCI using :quit command

Prelude> :quit
Leaving GHCi.

Or by pressing Control+D that sends EOF signal.

If GHCI is busy you have no choice other than killing the process manually.

like image 21
ivanjermakov Avatar answered Oct 02 '22 13:10

ivanjermakov


(Caveat lector: I use Linux, and run zsh on urxvt or gnome-terminal. If you use a different operating system, terminal, or shell, it's possible this will work differently for you.)

The way I usually handle this is to hit Ctrl+Z (which puts it in the background, pausing execution entirely as a side-effect) then kill the job. Usually this is kill %1, though you can run jobs to double-check.

You can also start a new terminal and do something like killall -9 ghci, but this has a much higher resource cost: you are spawning a few new processes, opening X connections, doing whatever it is your terminal does when it initializes itself, doing whatever it is your shell does when it initializes itself, etc. If you're in the situation I often find myself in -- ghci is swapping like crazy -- that just gives ghci more time to screw things up.

like image 122
Daniel Wagner Avatar answered Oct 02 '22 13:10

Daniel Wagner