sevo
sevo

Reputation: 4609

Is it possible join two modules as top-level in GHCI?

I discovered that changing order or paths given to :load changes visible bindings and it seems impossible to debug multiple modules at the same time. It is especially annoying as I lose bindings every time I :load.

It seems there can be only one module in *-form as suggested by wording of "the most recently successfuly loaded module". Despite that, the top level module seems to one given as first argument to :load.

Upvotes: 1

Views: 76

Answers (1)

Lamdas Everywhere
Lamdas Everywhere

Reputation: 1686

When I'm developing and I want to use two or more modules at once in GHCi, here's what I do. Let's say I want to use Control.Monad and Control.Lens, and my own module which I'm programming with called Main:

> :m Control.Lens Control.Monad

Now both Control.Lens and Control.Monad are in scope.

Now at this point, it seems I forgot to add Main, so I can easily put a + which will add modules. This is so handy, I usually always use it, I was showing you the above solely so you could see how to import multiple modules at once.

> :m + Main

Or, what I'd ordinarily do, as I just described:

> :m + Main Control.Lens Control.Monad

I think Main is usually included by default, but you get the picture :)

As to reloading, I use the :r command to reload, and yeah, it can suck that bindings are lost, but usually I put them into the code I'm writing in, sometimes temporarily, or I use the readline support of the OS to "go up" through the historical backscroll to find previous definitions.

Happy Haskelling!

Upvotes: 3

Related Questions