How to install ghc-mod to use it with Atom text editor

You are probably here because you want to configure your Atom to make use of Haskell IDE of some kind, but you are unable to do it correctly, or you find it challenging. Well, you are on the same page. In this story, I will show you how to install ghc-mod and configure it in Atom.

The problem

I was experimenting with Atom text editor recently, and one of the packages I wanted to install was ide-haskell to turn Atom into a lightweight IDE for Haskell.

This package though required to install haskell-ghc-mod.

The haskell-ghc-mod package requires to install ghc-mod from cabal which is straightforward: cabal install ghc-mod

After installing ghc-mod, I ran which ghc-mod from the terminal to find out the path of ghc-mod but unfortunately ghc-mod wasn’t in my path.

More importantly, because ghc-mod wasn’t in my path, the haskell-ghc-mod package of Atom was unable to find ghc-mod.


I spent quite a lot of time to find a solution to that. The solution at the end was ridiculously easy, but hey I am new to the Haskell world. What I really needed to do was to:

  • Find where ghc-mod is
  • Put it in my .bash_profile and that is.

So with the following in mind, I started looking for the rescue, best place to start? from the .cabal directory of course: cd ~/.cabal/

In this directory, I saw a file called where-is-my-stuff.txt. I said:

Aha! This file will give me what I want!

I then tried to see what is in there: cat where-is-my-stuff.txt

Which gave the following output:


=== Configuration for cabal has been written to

=== Executables will be installed in:

    You may wish to place this on your PATH by adding the following
    line to your ~/.bash_profile:

    export PATH="$HOME/Library/Haskell/bin:$PATH"

=== When documentation is built, a master index to all documentation
    will be placed in:


    You may wish to bookmark that file once it gets built (after the
    first cabal install).


I have added export PATH="$HOME/Library/Haskell/bin:$PATH" in my ~/.bash_profile and then I ran source ~/.bash_profile!

Now which ghc-mod returns a lovely path: /Users/rafael/Library/Haskell/bin/ghc-mod

I then went to Atom preferences > haskell-ghc-mod package settings, and underneath Ghc Mod Path I added the path output from which ghc-mod.

Haskell IDE integration with Atom is just awesome!

PS 1: Remember to install all the following Atom packages: autocomplete-haskell, haskell-ghc-mod, ide-haskell and language-haskell.

PS 2: I will soon post my impressions about Haskell programming language as I am about to finish the semester and complete the Functional Programming module.

© 2019 Rafael Papallas
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.