[Haskell-cafe] Correctly setting up emacs + ghc-mod

Arnaud Bailly arnaud.oqube at gmail.com
Fri Apr 18 14:20:07 UTC 2014


Hello,

I am struggling to get my emacs settings right for doing significant Haskell development, eg. something more involved than a bunch of source files in a single directory. The issue I am running in currently is that when trying to load files in the interpreter, most source paths are missing which means loading inevitably fails. This is especially annoying with tests: To get things working correctly I need to explicitly add in the console

> :set -iwhere/my/src/are

Is there any configuration I should be aware of in my cabal files or .emacs file that would correctly set the source roots? Am I missing something?

Here is my .emacs configuration. Thanks for any help.

;; haskell coding                                                                                                                                                                                          
(require 'auto-complete)
(require 'haskell-mode)
(require 'haskell-cabal)

(autoload 'ghc-init "ghc" nil t)

(add-hook 'haskell-mode-hook (lambda () (ghc-init)))

(eval-after-load "haskell-mode"
  '(progn
     (setq haskell-stylish-on-save t)
     (setq haskell-process-args-cabal-repl '("--ghc-option=-ferror-spans"
               "--with-ghc=ghci-ng"))

     (define-key haskell-mode-map (kbd "C-,") 'haskell-move-nested-left)
     (define-key haskell-mode-map (kbd "C-.") 'haskell-move-nested-right)
     (define-key haskell-mode-map (kbd "C-c v c") 'haskell-cabal-visit-file)
     (define-key haskell-mode-map (kbd "C-c C-c") 'haskell-compile)
     (define-key haskell-mode-map (kbd "C-x C-d") nil)
     (setq haskell-font-lock-symbols t)

     ;; Do this to get a variable in scope                                                                                                                                                                 
     (auto-complete-mode)

     ;; from http://pastebin.com/tJyyEBAS                                                                                                                                                                  
     (ac-define-source ghc-mod
       '((depends ghc)
         (candidates . (ghc-select-completion-symbol))
         (symbol . "s")
         (cache)))

     (defun my-ac-haskell-mode ()
       (setq ac-sources '(ac-source-words-in-same-mode-buffers
                          ac-source-dictionary
                          ac-source-ghc-mod)))
     (add-hook 'haskell-mode-hook 'my-ac-haskell-mode)


     (defun my-haskell-ac-init ()
       (when (member (file-name-extension buffer-file-name) '("hs" "lhs"))
         (auto-complete-mode t)
         (setq ac-sources '(ac-source-words-in-same-mode-buffers
                            ac-source-dictionary
                            ac-source-ghc-mod))))
     (add-hook 'find-file-hook 'my-haskell-ac-init)))

(add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)

(eval-after-load "which-func"
  '(add-to-list 'which-func-modes 'haskell-mode))

(eval-after-load "haskell-cabal"
    '(define-key haskell-cabal-mode-map (kbd "C-c C-c") 'haskell-compile))

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140418/2b632eab/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140418/2b632eab/attachment.sig>


More information about the Haskell-Cafe mailing list