Problems installing Haskell with Atom on a Mac

772 Views Asked by At

I want to program in Haskell using Atom on a Mac. Therefore I installed the following packages in Atom:

haskell-ghc-mod
ide-haskell
ide-haskell-cabal
language-haskell

After that I installed the Haskell Platform 8.2.1 from here: https://www.haskell.org/platform/#osx-none

This did not seem to work as I cannot compile and during every start of Atom there is this error message:

Haskell-ghc-mod: ghc-mod failed to launch. It is probably missing or misconfigured. ENOENT

Then I tried installing the necessary packages manually as described on https://atom-haskell.github.io/installation/installing-binary-dependencies/ which also failed (even unregistering failed):

Daniels-MacBook-Pro:ghc-mod-sandbox daniel$ cabal install ghc-mod stylish-haskell

Resolving dependencies...
cabal: Could not resolve dependencies:
trying: ghc-mod-5.8.0.0 (user goal)
next goal: base (dependency of ghc-mod-5.8.0.0)
rejecting: base-4.10.0.0/installed-4.1... (conflict: ghc-mod => base<4.10 &&
>=4.6.0.1)
rejecting: base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0,
base-4.8.1.0, base-4.8.0.0, base-4.7.0.2, base-4.7.0.1, base-4.7.0.0,
base-4.6.0.1, base-4.6.0.0, base-4.5.1.0, base-4.5.0.0, base-4.4.1.0,
base-4.4.0.0, base-4.3.1.0, base-4.3.0.0, base-4.2.0.2, base-4.2.0.1,
base-4.2.0.0, base-4.1.0.0, base-4.0.0.0, base-3.0.3.2, base-3.0.3.1
(constraint from non-upgradeable package requires installed instance)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, ghc-mod, syb
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
Daniels-MacBook-Pro:ghc-mod-sandbox daniel$ cabal uninstall ghc-mod stylish-haskell
cabal: This version of 'cabal-install' does not support the 'uninstall'
operation. It will likely be implemented at some point in the future; in the
meantime you're advised to use either 'ghc-pkg unregister ghc-mod' or 'cabal
sandbox hc-pkg -- unregister ghc-mod'.

Daniels-MacBook-Pro:ghc-mod-sandbox daniel$ ghc-pkg unregister ghc-mod

ghc-pkg: cannot find package ghc-mod

Daniels-MacBook-Pro:ghc-mod-sandbox daniel$ cabal sandbox hc-pkg -- unregister ghc-mod

ghc-pkg: cannot find package ghc-mod

Daniels-MacBook-Pro:ghc-mod-sandbox daniel$ cabal install ghc-mod stylish-haskell

Resolving dependencies...
cabal: Could not resolve dependencies:
trying: ghc-mod-5.8.0.0 (user goal)
next goal: base (dependency of ghc-mod-5.8.0.0)
rejecting: base-4.10.0.0/installed-4.1... (conflict: ghc-mod => base<4.10 &&
>=4.6.0.1)
rejecting: base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0,
base-4.8.1.0, base-4.8.0.0, base-4.7.0.2, base-4.7.0.1, base-4.7.0.0,
base-4.6.0.1, base-4.6.0.0, base-4.5.1.0, base-4.5.0.0, base-4.4.1.0,
base-4.4.0.0, base-4.3.1.0, base-4.3.0.0, base-4.2.0.2, base-4.2.0.1,
base-4.2.0.0, base-4.1.0.0, base-4.0.0.0, base-3.0.3.2, base-3.0.3.1
(constraint from non-upgradeable package requires installed instance)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, ghc-mod, syb
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox. 

I already searched stackoverflow for answers but nothing really worked for me. Can anybody tell me what I am missing?

1

There are 1 best solutions below

3
Michael Snoyman On

I can advise you on one part of the problem. The error message from cabal is very confusing, but what it means is:

  • ghc-mod does not work with a version 4.10.0.0 of the base
  • The base library ships with GHC and cannot be changed
  • GHC 8.2.1 ships with base 4.10.0.0
  • Therefore: you cannot build ghc-mod with the version of the Haskell Platform you downloaded

You can work around this by downloading an older Haskell Platform (8.0.2). In my opinion: it's premature for the promoted Haskell Platform version to be 8.2.1.

Another approach is using Stack, which will manage the installation of GHC installations for you. In this case, running stack install ghc-mod should just work. But since you'll still be using GHC 8.2.1 from the Haskell Platform, it won't do you much good, since ghc-mod is tied to your GHC version.

Personally: I never had success setting up ghc-mod. I've also never used either Atom or VS Code, but I've heard people sharing good experiences with VS Code + Haskero, so if you're looking for an IDE-like experience, that may be something worth considering. I've switched over to using emacs+intero mode, which may be something to consider.

Here are some links that may be helpful on getting started with tooling: