1 Mobile Web Applications

Programming of web applications for mobile devices in Haskell would be awesome - especially if these would even function, perhaps with limited functionality, when not connected to the internet. Tools like couchDB with its replication strategy makes this quite achievable. Unfortunately that seems not quite possible today:

This page collects experiences with different approaches. I reflects experiments carried out in August 2010 - updates are encouraged, corrections invited! (There is a 2010 wiki page 'web'[ http://www.haskell.org/haskellwiki/Web] which discusses web related packages and an old, seriously outdated page 'practical web programming in Haskell' [1])

The ultimate goal is to produce web apps written in Haskell which run in any browser without installation (client-side web app [2]]; this seem not achievable summer 2010. The second best thing is translating Haskell code to pieces which can be served by a web server (server-side web app). If this webserver is a standard web server, possibly running on a mobile device, then not much difference is to the client-side solution.

The difference is whether an application can run in a mobile device eventhough no web connection is available or not:

2 Internet connection independent web apps for mobile devices

The following focuses on Android based mobile devices - for iPhone the problems are likely more complicated due to the restrictions enforced by Apple.

The options to produce code running on a mobile device from Haskell sources are:
- porting a Haskell compiler to the device or using a cross compiler; there is some progress to produce a ghc version fro Maemo ([3]);

- compiling Haskell code to java byte code for the Java VM (or Dalvik for Android); discussions can be found on Haskell-cafe, but they are not encouraging;

- compiling Haskell to javascript; several project are found on Hackage:

2.1 Haskell to Javascript

The effort to use the York Haskell compiler and its intermediate code to produce javascript was started 2006 [4]. In 2010 it seems mostly abandoned:

Yhc can be downloade from hackage, but i could not get it compiled [5]; it seems that some parts are missing, especially the run time environment yhi -- but perhaps just some more instructions would make it work.

Yhccore seems part of an effort to produce the yhc intermediate language from ghc (at least that is my understanding) which could then be used by others to translate to, e.g., javascript. No examples how this could be used were found on the web. The wiki page [6] is ineresting, but the required libraries cannot be found on Hackage anymore.

yc2js is available from haskell darcs (http://code.haskell.org/yc2js/), but not on hackage. it contains examples of how Haskell code is translated to java; it seems superseeded by:

jsmv which is in Hackage and installs with cabal. The example code found on the web page run (helloWorld and calc). The code is quite complex and not exactly like ordinary Haskell; I could not apply an arbitrary function to a string the user has input and then put the result of the conversion (e.g. capitalize) back on screen.

3 Haskell code executed by web broswers

There is a new wiki page 'web' that describes and compares packages; the focus here is on how to use these from mobile devices. Two approaches can be separated:

3.1 Uses standard web server (e.g. Apache)

3.1.1 CGI based

Most web server understand the CGI interface and application can use it as an interface:
The package cgi from hackage can be installed with cabal (the newest version of the code is however in a git repository [7]); Haskell code compiles to an executable which is moved to the cgi-bin directory of the server and then accessible from the web. Limiting for mobile devices is that the executable produced by ghc runs only on the hardware it is produced for (i.e. not a ARM based android mobile).

3.2 Uses special servers

3.2.1 WASH and similar

The examples work, after precompilation with wash2hs; this allows to include web forms in the original form (with lots of <>). The result from precompilation are compiled with ghc and the executable copied to cgi-bin.

3.2.2 Frameworks

Most newer efforts do not only produce a server but a framework for application development, blending different tools which have been developed over the past years to simplify application development.