A Haskell development platform…almost

The Haskell Platform is really a great addition to the Haskell community. It adds a lot of common libraries and tools all at once, such as the Haskell package manager cabal. I suppose you could install each package as you need it, but in the Haskell world everyone loves cabal and darcs and you might as well get them all at once.  (note: I don’t think the Platform includes darcs).  Saves you time anyways.  Cabal is great for grabbing other Haskell libraries, and I suppose it is analogous to  Ruby gems or Python eggs.

I’m running OS X 10.5.8–yes, I know I need to upgrade–and thus I had to get Haskell Platform 2010.2.0.0 rather than the latest version.  OS X is still the third leg in the world of operating systems, however.  At work I have a Linux workstation, and for the most part everything just works, except for the occasional problem with amd64/x86_64 platform.  Trying to use anything not specifically designed for Mac is always an exercise in troubleshooting.  But I wouldn’t give up OS X as my main desktop system.

The platform installer is straight forward–a DMG image–and you just install the Glasgow Haskell Compiler, and then the Haskell Platform. Unfortunately, the Haskell Platform is not entirely perfect…

> cabal --help
dyld: unknown required load command 0x80000022
Trace/BPT trap

Yikes, dynamic linker errors! But a Google search turned up a solution to install cabal from the sources and ignore the cabal from the Platform. After downloading the tarball:

zcat cabal-install-0.10.2.tar.gz | tar xf -
cd cabal-install-0.10.2
chmod u+x bootstrap.sh
./bootstrap.sh

The script uses GHC to build cabal, and then installs it to ~/.cabal. Make sure to add ~/.cabal/bin to your PATH variable. We should also blow away the borked cabal.

sudo rm /usr/local/bin/cabal
sudo rm /usr/bin/cabal
sudo ln -s /Users/.cabal/bin /usr/local/bin/cabal

I tried running cabal again, and this time there were no dyld errors. I had wanted cabal so I could install the gtk2hs bindings that allow Haskell programs to create GTK+ GUIs. I was also hoping I wouldn’t have to be a GTK2+ guru or systems guru to install such a package.  Unfortunately, things did not really work out, and after checking the gtk2hs web page, installing for OS X is not as easy as a simple cabal command.  The dreaded MacPorts would be required…

First we must install GTK, and this does take awhile.  I thought I had installed GTK+ before, because I run EiffelStudio through Apple’s X11 implementation.  (EiffelStudio required MacPorts too, by the way).  Might as well try to install it though, just in case EiffelStudio was statically linked to the GTK libraries…or maybe it does not even use GTK+, thought it sure looks like it…

sudo port selfupdate
sudo port install gtk2 +universal
sudo port install cairo
sudo port install pango

It took forever to install gtk2.  It must have installed very library under the universe.  GTK+ has always made me crazy, it is dependent on so many libraries.  You might as well install all of a Linux distro onto your Mac for GTK+. Motif, while ugly these days, was so much nicer to work with.  So then I tried to install the gtk package with cabal, following the gtk2hs installation guide:

cabal install gtk2hs-buildtools
cabal install gtk --ghc-option="-DCABAL_VERSION_MINOR=10"

Unfortunately it fails when trying to reconcile the gio package.

Configuring gio-0.12.0...
Preprocessing library gio-0.12.0...
Building gio-0.12.0...
[ 1 of 24] Compiling System.GIO.Signals ( dist/build/System/GIO/Signals.hs, dist/build/System/GIO/Signals.o )
[ 2 of 24] Compiling System.GIO.Types ( dist/build/System/GIO/Types.hs, dist/build/System/GIO/Types.o )
[ 3 of 24] Compiling System.GIO.Enums ( dist/build/System/GIO/Enums.hs, dist/build/System/GIO/Enums.o )
[ 4 of 24] Compiling System.GIO.File.FileAttribute ( dist/build/System/GIO/File/FileAttribute.hs, dist/build/System/GIO/File/FileAttribute.o )
[ 5 of 24] Compiling System.GIO.Volumes.VolumeMonitor ( dist/build/System/GIO/Volumes/VolumeMonitor.hs, dist/build/System/GIO/Volumes/VolumeMonitor.o )

System/GIO/Volumes/VolumeMonitor.chs:56:4:
    Not in scope: `vmDriveStopButton'
cabal: Error: some packages failed to install:
cairo-0.12.0 failed during the building phase. The exception was:
ExitFailure 1
gio-0.12.0 failed during the building phase. The exception was:
ExitFailure 1
gtk-0.12.0 depends on gio-0.12.0 which failed to install.
pango-0.12.0 depends on cairo-0.12.0 which failed to install.

I don’t know that I want to spend anymore time on this.  And GUIs are overrated anyways.  I like to try different programming languages and technologies, but still I fall back to C++.  For this GUI app (a CAD app, thus it needs a GUI), I’ll just stick to C++ and Qt 4.  I suppose I always revert to C++ because I understand the errors and the tools, and I can quickly fix any problems I encounter.

At least I have GHC, cabal, and darcs installed,  I can at least do console programming with Haskell. I’m hooked on Erlang, but I still want to explore more with Haskell, if not for anything but learning more concepts.

I’m sure that Apple doesn’t make it any easier on the maintainers of the Haskell Platform with their ever-changing tools.  Apple is always quick to change things and break dependencies too.  Nonetheless, give the Haskell Platform a change.  I suspect if you’re on a Linux box it all just works, especially a Debian/Ubuntu system where apt-get will quickly take care of your prerequisites and dependencies.

I’ve got more interesting projects to work on, such as my ZigBee project.  I’d rather spend my time there then messing with GTK.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s