Haskell-ing in Emacs

emacs_logo

Turning Emacs into a helpful Haskell IDE

I imagine I'm like a great many programmers who feel they learn best by just jumping straight into writing some code. The issue with this: I am a lazy programmer and I like to make my development environment do all of the work! And therefore I encounter an issue where if I don't have a smart IDE I start to make huge mistakes that take forever to spot.

Because of this, I have spent my evening configuring a nice emacs config for Haskell, my current challenge, to produce an environment which would actively teach me whilst I practically experiment. I like something that will tell me off with big error lines and warnings as I code, not at run time with some verbose error output.

Anyhoo to the main point of this page and an explanation of how I found a pleasant setup for Haskell. This is all for a GNU/Linux setup (specifically debian based distros)

First: Make sure you have everything installed:

  • You'll want emacs if you don't have it
  • Haskell using the GHC compiler (Glasgow Haskell Compiler)
  • You'll want Haskell's package manager Cabal (think pip but for Haskell)
  • For some of our autocompletes (for importing modules etc) we want ghc-mod

Second: Get the required Emacs packages:

  • Using emacs built in package manager (have melpha and marmalade activated) (and assuming you already use company, else check this for the best instructions)

Third: Add some lines of config to your "~/.emacs.d/init.el":

Fourth: Enjoy having some of these features:

  • Spotting incomplete statements:

Screenshot from 2016-10-22 20-47-36

  • Scanning installed modules and suggesting completions:

Screenshot from 2016-10-22 20-48-04

  • Finding redundant-imports

Screenshot from 2016-10-22 20-51-54

  • Illustrating function signatures:

Screenshot from 2016-10-22 20-52-45

  • Giving warnings/errors for code-structure

Screenshot from 2016-10-22 20-52-07

 

540 total views, 1 views today

Your email address will not be published. Required fields are marked *

*