Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I persist the environment between GHCi reloads?

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

Is there some option to tell ghci keep it all?

like image 841
gorlum0 Avatar asked Sep 15 '11 08:09

gorlum0


1 Answers

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.

like image 195
n. 1.8e9-where's-my-share m. Avatar answered Sep 28 '22 03:09

n. 1.8e9-where's-my-share m.