In 2022, the Haskell Platform is deprecated and the officially recommended way for most platforms, including Mac, is to install GHCup first. GHCup
is basically a package manager for the Haskell toolchain (GHC
, Stack
, Cabal
, HLS
). It can install multiple versions of each of these into the home directory, and "set" (symlink) the ghc
/... commands to a specific version.
To install GHCup
, use the install script (source). This installs GHCup
and GHC
, asks some questions about setting up PATH etc., and prompts you to install the Apple developer command line tools if it notices them missing.
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
If you're on a Mac M1 and want to run ghc
8.10.7 or older, you will also need to install a version of llvm
between 9 and 12 (inclusive), and put it on the path so ghc
can find it. Currently however, 9.2.4 is the default, which has a native code generator (NCG) that works on M1 out of the box. It may still contain bugs on M1 though (see here for details) so consider upgrading to 9.4.2 with ghcup install ghc 9.4.2 && ghcup set ghc 9.4.2
. Currently, 9.4.2 lacks the breadth of package support enjoyed by 8.10.7, but it is has fewer known bugs.
If you find yourself in an install mess, you can start from a clean slate and reinstall both the Developer Tools and GHCup
with:
sudo rm -rf /Library/Developer/CommandLineTools
ghcup nuke
rm -rf ~/.ghcup
rm -rf ~/.stack
rm -rf ~/.cabal
# For the cautious, a reboot here is advised before proceeding
xcode-select --install
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
It's also possible to install GHCup
via Homebrew, though that requires to manually update $PATH and install/set the wanted tools.
brew install ghcup
# Now add $HOME/.ghcup/bin to $PATH
ghcup install ghc && ghcup set ghc