2

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

ase
  • 13,231
  • 4
  • 34
  • 46

2 Answers2

2

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.

Colin Woodbury
  • 1,799
  • 2
  • 15
  • 25
2

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)
ase
  • 13,231
  • 4
  • 34
  • 46
  • I agree now that `haskell-mode-map` is better to use. Also, instead of the `defvar`, you can just test directly on `haskell-process-type` like: `(if (equal 'ghci haskell-process-type) ...)` – Colin Woodbury Dec 11 '14 at 02:16
  • I also use the variable in some other part of my config not included here, and it makes for nicer code I believe. – ase Dec 14 '14 at 15:25