[Haskell-beginners] Decent Haskell REPL?

Tom Tobin korpios at korpios.com
Sat Feb 20 14:08:52 EST 2010

On Sat, Feb 20, 2010 at 1:44 PM, Jon Harrop <jon at ffconsultancy.com> wrote:
> On Saturday 20 February 2010 16:33:30 Tom Tobin wrote:
>> I just hit C-c C-r in my Haskell source file's buffer to get it
>> reloaded in the inferior ghci shell.
>> I think it's best to think of the source file as your scratchpad for
>> editing, with the "main" function changed as you go along to show
>> relevant output for testing, and the inferior ghci buffer as just an
>> "output window" of sorts.  It's not the same as writing code directly
>> shell, but I actually prefer it this way for all languages now, not
>> just Haskell -- particularly since it's much nicer editing code in a
>> proper editor vs. in a shell.
> I see. What happens if your program is producing non-trivial output that takes
> a long time to compute? How do you get around complete recomputation at the
> evaluation of every new expression?

Hm, I'm not sure.  I do seem to lose any local "let" bindings I do in
the ghci window when I reload, and the manual for ghci doesn't seem to
offer any way to save values between reloads [1].  I know you can
avoid that in other languages' shells (e.g., Python).  One workaround
I can think of is to use the "binary" package to save intermediate
computations out to disk, but that seems somewhat cumbersome when
you're trying to quickly prototype your code.

[1] http://www.haskell.org/ghc/docs/latest/html/users_guide/interactive-evaluation.html

More information about the Beginners mailing list