[Haskell-cafe] Rewriting a Python application to Haskell

basvandijk at home.nl basvandijk at home.nl
Fri Sep 1 10:38:43 EDT 2006


The company I work for [1] develops highly sensitive trace gas detectors. We also develop software that is used to control these detectors from a PC or laptop. With this software a user can setup an experiment, execute it and analyse and visualise the data in real-time. While executing, the application gives commands to the detector and gets concentrations from the detector which it plots. See [5] for a screenshot.

The application is written in Python and uses wxPython for its GUI. The software is highly threaded; The experiment executor, the analyzer, the communication system and the GUI all have their own threads. In order to synchronise these threads we make extensive use of locks [2]. This thread synchronisation mechanism worked fine in the beginning. However, as the application becomes more complex, it is increasingly difficult not to introduce bugs that are caused by forgetting to release or acquire locks. Also the use of locks makes the code hard to understand. Finally it's hard to compose functions that use locks.

I've long been interested in Haskell and played around with it for some time. Recently I became aware of the Haskell STM implementation [3]. I think STM can solve my thread synchronisation problems. Because of this and because I would like to know how suitable Haskell is for developing real-world GUI applications, I would like to rewrite our application in Haskell (in my free time of course ;-) ). I think I need to use wxHaskell for the GUI because it's runs on a lot of platforms and we are currently using wxPython which should make the transition easier.

1) I would like to know if its difficult to use wxHaskell and STM side by side and if there are any issues I need to know about.

2) Also, we use pySerial [4] for serial communication with the detector. Is there something like that for Haskell or is it easy to make it yourself?

3) How portable is Haskell? We like to run our application on Mac, Windows and Linux.


Bas van Dijk

[1] http://www.sensor-sense.nl
[2] http://docs.python.org/lib/lock-objects.html
[3] http://haskell.org/ghc/docs/latest/html/libraries/stm/Control-Concurrent-STM.html
[4] http://pyserial.sourceforge.net
[5] http://members.home.nl/basvandijk/vc-screenshot.png

More information about the Haskell-Cafe mailing list