Installing Haskell packages on Mac

ghci, happstack, haskell, haskell-snap-framework, macos

Solution

Updated May 22, 2021

Have you tried using homebrew? It handles the dependencies for you.

Using homebrew, you can use the `brew` command to install `ghc` and `cabal-install`.

$ brew install ghc cabal-install
==> Downloading https://ghcr.io/v2/homebrew/core/ghc/manifests/8.10.4
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ghc/blobs/sha256:965f94c14b56e3db7b239860e0a1d577be0b27caf8adb6212710a7430ce723d3
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:965f94c14b56e3db7b239860e0a1d577be0b27caf8adb6212710a7430ce723d3?se=2021-05-23T05%3A15%3A00Z&sig=fkH7sUY44VCLV8hI%2BtZT%2B
######################################################################## 100.0%
==> Pouring ghc--8.10.4.big_sur.bottle.tar.gz
==> /usr/local/Cellar/ghc/8.10.4/bin/ghc-pkg recache
  /usr/local/Cellar/ghc/8.10.4: 6,907 files, 1.5GB
==> Downloading https://ghcr.io/v2/homebrew/core/cabal-install/manifests/3.4.0.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/cabal-install/blobs/sha256:2c0c5cc90d4739515721557f8e9c02783b3b5f106033c5c09241657b4418b21f
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:2c0c5cc90d4739515721557f8e9c02783b3b5f106033c5c09241657b4418b21f?se=2021-05-23T05%3A15%3A00Z&sig=O7ylxHgq42YVADlzTacdRfY7W
######################################################################## 100.0%
==> Pouring cabal-install--3.4.0.0.big_sur.bottle.tar.gz
  /usr/local/Cellar/cabal-install/3.4.0.0: 7 files, 39.6MB

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 8.10.4: https://www.haskell.org/ghc/  :? for help
Prelude>

Hope this helps!

Problem

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?

Original source