Haskell for non-Haskell's sake

John Hughes rjmh@cs.chalmers.se
Fri, 5 Sep 2003 15:35:32 +0200 (MET DST)


On Thu, 4 Sep 2003, Sebastian Sylvan wrote:

> On Thu, 4 Sep 2003, John Hughes wrote:
> > I wrote the system for my (Haskell!) programming course, with 170 students
> > last year, and it is now also being used (at least) for our Java course
> > and a cryptography course. It consists of about 600 lines of Haskell and
> > 18 lines of C.
>
>
> Just curious. What was C used for?
>
>
> /One of the students in the mentioned haskell programming course...
>

I implemented a trivial "database", stored in ordinary files, and had to
ensure mutual exclusion of database access between simultaneously running
CGI scripts. Since each CGI run is short, I simply locked the entire
database for the entire run. Claiming a lock on a file is easy in C (well,
it takes 18 lines...), but there's nothing in the standard Haskell
libraries that can do it. So I borrowed a little C code from the net, and
called it via the FFI.

John