Charlie Harvey

Getting a later GHC/Haskell platform on Squeeze from Sid

I have, of late, been learning Haskell following my experience of it in my Seven Languages In Seven Weeks adventure. Now, I normally learn stuff from books, but browsing through Hacker News a while back, I spotted Rein Henrichs’s new series of Haskell Live tutorials. I decided to follow along and see what I could pick up.

Episode one was straightforward enough, covering some of the infrastructure that you’d need to make a chess engine — algebraic data types, some of the day to day language features and so on. And on Friday I spotted on twitter that episode two was up. Here it is.

But there is a problem. Part way through Rein introduces the note function from Control.Error.Util. Its quite useful. It allows you to convert from Maybe to Either. However, it isn’t installed on my Debian Squeeze system. Not to worry, I’ll see if its in the repositories. Nope. OK, I’ll try using cabal. The package name is errors. Oh, it wants me to have a later version of Cabal. Oh, that requires me to have a later version of GHC, maybe the Haskell platform — needless to say I have the vanilla squeeze one installed, ghc 6.12 which is kinda old. More googling. I’m really not feeling the option of compiling the Haskell platform from scratch.

So, reader, I did a bad thing and installed the version from Debian Unstable, aka Sid. Now, this is almost always taking a walk on the wild side. Caveat emptor and all that. But it worked for me®. There is two ways to do it, the hacky way and the proper way. Let’s examine the proper way.

apt-pinning

As most debian users know, you can have multiple repositories in your /etc/apt/sources.list file. In fact, you can even have repositories from different versions of Debian. Normally aptitiude will try and upgrade everything to the latest version. If you value stability you won't want to put Debian testing or unstable in there because that would upgrade your whole system. Not cool. But what if you just want one package from Sid (Debian unstable)? A fair number of packages can be found in the backports repository and these are always to be preferred.

But what if the package you want is haskell-platform and it ain't in backports? apt-pinning lets you add a later version of the Debian repositories to your sources.list, but to prefer your current version unless you specify otherwise. Now, bear in mind that using bits of different releases of Debian is like building a frankenstein’s monster. It is by no means certain that x from Sid will work with y from Squeeze. But its worth a crack if you're feelng brave.

First you will want to add the unstable repo to your /etc/apt/sources.list .deb http://mirror.ox.ac.uk/debian unstable main. Note that I use the Oxford Uni Debian repository. There is likely to be one closer to you. Unless you are in Oxford.

Next we want to tell our box to prefer Squeeze to Sid. In /etc/apt/preferences (create it if you need to) type the following. Package: * Pin: release a=squeeze Pin-Priority: 900 Package: * Pin: release a=unstable Pin-Priority: 800 Here we tell apt to prefer the Squeeze version, but to make available Unstable too. You'll want to run an aptitude update to fetch all the package indexes and whatnot.$ sudo aptitude update We can now see what versions of haskell-platform are available$ aptitude versions haskell-platform i 2010.1.0.0.1 stable 900 p 2012.2.0.0

Now we simply do one of the following $ sudo aptitude install haskell-platform/unstableor$ sudo aptitude -t unstable install haskell-platform The first version won’t try and resolve any dependencies, which can mean the install failing. The second resolves, installs or upgrades dependencies. Some folks prefer to set Unstable to have a negative Pin-Priority in order to avoid installing packages that are in Unstable but not in Squeeze. Anyhow if that all worked, you should be rocking ghc 7.4.1 and the latest cabal. Which means you can install errors and get on with Rein’s tutorial. Finally.

The hacky way

Of course, if you’re a bit of a slacker, you may have realized that you could just have added the unstable repo to sources.list, done an aptitude update, installed haskell-platform and then commented out the unstable repo. The advantage is not faffing round with your preferences file. The disadvantage is not getting the updates. You pays yer money and you takes yer choice as they say.


Comments

  • Be respectful. You may want to read the comment guidelines before posting.
  • You can use Markdown syntax to format your comments. You can only use level 5 and 6 headings.
  • You can add class="your language" to code blocks to help highlight.js highlight them correctly.

Privacy note: This form will forward your IP address, user agent and referrer to the Akismet, StopForumSpam and Botscout spam filtering services. I don’t log these details. Those services will. I do log everything you type into the form. Full privacy statement.