Can I switch the haskell-process-type on during an alive haskell session or when starting a new session?
Asked
Active
Viewed 562 times
2 Answers
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
-
Would `(define-key haskell-mode-map ...)` work aswell? – ase Dec 05 '14 at 10:50
-
And should that be `C-x C-e` to evaluate? – ase Dec 05 '14 at 10:53
-
You're right, I've made the correction. I'm not sure about `haskell-mode-map`. – Colin Woodbury Dec 06 '14 at 22:41
-
Could you put an edit in the OP explaining what you did? – Colin Woodbury Dec 07 '14 at 08:59
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