Haskellers are not exactly blessed with an abundance of IDEs. After trying Vim, Atom and Haskell for Mac I converged on Emacs with the Intero package. First let's run through a selection of alternatives that all have great features but are each lacking in some particular way.
Haskell for Mac
Haskell for Mac was nice while I was learning Haskell basics, but it's not adequate for larger projects because the
.cabal file inside the project folder can't be edited and it doesn't allow for multiple executables, or any custom project structure. On the upside, no other tool I've seen integrates the REPL as nicely as Haskell for Mac does. For beginners, this is a very good choice.
I struggled to configure Vim until I discovered Haskell-Vim-Now, which promises that "in less than ten minutes your Vim will transform into a beautiful Haskell paradise". I had some problems with the installation but these were resolved quickly thanks to very dedicated maintainers.
(See Issue #199 of Haskell-Vim-Now and Issue #63 of the Haskell codex package)
My remaining grief with Vim is the speed of type lookups and linter runs (Issue #201).
In general I really like Atom, and after some fiddling with path settings, it worked very well. What I don't like about Atom for Haskell is that the REPL isn't that well integrated, yet. The IDE-Haskell REPL package is in beta and currently offers a rather minimal interface into ghci.
A hassle-free, complete, one-stop solution is Intero for Emacs, and this is what is described here. It's really straightforward and does all the things you'd want, such as:
- syntax highlighting etc.
- type checking
- type identification
First, lets' pick a theme. Here's a reminder of how to do that in Emacs:
M-x package-install <RET> theme-name
theme-name plug in any theme available in MELPA, such as
atom-dark (see below). Then make a theme the default with this line in
(load-theme 'theme-name t)
The default font size is set as follows:
(set-face-attribute 'default nil :height 140)
where the value is 1/10pt. (See Q on stackexchange.)
- https://draculatheme.com/emacs/. Name is
- https://github.com/whitlockjc/atom-dark-theme-emacs. Name is
A nice list of monospace fonts for programming is at narga.net.
To set the font use this:
(set-default-font "Inconsolata 12")
This Q on stackexchange has more info.
Intero for emacs
Follow the instructions here: http://commercialhaskell.github.io/intero/.
Default key bindings:
|M-.||Jump to definition|
|C-c C-i||Show information of identifier at point|
|C-c C-t||Show the type of thing at point, or the selection|
|C-u C-c C-t||Insert a type signature for the thing at point|
|C-c C-l||Load this module in the REPL|
|C-c C-r||Apply suggestions from GHC|
|C-c C-k||Clear REPL|
|C-c C-z||Switch to and from the REPL|
Why does C-c C-l start the session, not the process?
Don't use emacs' haskell-session-, instead use haskell-process-:
|haskell-process-cabal||Prompts for a Cabal command to run|
|haskell-process-cabal-build||Build the Cabal project|
|haskell-process-restart||Restart the inferior Haskell process|
|haskell-process-clear||Clear the current process|
|haskell-process-reload||Reload the current buffer file|
|haskell-process-load-file||Load the current buffer file|
Here's how this looks in action:
Helm is an incremental completion and selection narrowing framework for Emacs.
Right now I only have this in my init.el:
(require 'helm-config) (helm-mode 1)
What I get is a nicer
C-x b for switching between buffers.
stack install hindent
and add this to the
(add-hook 'haskell-mode-hook #'hindent-mode)
hindent emacs package.
Then, by calling
M-q, you can reformat the current declaration.
https://github.com/purcell/flymake-haskell-multi: no success.
https://github.com/iquiw/company-ghc: no success
manage emacs packages
|M-x package-list-packages||list available packages|
|M-x package-refresh-contents||refresh list of packages|
M-: <RET> (find-file user-init-file)
The "right" Emacs for Mac Os X
brew install emacs --HEAD --use-git-head --with-cocoa --with-gnutls \ --with-rsvg --with-imagemagick