Attempt at fixing #1873, #1360
authorSimon Marlow <simonmar@microsoft.com>
Fri, 16 Nov 2007 15:21:48 +0000 (15:21 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Fri, 16 Nov 2007 15:21:48 +0000 (15:21 +0000)
I think I figured out a reasonable way to manage the GHCi context,
comments welcome.

Rule 1: external package modules in the context are persistent.  That
is, when you say 'import Data.Maybe' it survives over :load, :add,
:reload and :cd.

Rule 2: :load and :add remove all home-package modules from the
context and add the rightmost target, as a *-module if possible.  This
is as before, and makes sense for :load because we're starting a new
program; the old home-package modules don't make sense any more.  For
:add, it usually does what you want, because the new target will
become the context.

Rule 3: any modules from the context that fail to load during a
:reload are remembered, and re-added to the context at the next
successful :reload.

Claus' suggestion about adding the "remembered" modules to the prompt
prefixed with a ! is implemented but commented out.  I couldn't
decide whether it was useful or confusing.

One difference that people might notice is that after a :reload where
there were errors, GHCi would previously dump you in the most recent
module that it loaded.  Now it dumps you in whatever subset of the
current context still makes sense, and in the common case that will
probably be {Prelude}.


No differences found