Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell: GHCi treats Ctrl-Y like Ctrl-Z

According to the haskeline documentation, typing CTRL+Y should pop the most recent entry from the kill-ring (e.g. the line I just deleted via CTRL+U). I'm finding that instead, it suspends the REPL, as if I'd typed CTRL+Z.

As a clumsy workaround, I've found that typing CTRL+V CTRL+Y pops from the kill ring as a plain CTRL+Y is supposed to do.

Is this a know bug, or is something else at play? Can I fix it? I'm running GHC version 8.0.2.

Not sure if it matters, but I'm running GHCi via stack (e.g. stack ghci), and I brew installed stack (macOS).

like image 853
ivan Avatar asked Sep 19 '17 01:09

ivan


1 Answers

Mac OS terminals/ttys have a concept of a "dsusp" or "delayed suspend" key, and Ctrl-Y is the usual key assigned. At the tty level, when a CTRL+Y is read, it acts a little like CTRL+Z. The difference is that CTRL+Z causes an immediate suspend when it's typed; CTRL+Y causes the suspend when the underlying process tries to read characters and the CTRL+Y marker pops up in the input stream.

(CTRL+V is usually assigned to the "lnext" key, which skips terminal processing by making the next key "literal", which is why CTRL+V Ctrl+Y works.)

Ideally, GHCi would check for "dsusp" functionality (it doesn't exist on Linux, for example) and disable it if it's detected, but it looks like it's not doing this.

In the meantime, you can disable your "dsusp" key by running:

stty dsusp undef

before you launch GHCi. Sticking this in your ".bashrc" and/or ".profile" is a good idea, since the functionality is largely useless.

like image 173
K. A. Buhr Avatar answered Oct 17 '22 15:10

K. A. Buhr