just use GHC for OSX https://ghcformacosx.github.io
the rest of these directions are preserved for historical purposes
TLDR version, if you have homebrew
xcode-select --install ; brew tap homebrew/versions ; brew tap homebrew/dupes \ brew install apple-gcc42 ; brew link apple-gcc42
xcode-select --install is how you (re)install the mavericks xcode 5 CLI tools, you HAVE to do that. Either way, you should make sure you have CLI tools installed.
NB: apple-gcc42 is quite old, but doesn't require a build from source (so it can work right away). Those who have a bit more patience and want a more modern GCC can use
brew install gcc49 or the like (though the build may take a while).
then edit the settings file as follows:
type "ghc-pkg list"
the first line of the output will be a path like
go one directory up to
open the settings file.
there'll be a line indicating the path to the c compiler. It'll probably say
change that line to
/usr/local/bin/gcc-4.8(or whichever gcc version you brew installed, such as
you may also want to make sure that the
gccin your PATH points to this gcc. Many tools have calling
gcchard coded in.
if you point
gccto your gcc, be sure to also point
ccto that gcc, and
g++to the g++ associated with that gcc. (otherwise when you're building a project that uses a mix of c and c++, you'll have really really weird build errors)
one Alternative approach that works with xcode 5 and doesnt need HomeBrew (by @lukexi and Manuel) here http://justtesting.org/post/64947952690/the-glasgow-haskell-compiler-ghc-on-os-x-10-9
another alternative see http://www.haskell.org/pipermail/haskell-cafe/2013-October/111174.html and https://gist.github.com/mzero/7245290 for tools that should work on a stock mac using haskell platform (work courtesy of Mark Lentczner)
NB: both these approaches use Clang, which hits some exotic corner cases in CPP still, along with some build system quirks.
to recap -- the fastest way to have a working GHC / haskell platform install is the following. Much faster than the brew install approach, and uses the builds maintained by the official haskell platform folks.
so the total newb supervised install would be like
make sure the person has up to date CLI tools installed
brew install apple-gcc42
(3,optional, just skip to step 4 if you already have GHC)
install GHC or haskell platform etc (either) and make sure you've appropriately fixed up your path. 64 bit build here http://www.haskell.org/platform/mac.html
do my horrible edit your settings file thing to point the compiler to gcc42
(originaly shared here on reddit
the fastest work around is to use brew to build your own copy of GCC
brew install apple-gcc42 is fastest, i've used brew install gcc48
then type "ghc-pkg list"
the first line will be a path like /Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/package.conf.d
go one directory up to /Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/
then open the settings file.
there'll be a line indicating the path to the c compiler. It'll probably say "/bin/gcc"
change that line to "/usr/local/bin/gcc-4.8" (or whichever gcc version you brew installed, such as "/usr/local/bin/gcc-4.2")
enjoy life, haskell and mavericks/xcode 5.
NB: this is the power user fix. I recommend that most users instead do one of the approaches in http://www.haskell.org/pipermail/haskell-cafe/2013-September/110320.html
(directions for step 4 laid out below in the comments)