Installing and using Euterpea under OS X 10.9

By: Jeremy W. Sherman. Published: . Categories: how-to haskell book-club.

The BNR Book Club (JOIN US!) is working through Hudak’s The Haskell School of Music: From Signals to Symphonies.

The tricky part of working with pre-release books and unreleased software is getting both to run on your system.

The site itself warns you of the difficulties of using Euterpea under OS X, but if you’re pig-stubborn and Mac-happy like me, you might benefit from my setup instructions.

The Scene

I figured Chapter 2 would start by explaining how to set up Euterpea so you can actually run the code we’re encountering, but no dice.

There are some lengthy installation instructions available from the author that attempt to cover Windows, Linux, and OS X.

The short of it is, Windows is very well supported, Linux so-so, and Mac, you’re on your own.

Anecdotal reports indicate that if you have a 32-bit version of GHC installed, things will pretty much just work on your Mac. Otherwise, you’ll hit problems.

I have the 64-bit version and was able to get things mostly working, to the point that I can write notes to midi files on disk. The trick is knowing what doesn’t work so you avoid it.

Installing

Adjust GHC’s C Compiler Command

This patch-up is necessary as of the 2013.2.0.0 Haskell Platform release. It likely won’t be necessary after the next release.

Before you do anything else, if you’re on Mavericks, follow the instructions under “Xcode 5 & OS X 10.9 (Mavericks)” from the Haskell Platform Mac page. You will be adjusting the C compiler setting for GHC to go through a shim that fixes up some differences between how gcc and clang do things.

Clone and Cabal Install Euterpea

Then you can get on to Euterpea. Follow the basic checkout and build instructions:

git clone https://github.com/Euterpea/Euterpea
cd Euterpea
cabal update
cabal install

Gotchas

Once you have it, here’s what not to do:

Verifying Your Install

Here is what you should do:

How should you play the midi file? I just used timidity, per the install document. I cut out almost all the optional libraries to quicken build time, so my brew install line went like this:

brew install timidity --without-libogg --without-speex \
  --without-flac --without-libvorbis

I’ve attached a demo program you can use to check you have this all working. In the end, you should be able to do this and hear an F# Major chord:

ghc demo.hs && ./demo && timidity test.mid

Enjoy!

Now you should be able to hobble your way through the rest of the text. I hope. I’m still working my way through, as well.

This post first appeared as a somewhat less-structured post to the BNR Book Club Google Group.