[Haskell-cafe] xmonad on the openmoko mobile phone

John Meacham john at repetae.net
Wed Aug 27 20:07:28 EDT 2008

On Wed, Aug 27, 2008 at 02:15:48PM -0700, Don Stewart wrote:
> john:
> > On Sun, Aug 10, 2008 at 08:36:27PM +0400, Miguel Mitrofanov wrote:
> > >
> > > On 9 Aug 2008, at 23:43, Don Stewart wrote:
> > >
> > >> Haskell on the iphone next?
> > >
> > > Did that. Hugs compiles well; GHC will probably too, I just didn't have 
> > > time for this. No haskell-specific hacks, only jailbreak.
> > 
> > jhc cross compiles to iPhone as well.
> That's rather exciting. Any chance of a demo on your blog?

I'll see if I can put something together. jhc is in some sense natively
a cross compiler, it spits out 100% portable C code by default and you
have to work (by using 'foreign' imports on nonportable functions for
instance) at breaking cross-compilation.

So, for a quick and dirty cross compilation, take the foo_code.c file
that jhc generates, the first 3 lines will look something like so:

char jhc_c_compile[] = "gcc '-std=gnu99' -D_GNU_SOURCE '-falign-functions=4' -ffast-math -Wshadow -Wextra -Wall -Wno-unused-parameter  -DNDEBUG -O3 -fomit-frame-pointer";
char jhc_command[] = "jhc --noauto -v --ho-dir regress/results/ho --noauto -i./lib/base -i./lib/haskell98 -flint -o enum enum.hs";
char jhc_version[] = "jhc 0.5.20080307 (eogmidkiv-1)";                

and just change the 'gcc' in the jhc_c_compile line to gcc-iphone-arm or
whatever and run it on the command line.

I usually only test on linux so I occasionally accidentally break
cross compilation, but it is generally easy to fix. I try to test on Mac
OSX, solaris, and OpenBSD when possible as that gives a nice wide range.

Of course, you probably want to use some Mac OSX framework features,
which will require writing some foreign bindings, but I endevour to
ensure that if you only use haskell 98 or haskell' features (or your
library is built on top of said features) then jhc's output is pure,
portable (in practice), C.


John Meacham - ⑆repetae.net⑆john⑈

More information about the Haskell-Cafe mailing list