[Haskell-cafe] Run haskell program in emacs without typing "main" in the ghci buffer.

Ivan Miljenovic ivan.miljenovic at gmail.com
Mon Apr 26 19:51:18 EDT 2010

On 27 April 2010 05:43, Zura_ <xyz at gol.ge> wrote:
> Is it possible to run haskell program in emacs without typing "main" in the
> ghci buffer? Assuming "main" function exists of course.
> Or, maybe automate sending "main\n" string to ghci buffer input.
> In other words, I want edit/run/see result style session.

This is probably possible if you have enough elisp-fu (which I don't,
but have a look at Flymake Haskell).

If so, it would be better to have this as a different emacs keybinding
rather than the default haskell-load-file one, as 1) you won't always
have a main action and 2) you won't always want to _run_ your main
action (e.g. it launches nuclear missiles and you don't want to run
that when you're just testing your countdown function...).

However, by using ":main" in the ghci session you have a bit more
control as it allows you to specify command-line flags and inputs,
which running just "main" doesn't.

Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com

More information about the Haskell-Cafe mailing list