UPDATE 2017
now that we have Intero I would suggest you try Intero / Stack - it works pretty well.
With it, my configuration is reduced even lower:
;; ---------------------------------------------------------------------- ;; HASKELL (require 'haskell-mode) (require 'intero) (add-hook 'haskell-mode-hook 'intero-mode) (require 'flycheck) (setq flycheck-check-syntax-automatically '(save new-line)) (flycheck-add-next-checker 'intero '(warning . haskell-hlint))
Regarding REPL , you basically just upload the file and then Cc Cl to repl (you can always switch between two windows with Cc Cz and you can clear the relay with Cc Ck (when inside).
The only drawback is that Intero is usually installed locally in your project, so the first start in a new project will take some time for Intero to load / compile / download, but that doesn't really matter and you get a lot.
UPDATE
Now that the stack works and works fine, I would recommend setting haskell-process-type to auto and possibly installing ghc-mod using the stack.
here is the current setting I'm using:
(require 'haskell-mode) (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) (add-hook 'haskell-mode-hook 'linum-mode) (add-to-list 'exec-path "~/.local/bin") (eval-after-load 'haskell-mode '(progn (define-key haskell-mode-map (kbd "Cc Cl") 'haskell-process-load-file) (define-key haskell-mode-map (kbd "Cc Cn Ct") 'haskell-process-do-type) (define-key haskell-mode-map (kbd "Cc Cn Ci") 'haskell-process-do-info) (define-key haskell-mode-map "\C-ch" 'haskell-hoogle))) (eval-after-load 'haskell-cabal '(progn (define-key haskell-cabal-mode-map (kbd "Cc Ck") 'haskell-interactive-ode-clear) (define-key haskell-cabal-mode-map (kbd "Cc Cc") 'haskell-process-cabal-build) (define-key haskell-cabal-mode-map (kbd "Cc c") 'haskell-process-cabal))) (require 'company-ghci) (push 'company-ghci company-backends) (add-hook 'haskell-mode-hook 'company-mode) (add-hook 'haskell-interactive-mode-hook 'company-mode)
As you can see, I basically got rid of all the ghc-mod related stuff (the stack works as it is with the current haskell-mode ) and replaced the company backend (although this one is really slow and I hope to find something better)
variables
Theses you usually install in Emacs / Configuration Haskell-Mode
(custom-set-variables ;; there is of course more in here - these are the Haskell related: '(haskell-font-lock-symbols (quote unicode)) '(haskell-hoogle-command nil) '(haskell-mode-hook (quote (linum-mode turn-on-haskell-indentation turn-on-haskell-doc-mode)) t) '(haskell-process-auto-import-loaded-modules t) '(haskell-process-load-or-reload-prompt t) '(haskell-process-log t) '(haskell-process-suggest-language-pragmas nil) '(haskell-process-suggest-no-warn-orphans t) '(haskell-process-type (quote auto)) '(haskell-process-use-presentation-mode t) '(haskell-tags-on-save t) '(inferior-haskell-wait-and-jump t) '(safe-local-variable-values (quote ((haskell-process-use-ghci . t) (haskell-indent-spaces . 4)))) (uniquify)))
These are the packages I added:
- Haskell mode
- company (not Haskell related, not addiction)
- inter-company
- GHCi company
- GHCi termination
- shakespeare mode (for Yesod)
- company-quickhelp (for a good display
:i )
First
if it asks for your cabal directory - it wants to know where your myProject.cabal file is myProject.cabal - if you don't have one, just take the folder your file is in (by default - I think by default / find never let me down still).
if you need a sample .emacs-setup
Here is the part of my .emacs file that works for me:
(autoload 'ghc-init "ghc" nil t) (autoload 'ghc-debug "ghc" nil t) (add-hook 'haskell-mode-hook (lambda () (ghc-init))) (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) (eval-after-load 'haskell-mode '(progn (define-key haskell-mode-map (kbd "Cc Cl") 'haskell-process-load-or-reload) (define-key haskell-mode-map (kbd "C-`") 'haskell-interactive-bring) (define-key haskell-mode-map (kbd "Cc Cn Ct") 'haskell-process-do-type) (define-key haskell-mode-map (kbd "Cc Cn Ci") 'haskell-process-do-info) (define-key haskell-mode-map (kbd "Cc Cn Cc") 'haskell-process-cabal-build) (define-key haskell-mode-map (kbd "Cc Cn c") 'haskell-process-cabal))) (eval-after-load 'haskell-cabal '(progn (define-key haskell-cabal-mode-map (kbd "C-`") 'haskell-interactive-bring) (define-key haskell-cabal-mode-map (kbd "Cc Ck") 'haskell-interactive-ode-clear) (define-key haskell-cabal-mode-map (kbd "Cc Cc") 'haskell-process-cabal-build) (define-key haskell-cabal-mode-map (kbd "Cc c") 'haskell-process-cabal))) (custom-set-variables '(haskell-interactive-mode-hide-multi-line-errors nil) '(haskell-process-log t) '(haskell-process-type (quote cabal-repl)))
Pay attention to the part with (quote cabal-repl) - this should work with cabal sandboxes. It will also add additional logging information to a buffer named haskell-process-log, where you can find more about your problem.
I use this with ghc-mod version 5.1.0.2 compiled by GHC 7.8.3 and GHC 7.8.3.
Of course, you have to make sure your .cabal folder and the place where ghc-mod is in your path (I think you can configure this somewhere in emacs settings too, but it is much easier).
remarks
- you need to install the
ghc package in emacs not ghc-mod . - I used to have problems with a different version of ghc-mod and the emacs package - so make sure you get the latest version of cabal-install and then reinstall the emacs package (there were only problems parsing ghc output to my part, though)
Additional Information
If this does not help, please feel free to
run sample on my car
I edited an example file:

Then I remove Cc Cl and press y:

And accept the folder (where the file is located) and any other questions with Ret - now you should see the *haskell* buffer with the / lambda friendly message:

Finally, I can verify that the file is uploaded:
