Installing Haskell packages on Mac

Jonovono picture Jonovono · Mar 29, 2013 · Viewed 26.8k times · Source

I can't seem to get a few Haskell packages to install on my Mac (10.6.8). I first tried Happstack and it failed and then I tried Snap.

Sometimes when I run ghci I get a segmentation fault.

Other times it works and goes like this:

GHCi, version 7.4.2: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude>

When trying to get Snap:

....
....
....
Loading package vector-0.10.0.1 ... linking ... done.
Loading package zlib-0.5.4.0 ... linking ... done.
Loading package zlib-bindings-0.1.1.3 ... linking ... done.
Loading package zlib-enum-0.2.3 ... linking ... done.
Loading package snap-core-0.9.3.1 ... linking ... done.
Loading package snap-server-0.9.3.3 ... linking ... done.
Loading package directory-tree-0.11.0 ... linking ... done.
cabal: Error: some packages failed to install:
snap-0.11.2 failed during the building phase. The exception was:
ExitFailure 11

I have seen this problem a few times but nothing really solved it for me. Any ideas?

Answer

shadanan picture shadanan · Mar 29, 2013

Have you tried using homebrew? It handles the dependencies for you. I am on Mac OS X 10.7.5, but these instructions should work for you.

Using homebrew, you can install haskell-platform using the brew command. It will take a while. The compile stage for haskell-platform took 15 minutes.

$ brew search haskell
haskell-platform

$ brew install haskell-platform
==> Installing haskell-platform dependency: ghc
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/ghc-7.4.2.lion.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring ghc-7.4.2.lion.bottle.1.tar.gz
==> Caveats
This brew is for GHC only; you might also be interested in haskell-platform.
==> Summary
🍺  /usr/local/Cellar/ghc/7.4.2: 5176 files, 767M
==> Installing haskell-platform
==> Downloading http://lambda.haskell.org/platform/download/2012.4.0.0/haskell-platform-2012.4.0.0.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/haskell-platform/2012.4.0.0 --enable-unsupported-ghc-version
==> make install
==> Caveats
Run `cabal update` to initialize the package list.

If you are replacing a previous version of haskell-platform, you may want
to unregister packages belonging to the old version. You can find broken
packages using:
  ghc-pkg check --simple-output
You can uninstall them using:
  ghc-pkg check --simple-output | xargs -n 1 ghc-pkg unregister --force
==> Summary
🍺  /usr/local/Cellar/haskell-platform/2012.4.0.0: 952 files, 208M, built in 15.3 minutes

Once installed, you should be able to run:

$ ghc
ghc: no input files
Usage: For basic information, try the `--help' option.

As well as the Haskell interpreter, ghci:

$ ghci
GHCi, version 7.4.2: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> putStrLn "Hello World"
Hello World
Prelude>
Leaving GHCi.

Hope this helps!