12

When in a Haskell file, I use C-c C-l to run the command inferior-haskell-load-file which is intended to load the current file into the GHCI interpreter but Emacs just hangs until I hit C-g. Anyone know how I can get this to work?

GNU Emacs 23.3.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.5) of 2011-08-14 on allspice, modified by Debian

Using haskell-mode version v2.7.0

Luke Hoersten
  • 8,355
  • 3
  • 21
  • 18
  • 1
    Do you have a customised `.ghci` file? That might interfere, especially if you change the prompt... Otherwise, do you have a problem if you launch with "emacs -Q" and then explicitly load just the defaults? – ivanm Nov 02 '11 at 01:23
  • @ivanm that was it! Add it as the answer please. – Luke Hoersten Nov 03 '11 at 01:40

4 Answers4

11

inferior-haskell-mode does some parsing based upon the expected ghci prompt. As such, if you change the prompt in a .ghci file, then it can't detect it.

For more information, see where haskell-ghci.el sets the comint-prompt-regexp value to determine what a prompt is.

;; GHCi prompt should be of the form `ModuleName> '.
(setq comint-prompt-regexp
      "^\\*?[[:upper:]][\\._[:alnum:]]*\\( \\*?[[:upper:]][\\._[:alnum:]]*\\)*> ")

If you want to keep the setting in your .ghci file, then it may be possible to customise this settings.

ivanm
  • 3,927
  • 22
  • 29
  • Great tip. Thanks so much. You've saved me a ton of headache. – Luke Hoersten Nov 04 '11 at 14:02
  • Many of us have this in .ghci: `:set prompt "λ> "`. It would be nice to include λ by default in the pattern. – gawi Aug 16 '12 at 13:38
  • I'm out of luck trying to modify the regexp in order to accept "λ> ". This must be some regexp non-ascii issue... – gawi Aug 16 '12 at 14:26
  • 1
    @gawi: if you use Christopher Done's stuff that's currently in github then it uses λ> as the prompt. – ivanm Aug 18 '12 at 09:00
3

Old question, but as I just ran into this today, I wanted to share how to actually customize comint-prompt-regexp since I had to figure it out.

This customization will recognize λ> prompts, or actually any single character before >), but it doesn't break the existing regex. In your .emacs:

(load-library "inf-haskell")

(defun my-inf-haskell-hook ()
  (setq comint-prompt-regexp 
        (concat comint-prompt-regexp "\\|^.> ")))

(add-to-list 'inferior-haskell-mode-hook 'my-inf-haskell-hook)

You can add more dots to "\\|^.> " to recognize a longer prompt, but I wanted to keep it fixed-length for simplicity.

spopejoy
  • 791
  • 6
  • 5
0

I got the same error message when I tried to use stack with emacs. For me, adding this line to my .emacs/init.el resolved the problem:

(setq haskell-program-name "stack ghci")
Tad
  • 597
  • 5
  • 10
0

I had a similar problem caused by GHCi reporting some kind of error on startup, causing the Emacs haskell mode to wait for the GHCi prompt indefinitely (GHCi didn't show the standard prompt (Prelude>), but rather just showed >). You can try running GHCi externally and see if it reports any errors.

Rotsor
  • 13,655
  • 6
  • 43
  • 57