Switch haskell-process-type between cabal-repl and ghci

595 views Asked by At

Can I switch the haskell-process-type on during an alive haskell session or when starting a new session?

2

There are 2 answers

4
Colin Woodbury On BEST ANSWER

Yes, just type the following in a buffer and C-x C-e it afterwards (assuming cabal-repl is your default).

(setq haskell-process-type 'ghci)

In my .emacs I actually have this to make this easy, since I do this often:

(define-key haskell-mode-map (kbd "C-c h t") 
  (lambda () (interactive)
    (progn
      (setq haskell-process-type 'ghci)
      (message "Now in ghci mode."))))

Another C-c C-l will then load your interactive buffer with the correct mode.

EDIT: Using haskell-mode-map now.

2
ase On

In the end I extended fosskers answer a bit!

A function to toggle the process type:

(defvar haskell-process-use-ghci nil)

(defun haskell-process-toggle ()
  "Toggle GHCi process between cabal and ghci"
  (interactive)
  (if haskell-process-use-ghci
      (progn (setq haskell-process-type 'cabal-repl)
             (setq haskell-process-use-ghci nil)
             (message "Using cabal repl"))
    (progn (setq haskell-process-type 'ghci)
           (setq haskell-process-use-ghci t)
           (message "Using GHCi"))))

and a haskell-mode specific keybinding:

(define-key haskell-mode-map (kbd "C-c C-h C-t") 'haskell-process-toggle)