Installing GHCJS on OS X
Assuming that you’ve installed GHC using Homebrew, the following steps will
install GHCJS for you. These instructions perform a global install, but you
can do a sandbox install by dropping the --global argument and ensuring your
sandbox bin directory is higher on your $PATH than any other cabal
binary paths. You can likewise do a user install without --global and
ensuring your user cabal bin directory is higher on your $PATH than
the homebrew cabal’s bin directory.
I went global.
Upgrade your Cabal and cabal-install versions
GHCJS expects cabal-install 1.22.6.0, and Cabal 1.22.4.0. Homebrew’s most recent version of GHC will leave you with version 1.22.2.0 of both.
cabal update
cabal install --global Cabal
cabal install --global cabal-installThe order of these two installs is important; if you don’t build Cabal 1.22.4.0 before attempting to install cabal-install, you’ll just link against the old system version. You can verify that all is well with:
$ cabal --version
cabal-install version 1.22.6.0
using version 1.22.4.0 of the Cabal library
Enure you’re happy, Alex.
GHCJS has two dependencies you’ll need to manually install: happy and alex.
cabal install --global happy alexInstall GHCJS
GHCJS has two git repositories, and no hackage packages. You must git clone and install.
git clone https://github.com/ghcjs/ghcjs-prim.git
git clone https://github.com/ghcjs/ghcjs.git
cabal install --global ./ghcjs-prim ./ghcjsMany dependencies. Perhaps use -j to speed it up.
Boot GHCJS libraries
You’ll need a lot of base libraries rebuilt for GHCJS, and ghcjs-boot will do
that for you. If you don’t already have nodejs installed,
brew install it before doing this.
ghcjs-boot --dev --ghcjs-boot-dev-branch ghc-7.10You need to build to the 7.10 development branch, assuming your local install of GHC is 7.10.1 or so. This installs into your user directory, and doesn’t appear to support global or sandbox installs.
But once it’s done, you can compile Haskell for the Web.