To get the most out of your GHC environment, you should '~/.cabal/bin' to your PATH environment variable before the path where you have GHC installed. This will allow you to get and use cabal-updates, as well as other programs shipped with GHC like hsc2hs.

+

To get the most out of your GHC environment, you should add '~/.cabal/bin' to your PATH environment variable before the path where you have GHC installed. This will allow you to get and use cabal-updates, as well as other programs shipped with GHC like hsc2hs.

Mac OS X 10.6.x (Snow Leopard) works with GHC, after you apply a simple patch.

+

−

The problem is that GHC generates 32bit code, but gcc on Snow Leopard defaults to 64bit code on machines with processors that support it. The patch simply tells GHC to tell gcc to work in 32bit:

+

* Install the [http://hackage.haskell.org/platform/ Haskell Platform]

* Install the [http://hackage.haskell.org/platform/ Haskell Platform]

−

* Open <code>/Library/Frameworks/GHC.framework/Versions/Current/usr/bin/ghc-6.10.4</code> in a text editor

−

* Insert <code>-optc-m32 -opta-m32 -optl-m32</code> just before the last parameter.

+

To uninstall ghc call:

+

<code>

+

sudo uninstall-hs

+

</code>

−

The last line in that file is rather long, and should now end like <code> -dynload wrapped -optc-m32 -opta-m32 -optl-m32 ${1+"$@"}</code>

+

=== Xcode 4.1 ===

+

GHC needs Xcode to be installed so it has access to the bintools, headers, and link libraries of the platform. The later two are provided by the SDK that comes as part of Xcode. GHC 7.0.2 is compiled against the 10.5 SDK. Xcode 4.1 no longer ships with it. <tt>ghci</tt> will work, but linking and some compiles with <ghc> will not. To make those work you need a copy of the 10.5 SDK. You can get this one several ways:

−

Don't be tempted to just put an edited local copy of the script in ~/bin/ghc, or edit all the various GHC files in /usr/bin. There is a maze of twisty symlinks that all eventually lead to the above script, and fixing just it is far simpler.

+

* Before you install Xcode 4.1, if you have Xcode 3.2 installed, do one of the following:

** Move just the sdk aside, install Xcode 4.1, then move it back into the <tt>/Developer/SDKs</tt> directory.

+

* If you don't have Xcode 3.2, then you can download it from the Apple Developer site, and install it in a location other than "/Developer". If you have already installed Xcode 4.1 ''be sure'' that you customized the install and don't install the "System Tools" or "UNIX Development" packages.

−

See also [http://passingcuriosity.com/2009/haskell-on-snow-leopard/ Haskell on Snow Leopard].

Affected packages include things like zlib and mmap. Building them on Snow Leopard without the above trick leads to nasty bugs in packages depending on them (including darcs). For darcs built on an affected system symptoms include messages like "incompatible zlib version" and "memory allocation failed".

1 The Haskell Platform

There are Mac OS X installers of the full Haskell Platform development environment. We recommend it:

2 GHC

2.1 Important notes

To get the most out of your GHC environment, you should add '~/.cabal/bin' to your PATH environment variable before the path where you have GHC installed. This will allow you to get and use cabal-updates, as well as other programs shipped with GHC like hsc2hs.

In your ~/.profile, add the line:

export PATH="~/.cabal/bin:$PATH";

2.2 Mac OS X 10.5 (Leopard)

To install GHC on Mac OS X 10.5 (Leopard), there are the following options:

2.3 Mac OS X 10.6 (Snow Leopard) and 10.7 (Lion)

2.4 Xcode 4.1

GHC needs Xcode to be installed so it has access to the bintools, headers, and link libraries of the platform. The later two are provided by the SDK that comes as part of Xcode. GHC 7.0.2 is compiled against the 10.5 SDK. Xcode 4.1 no longer ships with it. ghci will work, but linking and some compiles with <ghc> will not. To make those work you need a copy of the 10.5 SDK. You can get this one several ways:

Before you install Xcode 4.1, if you have Xcode 3.2 installed, do one of the following:

Move just the sdk aside, install Xcode 4.1, then move it back into the /Developer/SDKs directory.

If you don't have Xcode 3.2, then you can download it from the Apple Developer site, and install it in a location other than "/Developer". If you have already installed Xcode 4.1 be sure that you customized the install and don't install the "System Tools" or "UNIX Development" packages.

3 HUGS

4 Installing libraries with external C bindings

Haskell libraries are installed with the cabal command line tool.

Some libraries depend on external C libraries, which are best installed with MacPorts. However, you have to tell cabal to include the /opt/local/ directories when searching for external libraries. The following shell script does that by wrapping the cabal utility