Next: Editing Cabal files, Previous: Inferior Haskell interpreter, Up: Top [Index]
An alternative mode providing a REPL (read–eval–print loop) via
GHCi sessions is called haskell-interactive-mode
, which
effectively replaces inferior-haskell-mode
, but comes with a
different set of features:
In order to use haskell-interactive-mode
instead of the default
inferior-haskell-mode
, you need to replace some of the default
keybindings in the haskell-mode-map
keymap with the respective
haskell-interactive-mode
counterparts:
(eval-after-load "haskell-mode" '(progn (define-key haskell-mode-map (kbd "C-x C-d") nil) (define-key haskell-mode-map (kbd "C-c C-z") 'haskell-interactive-switch) (define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-file) (define-key haskell-mode-map (kbd "C-c C-b") 'haskell-interactive-switch) (define-key haskell-mode-map (kbd "C-c C-t") 'haskell-process-do-type) (define-key haskell-mode-map (kbd "C-c C-i") 'haskell-process-do-info) (define-key haskell-mode-map (kbd "C-c M-.") nil) (define-key haskell-mode-map (kbd "C-c C-d") nil)))
With haskell-interactive-mode
, each Haskell source buffer is
associated with at most one GHCi session, so when you call
haskell-process-load-file
for a Haskell source buffer which has
no session associated yet, you’re asked which GHCi session to create or
associate with.
Put :set +c
in your .ghci
or run it in the REPL. Then use
these keybindings:
(define-key interactive-haskell-mode-map (kbd "M-.") 'haskell-mode-goto-loc) (define-key interactive-haskell-mode-map (kbd "C-c C-t") 'haskell-mode-show-type-at)
You have to load the module before it works, after that it will remember for the current GHCi session.