Spork Code

Code. Randomness. Sporks.

Posts Tagged ‘Cabal

Installing the Haskell Platform in Ubuntu

with 24 comments

After my previous article about installing Haskell’s Cabal package in Ubuntu, I decided to do a bit more research on using Haskell in Ubuntu. It turns out that the debian packages in the Ubuntu repositories for Haskell and GHC are hopelessly out of date, excluding not only the added functionality of new releases, but also the Haskell Platform, which is effectively an extended set of standard libraries surrounding Haskell. Funnily enough, the Haskell platform actually includes Cabal, which effectively makes my previous post useless. In its stead, I present to you a guide on installing GHC and the Haskell platform on your Ubuntu system (though these steps should work equally well on any Linux system with apt-get as a package manager).

First things first, lets get the dependencies out of the way.

sudo apt-get install libedit2 libedit-dev freeglut3-dev libglu1-mesa-dev

Now let’s remove any haskell packages we may have installed, as these will cause conflicts.

sudo apt-get autoremove ghc6

Note that if you installed cabal as per my previous post, you can remove the executable from your $PATH by executing the following:

sudo rm /usr/local/sbin/cabal 

This will not delete the executable, which is stored in $HOME/.cabal/bin/. This just removes the sym-link that was in your $PATH.

Next, lets grab the source for GHC 6.10.3 (which is required to build the Haskell Platform)

wget http://haskell.org/ghc/dist/6.10.3/ghc-6.10.3-i386-unknown-linux-n.tar.bz2

and untar it.

tar -xvvf http://haskell.org/ghc/dist/6.10.3/ghc-6.10.3-i386-unknown-linux-n.tar.bz2

next, lets configure it and build it:

cd ghc-6.10.3/
sudo make install

After this, installing the Haskell Platform is just more of the same:

#grab the tarball
wget http://hackage.haskell.org/platform/2009.2.0.1/haskell-platform-2009.2.0.1.tar.gz

# untar it
tar -xvvf http://hackage.haskell.org/platform/2009.2.0.1/haskell-platform-2009.2.0.1.tar.gz

# ... and install it.
cd haskell-platform-2009.2.0.1/
sudo make install

Along the way, the install scripts for the Haskell Platform will give you prompts for the next step to take.

Enjoy your Haskell Platform, and happy developing!

Written by John Gunderman

July 11, 2009 at 6:16 pm

Posted in Uncategorized

Tagged with , ,

Haskell Cabal in Ubuntu

with 8 comments

EDIT: You may prefer to install the entire haskell platform in one go, which includes cabal. Detailed instructions can be found here.

Recently I’ve begun to learn Haskell, the lazy functional language. Haskell is backed by a large library of packages, called Hackage. On Hackage, libraries and programs in a wide variety of genres are available for download. In order to simplify the download and install process for these packages a tool was born to allow command line grab/install maneuver. Think apt-get for Haskell.

The tool in question is called cabal, and it’s quite useful during Haskell development. Unfortunately, I’ve run into some issues while using it, mainly to do with resolving dependencies. I’ll get to that later.

Installing Cabal
Installing cabal was not as straight-forward as I had hoped. I first went to the offical cabal download page, to see what my options were. The only option on that page was to download a tarball and install it by hand. Of course, having been pampered by the power of apt-get, I figured there had to be a better way. Unfortunately, it seems as there is not. No cabal package exists in the Ubuntu repositories. I downloaded the tarball and prepared to install. The install from the tarball was painless as manual installs go, but unfortunately I had to resolve multiple dependencies to get the build to succeed. Here were the steps I took:

#get our dependant libraries (this assumes we already have ghc6 installed)
sudo apt-get install libghc6-network-dev libghc6-parsec-dev libghc6-mtl-dev libghc6-zlib-dev

#grab the source
wget http://haskell.org/cabal/release/cabal-install-0.6.2/cabal-install-0.6.2.tar.gz

#untar it
tar -xvvf cabal-install-0.6.2.tar.gz

#install it
sh cabal-install-0.6.2/bootstrap.sh

#link the executable into our path
sudo ln -s $HOME/.cabal/bin/cabal /usr/local/bin/cabal

Using Cabal

Cabal is not limited to simply downloading libraries. It can also allow you to easily create libraries of your own and upload them to Hackage, and also build projects (similar to make).

cabal --help will bring up your main options, which is always a good starting place. Let’s look at installing a package using cabal.

cabal install [package-name] installs the given package name. This should be very familiar to anyone who has used a package manager such as apt-get.

cabal list [string] is like apt-cache; it searches Hackage for packages pertaining to the string you entered.

Explore! Have fun! there’s plenty more features of cabal that I won’t be covering now, yet are plenty awesome.

I’ve had some strange dependency issues; for example, installing bloxorz –
cabal install bloxorz
gives me an error while trying to build a dependency that in turn depends on a C library which is not auto-resolved. Fun. Fortunately, such errors seem to be few and far between.

Written by John Gunderman

July 5, 2009 at 9:18 pm

Posted in Uncategorized

Tagged with , ,