Haskell for Gingerbread

Hi folks, I have been looking at developing for my Android phone which is running Gingerbread (Android version 2.3). The important thing about the official development kit is this: The new native development kit (C/C++ cross compiler for ARM) is that the you can create android applications from pure C without using the Dalvik/Java virtual machine at all. The thinking behind this was probably for game developers to be able to avoid their VM. So all that might be needed is a Haskell compiler with a C-backend that emits ARM-compatible code and an initially minimal android runtime. Implementing to the new "native_activity.h" allow for the usual application life-cycle: onStart, onPause, onResume, onStop... Some options I have not had a chance to look into: 1) GHC arm port and -via-C 2) jhc (and lhc) generated C 3) port nhc98 4) port yhc bytecode runtime Does anyone know who else is thinking along any of these lines? Are there 5th or 6th routes to take? Cheers, Chris Kuklewicz

There was work ongoing for an ARM port of GHC. See here:
http://tommd.wordpress.com/2010/01/19/ghc-on-arm/
Also see:
http://alpheccar.org/en/posts/show/94
Alpheccar's build uses the work of Stephen Blackheath to cross
compile, which originated in the GHC-iPhone project, based on ghc
6.10.2 I believe. They are both based on the unregistered C backend,
i.e. using the -fvia-C backend.
None of this work has been accepted upstream as of me typing this, as
far as I know. Certainly the large majority of Stephen's work is not
in GHC (in particular things like the POOLSIZE wrapper, which is a
workaround for not being able to generate code at runtime via libffi,
because the iPhone doesn't allow it. I don't think Android has the
same restrictions, here.)
There are some plans underway for adding cross compilation support to
the GHC build system, see here:
http://hackage.haskell.org/trac/ghc/wiki/CrossCompilation
In particular this avoids the need for non-standard and painful build
setups like alpheccar went through, or the peculiar dance that e.g.
HalVM has to go through to cross compile GHC for Xen.
Overwhelmingly, I would say focusing efforts on GHC is the way to go.
JHC is fiddly (and still fails badly on some simple programs,) ditto
for LHC which is highly experimental and not quite as portable. nhc98
would probably be a good baseline, but the lack of language extensions
and support from the community probably means you're not going to get
a lot to work with it. yhc seems unmaintained. GHC also generates
better code than pretty much anything else, too (except when JHC
manages to actually work.) GHC is what everybody uses and knows, so it
seems best to focus efforts here.
Getting GHC to actually support cross compilation in the build system
is IMO probably the biggest thing that needs to be done, before any
sort of registered ARM port, or adding support for android to the
runtime (if that would even be necessary, I have not looked at the
Android Gingerbread NDK notes - it may be possible to just have a
library that takes care of interfacing with the NDK.) I say this
because I think GHC being cross compilable is ultimately a much
greater goal than just a port to work on Android/ARM (even debian has
had unregistered arm/armel GHC builds for a while, IIRC) and would
make using GHC with more exotic toolchains much, much easier (android
included.) Until then, your only hope is porting the unregistered
compiler, which can be quite frustrating and delicate (and doesn't
always work - see the GHC wiki page on Porting.)
Perhaps we should be paging Mr. Simon Marlow in here, since he can
probably give a better and more concrete answer.
On Tue, Dec 28, 2010 at 1:27 PM, Chris Kuklewicz
Hi folks,
I have been looking at developing for my Android phone which is running Gingerbread (Android version 2.3). The important thing about the official development kit is this:
The new native development kit (C/C++ cross compiler for ARM) is that the you can create android applications from pure C without using the Dalvik/Java virtual machine at all. The thinking behind this was probably for game developers to be able to avoid their VM.
So all that might be needed is a Haskell compiler with a C-backend that emits ARM-compatible code and an initially minimal android runtime. Implementing to the new "native_activity.h" allow for the usual application life-cycle: onStart, onPause, onResume, onStop...
Some options I have not had a chance to look into:
1) GHC arm port and -via-C 2) jhc (and lhc) generated C 3) port nhc98 4) port yhc bytecode runtime
Does anyone know who else is thinking along any of these lines? Are there 5th or 6th routes to take?
Cheers, Chris Kuklewicz
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Regards, Austin

jhc generated C works on the android/ARM just fine. Android specific libraries arn't available, so you would have to bind to what you want with the FFI. John

On 28.12.10 21:25, John Meacham wrote:
jhc generated C works on the android/ARM just fine. Android specific libraries arn't available, so you would have to bind to what you want with the FFI.
is there a recommended procedure for porting code from GHC to JHC? i'd like to port an application of mine to ios/android, but my naive approach of specifying the jhc compiler in ~/.cabal/config fails with the first dependency (binary), because the base library does not have the required version. any hints? thanks, <sk>

On Thu, Jan 13, 2011 at 3:07 AM, Stefan Kersten
On 28.12.10 21:25, John Meacham wrote:
jhc generated C works on the android/ARM just fine. Android specific libraries arn't available, so you would have to bind to what you want with the FFI.
is there a recommended procedure for porting code from GHC to JHC? i'd like to port an application of mine to ios/android, but my naive approach of specifying the jhc compiler in ~/.cabal/config fails with the first dependency (binary), because the base library does not have the required version. any hints?
In general cabal and jhc don't work together. However, many libraries from hackage do "just work" when compiled with jhc manually so it isn't as big of an issue in practice as one might think but the porting isn't automated. If your code doesn't have any ghc specific code in it then just calling jhc directly on Main and specifying the packages you depend on with '-p' should do the right thing. If there are specific libraries you need that arn't included in the jhc distribution and should be, then ask on the jhc list and I'll see if I can get them in the next release. A more automated way to do this probably will appear at some point. There were some issues found recently by the iPhone target that probably apply to android too, see the following thread for how to resolve them. http://www.haskell.org/pipermail/jhc/2011-January/000858.html John

John Meacham wrote:
On Thu, Jan 13, 2011 at 3:07 AM, Stefan Kersten
wrote: jhc generated C works on the android/ARM just fine. Android specific libraries arn't available, so you would have to bind to what you want with the FFI. is there a recommended procedure for porting code from GHC to JHC? i'd like to
On 28.12.10 21:25, John Meacham wrote: port an application of mine to ios/android, but my naive approach of specifying the jhc compiler in ~/.cabal/config fails with the first dependency (binary), because the base library does not have the required version. any hints?
In general cabal and jhc don't work together.
Hey, some time ago I updated Cabal's support for JHC. I hope that it is still not outdated, again. I hoped to be able to install a pacakge and all of its dependencies automatically with cabal-install. This would work in principle, but in the real world the core packages for JHC and GHC are different. GHC's base is in fact a ghc-base, JHC has the same modules in different packages (like applicative). Thus I had to extend all the packages I wanted by Cabal flags. Not very nice. I do very very much hope, that GHC's base one day is suitably small in order to be used by all current Haskell systems, and that package developers try harder to write their packages such that they can be ported to compilers other than GHC (e.g. resist from using newest GHC features). Maybe programming those mobile devices are enough of an application to make JHC more important in future.
participants (5)
-
austin seipp
-
Chris Kuklewicz
-
Henning Thielemann
-
John Meacham
-
Stefan Kersten