shapr wrote:I've installed the debian image on my raspberry pi, and it has ghc6 debs available...But I'd like to use ghc 7.4.1, does anyone know if there's an apt source available for ghc 7.4.1 on armel?

Thanks,

shapr on #haskell

Hi shapr, so I've been looking into this after getting annoyed with 6.12.3!

On the wheezy sources of Debian you can install GHC 7.4.1 on your system and (so far) everything seems to work OK except GHCI - which doesn't work with ARM anyway. I haven't actually tested it on the Pi, I'm running it through QEMU as I don't want to replace my installation of Arch on my 'Pi.

I'm not sure how to get 7.4.x installed on Arch Linux unfortunately, and building GHC from scratch on the Pi is a non-starter as the memory on the device is too low.

So my current "solution" is to

a) Write haskell programs on my Macb) Start up a VM with ubuntu running on it c) Inside the VM start an instance of QEMU to emulate an ARM processor and boot the debian imaged) Inside the VM and then inside the QEMU ARM VM retrieve my haskell code from my mac and compile it into an executablee) Transfer this via SSH to my Pi and run the code

Unfortunately the problem with my method above is....it runs into a stumbling block when you attempt to compile a program with a haskell library you don't have on your machine. Installing cabal is fine but say if you do a quick "cabal install network", you'll run into problems after about 20 minutes because the device will run out of memory.

I'm trying to search desperately for a way to make QEMU boot the ARM image with more than 256mb of RAM but all indicators are pointing to the fact that only 256mb is supported.

The current available distributions of Linux available to the Pi, Arch Linux and Debian offer version 6 of GHC which is years out of date

Updating the source repository on the debian installation to "wheezy" will give you GHC version 7.4.1

The memory limit (256mb) on the Pi means that it's very difficult to compile large projects or use Cabal effectively, especially when retrieving and compiling large libraries such as Parsec or Network. The compiler will crash after a while as it runs out of memory

This means that the only viable option for compiling large projects is to compile them on a separate, more powerful machine and transfer the binaries across to your Pi. The problem is you cannot cross compile x86 to target an ARM platform (GHC is not a cross compiler)

So effectively the only option you have left is to either purchase a more powerful ARM based device (beagleboard? only slightly more RAM than the Pi....) or use QEMU to emulate an ARM computer. I chose the latter option, but as described in my previous post, there is an issue with the fact that the "versatilepb" machine type expressed in most Pi-QEMU tutorials is limited to 256mb.

To get round this I spent a while hacking about until I was able to boot the R-PI version of debian with 1024MB of ram using the options

and a few kernel bits and pieces gathered from various websites. After expanding the .img and booting into the system I was able to install LLVM-3.0, GHC-7.4.1 and GCC-4.6.3 and then I embarked on the long, arduous path of compiling GHC-7.4.2 which took 5 days to complete, although I suspect my Mac was erroneously going into sleep mode for some of that period.

After that completed and installed, my QEMU ARM VM was able to run GHC-7.4.2 and I could install cabal and all the libraries I needed without much issue and eventually, I was able to compile some haskell applications and transfer the binaries to my Pi accordingly.

Some observations: -

GHCI is supposed to be working on ARM in GHC7.4.2 but it crashes on mine at the moment.

I transferred the GHC 7.4.2 binaries and libraries to my Pi (running arch linux) and they run OK but I can't seem to compile apps directly on the Pi because I don't know how to get LLVM-3.0 on arch linux arm (pacman only seems to install 3.1 - which has been reported to have issues with GHC). Compiling LLVM-3.0 from source is out of the question because of the memory limitations

Binaries that you compile on ARM seem to be significantly larger than those generated for x86 architectures

Haskell http://www.haskell.org and O'Caml http://caml.inria.fr/ are distinct languages with separate implementations. The only connection is that both are statically typed and employ automatic type inference that started in ML back in the 70s. O'Caml is slighter older and is a more "pragmatic" design (call-by-value that allows impure side-effects such as I/O anywhere). Haskell is a more "mathematical" language (pure-by-default with side-effects controlled by an abstraction called monads). Both allow higher-levels and safer programming that imperative or OO languages; plus both have high performance implementations that compete with C++ and Java and are at least an higher of magnitude faster than scripting languages such as Python, Perl, Ruby,etc.

I received my Pi just a few days and being a Haskell programmer thought I'd share my experience so far. I'm running Debian wheezy ("raspbian") on a Sandisk 8GB Class 10 card.

There is a Haskell interpreter called Hugs (the debian package is "hugs") ; this is fine for learning or quick experimentation. There is also an optimizing compiler called GHC (package "ghc"); this requires more resources (both to install and run) but generates faster native ARM binaries that do not require the compiler/interpreter to run. On x86 GHC also includes its own interpreter (called ghci) but unfortunately this isn't (yet) available for the ARM architecture. There are also many development libraries some written in Haskell, other bindings to various C/C++ libraries. There is a blessed set of libraries and tools (package "haskell-platform"). Installing GHC plus the platform will require about 300 MB.

After a few toy examples, successfully compiled my HsTZAAR implementation of a modern boardgame with AI and a GTK user-interface (check the link here http://www.dcc.fc.up.pt/~pbv/stuff/hstzaar). Compiling took about 10 mins which is at least 10x slower than my linux x86 laptop. GHC also requires a lot of memory so I recommend compiling from the console (no X) and configuring the memory split as 240/16.However, the compiled executable is much more frugal: runs under X rather than the console, the interface is responsive and so is the AI (at least at lower search levels). Inspecting with top shows that it uses at most 16Mb of resident memory (actually very similiar to the x86 version).

So the moral of the story is: I am impressed that Haskell runs so well on the little Pi! I woudn't want to use it as a development machine simply because of the slow compilation, but porting existing code should work well (subject to the usual caveats of available resources, etc).