Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GHCi on raspberry pi 2?

I'm working on a few haskell projects that run on a raspberry pi 2 and the version of ghc that you can install with apt-get from raspbian (7.4.1). It has no GHCi though, which prevents some vital packages (like Vector) from compiling. I've seen a few rumors about being able to get later versions of ghc (with ghci) onto the pi, but nothing recent. The entry on the haskell wiki looks a couple years out of date. Has anyone had any luck with this?

like image 752
jhickner Avatar asked Mar 31 '15 22:03

jhickner


1 Answers

I have had some luck with this!

sagemuej@sagemuej-Aspire-5742G:~$ ssh pi-loc
Linux raspberrypi 3.12.28+ #709 PREEMPT Mon Sep 8 15:28:00 BST 2014 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Apr  1 00:24:44 2015 from sagemuej-aspire-5742g.localdomain
pi@raspberrypi:~$ ghci
GHCi, version 7.8.2: 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> :m +Data.Vector
Prelude Data.Vector> fromList [1,2,3]
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package primitive-0.5.2.1 ... linking ... done.
Loading package vector-0.10.9.1 ... linking ... done.
fromList [1,2,3]

Ain't it nice?

It is a full GHC 7.8. I had to bootstrap it from source, though. Worked pretty fine by the normal setup instructions if I recall correctly – though it took ages to build (like, half a week).

The main issue is memory: for some of the larger modules, the compiler needs more than the π can offer even when running without X. What I did was simply, I connected a USB hard drive and set up a swap partition on it. Of course, swapping makes everything even slower, but eventually it'll succeed. Did for me, at least.

like image 108
leftaroundabout Avatar answered Sep 28 '22 11:09

leftaroundabout