
Do any of the decent Haskell compilers allow you to just type function definitions at an interpreter prompt and use them in subsequent interactions, as you'd expect from a Lisp environment? I'm fed up of editing a tiny file separately and typing :reload each time, etc. Surely I'm missing something obvious? -- Mark

On 2001-07-25T14:39:06-0400, Mark Carroll wrote:
Do any of the decent Haskell compilers allow you to just type function definitions at an interpreter prompt and use them in subsequent interactions, as you'd expect from a Lisp environment? I'm fed up of editing a tiny file separately and typing :reload each time, etc. Surely I'm missing something obvious?
GHCi is what you want: $ ghci ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 5.00.2, For Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help. Loading package std ... linking ... done. Prelude> let f x = x + x Prelude> f 3 6 Prelude> -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig « ne gâche pas ta vie pour leur idée de patrie » le bouton me dit

Mark Carroll writes:
Do any of the decent Haskell compilers allow you to just type function definitions at an interpreter prompt and use them in subsequent interactions, as you'd expect from a Lisp environment? I'm fed up of editing a tiny file separately and typing :reload each time, etc.
GHCi (part of GHC >= 5.00) allows you to use let to bind expressions at the prompt. E.g. you can do something like Prelude> let foo n = sum [1..n] Prelude> foo 1000 500500 which I agree with you is a very handy thing to be able to do. :-) Cheers, Chris.
participants (3)
-
Chris Webb
-
Ken Shan
-
Mark Carroll