GHCi中的Haskell语句被中断似乎破坏了cmd [英] Haskell statements in GHCi being interrupted seems to break cmd
问题描述
我只是从Haskell开始,然后在cmd中玩GHCi。在尝试在PPCG上看到的内容后,我遇到了一个问题。每当我用Control-C中断 fix
时,所有操作都会死亡:
C :\用户\Scrooble> ghci
GHCi,版本8.2.1:http://www.haskell.org/ghc/:?寻求帮助
Prelude>导入Data.Function
前奏Data.Function>修复(\x-> x + 1)
In ^ tCerrupte
d。
C:\用户\Scrooble> Prelude Data.Function>退出
(挂起)
code> ^ 和 C
是我的键盘中断。 退出
也是我的。
已损坏
是对!到底是怎么回事?!我似乎已经退出了GHCi。当我中断退出
(再次提示 Prelude Data.Function>
)和:q时
,它有时会关闭,有时会再次提示我;但是,发生这种情况时,我所有命令的第一个字符都会被忽略!
C:\Users\Scrooble> exit
'xit'不被识别为内部或外部命令,
可操作程序或批处理文件。
0.o
我一个人在这?是否有修复程序
(ha)(不是不做愚蠢的事情)?
HP ProBook 4535s(带有Windows) 7 Professional,64位。 AMD A4-3300M APU处理器。
在PowerShell中也是如此。在Git Bash中,我中断 fix
后窗口冻结。
编辑:
我现在在打断其他无限递归时就遇到了这种情况,例如我的mergesort(哇!)并没有将单例视为必须排序。
似乎您正在运行已安装Haskell平台在Windows上。我习惯了这一点,但是如今,我通过 Stack 运行所有内容,因此我可能会错误地记住以下内容。 / p>
IIRC,但是,当您尝试在Windows中运行 ghci
时,它将显式显示警告消息,即 ghci
在Windows上的break命令存在问题,因此您应该通过批处理命令 ghcii.bat
运行GHCi。
当我使用Haskell平台时,我总是与 ghcii.bat
一起运行,通常没有问题。我一直在Git Bash中使用Haskell,这是Windows上的默认CLI,所以这也可能是一个决定性因素。
这些天,我在Windows 10,以及在Git Bash中,我无法重现该问题:
$ stack ghci
Prelude> :m + Data.Function
前奏Data.Function>修复(\x-> x + 1)
中断。
Prelude Data.Function>
Interrupted。
行是我打到的地方 Ctrl + C 。当我这样做时, fix
的阻止应用程序立即退出,REPL已准备好采取行动。
I'm just beginning with Haskell and playing around with GHCi in cmd. After trying out something I saw on PPCG, I ran into an issue. Whenever I interrupt fix
with control-C, everything dies:
C:\Users\Scrooble>ghci
GHCi, version 8.2.1: http://www.haskell.org/ghc/ :? for help
Prelude> import Data.Function
Prelude Data.Function> fix (\x -> x + 1)
In^tCerrupte
d.
C:\Users\Scrooble>Prelude Data.Function> exit
(hangs)
The ^
and C
were my keyboard interrupt. The exit
is mine as well.
Cerrupted
is right! What is going on?! I seem to have halfway exited GHCi. When I interrupt the exit
(prompt is Prelude Data.Function>
again) and :q
it, cmd sometimes just closes and sometimes prompts me with C:\Users\Scrooble
once more; however, when this happens, the first character of all my commands is ignored!
C:\Users\Scrooble>exit
'xit' is not recognized as an internal or external command,
operable program, or batch file.
0.o
Am I alone in this? Is there a fix
(ha) (other than not doing stupid things)?
HP ProBook 4535s, with Windows 7 Professional, 64-bit. AMD A4-3300M APU processor.
The same happens in PowerShell as well. In Git Bash, the window freezes after I interrupt the fix
.
Edit:
I've now experienced this when interrupting other infinite recursion, like my mergesort that (whoops!) didn't treat singletons as necessarily sorted.
It looks like you're running Haskell platform installed on Windows. I used to to that, but these days I run everything through Stack, so I may remember the following incorrectly.
IIRC, though, when you attempt to run ghci
in Windows, it explicitly prints a warning that ghci
is known to have problems with break commands on Windows, and that you should instead run GHCi via the batch command ghcii.bat
.
Back when I used the Haskell platform, I always ran with ghcii.bat
, and typically didn't have those problems. I've always used Haskell from within Git Bash, which is my default CLI on Windows, so that could be a determining factor as well.
These days I use Stack on Windows 10, and from within Git Bash, I can't reproduce the problem:
$ stack ghci
Prelude> :m +Data.Function
Prelude Data.Function> fix (\x -> x + 1)
Interrupted.
Prelude Data.Function>
The Interrupted.
line is where I hit Ctrl+C. When I did that, the blocking application of fix
immediately exited, and the REPL was ready for action.
这篇关于GHCi中的Haskell语句被中断似乎破坏了cmd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!