2

分析选项不适用于光泽度,即使安装了光泽度并启用了库分析~/.cabal/config

示例:Test.hs

import Graphics.Gloss
main = display (InWindow "test" (800, 600) (200, 200)) black blank

编译和运行:

$ ghc Test.hs
[1 of 1] Compiling Test             ( Test.hs, Test.o )
Linking Test ...
$ ./Test +RTS -s

然后我用窗口的 x 按钮关闭窗口,但没有任何 gc 输出。

如果我将 Test.hs 更改为main = print "test"并重复这些步骤,它会输出一些与垃圾收集相关的信息,这就是应该发生的情况。

4

1 回答 1

0

使用 Graphics.Gloss 进行分析时,您需要在代码中显式处理程序的结尾。您可能想要硬编码动画的超时,或者捕捉一些键盘输入并手动结束程序(使用简单的东西unsafePerformIO exitSuccess)。

actionOnwindowClose似乎在光泽开发者的愿望清单上,但目前无法正常工作(https://github.com/benl23x5/gloss/blob/b41f867ffb6c05a40f778a29f99933b603c11a31/gloss/Graphics/Gloss/Internals/Interface/Backend/GLUT. hs#L61 )

于 2018-10-25T22:08:07.203 回答