(Changed category from "Haskell" to "Web")
Latest revision as of 13:40, 14 April 2013
 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' )
The ultimate goal is to produce web apps written in Haskell which run in any browser without installation (client-side web app ]; 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 ();
- 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;
Yhc can be downloaded from hackage, but i could not get it compiled ; it seems that some parts are missing, especially the run time environment yhi -- but perhaps just some more instructions would make it work.
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 superseded 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 ); 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
Packages like WashNGo etc. are tools to author web pages. see: 
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.
For example: Salivia (http://hackage.haskell.org/package/salvia) gives a choice of different backends, including HTTP, CGI..
 4 Alternatives outside of Haskell
Two solutions using languages which are relatively close to Haskell are:
Lua is included in the Android Scripting Environment(http://google-opensource.blogspot.com/2009/06/introducing-android-scripting.html).
 5 Optimal choice
Given that producing apps directly for the mobile device is not yet possible, the goal is to select a method which will make eventual conversion simple.
 6 Coda
The page needs editing to add the references to the web pages.
I am currently working on producing web apps for mobile devices and interested to hear comments at frank at geoinfo dot tuwien dot ac dot at.
This category currently contains no pages or media.