如何在两次GHCi重新加载之间保持环境? [英] How can I persist the environment between GHCi reloads?

查看:45
本文介绍了如何在两次GHCi重新加载之间保持环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,当我:load name.hs 时,变量和绑定都消失了.

有什么办法告诉ghci保留所有内容吗?

解决方案

要加载新模块,可以使用

  Prelude>:m + Mymodule 

但是重新加载和保持交互式绑定通常是不可能的.重新加载本质上是忘记了所有模块,然后再次加载它们.绑定可能取决于已经加载的模块.依赖关系逻辑规定,当GHCI忘记模块时,它还需要忘记依赖于它的所有内容,包括交互式绑定.

GHCI可以例如存储用于创建绑定的命令的文本,并在重装时尝试重新运行这些命令,因为其中某些命令可能会失败.但这很快就会变得很毛茸茸,所以还没有完成.

Basically when I :load name.hs the variables and bindings are gone.

Is there some option to tell ghci keep it all?

解决方案

To load a new module, you can use

Prelude> :m + Mymodule

But reloading and keeping interactive bindings is not generally possible. Reloading is essentially forgetting all modules and loading them again. The bindings could depend on already loaded modules. The dependency logic dictates that when GHCI forgets a module, it also needs to forget everything that depends on it, including interactive bindings.

GHCI could e.g. store the text of commands that where used to create the bindings, and try to re-run those commands on reload, knowing that some of them might fail. But this can get hairy very quickly, so it's not being done.

这篇关于如何在两次GHCi重新加载之间保持环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆