Installing GHC in SliTaz

There is no GHC package in SliTaz’s repositories, so, if you want to play with Haskell in SliTaz, it’s an adventure. I managed it just now and I’m writing it down so I can do it again in the future if I have to. I am using SliTaz 4.0 base.

First I dug around the Debian repositories for a GHC package that I could tazpkg convert. I found one, took an i386 download link, and did

$ wget ftp://http.us.debian.org/debian/pool/main/g/ghc/ghc_7.4.1-4_i386.deb
$ tazpkg convert ghc_7.4.1-4_i386.deb
$ sudo tazpkg install ghc-7.4.1-4.tazpkg

The tazpkg convert took like five minutes in a VM with some resources, so be patient on that step. The tazpkg install should go through without a problem, but then:

$ ghci
/usr/lib/ghc/lib/ghc: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

I couldn’t find anything on the internet about libtinfo.so.5 under SliTaz. Going back to debian.org, I downloaded the Debian package and converted it:

$ wget ftp://ftp.us.debian.org/debian/pool/main/n/ncurses/libtinfo5_5.9-10_i386.deb
$ tazpkg convert libtinfo5_5.9-10_i386.deb
$ sudo tazpkg install libtinfo5-5.9-10.tazpkg

And…

$ ghci
/usr/lib/ghc/lib/ghc: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

So the file still isn’t where ghc is looking for it.

$ tazpkg list-files libtinfo5

Installed files with: libtinfo5
================================================================================
/lib/i386-linux-gnu/libtinfo.so.5
...

$ sudo ln -s /lib/i386-linux-gnu/libtinfo.so.5 /lib/libtinfo.so.5

And…

$ ghci
GHCi, version 7.4.1: http://www.haskell.org/ghc/  :? for help
/usr/lib/ghc/package.conf.d/package.cache: openBinaryFile: does not exist (No such file or directory)

That’s progress. Searching that error message leads us to this page which suggests sudo ghc-pkg recache. Trying again,

$ sudo ghc-pkg recache
$ ghci
GHCi, version 7.4.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
ghc: could not execute: /usr/bin/gcc

Finally, install gcc (via slitaz-toolchain), and we’re in:

$ sudo tazpkg get-install slitaz-toolchain
$ ghci
GHCi, version 7.4.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> [ n | n <- [1..100], n `mod` 12 == 1 ]
[1,13,25,37,49,61,73,85,97]