GHCi - 第二次运行时跳过断点
我是 Haskell 的新手,在调试时遇到了令人讨厌的行为。
- 我使用 :break 添加断点
- 我运行 main
- 一切正常
- 我输入 :continue 完成执行
当我重新运行 main 时,断点不再命中,但断点没有被删除,因为 :show Breaks 列出了它。有人知道发生了什么事吗?
我使用的是 Ubuntu 11.10,64 位。明天我会在不同的环境下测试它。
谢谢
I'm new to Haskell and I'm getting an annoying behaviour when debugging.
- I add my break point using :break
- I run main
- Everything is ok
- I type :continue to finish the execution
When I rerun main, the breakpoint does not hit anymore but the breakpoint wasn't removed because :show breaks lists it. Anyone knows what's going on?
I'm on Ubuntu 11.10, 64 bits. I'll test it on a different environment tomorrow.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果不看代码就很难知道,但听起来很可能在第二次运行 main 时永远不会到达断点,因为结果由于惰性求值而被缓存。第一次可能是 THUNK(暂停评估),第二次已经评估了。
It's hard to know without seeing the code, but it sounds likely that on the second run of main the breakpoint is never reached because the result is cached because of lazy evaluation. It probably was a THUNK (a suspended evaluation) first time, and the second time it is already evaluated.
为了避免重新计算,常量应用程序表单被替换为对其 redex 的间接引用。
例如,在下面的代码片段中,“papperlap”的右侧将被替换为指向“4”的间接节点。
如果您在“bla”上设置断点并请求“paperlap”两次,您将看到“bla”仅应用一次。但如果你两次请求“bla 3”,我们也会停止两次:
To avoid recomputations constant application forms are replaced with an indirection to its redex.
For example the following snippet the right hand side of 'papperlap' will be replaced with an indirection node pointing to '4'.
If you set a breakpoint on 'bla' and ask for 'papperlap' twice you will see that 'bla' is applied only once. But if you ask for 'bla 3' twice, we will also stop twice: