Search code examples
haskellemacshaskell-mode

Haskell Emacs haskell-mode: Run 'C-h f haskell-mode' for instruction how to setup a Haskell interaction mode


I am following the tutorial in https://learnhaskell.blogspot.com/2007/09/lesson-1-hello-world.html

I followed all the instructions but on emacs when I type in C-c C-l, I get Run 'C-h f haskell-mode' for instruction how to setup a Haskell interaction mode

When I type that it takes me a page which is not very helpful.

What do I do next? I followed the steps exactly in the tutorial except for removing the version numbers for ghi, emacs for apt.

My .emacs file is as follows, exactly like in the blog.

;; Font Locking, Programming Modes, and Compilation settings
;;

(global-font-lock-mode 1)
;; maximum colors
(setq font-lock-maximum-decoration t)

;; extra key bindings
(global-set-key "\M-C" 'compile)
(global-set-key "\C-^" 'next-error)
(global-set-key "\C-\M-g" 'goto-line)

;; use spaces instead of tabs
(setq-default indent-tabs-mode nil)

;; haskell mode configuration
(setq auto-mode-alist
      (append auto-mode-alist
              '(("\\.[hg]s$"  . haskell-mode)
                ("\\.hic?$"     . haskell-mode)
                ("\\.hsc$"     . haskell-mode)
  ("\\.chs$"    . haskell-mode)
                ("\\.l[hg]s$" . literate-haskell-mode))))
(autoload 'haskell-mode "haskell-mode"
   "Major mode for editing Haskell scripts." t)
(autoload 'literate-haskell-mode "haskell-mode"
   "Major mode for editing literate Haskell scripts." t)

;adding the following lines according to which modules you want to use:
(require 'inf-haskell)

(add-hook 'haskell-mode-hook 'turn-on-font-lock)
;(add-hook 'haskell-mode-hook 'turn-off-haskell-decl-scan)
;(add-hook 'haskell-mode-hook 'turn-off-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
;(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent)
;(add-hook 'haskell-mode-hook 'turn-on-haskell-hugs)
(add-hook 'haskell-mode-hook 'turn-on-haskell-ghci)
(add-hook 'haskell-mode-hook 
   (function
    (lambda ()
      (setq haskell-program-name "ghci")
      (setq haskell-ghci-program-name "ghci6"))))


Solution

  • The minor-mode interactive-haskell-mode must be enabled to open an interactive session between your Haskell code buffer and a Haskell interpreter. You can enable this mode for the current buffer with the command M-x interactive-haskell-mode.

    To have this mode enabled for every Haskell file you open, you can set a haskell-mode hook that will run this command (i.e. will enable interactive-haskell-mode) every time haskell-mode is enabled. The following line should be added to your .emacs file:

    (add-hook 'haskell-mode-hook 'interactive-haskell-mode)